cranelift_codegen::ir::immediates

Struct Ieee64

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

An IEEE binary64 immediate floating point value, represented as a u64 containing the bit pattern.

We specifically avoid using a f64 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 Ieee64

Source

pub const NAN: Self = _

The positive WebAssembly canonical NaN.

Source

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

Create a new Ieee64 containing the bits of bits.

Source

pub fn bits(self) -> u64

Get the bitwise representation.

Source

pub fn with_float(x: f64) -> Self

Create a new Ieee64 representing the number x.

Source

pub fn as_f64(self) -> f64

Converts self to a Rust f64.

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 Ieee64 number representing 2.0^n.

Source

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

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

Source

pub fn is_nan(self) -> bool

Check if the value is a NaN. For Ieee64, 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.

Source

pub fn sqrt(self) -> Self

Returns the square root of self.

Source

pub fn ceil(self) -> Self

Returns the smallest integer greater than or equal to self.

Source

pub fn floor(self) -> Self

Returns the largest integer less than or equal to self.

Source

pub fn trunc(self) -> Self

Returns the integer part of self. This means that non-integer numbers are always truncated towards zero.

Source

pub fn round_ties_even(self) -> Self

Returns the nearest integer to self. Rounds half-way cases to the number with an even least significant digit.

Trait Implementations§

Source§

impl Add for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl BitAnd for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitOr for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitXor for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl Clone for Ieee64

Source§

fn clone(&self) -> Ieee64

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 Ieee64

Source§

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

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

impl Display for Ieee64

Source§

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

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

impl Div for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl From<Ieee64> for DataValue

Source§

fn from(data: Ieee64) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Ieee64

Source§

fn from(x: f64) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Ieee64

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 Ieee64

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 Ieee64

Source§

fn into_bytes(self) -> Vec<u8>

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

impl Mul for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Neg for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl Not for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl PartialEq for Ieee64

Source§

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

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 Sub for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl TryInto<Ieee64> for DataValue

Source§

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 Copy for Ieee64

Source§

impl Eq for Ieee64

Source§

impl StructuralPartialEq for Ieee64

Auto Trait Implementations§

§

impl Freeze for Ieee64

§

impl RefUnwindSafe for Ieee64

§

impl Send for Ieee64

§

impl Sync for Ieee64

§

impl Unpin for Ieee64

§

impl UnwindSafe for Ieee64

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

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

Source§

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

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

impl<Q, K> Equivalent<K> for Q
where 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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