]> git.proxmox.com Git - rustc.git/blob - src/test/ui/asm/bad-reg.rs
016ea9329c4d0988407a47a7b85cad9de9fe05b5
[rustc.git] / src / test / ui / asm / bad-reg.rs
1 // only-x86_64
2 // compile-flags: -C target-feature=+avx2
3
4 #![feature(asm)]
5
6 fn main() {
7 let mut foo = 0;
8 let mut bar = 0;
9 unsafe {
10 // Bad register/register class
11
12 asm!("{}", in(foo) foo);
13 //~^ ERROR invalid register class `foo`: unknown register class
14 asm!("", in("foo") foo);
15 //~^ ERROR invalid register `foo`: unknown register
16 asm!("{:z}", in(reg) foo);
17 //~^ ERROR invalid asm template modifier for this register class
18 asm!("{:r}", in(xmm_reg) foo);
19 //~^ ERROR invalid asm template modifier for this register class
20 asm!("{:a}", const 0);
21 //~^ ERROR asm template modifiers are not allowed for `const` arguments
22 asm!("{:a}", sym main);
23 //~^ ERROR asm template modifiers are not allowed for `sym` arguments
24 asm!("{}", in(zmm_reg) foo);
25 //~^ ERROR register class `zmm_reg` requires the `avx512f` target feature
26 asm!("", in("zmm0") foo);
27 //~^ ERROR register class `zmm_reg` requires the `avx512f` target feature
28 asm!("", in("ebp") foo);
29 //~^ ERROR invalid register `ebp`: the frame pointer cannot be used as an operand
30 asm!("", in("rsp") foo);
31 //~^ ERROR invalid register `rsp`: the stack pointer cannot be used as an operand
32 asm!("", in("ip") foo);
33 //~^ ERROR invalid register `ip`: the instruction pointer cannot be used as an operand
34 asm!("", in("st(2)") foo);
35 //~^ ERROR invalid register `st(2)`: x87 registers are not currently supported as operands
36 asm!("", in("mm0") foo);
37 //~^ ERROR invalid register `mm0`: MMX registers are not currently supported as operands
38 asm!("", in("k0") foo);
39 //~^ ERROR invalid register `k0`: the k0 AVX mask register cannot be used as an operand
40
41 // Explicit register conflicts
42 // (except in/lateout which don't conflict)
43
44 asm!("", in("eax") foo, in("al") bar);
45 //~^ ERROR register `al` conflicts with register `ax`
46 asm!("", in("rax") foo, out("rax") bar);
47 //~^ ERROR register `ax` conflicts with register `ax`
48 asm!("", in("al") foo, lateout("al") bar);
49 asm!("", in("xmm0") foo, in("ymm0") bar);
50 //~^ ERROR register `ymm0` conflicts with register `xmm0`
51 asm!("", in("xmm0") foo, out("ymm0") bar);
52 //~^ ERROR register `ymm0` conflicts with register `xmm0`
53 asm!("", in("xmm0") foo, lateout("ymm0") bar);
54 }
55 }