Skip to main content

InstData

Enum InstData 

Source
pub enum InstData {
Show 55 variants IntConst(u64), FloatConst(u64), BoolConst(bool), CharConst(u32), StringConst(Spur), UnitConst, Bin { op: BinOp, lhs: InstRef, rhs: InstRef, }, Unary { op: UnaryOp, operand: InstRef, }, MakeRef { operand: InstRef, is_mut: bool, }, BareRangeSubscript, MakeSlice { base: InstRef, lo: Option<InstRef>, hi: Option<InstRef>, is_mut: bool, }, Branch { cond: InstRef, then_block: InstRef, else_block: Option<InstRef>, is_comptime: bool, }, Loop { cond: InstRef, body: InstRef, }, For { binding: Spur, is_mut: bool, iterable: InstRef, body: InstRef, }, InfiniteLoop { body: InstRef, }, Match { scrutinee: InstRef, arms_start: u32, arms_len: u32, }, Break, Continue, FnDecl { directives_start: u32, directives_len: u32, is_pub: bool, is_unchecked: bool, name: Spur, params_start: u32, params_len: u32, return_type: Spur, body: InstRef, has_self: bool, receiver_mode: u8, }, ConstDecl { directives_start: u32, directives_len: u32, is_pub: bool, name: Spur, ty: Option<Spur>, init: InstRef, }, Call { name: Spur, args_start: u32, args_len: u32, }, Intrinsic { name: Spur, args_start: u32, args_len: u32, }, TypeIntrinsic { name: Spur, type_arg: Spur, }, TypeInterfaceIntrinsic { name: Spur, type_arg: Spur, type_inst: Option<InstRef>, interface_arg: Spur, }, ParamRef { index: u32, name: Spur, }, Ret(Option<InstRef>), Block { extra_start: u32, len: u32, }, Alloc { directives_start: u32, directives_len: u32, name: Option<Spur>, is_mut: bool, ty: Option<Spur>, init: InstRef, }, StructDestructure { type_name: Spur, fields_start: u32, fields_len: u32, init: InstRef, }, VarRef { name: Spur, }, Assign { name: Spur, value: InstRef, }, StructDecl { directives_start: u32, directives_len: u32, is_pub: bool, posture: Posture, name: Spur, fields_start: u32, fields_len: u32, methods_start: u32, methods_len: u32, }, StructInit { module: Option<InstRef>, type_name: Spur, fields_start: u32, fields_len: u32, }, FieldGet { base: InstRef, field: Spur, }, FieldSet { base: InstRef, field: Spur, value: InstRef, }, EnumDecl { is_pub: bool, posture: Posture, name: Spur, variants_start: u32, variants_len: u32, methods_start: u32, methods_len: u32, directives_start: u32, directives_len: u32, }, EnumVariant { module: Option<InstRef>, type_name: Spur, variant: Spur, }, EnumStructVariant { module: Option<InstRef>, type_name: Spur, variant: Spur, fields_start: u32, fields_len: u32, }, ArrayInit { elems_start: u32, elems_len: u32, }, IndexGet { base: InstRef, index: InstRef, }, IndexSet { base: InstRef, index: InstRef, value: InstRef, }, MethodCall { receiver: InstRef, method: Spur, args_start: u32, args_len: u32, }, AssocFnCall { type_name: Spur, function: Spur, args_start: u32, args_len: u32, }, InterfaceDecl { is_pub: bool, name: Spur, methods_start: u32, methods_len: u32, directives_start: u32, directives_len: u32, }, InterfaceMethodSig { name: Spur, params_start: u32, params_len: u32, return_type: Spur, receiver_mode: u8, is_unchecked: bool, directives_start: u32, directives_len: u32, }, DeriveDecl { name: Spur, methods_start: u32, methods_len: u32, }, Comptime { expr: InstRef, }, ComptimeUnrollFor { binding: Spur, iterable: InstRef, body: InstRef, }, Checked { expr: InstRef, }, TypeConst { type_name: Spur, }, AnonStructType { directives_start: u32, directives_len: u32, fields_start: u32, fields_len: u32, methods_start: u32, methods_len: u32, }, AnonEnumType { directives_start: u32, directives_len: u32, variants_start: u32, variants_len: u32, methods_start: u32, methods_len: u32, }, AnonInterfaceType { methods_start: u32, methods_len: u32, }, TupleInit { elems_start: u32, elems_len: u32, }, AnonFnValue { method: InstRef, },
}
Expand description

