Expand description
Gruel Intermediate Representation (RIR) - Untyped IR.
RIR is the first IR in the Gruel compiler pipeline. It is generated from the AST and represents a lowered, linearized form of the program.
Key characteristics:
- Untyped: type information is not yet resolved
- Per-file: generated for each source file
- Dense encoding: instructions stored in arrays, referenced by index
Inspired by Zig’s ZIR (Zig Intermediate Representation).
Structs§
- AstGen
- Generates RIR from an AST.
- Function
Span - Stored representation of directive in the extra array. Layout: [name: u32, span_start: u32, span_len: u32, args_len: u32, args…] Variable size due to args. A span marking the boundaries of a function in the RIR.
- Inst
- A single RIR instruction.
- InstRef
- A reference to an instruction in the RIR.
- Rir
- The complete RIR for a source file.
- RirCall
Arg - An argument in a function call.
- RirDirective
- A directive in the RIR (e.g., @allow(unused_variable))
- RirFunction
View - A view into a function’s instructions within the RIR.
- RirParam
- A parameter in a function declaration.
- RirPattern
Binding - A binding in a data variant pattern.
- RirPrinter
- Printer for RIR that resolves symbols to their string values.
Enums§
- Inst
Data - Instruction data - the actual operation.
- RirArg
Mode - Argument passing mode in RIR.
- RirParam
Mode - Parameter passing mode in RIR.
- RirPattern
- A pattern in a match expression (RIR level - untyped).