There's a lot of extra stuff you get with targeting C: being able to write the run time in C very easily. For example its a lot easier to write your entire OO system in C in a few hundred lines, and keeping that easily debuggable is a massive time saver.
Wouldn't that be even easier if you used LLVM IR, as you'd then be able to write your runtime in any language that LLVM supports?
C as an intermediate language (2012)
11–20 of 32 posts
Re: C as an intermediate language (2012)
#12Earlier quoted context omitted.
Wouldn't that be even easier if you used LLVM IR, as you'd then be able to write your runtime in any language that LLVM supports?
Advantage of writing it in C: You can prototype an example client of your runtime in C before your code generator is working.
Re: C as an intermediate language (2012)
#13Fundamentally, CIL is a nice subset of C wrapped up into a nicely usable API. The idea is to shave off as many of C's inconsistent sharp edges as possible. You won't have to worry about quirks in the syntax or odd behavior because you have a nice high-level, curated API for generating C code.
It's designed to have a clean semantics, and semantics are very important. (Or so I maintain.)
Re: C as an intermediate language (2012)
#14There's a lot of extra stuff you get with targeting C: being able to write the run time in C very easily. For example its a lot easier to write your entire OO system in C in a few hundred lines, and keeping that easily debuggable is a massive time saver.
Wouldn't that be even easier if you used LLVM IR, as you'd then be able to write your runtime in any language that LLVM supports?
Re: C as an intermediate language (2012)
#15We took the code from IBM minicomputers and compiled it into C on many, many platforms (back when there were a few more unices, as well as OS/2 and VAX/VMS kicking around).
I only did a little maintenance on the compiler front end checker, though. I mostly worked on some supplemental tokenizers/runtimes for data file browser language and a DB/form DDL.
Anyway, GCC made a nice target to hit a large number of systems. (alas, Borland C on DOS at the time tended to choke on larger generated subroutines, being 16 bit w/out "huge" pointer support and all)
Re: C as an intermediate language (2012)
#16Earlier quoted context omitted.
Advantage of writing it in C: You can prototype an example client of your runtime in C before your code generator is working.
Again, why couldn't you do that with LLVM IR?
Re: C as an intermediate language (2012)
#17For anyone wanting to read about C as intermediate language, Compiler Design in C (1990) http://www.amazon.com/Compiler-Design-C-Prentice-Hall-softwa... EDIT: Adding some extra remarks I think might also be interesting to share. Another approach, that I really like, is to output bytecodes that are mapped directly to macros in typical macro assemblers like NASM/MASM/TASM. Those macro assemblers provide very powerful m…
Re: C as an intermediate language (2012)
#18There has been a little bit of research done on writing optimising compilers that use source-code-like intermediate representations: the Janus project from the 1990s springs to mind.
Re: C as an intermediate language (2012)
#19Earlier quoted context omitted.
Again, why couldn't you do that with LLVM IR?
LLVM IR is designed for machine, not human, it's too verbose, and requires SSA form. A normal person can't easily reason the logic in such verbose language. Plus people are more familiar with C.
Re: C as an intermediate language (2012)
#20There's a lot of extra stuff you get with targeting C: being able to write the run time in C very easily. For example its a lot easier to write your entire OO system in C in a few hundred lines, and keeping that easily debuggable is a massive time saver.
Wouldn't that be even easier if you used LLVM IR, as you'd then be able to write your runtime in any language that LLVM supports?