Add support for //@ ignore-i586

There are a few tests that were trying to skip i586 targets via the `TARGET`
environment variable instead, so better to just add support for the directive.
This commit is contained in:
Zalathar 2025-10-20 15:31:18 +11:00
parent c7a635f33c
commit ff0c0967c1
7 changed files with 21 additions and 29 deletions

View file

@ -701,10 +701,13 @@ impl Config {
}
pub fn matches_arch(&self, arch: &str) -> bool {
self.target_cfg().arch == arch ||
// Matching all the thumb variants as one can be convenient.
// (thumbv6m, thumbv7em, thumbv7m, etc.)
(arch == "thumb" && self.target.starts_with("thumb"))
self.target_cfg().arch == arch
|| {
// Matching all the thumb variants as one can be convenient.
// (thumbv6m, thumbv7em, thumbv7m, etc.)
arch == "thumb" && self.target.starts_with("thumb")
}
|| (arch == "i586" && self.target.starts_with("i586-"))
}
pub fn matches_os(&self, os: &str) -> bool {

View file

@ -166,6 +166,14 @@ fn parse_cfg_name_directive<'a>(
message: "when the architecture is part of the Thumb family"
}
// The "arch" of `i586-` targets is "x86", so for more specific matching
// we have to resort to a string-prefix check.
condition! {
name: "i586",
condition: config.matches_arch("i586"),
message: "when the subarchitecture is i586",
}
condition! {
name: "apple",
condition: config.target.contains("apple"),

View file

@ -70,6 +70,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-gnu",
"ignore-haiku",
"ignore-horizon",
"ignore-i586",
"ignore-i686-pc-windows-gnu",
"ignore-i686-pc-windows-msvc",
"ignore-illumos",

View file

@ -605,6 +605,8 @@ fn ignore_arch() {
("i686-unknown-linux-gnu", "x86"),
("nvptx64-nvidia-cuda", "nvptx64"),
("thumbv7m-none-eabi", "thumb"),
("i586-unknown-linux-gnu", "x86"),
("i586-unknown-linux-gnu", "i586"),
];
for (target, arch) in archs {
let config: Config = cfg().target(target).build();

View file

@ -1,9 +1,6 @@
//@ assembly-output: emit-asm
// FIXME(#114479): LLVM miscompiles loading and storing `f32` and `f64` when SSE is disabled.
// There's no compiletest directive to ignore a test on i586 only, so just always explicitly enable
// SSE2.
// Use the same target CPU as `i686` so that LLVM orders the instructions in the same order.
//@ compile-flags: -Ctarget-feature=+sse2 -Ctarget-cpu=pentium4
// (As of #136758, this test cross-compiles to selected i686 targets only, which have SSE.)
// Force frame pointers to make ASM more consistent between targets
//@ compile-flags: -C force-frame-pointers
// At opt-level=3, LLVM can merge two movss into one movsd, and we aren't testing for that.

View file

@ -7,6 +7,7 @@
//@ run-pass
//@ needs-subprocess
//@ ignore-backends: gcc
//@ ignore-i586 (no SSE2)
#![allow(overflowing_literals)]
#![allow(unused_variables)]
@ -19,16 +20,6 @@ fn main() {
return test::main(&level)
}
match std::env::var("TARGET") {
Ok(s) => {
// Skip this tests on i586-unknown-linux-gnu where sse2 is disabled
if s.contains("i586") {
return
}
}
Err(_) => return,
}
let me = env::current_exe().unwrap();
for level in ["sse", "avx", "avx512"].iter() {
let status = Command::new(&me).arg(level).status().unwrap();

View file

@ -2,22 +2,12 @@
//! specifically `sse2` on x86/x86_64 platforms, and correctly reports absent features.
//@ run-pass
//@ ignore-i586 (no SSE2)
#![allow(stable_features)]
#![feature(cfg_target_feature)]
use std::env;
fn main() {
match env::var("TARGET") {
Ok(s) => {
// Skip this tests on i586-unknown-linux-gnu where sse2 is disabled
if s.contains("i586") {
return;
}
}
Err(_) => return,
}
if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {
assert!(
cfg!(target_feature = "sse2"),