pub struct Inst(_);
Expand description

An opaque reference to an instruction in a Function.

Most usage of Inst is internal. Instructions are returned by InstBuilder instructions that do not return a Value, such as control flow and trap instructions, as well as instructions that return a variable (potentially zero!) number of values, like call or call-indirect instructions. To get the Value of such instructions, use inst_results or its analogue in cranelift_frontend::FuncBuilder.

If you look around the API, you can find many inventive uses for Inst, such as annotating specific instructions with a comment or performing reflection at compile time on the type of instruction.

While the order is stable, it is arbitrary and does not necessarily resemble the layout order.

Implementations§

source§

impl Inst

source

pub fn from_u32(x: u32) -> Self

Create a new instance from a u32.

source

pub fn as_u32(self) -> u32

Return the underlying index value as a u32.

source

pub fn as_bits(self) -> u32

Return the raw bit encoding for this instance.

source

pub fn from_bits(x: u32) -> Self

Create a new instance from the raw bit encoding.

Trait Implementations§

source§

impl Clone for Inst

source§

fn clone(&self) -> Inst

Returns a copy 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 Inst

source§

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

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

impl Display for Inst

source§

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

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

impl EntityRef for Inst

source§

fn new(index: usize) -> Self

Create a new entity reference from a small integer. This should crash if the requested index is not representable.
source§

fn index(self) -> usize

Get the index that was used to create this entity reference.
source§

impl From<Inst> for AnyEntity

source§

fn from(r: Inst) -> Self

Converts to this type from the input type.
source§

impl From<Inst> for ExpandedProgramPoint

source§

fn from(inst: Inst) -> Self

Converts to this type from the input type.
source§

impl From<Inst> for ProgramPoint

source§

fn from(inst: Inst) -> Self

Converts to this type from the input type.
source§

impl Hash for Inst

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Index<Inst> for Insts

Allow immutable access to instructions via indexing.

§

type Output = InstructionData

The returned type after indexing.
source§

fn index(&self, inst: Inst) -> &InstructionData

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<Inst> for Insts

Allow mutable access to instructions via indexing.

source§

fn index_mut(&mut self, inst: Inst) -> &mut InstructionData

Performs the mutable indexing (container[index]) operation. Read more
source§

impl Ord for Inst

source§

fn cmp(&self, other: &Inst) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Inst> for Inst

source§

fn eq(&self, other: &Inst) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Inst> for Inst

source§

fn partial_cmp(&self, other: &Inst) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl ReservedValue for Inst

source§

fn reserved_value() -> Inst

Create an instance of the reserved value.
source§

fn is_reserved_value(&self) -> bool

Checks whether value is the reserved one.
source§

impl Copy for Inst

source§

impl Eq for Inst

source§

impl StructuralEq for Inst

source§

impl StructuralPartialEq for Inst

Auto Trait Implementations§

§

impl RefUnwindSafe for Inst

§

impl Send for Inst

§

impl Sync for Inst

§

impl Unpin for Inst

§

impl UnwindSafe for Inst

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.

source§

impl<T> SparseMapValue<T> for Twhere T: EntityRef,

source§

fn key(&self) -> T

Get the key of this sparse map value. This key is not allowed to change while the value is a member of the map.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.