A Complete Guide to LLVM for Programming Language Creators
mukulrathi.co.uk
A Complete Guide to LLVM for Programming Language Creators
1–10 of 47 posts
Re: A Complete Guide to LLVM for Programming Language Creators
#2I think assembly is more readable than the dumped LLVM IR output of a real compiler…
Anyway, that was a good overview of how to build simple LLVM IR. :)
Re: A Complete Guide to LLVM for Programming Language Creators
#3Just wanted to appreciate you for writing this awesome guide
Re: A Complete Guide to LLVM for Programming Language Creators
#4> LLVM IR looks like a more readable form of assembly I think assembly is more readable than the dumped LLVM IR output of a real compiler… Anyway, that was a good overview of how to build simple LLVM IR. :)
Re: A Complete Guide to LLVM for Programming Language Creators
#5In 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.
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.
Re: A Complete Guide to LLVM for Programming Language Creators
#6Re: A Complete Guide to LLVM for Programming Language Creators
#7It 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.
Re: A Complete Guide to LLVM for Programming Language Creators
#8A question for the LLVM experts here: 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. 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…
Ultimately the C++ API isn't too difficult to use but LLVM mandates a fairly hardcore level of C++ knowledge to play with it's internals.
Quick Tip: if you're thinking "Holy shit how do I get from [complicated] all the way down to IR instructions" lower the big thing to a something simpler so you can reuse the code to generate IR from that - for example, a foreach loop is expressible as a for loop under the hood, now you only have to be compile for loops. This would usually be done in the AST itself.
Re: A Complete Guide to LLVM for Programming Language Creators
#9Re: A Complete Guide to LLVM for Programming Language Creators
#10A question for the LLVM experts here: 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. 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…