cranelift: Implement PartialEq on Ieee{32,64} (#4849)
* cranelift: Add `fcmp` tests
Some of these are disabled on aarch64 due to not being implemented yet.
* cranelift: Implement float PartialEq for Ieee{32,64} (fixes #4828)
Previously `PartialEq` was auto derived. This means that it was implemented in terms of PartialEq in a u32.
This is not correct for floats because `NaN != NaN`.
PartialOrd was manually implemented in 6d50099816, but it seems like it was an oversight to leave PartialEq out until now.
The test suite depends on the previous behaviour so we adjust it to keep comparing bits instead of floats.
* cranelift: Disable `fcmp ord` tests on aarch64
* cranelift: Disable `fcmp ueq` tests on aarch64
This commit is contained in:
@@ -473,7 +473,7 @@ impl FromStr for Offset32 {
|
||||
/// containing the bit pattern.
|
||||
///
|
||||
/// All bit patterns are allowed.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
#[derive(Copy, Clone, Debug, Eq, Hash)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[repr(C)]
|
||||
pub struct Ieee32(u32);
|
||||
@@ -482,7 +482,7 @@ pub struct Ieee32(u32);
|
||||
/// containing the bit pattern.
|
||||
///
|
||||
/// All bit patterns are allowed.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
#[derive(Copy, Clone, Debug, Eq, Hash)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[repr(C)]
|
||||
pub struct Ieee64(u64);
|
||||
@@ -839,6 +839,12 @@ impl PartialOrd for Ieee32 {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<Ieee32> for Ieee32 {
|
||||
fn eq(&self, other: &Ieee32) -> bool {
|
||||
self.as_f32().eq(&other.as_f32())
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Ieee32 {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
let bits: u32 = self.0;
|
||||
@@ -1025,6 +1031,12 @@ impl PartialOrd for Ieee64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<Ieee64> for Ieee64 {
|
||||
fn eq(&self, other: &Ieee64) -> bool {
|
||||
self.as_f64().eq(&other.as_f64())
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Ieee64 {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
let bits: u64 = self.0;
|
||||
|
||||
Reference in New Issue
Block a user