Skip to content

Commit

Permalink
Fix target-cpu fpu features on Armv8-R.
Browse files Browse the repository at this point in the history
This is a follow-up to #123159, but applied to Armv8-R.

This required llvm/llvm-project#88287 to work
properly. Now that this change exists in rustc's llvm, we can fix
Armv8-R's default fpu features.

Add a run-make test that target-cpu=cortex-r52 enables double-precision
and neon.
  • Loading branch information
chrisnc committed Sep 14, 2024
1 parent 5e3ede2 commit f456598
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub(crate) fn target() -> Target {
// Reference:
// Arm Cortex-R52 Processor Technical Reference Manual
// - Chapter 15 Advanced SIMD and floating-point support
features: "+fp-armv8,-fp64,-d32".into(),
features: "+fp-armv8d16sp".into(),
max_atomic_width: Some(64),
emit_debug_gdb_scripts: false,
// GCC defaults to 8 for arm-none here.
Expand Down
10 changes: 10 additions & 0 deletions tests/run-make/arm-target-cpu-fp/armv8r_none_eabihf.checks
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// CHECK-LABEL: vadd_q:
// CHECK: vld{{.*}}
// CHECK: vld{{.*}}
// CHECK: vadd.f32{{.*}}q
// CHECK: vst{{.*}} [r0]
// CHECK: bx lr

// CHECK-LABEL: vadd_f64:
// CHECK: vadd.f64 d0, d0, d1
// CHECK: bx lr
13 changes: 13 additions & 0 deletions tests/run-make/arm-target-cpu-fp/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![no_std]

#[no_mangle]
pub fn vadd_q(x: &mut [f32; 4], y: &[f32; 4]) {
for i in 0..4 {
x[i] += y[i];
}
}

#[no_mangle]
pub fn vadd_f64(x: f64, y: f64) -> f64 {
x + y
}
27 changes: 27 additions & 0 deletions tests/run-make/arm-target-cpu-fp/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// This tests that target-cpu=cortex-r52 correctly enables double-precision and neon.

use run_make_support::{llvm_filecheck, llvm_objdump, rustc, static_lib_name};

fn main() {
let lib = static_lib_name("lib");

rustc()
.edition("2021")
.arg("--target=armv8r-none-eabihf")
.arg("-Ctarget-cpu=cortex-r52")
.arg("-Copt-level=3")
.crate_type("rlib")
.input("lib.rs")
.output(&lib)
.run();

let dis = llvm_objdump()
.arg("--arch-name=arm")
.arg("--mcpu=cortex-r52")
.disassemble()
.input(&lib)
.run()
.stdout_utf8();

llvm_filecheck().patterns("armv8r_none_eabihf.checks").stdin_buf(dis).run();
}

0 comments on commit f456598

Please sign in to comment.