]>
Commit | Line | Data |
---|---|---|
f9f354fc XL |
1 | // only-x86_64 |
2 | // compile-flags: -C target-feature=+avx2 | |
3 | ||
a2a8927a XL |
4 | #![feature(asm_const, asm_sym)] |
5 | ||
6 | use std::arch::asm; | |
f9f354fc XL |
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(xmm_reg) foo); | |
21 | //~^ ERROR invalid asm template modifier for this register class | |
22 | asm!("{:a}", const 0); | |
23 | //~^ ERROR asm template modifiers are not allowed for `const` arguments | |
24 | asm!("{:a}", sym main); | |
25 | //~^ ERROR asm template modifiers are not allowed for `sym` arguments | |
f9f354fc XL |
26 | asm!("", in("ebp") foo); |
27 | //~^ ERROR invalid register `ebp`: the frame pointer cannot be used as an operand | |
28 | asm!("", in("rsp") foo); | |
29 | //~^ ERROR invalid register `rsp`: the stack pointer cannot be used as an operand | |
30 | asm!("", in("ip") foo); | |
31 | //~^ ERROR invalid register `ip`: the instruction pointer cannot be used as an operand | |
f9f354fc | 32 | |
136023e0 XL |
33 | asm!("", in("st(2)") foo); |
34 | //~^ ERROR register class `x87_reg` can only be used as a clobber, not as an input or output | |
923072b8 | 35 | //~| ERROR `i32` cannot be used with this register class |
136023e0 XL |
36 | asm!("", in("mm0") foo); |
37 | //~^ ERROR register class `mmx_reg` can only be used as a clobber, not as an input or output | |
923072b8 | 38 | //~| ERROR `i32` cannot be used with this register class |
04454e1e FG |
39 | asm!("", in("k0") foo); |
40 | //~^ ERROR register class `kreg0` can only be used as a clobber, not as an input or output | |
923072b8 | 41 | //~| ERROR `i32` cannot be used with this register class |
136023e0 XL |
42 | asm!("", out("st(2)") _); |
43 | asm!("", out("mm0") _); | |
44 | asm!("{}", in(x87_reg) foo); | |
45 | //~^ ERROR register class `x87_reg` can only be used as a clobber, not as an input or output | |
923072b8 | 46 | //~| ERROR `i32` cannot be used with this register class |
136023e0 XL |
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 | |
923072b8 | 49 | //~| ERROR `i32` cannot be used with this register class |
136023e0 XL |
50 | asm!("{}", out(x87_reg) _); |
51 | //~^ ERROR register class `x87_reg` can only be used as a clobber, not as an input or output | |
52 | asm!("{}", out(mmx_reg) _); | |
53 | //~^ ERROR register class `mmx_reg` can only be used as a clobber, not as an input or output | |
54 | ||
f9f354fc XL |
55 | // Explicit register conflicts |
56 | // (except in/lateout which don't conflict) | |
57 | ||
58 | asm!("", in("eax") foo, in("al") bar); | |
59 | //~^ ERROR register `al` conflicts with register `ax` | |
923072b8 | 60 | //~| ERROR `i32` cannot be used with this register class |
f9f354fc XL |
61 | asm!("", in("rax") foo, out("rax") bar); |
62 | //~^ ERROR register `ax` conflicts with register `ax` | |
63 | asm!("", in("al") foo, lateout("al") bar); | |
923072b8 FG |
64 | //~^ ERROR `i32` cannot be used with this register class |
65 | //~| ERROR `i32` cannot be used with this register class | |
f9f354fc XL |
66 | asm!("", in("xmm0") foo, in("ymm0") bar); |
67 | //~^ ERROR register `ymm0` conflicts with register `xmm0` | |
68 | asm!("", in("xmm0") foo, out("ymm0") bar); | |
69 | //~^ ERROR register `ymm0` conflicts with register `xmm0` | |
70 | asm!("", in("xmm0") foo, lateout("ymm0") bar); | |
71 | } | |
72 | } |