Skip to main content

Air

Struct Air 

Source
pub struct Air { /* private fields */ }
Expand description

The complete AIR for a function.

Implementations§

Source§

impl Air

Source

pub fn new(return_type: Type) -> Self

Create a new empty AIR.

Source

pub fn add_inst(&mut self, inst: AirInst) -> AirRef

Add an instruction and return its reference.

Source

pub fn get(&self, inst_ref: AirRef) -> &AirInst

Get an instruction by reference.

Source

pub fn return_type(&self) -> Type

The return type of this function.

Source

pub fn len(&self) -> usize

The number of instructions.

Source

pub fn is_empty(&self) -> bool

Whether there are no instructions.

Source

pub fn iter(&self) -> impl Iterator<Item = (AirRef, &AirInst)>

Iterate over all instructions with their references.

Source

pub fn add_extra(&mut self, data: &[u32]) -> u32

Add extra data and return the start index.

Source

pub fn get_extra(&self, start: u32, len: u32) -> &[u32]

Get extra data slice by start index and length.

Source

pub fn get_air_refs( &self, start: u32, len: u32, ) -> impl Iterator<Item = AirRef> + '_

Get AirRefs from extra array (for blocks, array elements, intrinsic args, etc.).

Source

pub fn get_call_args( &self, start: u32, len: u32, ) -> impl Iterator<Item = AirCallArg> + '_

Get call arguments from extra array. Each call arg is encoded as 2 u32s: (air_ref, mode).

Source

pub fn get_match_arms( &self, start: u32, len: u32, ) -> impl Iterator<Item = (AirPattern, AirRef)> + '_

Get match arms from extra array. Each match arm is encoded based on pattern type plus the body AirRef.

Source

pub fn get_struct_init( &self, fields_start: u32, fields_len: u32, source_order_start: u32, ) -> (impl Iterator<Item = AirRef> + '_, impl Iterator<Item = usize> + '_)

Get struct init data from extra array. Returns (field_refs_iterator, source_order_iterator).

Source

pub fn remap_string_ids<F>(&mut self, map_fn: F)
where F: Fn(u32) -> u32,

Remap string constant IDs using the provided mapping function.

This is used after parallel function analysis to convert local string IDs (per-function) to global string IDs (across all functions). The mapping function takes a local string ID and returns the global string ID.

Source

pub fn instructions(&self) -> &[AirInst]

Get a reference to all instructions.

Source

pub fn rewrite_inst_data(&mut self, index: usize, new_data: AirInstData)

Rewrite the data of an instruction at a given index.

This is used by the specialization pass to rewrite CallGeneric to Call. The type and span are preserved.

Source

pub fn push_projections( &mut self, projs: impl IntoIterator<Item = AirProjection>, ) -> (u32, u32)

Add projections to the projections array and return (start, len).

Used for PlaceRead and PlaceWrite instructions.

Source

pub fn get_projections(&self, start: u32, len: u32) -> &[AirProjection]

Get a slice from the projections array.

Source

pub fn get_place_projections(&self, place: &AirPlace) -> &[AirProjection]

Get projections for a place.

Source

pub fn make_place( &mut self, base: AirPlaceBase, projs: impl IntoIterator<Item = AirProjection>, ) -> AirPlaceRef

Create a place with the given base and projections.

This adds the projections to the projections array and returns a PlaceRef that references the place.

Source

pub fn get_place(&self, place_ref: AirPlaceRef) -> &AirPlace

Get a place by reference.

Source

pub fn places(&self) -> &[AirPlace]

Get all places.

Source

pub fn projections(&self) -> &[AirProjection]

Get all projections.

Trait Implementations§

Source§

impl Debug for Air

Source§

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

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

impl Default for Air

Source§

fn default() -> Air

Returns the “default value” for a type. Read more
Source§

impl Display for Air

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Air

§

impl RefUnwindSafe for Air

§

impl Send for Air

§

impl Sync for Air

§

impl Unpin for Air

§

impl UnsafeUnpin for Air

§

impl UnwindSafe for Air

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more