Instruction data - the actual operation.

Variants§

§

IntConst(u64)

Integer constant

§

FloatConst(u64)

Floating-point constant, stored as f64 bits for Eq/Hash/Copy compatibility. Use f64::from_bits() to recover the value.

§

BoolConst(bool)

Boolean constant

§

CharConst(u32)

Char constant — Unicode scalar value (ADR-0071).

§

StringConst(Spur)

String constant (interned string content)

§

UnitConst

Unit constant (for blocks that produce unit type)

§

Bin

Binary operation: lhs <op> rhs. Covers arithmetic, comparison, logical, and bitwise ops. The specific op is in BinOp. Logical And/Or are short-circuiting and are lowered to control flow during CFG construction.

Fields

§op: BinOp
§

Unary

Unary operation: <op> operand. Covers -, !, and ~.

Fields

§op: UnaryOp
§operand: InstRef
§

MakeRef

Reference construction (ADR-0062): &x (is_mut = false) or &mut x (is_mut = true). Operand must be an lvalue. Result type is Ref(T) or MutRef(T) where T is the operand’s type.

Fields

§operand: InstRef
§is_mut: bool
§

BareRangeSubscript

ADR-0064: a range-shaped subscript that wasn’t borrowed by & or &mut. There is no slice value without a borrow, so this carries no operands; sema reports the error and continues.

§

MakeSlice

Slice construction by borrow over a range subscript (ADR-0064).

Lowered from &arr[range] (is_mut = false) and &mut arr[range] (is_mut = true). The base must be an lvalue of array type. lo and hi are the range endpoints; None means the implicit default (0 for lo, arr.len() for hi).

Fields

§base: InstRef
§is_mut: bool
§

Branch

Branch: if cond then then_block else else_block

Fields

§cond: InstRef
§then_block: InstRef
§else_block: Option<InstRef>
§is_comptime: bool

ADR-0079 follow-up: when set, sema evaluates cond at comptime and emits only the chosen branch — the discarded branch is never analyzed (so it’s free to reference shapes that don’t apply to the surrounding type, e.g. @uninit(Self) inside a struct-only branch when Self is enum). Source form: comptime if cond { … }.

§

Loop

While loop: while cond { body }

Fields

§cond: InstRef
§body: InstRef
§

For

For-in loop: for [mut] binding in iterable { body }

Fields

§binding: Spur

The loop variable name

§is_mut: bool

Whether the loop variable is mutable

§iterable: InstRef

The iterable expression (array or @range result)

§body: InstRef

The loop body

§

InfiniteLoop

Infinite loop: loop { body }

Fields

§body: InstRef
§

Match

Match expression: match scrutinee { pattern => expr, … } Arms are stored in the extra array using add_match_arms/get_match_arms.

Fields

§scrutinee: InstRef

The value being matched

§arms_start: u32

Index into extra data where arms start

§arms_len: u32

Number of match arms

§

Break

Break: exits the innermost loop

§

Continue

Continue: jumps to the next iteration of the innermost loop

§

FnDecl

Function definition Contains: name symbol, parameters, return type symbol, body instruction ref Directives and params are stored in the extra array.

Fields

§directives_start: u32

Index into extra data where directives start

§directives_len: u32

Number of directives

§is_pub: bool

Whether this function is public (requires –preview modules)

§is_unchecked: bool

Whether this function is marked unchecked (can only be called from checked blocks)

§name: Spur
§params_start: u32

Index into extra data where params start

§params_len: u32

Number of parameters

§return_type: Spur
§body: InstRef
§has_self: bool

Whether this function/method takes self as a receiver. Only true for methods in impl blocks that have a self parameter. Used by sema to know to add the implicit self parameter.

§receiver_mode: u8

Receiver shape for methods (ADR-0060, ADR-0076). Encoded as a byte: 0 = self/self : Self (by-value), 1 = self : MutRef(Self), 2 = self : Ref(Self). Ignored when !has_self.

§

ConstDecl

Constant declaration Contains: name symbol, optional type, initializer expression ref Directives are stored in the extra array. Used for module re-exports: pub const strings = @import("utils/strings.gruel");

Fields

§directives_start: u32

