4 ms·
LLVM is a great project. I'm writing a programming language based on it. It is so much easier because: (1) it's easier than writing machine code translation a
by tanin 8y ago
LLVM is a great project. I'm writing a programming language based on it.
It is so much easier because: (1) it's easier than writing machine code translation and (2) it's also easier than translating your code to C which would be purely textual.
Nevertheless, it's difficult to learn for people coming from high-level languages, even for me, who knows C to some degree.
The documentation around IR is scarce.
Then, I've stumbled upon a trick where I can just write C code and compile to LLVM IR with Clang. With this trick, I can answer many questions on my own (e.g. how to implement if-else, how to call printf, how to make a dynamic-sized array.)
- pnloyd 8y agoThat last tip is so clever! I'll have to remember that if I ever want to undergo such a project.
- jclay 8y agoNice tip! I've also been watching the Godbolt.org progress improving LLVM IR support which could also be helpful for interactively exploring IR generation. The results are pretty good today if you select Clang compiler and pass `-emit-llvm` flag.
- tanin 8y agoThat's exactly what I have been doing `clang -S --emit-llvm <filename>`. Godbolt.org is even more handy!