What needs to be done to make rune generate C code? #43
Replies: 1 comment 1 reply
-
There are 2 approaches, and whoever builds it will probably decide which path to take.
The current bottleneck is that I'm writing most of the C code myself, since I am the only one with extensive experience writing C code backed by the DataDraw code generator. Once the new binder is complete (maybe 4 weeks from now?) we should be able to make good progress rewriting Rune in Rune. Also, other folks at Google and in the community might be in a better position to contribute code in Rune. The current code generator is a 4,000 line mess that needs rewriting in any case. I read a tutorial on using LLVM to write a new compiler for a new language, and the tutorial said that after type resolution that writing the LLVM IR was easy, and more or less left it as an exercise for the reader. The tutorial was wrong! The right approach is to do all the mods to the AST (or DataDraw classes in our case), such as adding calls to ref/unref for ref counted objects, allocation/freeing of objects in constructors/destructors, allocation/freeing of temporary arrays, etc. Most of that 4,000 line code generator is devoted to writing LLVM code that works as if those changes had already been applied to the AST. In short, whoever wants to tackle this first probably gets to decide the approach, and they'll get to decide whether to work in DataDraw style C code vs Rune. |
Beta Was this translation helpful? Give feedback.
-
What are the approximate steps that needs to be made to enable rune to generate C code, so C compilers optimisations can be harvested?
Beta Was this translation helpful? Give feedback.
All reactions