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, is_pub) and return (start, len).
Layout: [name: u32, type: u32, is_pub: u32] per field. ADR-0073 added
the is_pub slot; pre-ADR call sites pass false for compatibility.
Sourcepub fn add_field_decls_with_vis(
&mut self,
fields: &[(Spur, Spur, bool)],
) -> (u32, u32)
pub fn add_field_decls_with_vis( &mut self, fields: &[(Spur, Spur, bool)], ) -> (u32, u32)
Store field declarations including visibility (ADR-0073).
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 (name, type) from the extra array.
Sourcepub fn get_field_decls_with_vis(
&self,
start: u32,
len: u32,
) -> Vec<(Spur, Spur, bool)>
pub fn get_field_decls_with_vis( &self, start: u32, len: u32, ) -> Vec<(Spur, Spur, bool)>
Retrieve field declarations with visibility (ADR-0073).
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).
binding_name is Option<Spur>. None encodes as u32::MAX —
using 0 as the sentinel was wrong because Spur::into_usize is
0-indexed (the first-interned Spur lives at index 0), so the very
first name interned in the build would round-trip back as None
and lose its binding. u32::MAX matches the encoding already used
by encode_binding / decode_binding above.
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_extern_fn(&mut self, extern_fn: RirExternFn)
pub fn add_extern_fn(&mut self, extern_fn: RirExternFn)
Add a function span to track function boundaries.
ADR-0085: append an extern fn declaration (from inside a link_extern
block).
Sourcepub fn extern_fns(&self) -> &[RirExternFn]
pub fn extern_fns(&self) -> &[RirExternFn]
ADR-0085: read-only view over all extern fns declared in this file.
Sourcepub fn add_empty_link_extern_block(
&mut self,
library: Spur,
link_mode: RirLinkMode,
span: Span,
)
pub fn add_empty_link_extern_block( &mut self, library: Spur, link_mode: RirLinkMode, span: Span, )
ADR-0085: append an empty link_extern("lib") { } block.
Sourcepub fn empty_link_extern_blocks(&self) -> &[(Spur, RirLinkMode, Span)]
pub fn empty_link_extern_blocks(&self) -> &[(Spur, RirLinkMode, Span)]
ADR-0085: read-only view over link_extern blocks that declared
no symbols. Sema validates the library name and emits the
corresponding -l<lib> link flag.
pub fn add_function_span(&mut self, span: FunctionSpan)
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Rir
impl<'de> Deserialize<'de> for Rir
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Rir
impl RefUnwindSafe for Rir
impl Send for Rir
impl Sync for Rir
impl Unpin for Rir
impl UnsafeUnpin for Rir
impl UnwindSafe for Rir
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].