-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a run-make test for Arm target-cpu features.
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Cortex-M7 does not have Advanced SIMD, so don't check anything in vadd_f32_q. | ||
CHECK-LABEL: vadd_f32_q: | ||
|
||
// Cortex-M7 enables double-precision. | ||
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,12 @@ | ||
// Cortex-M85 enables the Helium instructions. | ||
CHECK-LABEL: vadd_f32_q: | ||
CHECK: vld{{.*}} | ||
CHECK: vld{{.*}} | ||
CHECK: vadd.f32{{.*}}q | ||
CHECK: vst{{.*}} [r0] | ||
CHECK: bx lr | ||
|
||
// Cortex-M85 enables double-precision. | ||
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_f32_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,55 @@ | ||
// This tests that target-cpu correctly enables additional features for some Arm targets. | ||
// These targets were originally defined in such a way that features provided by target-cpu would be | ||
// disabled by the target spec itself. This was fixed in #123159. | ||
|
||
// FIXME: This test should move to tests/assembly when building without #![no_core] in | ||
// that environment is possible, tracked by #130375. | ||
|
||
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: "thumbv7em-none-eabihf", cpu: "cortex-m7" }, | ||
TestCase { target: "thumbv8m.main-none-eabihf", cpu: "cortex-m85" }, | ||
]; | ||
|
||
fn main() { | ||
for case in CASES { | ||
let lib = static_lib_name(case.cpu); | ||
let checks = format!("{}.checks", case.cpu); | ||
|
||
let rustc_command = || { | ||
let mut cmd = rustc(); | ||
cmd.edition("2021") | ||
.target(case.target) | ||
.arg("-Copt-level=3") | ||
.crate_type("rlib") | ||
.input("lib.rs") | ||
.output(&lib); | ||
cmd | ||
}; | ||
|
||
let objdump_command = || { | ||
let mut cmd = llvm_objdump(); | ||
cmd.arg("--arch-name=arm") | ||
.arg(format!("--mcpu={}", case.cpu)) | ||
.disassemble() | ||
.input(&lib); | ||
cmd | ||
}; | ||
|
||
// First, run without target-cpu and confirm that it fails. | ||
rustc_command().run(); | ||
let dis = objdump_command().run().stdout_utf8(); | ||
llvm_filecheck().patterns(&checks).stdin_buf(dis).run_fail(); | ||
|
||
// Then, run with target-cpu and confirm that it succeeds. | ||
rustc_command().arg(format!("-Ctarget-cpu={}", case.cpu)).run(); | ||
let dis = objdump_command().run().stdout_utf8(); | ||
llvm_filecheck().patterns(&checks).stdin_buf(dis).run(); | ||
} | ||
} |