I feel like HN seems to be good place to ask this question because compilers seems to be quite popular topic here, so I'm going to ask
I want to write yet another programming lang which uses LLVM to generate WebAssembly
My perception of it is that I have to write parser of my lang and then some "translation layer" which will translate abstraction over my language to LLVM IR
But I'm not sure whether I should write "raw IR" or use some library like https://github.com/microsoft/LLVMSharp
I feel like "raw IR" is better / more reliable way, but I've no experience with low lvl stuff (asm and so on)
Also I'm not sure about how good LLVMSharp actually is
PS: I've heard about other LLVM IR wrappers in other languages, I'd rather stick to C# because I have some kind of deadline on it
Thanks in advance
LLVM is well documented, and generates extremely fast code. Robot control used a lot of floating point ops, and LLVM turns it into a surprisingly small number of SSE4 instructions.
I found it easier to call the LLVM API than to generate the IR as text. But it's extremely convenient to be able to dump the result as IR. Like 80% of my debugging involved looking at IR dumps. And for really hard-core debug sessions you can hand-edit the IR, compile it, and call it from C programs.
I'm calling LLVM directly from C++, but LLVMSharp is probably the way to go if you want to work in C#.
If you use LLVM's JIT system, beware that orc::jit is about the 3rd different API and there are tutorials on the web for the previous APIs. You should probably start with LLVM 9.0.1 and ignore any tutorial not for orc::jit.