cranelift_codegen::ir::immediates

Struct Ieee128

Source
#[repr(C)]
pub struct Ieee128 { /* private fields */ }
Expand description

An IEEE binary128 immediate floating point value, represented as a u128 containing the bit pattern.

We specifically avoid using a f128 here since some architectures may silently alter floats. See: https://github.com/bytecodealliance/wasmtime/pull/2251#discussion_r498508646

The PartialEq and Hash implementations are over the underlying bit pattern, but PartialOrd respects IEEE754 semantics.

All bit patterns are allowed.

Implementations§

Source§

impl Ieee128

Source

pub const NAN: Self = _

The positive WebAssembly canonical NaN.

Source

pub const fn with_bits(bits: u128) -> Self

Create a new Ieee128 containing the bits of bits.

Source

pub fn bits(self) -> u128

Get the bitwise representation.

Source

pub fn abs(self) -> Self

Computes the absolute value of self.

Source

pub fn copysign(self, sign: Self) -> Self

Returns a number composed of the magnitude of self and the sign of sign.

Source

pub fn minimum(self, other: Self) -> Self

Returns the minimum of self and other, following the WebAssembly/IEEE 754-2019 definition.

Source

pub fn maximum(self, other: Self) -> Self

Returns the maximum of self and other, following the WebAssembly/IEEE 754-2019 definition.

Source

pub fn pow2<I: Into<i32>>(n: I) -> Self

Create an Ieee128 number representing 2.0^n.

Source

pub fn fcvt_to_sint_negative_overflow<I: Into<i32>>(n: I) -> Self

Create an Ieee128 number representing the greatest negative value not convertible from f128 to a signed integer with width n.

Source

pub fn is_nan(self) -> bool

Check if the value is a NaN. For Ieee128, this means checking that all the exponent bits are set and the significand is non-zero.

Source

pub fn is_positive(self) -> bool

Returns true if self has a negative sign, including 0.0, NaNs with positive sign bit and positive infinity.

Source

pub fn is_negative(self) -> bool

Returns true if self has a negative sign, including -0.0, NaNs with negative sign bit and negative infinity.

Source

pub fn is_zero(self) -> bool

Returns true if self is positive or negative zero.

Source

pub fn non_nan(self) -> Option<Self>

Returns None if self is a NaN and Some(self) otherwise.

Trait Implementations§

Source§

impl BitAnd for Ieee128

Source§

type Output = Ieee128

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self

Performs the & operation. Read more
Source§

impl BitOr for Ieee128

Source§

type Output = Ieee128

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
Source§

impl BitXor for Ieee128

Source§

type Output = Ieee128

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self

Performs the ^ operation. Read more
Source§

impl Clone for Ieee128

Source§

fn clone(&self) -> Ieee128

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 Ieee128

Source§

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

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

impl<'de> Deserialize<'de> for Ieee128

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 Ieee128

Source§

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

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

impl From<Ieee128> for ConstantData

Source§

fn from(v: Ieee128) -> Self

Converts to this type from the input type.
Source§

impl From<Ieee128> for DataValue

Source§

fn from(data: Ieee128) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Ieee128

Source§

type Err = &'static str

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, &'static str>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Ieee128

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 IntoBytes for Ieee128

Source§

fn into_bytes(self) -> Vec<u8>

Return the little-endian byte representation of the implementing type.
Source§

impl Neg for Ieee128

Source§

type Output = Ieee128

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl Not for Ieee128

Source§

type Output = Ieee128

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl PartialEq for Ieee128

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Ieee128

Source§

fn partial_cmp(&self, rhs: &Self) -> 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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Ieee128

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

impl TryFrom<&ConstantData> for Ieee128

Source§

type Error = <[u8; 16] as TryFrom<&'static [u8]>>::Error

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

fn try_from(value: &ConstantData) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryInto<Ieee128> for DataValue

Source§

type Error = DataValueCastFailure

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

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

Performs the conversion.
Source§

impl Copy for Ieee128

Source§

impl Eq for Ieee128

Source§

impl StructuralPartialEq for Ieee128

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, dst: *mut u8)

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

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

§

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

Checks if this value is equivalent to the given key. Read more
§

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

§

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

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

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

§

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

Checks if this value is equivalent to the given key. 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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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§

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

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