cranelift_codegen::ir::immediates

Struct Ieee16

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

An IEEE binary16 immediate floating point value, represented as a u16 containing the bit pattern.

We specifically avoid using a f16 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 Ieee16

Source

pub const NAN: Self = _

The positive WebAssembly canonical NaN.

Source

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

Create a new Ieee16 containing the bits of bits.

Source

pub fn bits(self) -> u16

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

Source

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

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

Source

pub fn is_nan(self) -> bool

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

Source§

type Output = Ieee16

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitOr for Ieee16

Source§

type Output = Ieee16

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitXor for Ieee16

Source§

type Output = Ieee16

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl Clone for Ieee16

Source§

fn clone(&self) -> Ieee16

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 Ieee16

Source§

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

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

impl Display for Ieee16

Source§

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

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

impl From<Ieee16> for DataValue

Source§

fn from(data: Ieee16) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Ieee16

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 Ieee16

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 Ieee16

Source§

fn into_bytes(self) -> Vec<u8>

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

impl Neg for Ieee16

Source§

type Output = Ieee16

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl Not for Ieee16

Source§

type Output = Ieee16

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl PartialEq for Ieee16

Source§

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

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 TryInto<Ieee16> for DataValue

Source§

type Error = DataValueCastFailure

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

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

Performs the conversion.
Source§

impl Copy for Ieee16

Source§

impl Eq for Ieee16

Source§

impl StructuralPartialEq for Ieee16

Auto Trait Implementations§

§

impl Freeze for Ieee16

§

impl RefUnwindSafe for Ieee16

§

impl Send for Ieee16

§

impl Sync for Ieee16

§

impl Unpin for Ieee16

§

impl UnwindSafe for Ieee16

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.