I'm bootstrapping a programming language compiler on top of LLVM. Currently I'm mostly done writing a compiler for a subset of C which is self-compiling. When I'm finished with that, I'll bootstrap my language away from C, maintaining self-compilation as I go.
Since the compiler is self-compiling, any features of C that I use I will have to implement. So it's a constant balance: if I use too many features I will have to implement more than I want to, but if I don't implement enough features it will be difficult to write code.
One such feature is the LLVM bindings. Generating LLVM intermediate representation without the LLVM C bindings is difficult. However, if I us the LLVM bindings, I have to implement them again when I branch away from C.
I'm having some difficulty here, so I a looking for alternative solutions. Any ideas?
You could use the LLVM C bindings, but that requires your language understand enough C to do that.
Another alternative is to write out LLVM assembly language (a text file) and use llvm-as to turn that into bitcode.
I re-read you question, I think you already understand the llvm-as vs. binding stuff.
Your language will probably want to be able to bind to C anyway for support libraries, etc. Use the C bindings for now and write your own bindings when you get further along.
A Strategy for using ANTLR + StringTemplate + LLVM
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With