diff --git a/cranelift/codegen/src/ir/immediates.rs b/cranelift/codegen/src/ir/immediates.rs index 21d8376e37..36cc470aef 100644 --- a/cranelift/codegen/src/ir/immediates.rs +++ b/cranelift/codegen/src/ir/immediates.rs @@ -665,6 +665,12 @@ impl FromStr for Ieee32 { } } +impl From for Ieee32 { + fn from(x: f32) -> Self { + Ieee32::with_float(x) + } +} + impl Ieee64 { /// Create a new `Ieee64` containing the bits of `x`. pub fn with_bits(x: u64) -> Self { @@ -726,6 +732,12 @@ impl FromStr for Ieee64 { } } +impl From for Ieee64 { + fn from(x: f64) -> Self { + Ieee64::with_float(x) + } +} + #[cfg(test)] mod tests { use super::*;