Skip to content

Commit

Permalink
More MinGW fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Jan 6, 2025
1 parent 5574cee commit 68f1e5a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions crates/math/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub trait WasmFloat {
fn wasm_nearest(self) -> Self;
fn wasm_minimum(self, other: Self) -> Self;
fn wasm_maximum(self, other: Self) -> Self;
fn mul_add(self, b: Self, c: Self) -> Self;
fn wasm_mul_add(self, b: Self, c: Self) -> Self;
}

impl WasmFloat for f32 {
Expand Down Expand Up @@ -148,9 +148,11 @@ impl WasmFloat for f32 {
}
}
#[inline]
fn mul_add(self, b: f32, c: f32) -> f32 {
fn wasm_mul_add(self, b: f32, c: f32) -> f32 {
// The MinGW implementation of `fma` differs from other platforms, so
// favor `libm` there instead.
#[cfg(feature = "std")]
if true {
if !(cfg!(windows) && cfg!(target_env = "gnu")) {
return self.mul_add(b, c);
}
libm::fmaf(self, b, c)
Expand Down Expand Up @@ -271,7 +273,7 @@ impl WasmFloat for f64 {
}
}
#[inline]
fn mul_add(self, b: f64, c: f64) -> f64 {
fn wasm_mul_add(self, b: f64, c: f64) -> f64 {
// The MinGW implementation of `fma` differs from other platforms, so
// favor `libm` there instead.
#[cfg(feature = "std")]
Expand Down
4 changes: 2 additions & 2 deletions crates/wasmtime/src/runtime/vm/libcalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,11 +1289,11 @@ pub mod relocs {
}

pub extern "C" fn fmaf32(a: f32, b: f32, c: f32) -> f32 {
wasmtime_math::WasmFloat::mul_add(a, b, c)
wasmtime_math::WasmFloat::wasm_mul_add(a, b, c)
}

pub extern "C" fn fmaf64(a: f64, b: f64, c: f64) -> f64 {
wasmtime_math::WasmFloat::mul_add(a, b, c)
wasmtime_math::WasmFloat::wasm_mul_add(a, b, c)
}

// This intrinsic is only used on x86_64 platforms as an implementation of
Expand Down
4 changes: 2 additions & 2 deletions pulley/src/interp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4775,7 +4775,7 @@ impl ExtendedOpVisitor for Interpreter<'_> {
let b = self.state[b].get_f32x4();
let c = self.state[c].get_f32x4();
for ((a, b), c) in a.iter_mut().zip(b).zip(c) {
*a = a.mul_add(b, c);
*a = a.wasm_mul_add(b, c);
}
self.state[dst].set_f32x4(a);
ControlFlow::Continue(())
Expand All @@ -4786,7 +4786,7 @@ impl ExtendedOpVisitor for Interpreter<'_> {
let b = self.state[b].get_f64x2();
let c = self.state[c].get_f64x2();
for ((a, b), c) in a.iter_mut().zip(b).zip(c) {
*a = a.mul_add(b, c);
*a = a.wasm_mul_add(b, c);
}
self.state[dst].set_f64x2(a);
ControlFlow::Continue(())
Expand Down

0 comments on commit 68f1e5a

Please sign in to comment.