LLVM (Low Level Virtual Machine)
- LLVM is a set of
compiler
andtoolchain technologies
- Allows creating
frontends
for any programming language - Allows creating
backends
for any instruction set architecture - It is designed around a language independent
Intermediate Representation (IR)
Steps
-
Frontend
-
Source Code
- Lexical Analysis (AST)
-
IR Code
-
Middle
-
IR code optimization
-
Backend
-
IR code
- Machine code
Bulding LLVM
Lexer
- Scans the source code and breaks into a collection of tokens
- Tokens
Identifier
: x, color, UPKeyword
: if, while, returnSeparator
: }, (, ;Operator
: +, <, =Literal
: true, 6.02e23, "music"
AST (Abstract Syntax Tree)
- Tree to represent to
structure of the code
and therelation between the tokens
Parser
- Builds the AST
IR
- Generates the
intermediate representation
code