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.)
Nice 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.
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.)