Skip to content

Commit bd34871

Browse files
committed
Auto merge of rust-lang#143227 - tshepang:asm-label-operand, r=Amanieu
add multi-arch asm! label operand test Added this since the other label operand tests are only for x86
2 parents 61efd19 + c7d180c commit bd34871

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed

src/tools/compiletest/src/directives.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -644,11 +644,9 @@ impl TestProps {
644644

645645
self.update_add_core_stubs(ln, config);
646646

647-
if let Some(flags) = config.parse_name_value_directive(
648-
ln,
649-
directives::CORE_STUBS_COMPILE_FLAGS,
650-
testfile,
651-
) {
647+
if let Some(flags) =
648+
config.parse_name_value_directive(ln, CORE_STUBS_COMPILE_FLAGS, testfile)
649+
{
652650
let flags = split_flags(&flags);
653651
for flag in &flags {
654652
if flag == "--edition" || flag.starts_with("--edition=") {

src/tools/compiletest/src/directives/directive_names.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
191191
"only-aarch64-unknown-linux-gnu",
192192
"only-apple",
193193
"only-arm",
194+
"only-arm64ec",
194195
"only-avr",
195196
"only-beta",
196197
"only-bpf",
@@ -217,6 +218,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
217218
"only-nightly",
218219
"only-nvptx64",
219220
"only-powerpc",
221+
"only-riscv32",
220222
"only-riscv64",
221223
"only-rustc_abi-x86-sse2",
222224
"only-s390x",

tests/ui/asm/label-operand.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//@ run-pass
2+
//@ reference: asm.operand-type.supported-operands.label
3+
//@ revisions: aarch64 arm arm64ec riscv32 riscv64 x86 x86_64
4+
//@ needs-asm-support
5+
//@[aarch64] only-aarch64
6+
//@[arm64ec] only-arm64ec
7+
//@[arm] only-arm
8+
//@[riscv32] only-riscv32
9+
//@[riscv64] only-riscv64
10+
//@[x86] only-x86
11+
//@[x86_64] only-x86_64
12+
13+
#[cfg(any(aarch64, arm, arm64ec))]
14+
fn make_true(value: &mut bool) {
15+
unsafe {
16+
core::arch::asm!(
17+
"b {}",
18+
label {
19+
*value = true;
20+
}
21+
);
22+
}
23+
}
24+
25+
#[cfg(any(riscv32, riscv64))]
26+
fn make_true(value: &mut bool) {
27+
unsafe {
28+
core::arch::asm!(
29+
"j {}",
30+
label {
31+
*value = true;
32+
}
33+
);
34+
}
35+
}
36+
37+
#[cfg(any(x86, x86_64))]
38+
fn make_true(value: &mut bool) {
39+
unsafe {
40+
core::arch::asm!(
41+
"jmp {}",
42+
label {
43+
*value = true;
44+
}
45+
);
46+
}
47+
}
48+
49+
fn main() {
50+
let mut value = false;
51+
make_true(&mut value);
52+
assert!(value);
53+
}

0 commit comments

Comments
 (0)