forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#128388 - beetrees:f16-f128-slightly-improve…
…-windows-abi, r=tgross35 Match LLVM ABI in `extern "C"` functions for `f128` on Windows As MSVC doesn't support `_Float128`, x86-64 Windows doesn't have a defined ABI for `f128`. Currently, Rust will pass and return `f128` indirectly for `extern "C"` functions. This is inconsistent with LLVM, which passes and returns `f128` in XMM registers, meaning that e.g. the ABI of `extern "C"` compiler builtins won't match. This PR fixes this discrepancy by making the x86-64 Windows `extern "C"` ABI pass `f128` directly through to LLVM, so that Rust will follow whatever LLVM does. This still leaves the difference between LLVM and GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054) but this PR is still an improvement as at least Rust is now consistent with it's primary codegen backend and compiler builtins from `compiler-builtins` will now work. I've also fixed the x86-64 Windows `has_reliable_f16` match arm in `std` `build.rs` to refer to the correct target, and added an equivalent match arm to `has_reliable_f128` as the LLVM-GCC ABI difference affects both `f16` and `f128`. Tracking issue: rust-lang#116909 try-job: x86_64-msvc try-job: x86_64-mingw
- Loading branch information
Showing
3 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//@ assembly-output: emit-asm | ||
//@ compile-flags: -O | ||
//@ only-windows | ||
//@ only-x86_64 | ||
|
||
#![feature(f16, f128)] | ||
#![crate_type = "lib"] | ||
|
||
// CHECK-LABEL: second_f16 | ||
// CHECK: movaps %xmm1, %xmm0 | ||
// CHECK-NEXT: retq | ||
#[no_mangle] | ||
pub extern "C" fn second_f16(_: f16, x: f16) -> f16 { | ||
x | ||
} | ||
|
||
// CHECK-LABEL: second_f32 | ||
// CHECK: movaps %xmm1, %xmm0 | ||
// CHECK-NEXT: retq | ||
#[no_mangle] | ||
pub extern "C" fn second_f32(_: f32, x: f32) -> f32 { | ||
x | ||
} | ||
|
||
// CHECK-LABEL: second_f64 | ||
// CHECK: movaps %xmm1, %xmm0 | ||
// CHECK-NEXT: retq | ||
#[no_mangle] | ||
pub extern "C" fn second_f64(_: f64, x: f64) -> f64 { | ||
x | ||
} | ||
|
||
// CHECK-LABEL: second_f128 | ||
// CHECK: movaps %xmm1, %xmm0 | ||
// CHECK-NEXT: retq | ||
#[no_mangle] | ||
pub extern "C" fn second_f128(_: f128, x: f128) -> f128 { | ||
x | ||
} |