A question for the LLVM experts here:<p>In the past when I've looked at LLVM from a distance, the biggest stumbling block I found were that it's written in C++ , which isn't the language I'm using for my frontend.<p>How important is the C++ API in practice? Are the bindings for other languages usable? Is it possible to have my frontend emit LLVM IR in a text format, similarly to how you can feed assembly language source code to an asssembler? Or should one really just bite the bullet and use C++ to generate the IR? I noticed that the compiler in this tutorial has a frontend in Ocaml and a backend in C++, with the communication between them being done via protobufs.
As someone who writes a lot of toy languages, I made this scaffolding for a LLVM-based compiler: <a href="https://github.com/finiteloop/compiler" rel="nofollow">https://github.com/finiteloop/compiler</a><p>It uses Bison and Flex for parsing and lexing unlike this post, but may be a useful starting point for those building their own toy languages.
While we're here, let's not forget about the incredible Kaleidoscope tutorial. They really helped me get a grip with LLVM.<p><a href="https://llvm.org/docs/tutorial/index.html" rel="nofollow">https://llvm.org/docs/tutorial/index.html</a>
> LLVM IR looks like a more readable form of assembly<p>I think assembly is more readable than the dumped LLVM IR output of a real compiler…<p>Anyway, that was a good overview of how to build simple LLVM IR. :)
It’s possible I missed this from the article, since I’m not actually following along, but why do I need to create the custom C++ adapter? The article mentions both ll bc formats, but I don’t see how they are used?<p>If I wanted to target LLVM, why wouldn’t I emit ll or bc files?
Is there a similar resource for liblldb? The only documentation I could find was the Doxygen-based one, and it doesn't provide enough hints to a newcomer to know where to get started if I want to write a debugger frontend.
When I studied compilers back in the university, the subject consist in reading understanding and putting in practice the 'dragon book' (not the full book but a big part of it). We all used flex+yacc and a simplified ASM that was interpreted by some educational software which name I cant remember. The project for the year was to implement a basic compiler language: included if/for loops, function calls, recursivity ... basic stuff but enough as starting point to build something.<p>Trying to get into LLVM, Id love to find an example done in flex+yacc vs the same done in LLVM.
I'm playing around trying to create a JIT execution engine for Rust code. I was struggling a bit with the codegen part, so the description of the function structure helped make more sense of what I'm trying to do.<p>Thanks
Thanks for this,
I used to have other resources too about 3 years ago when I was making my own toy blockchain project that takes in a programming language to create smart contracts<p>let me see if i can still find those