Index into extra data where directives start

§directives_len: u32

Number of directives

§is_pub: bool

Whether this constant is public (requires –preview modules)

§name: Spur

Constant name

§ty: Option<Spur>

Optional type annotation (interned string, None if inferred)

§init: InstRef

Initializer expression

§

Call

Function call Args are stored in the extra array using add_call_args/get_call_args.

Fields

§name: Spur

Function name

§args_start: u32

Index into extra data where args start

§args_len: u32

Number of arguments

§

Intrinsic

Intrinsic call with expression arguments (e.g., @dbg) Args are stored in the extra array using add_inst_refs/get_inst_refs.

Fields

§name: Spur

Intrinsic name (without @)

§args_start: u32

Index into extra data where args start

§args_len: u32

Number of arguments

§

TypeIntrinsic

Intrinsic call with a type argument (e.g., @size_of, @align_of)

Fields

§name: Spur

Intrinsic name (without @)

§type_arg: Spur

Type argument (as an interned string, e.g., “i32”, “Point”, “[i32; 4]”)

§

TypeInterfaceIntrinsic

Intrinsic call with a type argument and an interface argument (e.g., @implements(T, Drop)).

type_arg is the interned name when the source has a bare type name or type expression. type_inst, when Some, is an arbitrary expression that comptime-evaluates to a Type value (e.g. f.field_type projecting out of @type_info). Sema prefers type_inst when set.

Fields

§name: Spur

Intrinsic name (without @)

§type_arg: Spur

Type argument (interned name).

§type_inst: Option<InstRef>

Optional comptime-evaluable type expression. When set, supersedes type_arg.

§interface_arg: Spur

Interface argument (interned name).

§

ParamRef

Reference to a function parameter

Fields

§index: u32

Parameter index (0-based)

§name: Spur

Parameter name (for error messages)

§

Ret(Option<InstRef>)

Return value from function (None for return; in unit-returning functions)

§

Block

Block of instructions (for function bodies) The result is the last instruction in the block

Fields

§extra_start: u32

Index into extra data where instruction refs start

§len: u32

Number of instructions in the block

§

Alloc

Local variable declaration: allocates storage and initializes If name is None, this is a wildcard pattern that discards the value Directives are stored in the extra array using add_directives/get_directives.

Fields

§directives_start: u32

Index into extra data where directives start

§directives_len: u32

Number of directives

§name: Option<Spur>

Variable name (None for wildcard _ pattern that discards the value)

§is_mut: bool

Whether the variable is mutable

§ty: Option<Spur>

Optional type annotation

§init: InstRef

Initial value instruction

§

StructDestructure

Struct destructuring: let TypeName { fields } = expr; Fields are stored in the extra array as groups of 4 u32s: [field_name, binding_name (0 = shorthand), is_wildcard, is_mut]

Fields

§type_name: Spur

Struct type name

§fields_start: u32

Index into extra data where field data starts

§fields_len: u32

Number of fields

§init: InstRef

Initializer expression

§

VarRef

Variable reference: reads the value of a variable

Fields

§name: Spur

Variable name

§

Assign

Assignment: stores a value into a mutable variable

Fields

§name: Spur

Variable name

§value: InstRef

Value to store

§

StructDecl

Struct type declaration Directives, fields, and methods are stored in the extra array.

Fields

§directives_start: u32

Index into extra data where directives start

§directives_len: u32

Number of directives

§is_pub: bool

Whether this struct is public (requires –preview modules)

§posture: Posture

Declared ownership posture (ADR-0080). Affine when neither @mark(copy) nor @mark(linear) appears in the directive list.

§name: Spur

Struct name

§fields_start: u32

Index into extra data where fields start

§fields_len: u32

Number of fields

§methods_start: u32

Index into extra data where method refs start

§methods_len: u32

Number of methods

§

StructInit

Struct literal: creates a new struct instance Fields are stored in the extra array using add_field_inits/get_field_inits.

Fields

§module: Option<InstRef>

Optional module reference (for qualified struct literals like module.Point { ... }) If Some, the struct is looked up in the module’s exports.

§type_name: Spur

Struct type name

§fields_start: u32

Index into extra data where fields start

§fields_len: u32

Number of fields

§

FieldGet

Field access: reads a field from a struct

Fields

§base: InstRef

Base struct value

§field: Spur

