pub enum DataValue {
    I8(i8),
    I16(i16),
    I32(i32),
    I64(i64),
    I128(i128),
    F32(Ieee32),
    F64(Ieee64),
    V128([u8; 16]),
    V64([u8; 8]),
}
Expand description

Represent a data value. Where Value is an SSA reference, DataValue is the type + value that would be referred to by a Value.

Variants§

§

I8(i8)

§

I16(i16)

§

I32(i32)

§

I64(i64)

§

I128(i128)

§

F32(Ieee32)

§

F64(Ieee64)

§

V128([u8; 16])

§

V64([u8; 8])

Implementations§

source§

impl DataValue

source

pub fn from_integer( imm: i128, ty: Type ) -> Result<DataValue, DataValueCastFailure>

Try to cast an immediate integer (a wrapped i64 on most Cranelift instructions) to the given Cranelift Type.

source

pub fn ty(&self) -> Type

Return the Cranelift IR Type for this DataValue.

source

pub fn is_vector(&self) -> bool

Return true if the value is a vector (i.e. DataValue::V128).

source

pub fn to_be(self) -> Self

Converts self to big endian from target’s endianness.

source

pub fn to_le(self) -> Self

Converts self to little endian from target’s endianness.

source

pub fn write_to_slice_ne(&self, dst: &mut [u8])

Write a DataValue to a slice in native-endian byte order.

Panics:

Panics if the slice does not have enough space to accommodate the DataValue

source

pub fn write_to_slice_be(&self, dst: &mut [u8])

Write a DataValue to a slice in big-endian byte order.

Panics:

Panics if the slice does not have enough space to accommodate the DataValue

source

pub fn write_to_slice_le(&self, dst: &mut [u8])

Write a DataValue to a slice in little-endian byte order.

Panics:

Panics if the slice does not have enough space to accommodate the DataValue

source

pub fn read_from_slice_ne(src: &[u8], ty: Type) -> Self

Read a DataValue from a slice using a given Type with native-endian byte order.

Panics:

Panics if the slice does not have enough space to accommodate the DataValue

source

pub fn read_from_slice_be(src: &[u8], ty: Type) -> Self

Read a DataValue from a slice using a given Type in big-endian byte order.

Panics:

Panics if the slice does not have enough space to accommodate the DataValue

source

pub fn read_from_slice_le(src: &[u8], ty: Type) -> Self

Read a DataValue from a slice using a given Type in little-endian byte order.

Panics:

Panics if the slice does not have enough space to accommodate the DataValue

source

pub unsafe fn write_value_to(&self, p: *mut u128)

Write a DataValue to a memory location in native-endian byte order.

source

pub unsafe fn read_value_from(p: *const u128, ty: Type) -> Self

Read a DataValue from a memory location using a given Type in native-endian byte order.

source

pub fn bitwise_eq(&self, other: &DataValue) -> bool

Performs a bitwise comparison over the contents of DataValue.

Returns true if all bits are equal.

This behaviour is different from PartialEq for NaN floats.

Trait Implementations§

source§

impl Clone for DataValue

source§

fn clone(&self) -> DataValue

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 DataValue

source§

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

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

impl Display for DataValue

source§

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

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

impl From<[u8; 16]> for DataValue

source§

fn from(data: [u8; 16]) -> Self

Converts to this type from the input type.
source§

impl From<[u8; 8]> for DataValue

source§

fn from(data: [u8; 8]) -> Self

Converts to this type from the input type.
source§

impl From<Ieee32> for DataValue

source§

fn from(data: Ieee32) -> Self

Converts to this type from the input type.
source§

impl From<Ieee64> for DataValue

source§

fn from(data: Ieee64) -> Self

Converts to this type from the input type.
source§

impl From<Offset32> for DataValue

source§

fn from(o: Offset32) -> Self

Converts to this type from the input type.
source§

impl From<i128> for DataValue

source§

fn from(data: i128) -> Self

Converts to this type from the input type.
source§

impl From<i16> for DataValue

source§

fn from(data: i16) -> Self

Converts to this type from the input type.
source§

impl From<i32> for DataValue

source§

fn from(data: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for DataValue

source§

fn from(data: i64) -> Self

Converts to this type from the input type.
source§

impl From<i8> for DataValue

source§

fn from(data: i8) -> Self

Converts to this type from the input type.
source§

impl PartialEq<DataValue> for DataValue

source§

fn eq(&self, other: &Self) -> 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<DataValue> for DataValue

source§

fn partial_cmp(&self, other: &DataValue) -> 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 TryInto<[u8; 16]> for DataValue

§

type Error = DataValueCastFailure

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

fn try_into(self) -> Result<[u8; 16], Self::Error>

Performs the conversion.
source§

impl TryInto<[u8; 8]> for DataValue

§

type Error = DataValueCastFailure

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

fn try_into(self) -> Result<[u8; 8], Self::Error>

Performs the conversion.
source§

impl TryInto<Ieee32> for DataValue

§

type Error = DataValueCastFailure

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

fn try_into(self) -> Result<Ieee32, Self::Error>

Performs the conversion.
source§

impl TryInto<Ieee64> for DataValue

§

type Error = DataValueCastFailure

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

fn try_into(self) -> Result<Ieee64, Self::Error>

Performs the conversion.
source§

impl TryInto<i128> for DataValue

§

type Error = DataValueCastFailure

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

fn try_into(self) -> Result<i128, Self::Error>

Performs the conversion.
source§

impl TryInto<i16> for DataValue

§

type Error = DataValueCastFailure

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

fn try_into(self) -> Result<i16, Self::Error>

Performs the conversion.
source§

impl TryInto<i32> for DataValue

§

type Error = DataValueCastFailure

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

fn try_into(self) -> Result<i32, Self::Error>

Performs the conversion.
source§

impl TryInto<i64> for DataValue

§

type Error = DataValueCastFailure

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

fn try_into(self) -> Result<i64, Self::Error>

Performs the conversion.
source§

impl TryInto<i8> for DataValue

§

type Error = DataValueCastFailure

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

fn try_into(self) -> Result<i8, Self::Error>

Performs the conversion.

Auto Trait Implementations§

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

source§

impl<T, U> Into<U> for Twhere 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.

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

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

Performs the conversion.