OSDev.org
https://forum.osdev.org/

Speeding up compiler development
https://forum.osdev.org/viewtopic.php?f=13&t=31315
Page 1 of 1

Author:  glauxosdever [ Sun Jan 29, 2017 1:58 pm ]
Post subject:  Speeding up compiler development

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

Author:  dozniak [ Sun Jan 29, 2017 2:34 pm ]
Post subject:  Re: Speeding up compiler development

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.

Author:  glauxosdever [ Sun Jan 29, 2017 2:45 pm ]
Post subject:  Re: Speeding up compiler development

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

Author:  dozniak [ Sun Jan 29, 2017 3:01 pm ]
Post subject:  Re: Speeding up compiler development

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!

Author:  glauxosdever [ Sun Jan 29, 2017 3:09 pm ]
Post subject:  Re: Speeding up compiler development

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

Author:  sortie [ Mon Jan 30, 2017 12:27 am ]
Post subject:  Re: Speeding up compiler development

lgtm +2

Author:  dchapiesky [ Mon Jan 30, 2017 2:43 am ]
Post subject:  Re: Speeding up compiler development

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

Author:  dchapiesky [ Mon Jan 30, 2017 2:45 am ]
Post subject:  Re: Speeding up compiler development

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!

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/