This commit is contained in:
parent
a64b2d6ec3
commit
8b5cca921b
1 changed files with 27 additions and 0 deletions
27
docs/ir.md
Normal file
27
docs/ir.md
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Intermediate Representation
|
||||||
|
|
||||||
|
## Static Single Assignment
|
||||||
|
|
||||||
|
The SSA IR follows a simple rule: every value is assigned exactly once.
|
||||||
|
|
||||||
|
### Basic Blocks
|
||||||
|
|
||||||
|
Every function has a list of basic blocks. Basic blocks store values in the order they appear in the original code.
|
||||||
|
|
||||||
|
### Instructions
|
||||||
|
|
||||||
|
Instructions are no different from values. The calculation `1 + 2` is represented as 3 values using 2 int constants and 1 binary operation:
|
||||||
|
|
||||||
|
```
|
||||||
|
t0 = 1
|
||||||
|
t1 = 2
|
||||||
|
t2 = t0 + t1
|
||||||
|
```
|
||||||
|
|
||||||
|
All of these are considered values even in cases where the type of the value is `void` such as in procedural function calls with side effects.
|
||||||
|
|
||||||
|
### Pointers
|
||||||
|
|
||||||
|
There are no IDs or indices, therefore values don't know their position in a basic block.
|
||||||
|
|
||||||
|
Values reference other values by including a pointer to them.
|
Loading…
Add table
Add a link
Reference in a new issue