pub struct Rir { /* private fields */ }Expand description
The complete RIR for a source file.
Implementations§
Source§impl Rir
impl Rir
Sourcepub fn get_mut(&mut self, inst_ref: InstRef) -> &mut Inst
pub fn get_mut(&mut self, inst_ref: InstRef) -> &mut Inst
Get a mutable reference to an instruction.
Sourcepub fn iter(&self) -> impl Iterator<Item = (InstRef, &Inst)>
pub fn iter(&self) -> impl Iterator<Item = (InstRef, &Inst)>
Iterate over all instructions with their references.
Sourcepub fn add_inst_refs(&mut self, refs: &[InstRef]) -> (u32, u32)
pub fn add_inst_refs(&mut self, refs: &[InstRef]) -> (u32, u32)
Store a slice of InstRefs and return (start, len).
Sourcepub fn get_inst_refs(&self, start: u32, len: u32) -> Vec<InstRef>
pub fn get_inst_refs(&self, start: u32, len: u32) -> Vec<InstRef>
Retrieve InstRefs from the extra array.
Sourcepub fn add_symbols(&mut self, symbols: &[Spur]) -> (u32, u32)
pub fn add_symbols(&mut self, symbols: &[Spur]) -> (u32, u32)
Store a slice of Spurs and return (start, len).
Sourcepub fn get_symbols(&self, start: u32, len: u32) -> Vec<Spur>
pub fn get_symbols(&self, start: u32, len: u32) -> Vec<Spur>
Retrieve Spurs from the extra array.
Sourcepub fn add_enum_variant_decls(
&mut self,
variants: &[(Spur, Vec<Spur>, Vec<Spur>)],
) -> (u32, u32)
pub fn add_enum_variant_decls( &mut self, variants: &[(Spur, Vec<Spur>, Vec<Spur>)], ) -> (u32, u32)
Store enum variant declarations and return (start, variant_count).
Each variant is encoded as variable-length data in the extra array:
[name_spur, field_count, is_struct, field_type_0, ..., field_type_n, field_name_0?, ..., field_name_n?]
is_struct: 0 for unit/tuple variants, 1 for struct variants.- For struct variants, field names follow field types.
- Unit variants have
field_count = 0.
Sourcepub fn get_enum_variant_decls(
&self,
start: u32,
variant_count: u32,
) -> Vec<(Spur, Vec<Spur>, Vec<Spur>)>
pub fn get_enum_variant_decls( &self, start: u32, variant_count: u32, ) -> Vec<(Spur, Vec<Spur>, Vec<Spur>)>
Retrieve enum variant declarations from the extra array.
Returns a vec of (variant_name, field_types, field_names) triples.
field_names is empty for unit/tuple variants.
Sourcepub fn add_call_args(&mut self, args: &[RirCallArg]) -> (u32, u32)
pub fn add_call_args(&mut self, args: &[RirCallArg]) -> (u32, u32)
Store RirCallArgs and return (start, len). Layout: [value: u32, mode: u32] per arg
Sourcepub fn get_call_args(&self, start: u32, len: u32) -> Vec<RirCallArg>
pub fn get_call_args(&self, start: u32, len: u32) -> Vec<RirCallArg>
Retrieve RirCallArgs from the extra array.
Sourcepub fn add_params(&mut self, params: &[RirParam]) -> (u32, u32)
pub fn add_params(&mut self, params: &[RirParam]) -> (u32, u32)
Store RirParams and return (start, len). Layout: [name: u32, ty: u32, mode: u32, is_comptime: u32] per param
Sourcepub fn get_params(&self, start: u32, len: u32) -> Vec<RirParam>
pub fn get_params(&self, start: u32, len: u32) -> Vec<RirParam>
Retrieve RirParams from the extra array.
Sourcepub fn add_match_arms(&mut self, arms: &[(RirPattern, InstRef)]) -> (u32, u32)
pub fn add_match_arms(&mut self, arms: &[(RirPattern, InstRef)]) -> (u32, u32)
Store match arms (pattern + body pairs) and return (start, arm_count). Each arm is stored with variable size depending on pattern kind.
Sourcepub fn get_match_arms(
&self,
start: u32,
arm_count: u32,
) -> Vec<(RirPattern, InstRef)>
pub fn get_match_arms( &self, start: u32, arm_count: u32, ) -> Vec<(RirPattern, InstRef)>
Retrieve match arms from the extra array.
Sourcepub fn add_field_inits(&mut self, fields: &[(Spur, InstRef)]) -> (u32, u32)
pub fn add_field_inits(&mut self, fields: &[(Spur, InstRef)]) -> (u32, u32)
Store field initializers (name, value) and return (start, len). Layout: [name: u32, value: u32] per field
Sourcepub fn get_field_inits(&self, start: u32, len: u32) -> Vec<(Spur, InstRef)>
pub fn get_field_inits(&self, start: u32, len: u32) -> Vec<(Spur, InstRef)>
Retrieve field initializers from the extra array.
Sourcepub fn add_field_decls(&mut self, fields: &[(Spur, Spur)]) -> (u32, u32)
pub fn add_field_decls(&mut self, fields: &[(Spur, Spur)]) -> (u32, u32)
Store field declarations (name, type) and return (start, len). Layout: [name: u32, type: u32] per field
Sourcepub fn get_field_decls(&self, start: u32, len: u32) -> Vec<(Spur, Spur)>
pub fn get_field_decls(&self, start: u32, len: u32) -> Vec<(Spur, Spur)>
Retrieve field declarations from the extra array.
Sourcepub fn add_directives(&mut self, directives: &[RirDirective]) -> (u32, u32)
pub fn add_directives(&mut self, directives: &[RirDirective]) -> (u32, u32)
Store directives and return (start, directive_count). Layout: [name: u32, span_start: u32, span_len: u32, args_len: u32, args…] per directive
Sourcepub fn get_directives(
&self,
start: u32,
directive_count: u32,
) -> Vec<RirDirective>
pub fn get_directives( &self, start: u32, directive_count: u32, ) -> Vec<RirDirective>
Retrieve directives from the extra array.
Sourcepub fn add_destructure_fields(
&mut self,
fields: &[RirDestructureField],
) -> (u32, u32)
pub fn add_destructure_fields( &mut self, fields: &[RirDestructureField], ) -> (u32, u32)
Store destructure fields and return (start, field_count).
Sourcepub fn get_destructure_fields(
&self,
start: u32,
count: u32,
) -> Vec<RirDestructureField>
pub fn get_destructure_fields( &self, start: u32, count: u32, ) -> Vec<RirDestructureField>
Retrieve destructure fields from the extra array.
Sourcepub fn add_function_span(&mut self, span: FunctionSpan)
pub fn add_function_span(&mut self, span: FunctionSpan)
Add a function span to track function boundaries.
Sourcepub fn function_spans(&self) -> &[FunctionSpan]
pub fn function_spans(&self) -> &[FunctionSpan]
Get all function spans.
Sourcepub fn functions(&self) -> impl Iterator<Item = &FunctionSpan>
pub fn functions(&self) -> impl Iterator<Item = &FunctionSpan>
Iterate over function spans.
Sourcepub fn function_count(&self) -> usize
pub fn function_count(&self) -> usize
Get the number of functions.
Sourcepub fn function_view(&self, fn_span: &FunctionSpan) -> RirFunctionView<'_>
pub fn function_view(&self, fn_span: &FunctionSpan) -> RirFunctionView<'_>
Get a view of just one function’s instructions.
Sourcepub fn find_function(&self, name: Spur) -> Option<&FunctionSpan>
pub fn find_function(&self, name: Spur) -> Option<&FunctionSpan>
Find a function span by name.
Sourcepub fn current_inst_index(&self) -> u32
pub fn current_inst_index(&self) -> u32
Get the current instruction count (useful for tracking body start).
Sourcepub fn merge(rirs: &[Rir]) -> Rir
pub fn merge(rirs: &[Rir]) -> Rir
Merge multiple RIRs into a single RIR.
This is used for parallel per-file RIR generation. Each file generates its own RIR in parallel, then they are merged into a single RIR with all instruction references renumbered to be valid in the merged RIR.
§Arguments
rirs- Slice of RIRs to merge (typically one per source file)
§Returns
A new merged RIR containing all instructions from all input RIRs.