-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. In Armv8-R's case, the default features from LLVM for floating-point are sufficient, because there is no integer-only variant of this architecture. Add a run-make test that target-cpu=cortex-r52 enables double-precision and neon.
- Loading branch information
Showing
4 changed files
with
66 additions
and
6 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
10 changes: 10 additions & 0 deletions
10
tests/run-make/arm-target-cpu-fp/armv8r_none_eabihf_cortex_r52.checks
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,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 |
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,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 | ||
} |
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,37 @@ | ||
// This tests that target-cpu correctly enables additional floating-point features. | ||
|
||
use run_make_support::{llvm_filecheck, llvm_objdump, rustc, static_lib_name}; | ||
|
||
struct TestCase { | ||
target: &'static str, | ||
cpu: &'static str, | ||
} | ||
|
||
static CASES: &[TestCase] = &[TestCase { target: "armv8r-none-eabihf", cpu: "cortex-r52" }]; | ||
|
||
fn main() { | ||
for case in CASES { | ||
let lib = static_lib_name(case.cpu); | ||
|
||
rustc() | ||
.edition("2021") | ||
.arg(format!("--target={}", case.target)) | ||
.arg(format!("-Ctarget-cpu={}", case.cpu)) | ||
.arg("-Copt-level=3") | ||
.crate_type("rlib") | ||
.input("lib.rs") | ||
.output(&lib) | ||
.run(); | ||
|
||
let dis = llvm_objdump() | ||
.arg("--arch-name=arm") | ||
.arg(format!("--mcpu={}", case.cpu)) | ||
.disassemble() | ||
.input(&lib) | ||
.run() | ||
.stdout_utf8(); | ||
|
||
let check_file = format!("{}_{}.checks", case.target, case.cpu).replace("-", "_"); | ||
llvm_filecheck().patterns(check_file).stdin_buf(dis).run(); | ||
} | ||
} |