
Ask HN: Should I use “raw” LLVM IR or some wrapper over it? - tester756
Hi!<p>I feel like HN seems to be good place to ask this question because compilers seems to be quite popular topic here, so I&#x27;m going to ask<p>I want to write yet another programming lang which uses LLVM to generate WebAssembly<p>My perception of it is that I have to write parser of my lang and then some &quot;translation layer&quot; which will translate abstraction over my language to LLVM IR<p>But I&#x27;m not sure whether I should write &quot;raw IR&quot; or use some library like https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;LLVMSharp<p>I feel like &quot;raw IR&quot; is better &#x2F; more reliable way, but I&#x27;ve no experience with low lvl stuff (asm and so on)<p>Also I&#x27;m not sure about how good LLVMSharp actually is<p>PS: I&#x27;ve heard about other LLVM IR wrappers in other languages, I&#x27;d rather stick to C# because I have some kind of deadline on it<p>Thanks in advance
======
tlb
I built Yoga (a language for real-time robot control) using LLVM as the code
generator in ORCJIT (on request just in time) mode. I'm pretty happy with
LLVM.

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.

~~~
tester756
Thanks

