From b88e38b32b77e11f6d7bc85a394d94b9b9609dc1 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 30 Sep 2026 17:11:29 +0200 Subject: [PATCH] arm: only f32 and f64 are valid HFA bases --- compiler/rustc_target/src/callconv/arm.rs | 4 ++-- .../arm-abi/homogeneous-aggregate.rs | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_target/src/callconv/arm.rs b/compiler/rustc_target/src/callconv/arm.rs index f226dcdcd6cfa..a9eeb0bcabace 100644 --- a/compiler/rustc_target/src/callconv/arm.rs +++ b/compiler/rustc_target/src/callconv/arm.rs @@ -25,9 +25,9 @@ where let valid_unit = match unit.kind { RegKind::Integer => false, - RegKind::Float => true, - RegKind::PpcF128 => unreachable!(), + RegKind::Float => unit.size.bits() == 32 || unit.size.bits() == 64, RegKind::Vector { .. } => unit.size.bits() == 64 || unit.size.bits() == 128, + RegKind::PpcF128 => unreachable!(), }; valid_unit.then_some(Uniform::consecutive(unit, size)) diff --git a/tests/codegen-llvm/arm-abi/homogeneous-aggregate.rs b/tests/codegen-llvm/arm-abi/homogeneous-aggregate.rs index 272eb419494b0..8efd10b02c2a8 100644 --- a/tests/codegen-llvm/arm-abi/homogeneous-aggregate.rs +++ b/tests/codegen-llvm/arm-abi/homogeneous-aggregate.rs @@ -11,7 +11,7 @@ // Test that homogeneous aggregates are passed and returned with the correct ABI on 32-bit arm. #![feature(no_core, lang_items)] -#![feature(arm_target_feature)] +#![feature(arm_target_feature, f16, f128)] #![crate_type = "lib"] #![no_core] @@ -151,6 +151,20 @@ pub extern "C" fn test_floats_5(a: Floats5) { hint::black_box(a); } +// Only f32 and f64 qualify as an HFA base. + +// linux: define void @test_f16([2 x i32] %0) +#[unsafe(no_mangle)] +pub extern "C" fn test_f16(a: [f16; 3]) { + hint::black_box(a); +} + +// linux: define void @test_f128([2 x i64] %0) +#[unsafe(no_mangle)] +pub extern "C" fn test_f128(a: [f128; 1]) { + hint::black_box(a); +} + // Just a big struct, note how watchOS passes it indirectly. #[repr(C)] pub struct Ints6 {