add multi-arch asm! label operand test

This commit is contained in:
Tshepang Mbambo 2025-10-06 05:54:53 +02:00
parent 5a38eb1ba8
commit c7d180cd60
2 changed files with 55 additions and 0 deletions

View file

@ -191,6 +191,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-aarch64-unknown-linux-gnu",
"only-apple",
"only-arm",
"only-arm64ec",
"only-avr",
"only-beta",
"only-bpf",
@ -217,6 +218,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-nightly",
"only-nvptx64",
"only-powerpc",
"only-riscv32",
"only-riscv64",
"only-rustc_abi-x86-sse2",
"only-s390x",

View file

@ -0,0 +1,53 @@
//@ run-pass
//@ reference: asm.operand-type.supported-operands.label
//@ revisions: aarch64 arm arm64ec riscv32 riscv64 x86 x86_64
//@ needs-asm-support
//@[aarch64] only-aarch64
//@[arm64ec] only-arm64ec
//@[arm] only-arm
//@[riscv32] only-riscv32
//@[riscv64] only-riscv64
//@[x86] only-x86
//@[x86_64] only-x86_64
#[cfg(any(aarch64, arm, arm64ec))]
fn make_true(value: &mut bool) {
unsafe {
core::arch::asm!(
"b {}",
label {
*value = true;
}
);
}
}
#[cfg(any(riscv32, riscv64))]
fn make_true(value: &mut bool) {
unsafe {
core::arch::asm!(
"j {}",
label {
*value = true;
}
);
}
}
#[cfg(any(x86, x86_64))]
fn make_true(value: &mut bool) {
unsafe {
core::arch::asm!(
"jmp {}",
label {
*value = true;
}
);
}
}
fn main() {
let mut value = false;
make_true(&mut value);
assert!(value);
}