OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Aug 17, 2017 12:15 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Speeding up compiler development
PostPosted: Sun Jan 29, 2017 1:58 pm 
Offline
Member
Member
User avatar

Joined: Wed Jun 17, 2015 9:40 am
Posts: 411
Location: Athens, Greece
Hi,


I'd like to speed up compiler development, since during the next period I won't have much time because of finals.

Do you think it makes much sense to use a LLVM backend for the temporary compiler instead of implementing everything exactly the way I designed it? Mostly, what concerns me is whether I'll be able to implement two compatible compilers, one using the LLVM backend, and one using the proper design.

The lack of time however pressures me too much and I need some trade-offs. Do you by chance have any better ideas to speed up development time?

Note: I'm actually ok with not-so-good for temporary things, but their input and output (in this case project file, error reports and output executables and libraries in the intended format(s)) should be as compatible as possible with those of the proper things.

Edit: The proposed design of the compiler can be found here: http://glaux-os.org/design/compiler/

Thanks in advance. :-)


Regards,
glauxosdever

_________________
Before implementing any piece of software, make sure you have designed it to be extendable. Backporting new features into old code is not always easy.


Top
 Profile  
 
 Post subject: Re: Speeding up compiler development
PostPosted: Sun Jan 29, 2017 2:34 pm 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 712
Location: Tallinn, Estonia
Yes, using LLVM backend is the only sane option if you would like to have production-quality optimiser and code generation in relatively short time (say, 2-4 weeks).

LLVM has educational language called Kaleidoscope on their docs site which explains what to do to use LLVM as backend.

LLVM also has the first level representation (LLVM IR with annotations) and second level (lowered IR before translation to MC), so it won't be too different from your design. You will most probably NOT need to reinvent the wheel yet again.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: Speeding up compiler development
PostPosted: Sun Jan 29, 2017 2:45 pm 
Offline
Member
Member
User avatar

Joined: Wed Jun 17, 2015 9:40 am
Posts: 411
Location: Athens, Greece
Hi,


In my design, both first-level and second-level IRs have the same format, which is a form of AST. But maybe it shouldn't matter how it is done in the initial compiler, since the only requirement is that the code that compiles in the initial compiler should compile in the final compiler and vice-versa (and IRs won't be shared).

Just to be clear, the final compiler will be rewritten wholly from scratch. I just want to gain some time now, so I have something worthwhile to show in the university. :P


Regards,
glauxosdever

_________________
Before implementing any piece of software, make sure you have designed it to be extendable. Backporting new features into old code is not always easy.


Top
 Profile  
 
 Post subject: Re: Speeding up compiler development
PostPosted: Sun Jan 29, 2017 3:01 pm 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 712
Location: Tallinn, Estonia
glauxosdever wrote:
In my design, both first-level and second-level IRs have the same format, which is a form of AST.


LLVM is entirely different... not.

If your IR will have the same detailed docs as LLVM has, sure, go for it, more interesting well-documented IRs for everyone!

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: Speeding up compiler development
PostPosted: Sun Jan 29, 2017 3:09 pm 
Offline
Member
Member
User avatar

Joined: Wed Jun 17, 2015 9:40 am
Posts: 411
Location: Athens, Greece
Hi,


I think it would still make sense to disregard the differences in the IR format anyway, since the IR doesn't need to be compatible between the initial and the final compiler. (Although libraries will be in the IR format, I could just require them to be compiled with the same iteration of the compiler as the linked code).


Regards,
glauxosdever

_________________
Before implementing any piece of software, make sure you have designed it to be extendable. Backporting new features into old code is not always easy.


Top
 Profile  
 
 Post subject: Re: Speeding up compiler development
PostPosted: Mon Jan 30, 2017 12:27 am 
Offline
Member
Member
User avatar

Joined: Wed Mar 21, 2012 3:01 pm
Posts: 913
lgtm +2


Top
 Profile  
 
 Post subject: Re: Speeding up compiler development
PostPosted: Mon Jan 30, 2017 2:43 am 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 196
dozniak wrote:
Yes, using LLVM backend is the only sane option if you would like to have production-quality optimiser and code generation in relatively short time (say, 2-4 weeks).

LLVM has educational language called Kaleidoscope on their docs site which explains what to do to use LLVM as backend.

LLVM also has the first level representation (LLVM IR with annotations) and second level (lowered IR before translation to MC), so it won't be too different from your design. You will most probably NOT need to reinvent the wheel yet again.


++++++1

There are so many examples for language --> AST --> llvm --> object code --- you will NOT have any trouble finding examples of how to use it.

If you are feeling adventurous then go the extra distance and use Clang as your starting point and rip out the parser and insert your own language front end --- clang already having the boiler plate code in place I mean.

Cheers

_________________
Plagiarize. Plagiarize. Let not one line escape thine eyes...


Top
 Profile  
 
 Post subject: Re: Speeding up compiler development
PostPosted: Mon Jan 30, 2017 2:45 am 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 196
If you go the LLVM route I would hope you do know what Single Assignment means in terms of registers....

other than that... good luck!

_________________
Plagiarize. Plagiarize. Let not one line escape thine eyes...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group