forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#133102 - RalfJung:aarch64-softfloat, r=davi…
…dtwco,wesleywiser aarch64 softfloat target: always pass floats in int registers This is a part of rust-lang#131058: on softfloat aarch64 targets, the float registers may be unavailable. And yet, LLVM will happily use them to pass float types if the corresponding target features are enabled. That's a problem as it means enabling/disabling `neon` instructions can change the ABI. Other targets have a `soft-float` target feature that forces the use of the soft-float ABI no matter whether float registers are enabled or not; aarch64 has nothing like that. So we follow the aarch64 [softfloat ABI](rust-lang#131058 (comment)) and treat floats like integers for `extern "C"` functions. For the "Rust" ABI, we do the same for scalars, and then just do something reasonable for ScalarPair that avoids the pointer indirection. Cc `@workingjubilee`
- Loading branch information
Showing
3 changed files
with
106 additions
and
5 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,48 @@ | ||
//@ compile-flags: --target aarch64-unknown-none-softfloat -Zmerge-functions=disabled | ||
//@ needs-llvm-components: aarch64 | ||
#![crate_type = "lib"] | ||
#![feature(no_core, lang_items)] | ||
#![no_core] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
#[lang = "copy"] | ||
trait Copy {} | ||
impl Copy for f32 {} | ||
impl Copy for f64 {} | ||
|
||
// CHECK: i64 @pass_f64_C(i64 {{[^,]*}}) | ||
#[no_mangle] | ||
extern "C" fn pass_f64_C(x: f64) -> f64 { | ||
x | ||
} | ||
|
||
// CHECK: i64 @pass_f32_pair_C(i64 {{[^,]*}}) | ||
#[no_mangle] | ||
extern "C" fn pass_f32_pair_C(x: (f32, f32)) -> (f32, f32) { | ||
x | ||
} | ||
|
||
// CHECK: [2 x i64] @pass_f64_pair_C([2 x i64] {{[^,]*}}) | ||
#[no_mangle] | ||
extern "C" fn pass_f64_pair_C(x: (f64, f64)) -> (f64, f64) { | ||
x | ||
} | ||
|
||
// CHECK: i64 @pass_f64_Rust(i64 {{[^,]*}}) | ||
#[no_mangle] | ||
fn pass_f64_Rust(x: f64) -> f64 { | ||
x | ||
} | ||
|
||
// CHECK: i64 @pass_f32_pair_Rust(i64 {{[^,]*}}) | ||
#[no_mangle] | ||
fn pass_f32_pair_Rust(x: (f32, f32)) -> (f32, f32) { | ||
x | ||
} | ||
|
||
// CHECK: void @pass_f64_pair_Rust(ptr {{[^,]*}}, ptr {{[^,]*}}) | ||
#[no_mangle] | ||
fn pass_f64_pair_Rust(x: (f64, f64)) -> (f64, f64) { | ||
x | ||
} |