Skip to content

Commit 4bf1367

Browse files
Rollup merge of #163556 - folkertdev:arm-hfa-base, r=davidtwco
arm: only f32 and f64 are valid HFA bases based on the spec: https://github.com/ARM-software/abi-aa/blob/a5e86d3fec7342719f3bd1f939ec1b8ac6438c4f/aapcs32/aapcs32.rst#procedure-calling > A Homogeneous Aggregate with a Base Type of a single- or double-precision floating-point type with one to four Elements. So `f16` and `f128` don't qualify. Neither does `f16b`, but it is not currently marked as reliable on arm. This change makes rust consistent with clang, but inconsistent with GCC. r? davidtwco
2 parents c6a43f6 + f85bd67 commit 4bf1367

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

‎compiler/rustc_target/src/callconv/arm.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ where
2525

2626
let valid_unit = match unit.kind {
2727
RegKind::Integer => false,
28-
RegKind::Float => true,
29-
RegKind::PpcF128 => unreachable!(),
28+
RegKind::Float => unit.size.bits() == 32 || unit.size.bits() == 64,
3029
RegKind::Vector { .. } => unit.size.bits() == 64 || unit.size.bits() == 128,
30+
RegKind::PpcF128 => unreachable!(),
3131
};
3232

3333
valid_unit.then_some(Uniform::consecutive(unit, size))

‎tests/codegen-llvm/arm-abi/homogeneous-aggregate.rs‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// Test that homogeneous aggregates are passed and returned with the correct ABI on 32-bit arm.
1515

1616
#![feature(no_core, lang_items)]
17-
#![feature(arm_target_feature)]
17+
#![feature(arm_target_feature, f16, f128)]
1818
#![crate_type = "lib"]
1919
#![no_core]
2020

@@ -186,6 +186,20 @@ pub extern "C" fn test_floats_5(a: Floats5) {
186186
hint::black_box(a);
187187
}
188188

189+
// Only f32 and f64 qualify as an HFA base.
190+
191+
// linux: define void @test_f16([2 x i32] %0)
192+
#[unsafe(no_mangle)]
193+
pub extern "C" fn test_f16(a: [f16; 3]) {
194+
hint::black_box(a);
195+
}
196+
197+
// linux: define void @test_f128([2 x i64] %0)
198+
#[unsafe(no_mangle)]
199+
pub extern "C" fn test_f128(a: [f128; 1]) {
200+
hint::black_box(a);
201+
}
202+
189203
// Just a big struct, note how watchOS passes it indirectly.
190204
#[repr(C)]
191205
pub struct Ints6 {

‎tests/codegen-llvm/complex-abi.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub extern "C" fn cplx_f16(x: Complex<f16>) -> Complex<f16> {
140140
// AARCH64_DARWIN: define{{.*}} [2 x half] @cplx_f16([2 x half] {{.*}})
141141
// AARCH64_MSVC: define{{.*}} [2 x half] @cplx_f16([2 x half] {{.*}})
142142
// ARM64EC: define{{.*}} [2 x half] @cplx_f16([2 x half] {{.*}})
143-
// ARM: define{{.*}} [2 x half] @cplx_f16([2 x half] {{.*}})
143+
// ARM: define{{.*}} i32 @cplx_f16([1 x i32] {{.*}})
144144
// I686: define{{.*}} <2 x half> @cplx_f16(ptr {{.*}} byval([4 x i8]) {{.*}})
145145
// LOONGARCH32: define{{.*}} { half, half } @cplx_f16({ half, half } {{.*}})
146146
// LOONGARCH64: define{{.*}} { half, half } @cplx_f16({ half, half } {{.*}})
@@ -466,7 +466,7 @@ pub extern "C" fn wrapper_cplx_f16(
466466
// AARCH64_DARWIN: define{{.*}} [2 x half] @wrapper_cplx_f16([2 x half] {{.*}})
467467
// AARCH64_MSVC: define{{.*}} [2 x half] @wrapper_cplx_f16([2 x half] {{.*}})
468468
// ARM64EC: define{{.*}} [2 x half] @wrapper_cplx_f16([2 x half] {{.*}})
469-
// ARM: define{{.*}} [2 x half] @wrapper_cplx_f16([2 x half] {{.*}})
469+
// ARM: define{{.*}} i32 @wrapper_cplx_f16([1 x i32] {{.*}})
470470
// I686: define{{.*}} <2 x half> @wrapper_cplx_f16(ptr {{.*}} byval([4 x i8]) {{.*}})
471471
// LOONGARCH32: define{{.*}} { half, half } @wrapper_cplx_f16({ half, half } {{.*}})
472472
// LOONGARCH64: define{{.*}} { half, half } @wrapper_cplx_f16({ half, half } {{.*}})

0 commit comments

Comments
 (0)