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?
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.
Answered by thesecretmaster on August 21, 2021
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.
Answered by Buffy on August 21, 2021
4 Asked on February 1, 2021 by user9137
3 Asked on January 29, 2021 by neal-zupancic
1 Asked on January 28, 2021
3 Asked on January 5, 2021 by user9790
5 Asked on December 30, 2020 by buffy
3 Asked on December 29, 2020 by neelesh-v
8 Asked on December 27, 2020 by louis-b
3 Asked on December 20, 2020 by pluke
21 Asked on December 11, 2020 by ben-i
0 Asked on December 8, 2020
5 Asked on December 7, 2020 by totera
3 Asked on December 4, 2020 by technosam
Get help from others!