Skip to content

Commit f456598

Browse files
committed
Fix target-cpu fpu features on Armv8-R.
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.
1 parent 5e3ede2 commit f456598

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

compiler/rustc_target/src/spec/targets/armv8r_none_eabihf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(crate) fn target() -> Target {
3030
// Reference:
3131
// Arm Cortex-R52 Processor Technical Reference Manual
3232
// - Chapter 15 Advanced SIMD and floating-point support
33-
features: "+fp-armv8,-fp64,-d32".into(),
33+
features: "+fp-armv8d16sp".into(),
3434
max_atomic_width: Some(64),
3535
emit_debug_gdb_scripts: false,
3636
// GCC defaults to 8 for arm-none here.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// CHECK-LABEL: vadd_q:
2+
// CHECK: vld{{.*}}
3+
// CHECK: vld{{.*}}
4+
// CHECK: vadd.f32{{.*}}q
5+
// CHECK: vst{{.*}} [r0]
6+
// CHECK: bx lr
7+
8+
// CHECK-LABEL: vadd_f64:
9+
// CHECK: vadd.f64 d0, d0, d1
10+
// CHECK: bx lr
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![no_std]
2+
3+
#[no_mangle]
4+
pub fn vadd_q(x: &mut [f32; 4], y: &[f32; 4]) {
5+
for i in 0..4 {
6+
x[i] += y[i];
7+
}
8+
}
9+
10+
#[no_mangle]
11+
pub fn vadd_f64(x: f64, y: f64) -> f64 {
12+
x + y
13+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This tests that target-cpu=cortex-r52 correctly enables double-precision and neon.
2+
3+
use run_make_support::{llvm_filecheck, llvm_objdump, rustc, static_lib_name};
4+
5+
fn main() {
6+
let lib = static_lib_name("lib");
7+
8+
rustc()
9+
.edition("2021")
10+
.arg("--target=armv8r-none-eabihf")
11+
.arg("-Ctarget-cpu=cortex-r52")
12+
.arg("-Copt-level=3")
13+
.crate_type("rlib")
14+
.input("lib.rs")
15+
.output(&lib)
16+
.run();
17+
18+
let dis = llvm_objdump()
19+
.arg("--arch-name=arm")
20+
.arg("--mcpu=cortex-r52")
21+
.disassemble()
22+
.input(&lib)
23+
.run()
24+
.stdout_utf8();
25+
26+
llvm_filecheck().patterns("armv8r_none_eabihf.checks").stdin_buf(dis).run();
27+
}

0 commit comments

Comments
 (0)