Answers.Body: <p>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.</p>
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-20T14:59:10.537Z
Answers.Text: Note that LLVM isn't just for the back end (code gen).
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-20T15:46:53.613Z
Answers.Text: @Buffy Oh, I was under the impression it just did code gen and optimization on the IR. What else does it do?
Answers.UserDisplayName: thesecretmaster
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-20T15:50:24.043Z
Answers.Text: 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.
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-20T15:53:47.337Z
Answers.Text: 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.
Answers.UserDisplayName: thesecretmaster
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-20T15:57:42.130Z
Answers.Text: Difference in terminology then. https://llvm.org. I was thinking of the project as a whole.
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-20T13:33:11.930Z
Answers.LastActivityDate: 2020-06-20T13:33:11.930Z
Answers.UserDisplayName: thesecretmaster
Answers.Body: <p>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.</p>
  <p>Since you say this is for a course, look to the text assigned, I think. The standard is by <a href="https://rads.stackoverflow.com/amzn/click/com/0321486811" rel="nofollow noreferrer" rel="nofollow noreferrer">Aho, Lam, Sethi, and Ullman</a>. There are simpler ones, but ASTs are pretty fundamental.</p>
  <p>Almost any good book will have an early overview of the process.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-19T19:47:02.333Z
Answers.LastActivityDate: 2020-06-19T19:47:02.333Z
Answers.UserDisplayName: Buffy
Body: <p>I think the <a href="https://llvm.org/docs/tutorial/index.html" rel="nofollow noreferrer">https://llvm.org/docs/tutorial/index.html</a> 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?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-18T16:49:34.707Z
Comments.Text: 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.
Comments.UserDisplayName: ctrl-alt-delor
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-19T00:33:37.327Z
Comments.Text: Is this for curiosity?  For a job?  How intensively do you need/intend to study in order to grasp this?
Comments.UserDisplayName: Ben I.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-19T16:21:05.527Z
Comments.Text: 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
Comments.UserDisplayName: Joshua Segal
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-20T21:08:43.747Z
Comments.Text: Will you be using it, extending it, studying how it works, …? **Edit your question** to make this clear.
Comments.UserDisplayName: ctrl-alt-delor
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-30T13:59:57.450Z
Comments.Text: 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 https://manuelselva.pages.ensimag.fr/docs/teach/tp-llvm/sujet.pdf It is lbased as stated in the intro on this tutorial https://www.cs.cornell.edu/~asampson/blog/llvm.html which is super great in my opinion but doesn not visually show the tools.
Comments.UserDisplayName: Manuel Selva
Tags: <self-learning><compiling>
Title: Any good beginner tutorials for learning LLVM
ThreadText: # Any good beginner tutorials for learning LLVM
  
  (Asked by: username_0 on 2020-06-18)
  
  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?
  
  **Tags:** self-learning, compiling
  
  > **Comments:**
  > **username_1**: 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.  
  > **username_2**: Is this for curiosity?  For a job?  How intensively do you need/intend to study in order to grasp this?  
  > **username_0**: 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  
  > **username_1**: Will you be using it, extending it, studying how it works, …? **Edit your question** to make this clear.  
  > **username_3**: 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 https://username_3.pages.ensimag.fr/docs/teach/tp-llvm/sujet.pdf It is lbased as stated in the intro on this tutorial https://www.cs.cornell.edu/~asampson/blog/llvm.html which is super great in my opinion but doesn not visually show the tools.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_4 on 2020-06-20. Score: 1
  
  As stated in username_5'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.
  
  > **Comments:**
  > **username_5**: Note that LLVM isn't just for the back end (code gen).  
  > **username_4**: @username_5 Oh, I was under the impression it just did code gen and optimization on the IR. What else does it do?  
  > **username_5**: 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.  
  > **username_4**: 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.  
  > **username_5**: Difference in terminology then. https://llvm.org. I was thinking of the project as a whole.  
  
  ---
  
  ### Answer by username_5 on 2020-06-19. Score: 0
  
  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](https://rads.stackoverflow.com/amzn/click/com/0321486811). There are simpler ones, but ASTs are pretty fundamental.
  
  Almost any good book will have an early overview of the process.
  
  
  ---
  
  