Three Address Code (3AC)
NyxLang lowers AST into an intermediate representation defined in 3ac.zig.
Why 3AC?
Section titled “Why 3AC?”3AC makes complex AST expressions explicit and linear:
- temporaries store intermediate values
- control flow is explicit via labels/branches
- easier backend lowering than a tree AST
Typical instruction shapes
Section titled “Typical instruction shapes”Even if the exact representation differs, most 3AC IRs include:
t = op a b(binary)t = op a(unary)t = load addrstore value -> addrgoto Lif cond goto LL:labelscall f(args...)return value
Control flow lowering
Section titled “Control flow lowering”if/elsebecomes conditional branches + join label- loops become header/body/exit labels with back-edges
Conventions
Section titled “Conventions”Document the conventions your backend expects, e.g.:
- is
x = ya move? - are booleans 0/1?
- how are comparisons represented?