Work in progress…
Planned to be a simpler version of what LLVM is at its core; “An optimizer and transpiler of its very own LLVM IR to various architecture’s ISA”.
function L, n
arg id
id = op
id = op1 arith op2
id = unary op
goto L
label L
if (op1 relop op2) goto L
id = op1 relop op2
param op
id = call L, n
ret op

In the IRL architecture, the initial step involves converting the source code into an AST (Abstract Syntax Tree) using the frontend (fe) module. The resulting AST then passes through a middleware (mw) module that invokes AST passes for correction and validation. Two default AST passes include validate_iden_pass, which ensures all identifiers used in instructions are valid, and add_goto_pass, which inserts goto statements before necessary label instructions.
The corrected AST then proceeds to the optimization (opt) module, where it is transformed into a CFG (Control Flow Graph). This module applies Compiler Passes to the CFG to optimize it, including reduce_pass for simplifying the CFG, constant_fold_pass for folding constants, and reaching_definition_pass for eliminating redundant instructions.
The optimized CFG is then passed to the translation (trn) module, which translates it into assembly code tailored to the target architecture.
| flag | Status | Notes |
|---|---|---|
fasm-linux-x86_64 | ✔️ Supported | Full functionality available |
fasm-windows-x86_64 | ✖️ Planned | Future support under development |
wasm | ✖️ Planned | Future support under development |
function fib, 1
arg n
a = 0
b = 1
i = 1
label begin
if (i == n) goto end
t = b
b = a + b
a = t
i = i + 1
goto begin
label end
ret b
function main, 0
param 6
a = call fib, 1
param a
tmp = call print, 1
ret 0
$ cargo run -- compile -r -f ./eg/fib.irl --cfg --fasm-linux-x86_64
8
$ echo $?
0
Generated control flow graph of this example
