2
$\begingroup$

I think the https://llvm.org/docs/tutorial/index.html assumes you know too much. It's written in an unfamiliar language to me, OCaml, and they assume you know about lexers, parsers, AST. Any thorough beginner tutorials out there?

$\endgroup$
  • $\begingroup$ Depends what you want to learn: do you want to use it, extend it, study how it works, …? Edit your question to make this clear. $\endgroup$ – ctrl-alt-delor Jun 18 at 16:49
  • 2
    $\begingroup$ Is this for curiosity? For a job? How intensively do you need/intend to study in order to grasp this? $\endgroup$ – Ben I. Jun 19 at 0:33
  • $\begingroup$ it's for a course. It kind of assumes some knowledge on LLVM and I want to learn and create something in it before the class starts. I want to understand it's components and I want to build something $\endgroup$ – Joshua Segal Jun 19 at 16:21
  • 1
    $\begingroup$ Will you be using it, extending it, studying how it works, …? Edit your question to make this clear. $\endgroup$ – ctrl-alt-delor Jun 20 at 21:08
  • $\begingroup$ I wrote few years ago a small lab to get started practically with LLVM. It is in french but in case it may help here it is manuelselva.pages.ensimag.fr/docs/teach/tp-llvm/sujet.pdf It is lbased as stated in the intro on this tutorial cs.cornell.edu/~asampson/blog/llvm.html which is super great in my opinion but doesn not visually show the tools. $\endgroup$ – Manuel Selva Jul 30 at 13:59
0
$\begingroup$

This isn't really an answer, but a suggestion that before you try to jump into tools that enable/facilitate compiler construction, you need to study the key ideas. If you don't know anything at all of scanning, parsing, optimization, and code generation, the tools are just gibberish.

Since you say this is for a course, look to the text assigned, I think. The standard is by Aho, Lam, Sethi, and Ullman. There are simpler ones, but ASTs are pretty fundamental.

Almost any good book will have an early overview of the process.

| improve this answer | |
$\endgroup$
0
$\begingroup$

As stated in Buffy's answer, you'll want to first be familiar with the other steps of compilation, because code generation is typically the last step in the compiler pipeline. If you haven't already, I'd suggest looking in to lexing and parsing as well. Optimization is nice as a bonus, but llvm does a good deal of optimization on its IR by itself.

Once you're familiar with the general outline of how a compiler works, you can start building one yourself. There is a language that is designed to be easy to build a llvm compiler for, called Kaleidoscope, and I'd recommend looking up a tutorial for building a Kaleidoscope compiler in whatever language you choose. llvm has bindings to many different languages ranging from haskell to C, although you will likely have the best experience learning in C++ since that's how llvm's API is implemented.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Note that LLVM isn't just for the back end (code gen). $\endgroup$ – Buffy Jun 20 at 14:59
  • $\begingroup$ @Buffy Oh, I was under the impression it just did code gen and optimization on the IR. What else does it do? $\endgroup$ – thesecretmaster Jun 20 at 15:46
  • $\begingroup$ I read only a brief description, but it suggests it is an end to end tool. Scanning through codegen. Most of the tools I'm familiar with don't do much of anything on the back end, so if I were still teaching compilers it is something I'd look at. $\endgroup$ – Buffy Jun 20 at 15:50
  • $\begingroup$ As I understand it, llvm itself is just code gen and optimization, although there are other tools within the larger llvm project such as clang, a C compiler which uses llvm as a backend. $\endgroup$ – thesecretmaster Jun 20 at 15:53
  • $\begingroup$ Difference in terminology then. llvm.org. I was thinking of the project as a whole. $\endgroup$ – Buffy Jun 20 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.