Field name

§

FieldSet

Field assignment: writes a value to a struct field

Fields

§base: InstRef

Base struct value

§field: Spur

Field name

§value: InstRef

Value to store

§

EnumDecl

Enum type declaration Variants are stored in the extra array using add_enum_variant_decls/get_enum_variant_decls. Each variant encodes: [name_spur, field_count, field_type_0, …, field_type_n].

Fields

§is_pub: bool

Whether this enum is public (requires –preview modules)

§posture: Posture

Declared ownership posture (ADR-0080). Affine when neither @mark(copy) nor @mark(linear) appears in the directive list.

§name: Spur

Enum name

§variants_start: u32

Index into extra data where variants start

§variants_len: u32

Number of variants

§methods_start: u32

Index into extra data where method refs start

§methods_len: u32

Number of methods

§directives_start: u32

Index into extra data where directives start (ADR-0079).

§directives_len: u32

Number of directives.

§

EnumVariant

Enum variant: creates a value of an enum type

Fields

§module: Option<InstRef>

Optional module reference (for qualified paths like module.Color::Red) If Some, the enum is looked up in the module’s exports.

§type_name: Spur

Enum type name

§variant: Spur

Variant name

§

EnumStructVariant

Enum struct variant construction: Enum::Variant { field: value, ... } Fields are stored in the extra array using add_field_inits/get_field_inits.

Fields

§module: Option<InstRef>

Optional module reference (for qualified paths)

§type_name: Spur

Enum type name

§variant: Spur

Variant name

§fields_start: u32

Start of field initializers in extra array

§fields_len: u32

Number of field initializers

§

ArrayInit

Array literal: creates a new array from element values Elements are stored in the extra array using add_inst_refs/get_inst_refs.

Fields

§elems_start: u32

Index into extra data where elements start

§elems_len: u32

Number of elements

§

IndexGet

Array index read: reads an element from an array

Fields

§base: InstRef

Base array value

§index: InstRef

Index expression

§

IndexSet

Array index write: writes a value to an array element

Fields

§base: InstRef

Base array value (must be a VarRef to a mutable variable)

§index: InstRef

Index expression

§value: InstRef

Value to store

§

MethodCall

Method call: receiver.method(args) Args are stored in the extra array using add_call_args/get_call_args.

Fields

§receiver: InstRef

Receiver expression (the struct value)

§method: Spur

Method name

§args_start: u32

Index into extra data where args start

§args_len: u32

Number of arguments

§

AssocFnCall

Associated function call: Type::function(args) Args are stored in the extra array using add_call_args/get_call_args.

Fields

§type_name: Spur

Type name (e.g., Point)

§function: Spur

Function name (e.g., origin)

§args_start: u32

Index into extra data where args start

§args_len: u32

Number of arguments

§

InterfaceDecl

Interface declaration (ADR-0056): a structurally typed set of method requirements.

Method signatures are stored as InstRefs to InterfaceMethodSig instructions in the inst-refs extra array.

Fields

§is_pub: bool

Whether this interface is public.

§name: Spur

Interface name.

§methods_start: u32

Start of method-sig inst refs in extra data.

§methods_len: u32

Number of method signatures.

§directives_start: u32

Start of directives in extra data (ADR-0079).

§directives_len: u32

Number of directives.

§

InterfaceMethodSig

A single method signature inside an InterfaceDecl.

No body. The receiver is always present (interface methods cannot be associated functions in MVP); its surface shape (self, self : MutRef(Self), or self : Ref(Self)) is encoded in receiver_mode using the byte mapping 0/1/2.

Fields

§name: Spur

Method name.

§params_start: u32

Start of params in extra data (excluding self).

§params_len: u32

Number of explicit parameters.

§return_type: Spur

Return type symbol (() if none was written).

§receiver_mode: u8

Receiver mode encoded as RirParamMode (ADR-0060).

§is_unchecked: bool

ADR-0088: whether this signature was declared @mark(unchecked).

§directives_start: u32

ADR-0088: start of the signature’s directive list in the extra-array, kept so sema can reject non-applicable markers (e.g. @mark(c)) at validation time.

§directives_len: u32

Number of directives.

§

DeriveDecl

Derive declaration (ADR-0058): derive Name { fn ... }.

