LLVM (Low Level Virtual Machine)
- LLVM is a set of
compilerandtoolchain technologies - Allows creating
frontendsfor any programming language - Allows creating
backendsfor 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 codeand therelation between the tokens
Parser
- Builds the AST
IR
- Generates the
intermediate representationcode