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 record_spawn_target( &mut self, air_ref: AirRef, worker_fn: Spur, arg_type: Type, return_type: Type, )

ADR-0084: record codegen bookkeeping for a @spawn site.

Source

pub fn spawn_target(&self, air_ref: AirRef) -> Option<&SpawnTarget>

Look up the bookkeeping recorded for a @spawn site, if any.

Source

pub fn set_comptime_value_args( &mut self, inst_index: u32, value_args: Vec<ConstValue>, )

Record the comptime value arguments captured at a CallGeneric site. Indexed by the CallGeneric instruction’s index in instructions.

Source

pub fn comptime_value_args(&self, inst_index: u32) -> &[ConstValue]

Retrieve the comptime value arguments captured at the given CallGeneric site, or an empty slice if none were recorded.

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 remap_bytes_ids<F>(&mut self, map_fn: F)
where F: Fn(u32) -> u32,

Remap byte-blob IDs after merging per-function bytes pools into a single global pool (mirrors remap_string_ids).

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 Clone for Air

Source§

fn clone(&self) -> Air

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 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<'de> Deserialize<'de> for Air

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 Display for Air

Source§

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

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

impl Serialize for Air

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§

§

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> 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.

§

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,

§

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> 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
Source§

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

§

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