Holds a list of method declarations (each emitted as a FnDecl instruction with has_self set when the method takes self). When a @derive(Name) directive on a struct or enum names this derive, the methods are spliced into the host type’s method list with Self bound to the host.

Fields

§name: Spur

Derive name (e.g., Drop).

§methods_start: u32

Start of method-decl inst refs in extra data.

§methods_len: u32

Number of methods.

§

Comptime

Comptime block expression: comptime { expr } The inner expression must be evaluable at compile time.

Fields

§expr: InstRef

The expression to evaluate at compile time

§

ComptimeUnrollFor

Comptime unroll for loop: comptime_unroll for binding in iterable { body } The iterable must be evaluable at compile time. The body is duplicated once per iteration with the binding replaced by each element’s value.

Fields

§binding: Spur

The loop variable name

§iterable: InstRef

The iterable expression (must be comptime-evaluable, e.g. @type_info fields)

§body: InstRef

The loop body (will be unrolled at compile time)

§

Checked

Checked block expression: checked { expr } Unchecked operations (raw pointer manipulation, calling unchecked functions) are only allowed inside checked blocks.

Fields

§expr: InstRef

The expression inside the checked block

§

TypeConst

Type constant: a type used as a value expression (e.g., i32 in identity(i32, 42)) The type_name is the symbol for the type (e.g., “i32”, “bool”).

Fields

§type_name: Spur

The type name symbol

§

AnonStructType

Anonymous struct type: a struct type used as a value expression (e.g., struct { first: T, second: T, fn method(self) -> T { ... } } in comptime type construction) Fields are stored in the extra array using add_field_decls/get_field_decls. Methods are stored as InstRefs to FnDecl instructions in the extra array.

Fields

§directives_start: u32

Index into extra data where directives start (ADR-0058 anon hosts).

§directives_len: u32

Number of directives.

§fields_start: u32

Index into extra data where fields start

§fields_len: u32

Number of fields

§methods_start: u32

Index into extra data where method InstRefs start

§methods_len: u32

Number of methods (InstRefs to FnDecl instructions)

§

AnonEnumType

Anonymous enum type: an enum type used as a value expression (e.g., enum { Some(T), None, fn method(self) -> T { ... } } in comptime type construction) Variants are stored in the extra array using add_enum_variant_decls/get_enum_variant_decls. Methods are stored as InstRefs to FnDecl instructions in the extra array.

Fields

§directives_start: u32

Index into extra data where directives start (ADR-0058 anon hosts).

§directives_len: u32

Number of directives.

§variants_start: u32

Index into extra data where variants start

§variants_len: u32

Number of variants

§methods_start: u32

Index into extra data where method InstRefs start

§methods_len: u32

Number of methods (InstRefs to FnDecl instructions)

§

AnonInterfaceType

Anonymous interface type (ADR-0057): an interface type used as a value expression inside a comptime function body.

The methods are stored as InstRefs to InterfaceMethodSig instructions in the inst-refs extra array, mirroring InterfaceDecl for named interfaces.

Fields

§methods_start: u32

Index into extra data where method-sig inst refs start.

§methods_len: u32

Number of method signatures.

§

TupleInit

Tuple literal: (e0, e1, ..., eN-1) (ADR-0048). Lowered in sema to a StructInit against a synthesised anon struct with field names “0”, “1”, … and field types inferred from the elements. Elements are stored as raw u32 InstRefs in the extra array.

Tuple field access t.N is not a distinct RIR instruction; astgen lowers it to a regular FieldGet whose field is the stringified index interned as a Spur. Struct field names are identifiers (never start with a digit), so synthetic tuple field names cannot collide with user code.

Fields

§elems_start: u32

Index into extra data where element InstRefs start

§elems_len: u32

Number of elements

§

AnonFnValue

Anonymous function value (ADR-0055). Lowered in sema to a fresh lambda-tagged anon struct with zero fields and one __call method, then instantiated as an empty StructInit. The struct type is unique per-site — sema skips structural dedup for lambda-origin structs so two same-signature fn(...) expressions produce distinct types.

Fields

§method: InstRef

InstRef to the FnDecl for the synthesized __call method.

Trait Implementations§

Source§

impl Clone for InstData

Source§

fn clone(&self) -> InstData

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InstData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for InstData

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for InstData

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

§

type Proj<U: 'src> = U

§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a [MaybeRef].
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,