cranelift: Added fp and, or, xor, not ops to interpreter. (#4999)
* cranelift: Added fp and, or, xor, not ops to interpreter. * Formatting. * Removed archtecture dependent test on float-bitops.
This commit is contained in:
@@ -8,7 +8,7 @@ use alloc::vec::Vec;
|
||||
use core::cmp::Ordering;
|
||||
use core::convert::TryFrom;
|
||||
use core::fmt::{self, Display, Formatter};
|
||||
use core::ops::{Add, Div, Mul, Neg, Sub};
|
||||
use core::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Not, Sub};
|
||||
use core::str::FromStr;
|
||||
use core::{i32, u32};
|
||||
#[cfg(feature = "enable-serde")]
|
||||
@@ -921,6 +921,38 @@ impl Div for Ieee32 {
|
||||
}
|
||||
}
|
||||
|
||||
impl BitAnd for Ieee32 {
|
||||
type Output = Ieee32;
|
||||
|
||||
fn bitand(self, rhs: Self) -> Self::Output {
|
||||
Self::with_bits(self.bits() & rhs.bits())
|
||||
}
|
||||
}
|
||||
|
||||
impl BitOr for Ieee32 {
|
||||
type Output = Ieee32;
|
||||
|
||||
fn bitor(self, rhs: Self) -> Self::Output {
|
||||
Self::with_bits(self.bits() | rhs.bits())
|
||||
}
|
||||
}
|
||||
|
||||
impl BitXor for Ieee32 {
|
||||
type Output = Ieee32;
|
||||
|
||||
fn bitxor(self, rhs: Self) -> Self::Output {
|
||||
Self::with_bits(self.bits() ^ rhs.bits())
|
||||
}
|
||||
}
|
||||
|
||||
impl Not for Ieee32 {
|
||||
type Output = Ieee32;
|
||||
|
||||
fn not(self) -> Self::Output {
|
||||
Self::with_bits(!self.bits())
|
||||
}
|
||||
}
|
||||
|
||||
impl Ieee64 {
|
||||
/// Create a new `Ieee64` containing the bits of `x`.
|
||||
pub fn with_bits(x: u64) -> Self {
|
||||
@@ -1113,6 +1145,38 @@ impl Div for Ieee64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl BitAnd for Ieee64 {
|
||||
type Output = Ieee64;
|
||||
|
||||
fn bitand(self, rhs: Self) -> Self::Output {
|
||||
Self::with_bits(self.bits() & rhs.bits())
|
||||
}
|
||||
}
|
||||
|
||||
impl BitOr for Ieee64 {
|
||||
type Output = Ieee64;
|
||||
|
||||
fn bitor(self, rhs: Self) -> Self::Output {
|
||||
Self::with_bits(self.bits() | rhs.bits())
|
||||
}
|
||||
}
|
||||
|
||||
impl BitXor for Ieee64 {
|
||||
type Output = Ieee64;
|
||||
|
||||
fn bitxor(self, rhs: Self) -> Self::Output {
|
||||
Self::with_bits(self.bits() ^ rhs.bits())
|
||||
}
|
||||
}
|
||||
|
||||
impl Not for Ieee64 {
|
||||
type Output = Ieee64;
|
||||
|
||||
fn not(self) -> Self::Output {
|
||||
Self::with_bits(!self.bits())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user