]> git.lizzy.rs Git - rust.git/blob - src/test/ui/asm/x86_64/bad-reg.rs
Rollup merge of #87631 - :solarish_upd_fs, r=joshtriplett
[rust.git] / src / test / ui / asm / x86_64 / 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("k0") foo);
35         //~^ ERROR invalid register `k0`: the k0 AVX mask register cannot be used as an operand
36         asm!("", in("ah") foo);
37         //~^ ERROR invalid register `ah`: high byte registers cannot be used as an operand
38
39         asm!("", in("st(2)") foo);
40         //~^ ERROR register class `x87_reg` can only be used as a clobber, not as an input or output
41         asm!("", in("mm0") foo);
42         //~^ ERROR register class `mmx_reg` can only be used as a clobber, not as an input or output
43         asm!("", out("st(2)") _);
44         asm!("", out("mm0") _);
45         asm!("{}", in(x87_reg) foo);
46         //~^ ERROR register class `x87_reg` can only be used as a clobber, not as an input or output
47         asm!("{}", in(mmx_reg) foo);
48         //~^ ERROR register class `mmx_reg` can only be used as a clobber, not as an input or output
49         asm!("{}", out(x87_reg) _);
50         //~^ ERROR register class `x87_reg` can only be used as a clobber, not as an input or output
51         asm!("{}", out(mmx_reg) _);
52         //~^ ERROR register class `mmx_reg` can only be used as a clobber, not as an input or output
53
54         // Explicit register conflicts
55         // (except in/lateout which don't conflict)
56
57         asm!("", in("eax") foo, in("al") bar);
58         //~^ ERROR register `al` conflicts with register `ax`
59         asm!("", in("rax") foo, out("rax") bar);
60         //~^ ERROR register `ax` conflicts with register `ax`
61         asm!("", in("al") foo, lateout("al") bar);
62         asm!("", in("xmm0") foo, in("ymm0") bar);
63         //~^ ERROR register `ymm0` conflicts with register `xmm0`
64         asm!("", in("xmm0") foo, out("ymm0") bar);
65         //~^ ERROR register `ymm0` conflicts with register `xmm0`
66         asm!("", in("xmm0") foo, lateout("ymm0") bar);
67     }
68 }