]> git.proxmox.com Git - rustc.git/blob - src/test/ui/asm/aarch64/bad-reg.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / asm / aarch64 / bad-reg.rs
1 // only-aarch64
2 // compile-flags: -C target-feature=+neon
3
4 #![feature(asm_const, asm_sym)]
5
6 use std::arch::asm;
7
8 fn main() {
9 let mut foo = 0;
10 let mut bar = 0;
11 unsafe {
12 // Bad register/register class
13
14 asm!("{}", in(foo) foo);
15 //~^ ERROR invalid register class `foo`: unknown register class
16 asm!("", in("foo") foo);
17 //~^ ERROR invalid register `foo`: unknown register
18 asm!("{:z}", in(reg) foo);
19 //~^ ERROR invalid asm template modifier for this register class
20 asm!("{:r}", in(vreg) foo);
21 //~^ ERROR invalid asm template modifier for this register class
22 asm!("{:r}", in(vreg_low16) foo);
23 //~^ ERROR invalid asm template modifier for this register class
24 asm!("{:a}", const 0);
25 //~^ ERROR asm template modifiers are not allowed for `const` arguments
26 asm!("{:a}", sym main);
27 //~^ ERROR asm template modifiers are not allowed for `sym` arguments
28 asm!("", in("x29") foo);
29 //~^ ERROR invalid register `x29`: the frame pointer cannot be used as an operand
30 asm!("", in("sp") foo);
31 //~^ ERROR invalid register `sp`: the stack pointer cannot be used as an operand
32 asm!("", in("xzr") foo);
33 //~^ ERROR invalid register `xzr`: the zero register cannot be used as an operand
34 asm!("", in("x19") foo);
35 //~^ ERROR invalid register `x19`: x19 is used internally by LLVM and cannot be used as an operand for inline asm
36
37 asm!("", in("p0") foo);
38 //~^ ERROR register class `preg` can only be used as a clobber, not as an input or output
39 //~| ERROR type `i32` cannot be used with this register class
40 asm!("", out("p0") _);
41 asm!("{}", in(preg) foo);
42 //~^ ERROR register class `preg` can only be used as a clobber, not as an input or output
43 //~| ERROR type `i32` cannot be used with this register class
44 asm!("{}", out(preg) _);
45 //~^ ERROR register class `preg` can only be used as a clobber, not as an input or output
46
47 // Explicit register conflicts
48 // (except in/lateout which don't conflict)
49
50 asm!("", in("x0") foo, in("w0") bar);
51 //~^ ERROR register `x0` conflicts with register `x0`
52 asm!("", in("x0") foo, out("x0") bar);
53 //~^ ERROR register `x0` conflicts with register `x0`
54 asm!("", in("w0") foo, lateout("w0") bar);
55 asm!("", in("v0") foo, in("q0") bar);
56 //~^ ERROR register `v0` conflicts with register `v0`
57 asm!("", in("v0") foo, out("q0") bar);
58 //~^ ERROR register `v0` conflicts with register `v0`
59 asm!("", in("v0") foo, lateout("q0") bar);
60 }
61 }