Added IR documentation
All checks were successful
/ test (push) Successful in 15s

This commit is contained in:
Eduard Urbach 2025-07-08 15:43:46 +02:00
parent a64b2d6ec3
commit 8b5cca921b
Signed by: ed
GPG key ID: 49226B848C78F6C8

27
docs/ir.md Normal file
View 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.