summaryrefslogtreecommitdiffstats
path: root/src/test/ui/asm/aarch64/bad-reg.rs
blob: 2b6a9b71cd506390b41464288f84f165b3b6c9db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// only-aarch64
// compile-flags: -C target-feature=+neon

#![feature(asm_const, asm_sym)]

use std::arch::asm;

fn main() {
    let mut foo = 0;
    let mut bar = 0;
    unsafe {
        // Bad register/register class

        asm!("{}", in(foo) foo);
        //~^ ERROR invalid register class `foo`: unknown register class
        asm!("", in("foo") foo);
        //~^ ERROR invalid register `foo`: unknown register
        asm!("{:z}", in(reg) foo);
        //~^ ERROR invalid asm template modifier for this register class
        asm!("{:r}", in(vreg) foo);
        //~^ ERROR invalid asm template modifier for this register class
        asm!("{:r}", in(vreg_low16) foo);
        //~^ ERROR invalid asm template modifier for this register class
        asm!("{:a}", const 0);
        //~^ ERROR asm template modifiers are not allowed for `const` arguments
        asm!("{:a}", sym main);
        //~^ ERROR asm template modifiers are not allowed for `sym` arguments
        asm!("", in("x29") foo);
        //~^ ERROR invalid register `x29`: the frame pointer cannot be used as an operand
        asm!("", in("sp") foo);
        //~^ ERROR invalid register `sp`: the stack pointer cannot be used as an operand
        asm!("", in("xzr") foo);
        //~^ ERROR invalid register `xzr`: the zero register cannot be used as an operand
        asm!("", in("x19") foo);
        //~^ ERROR invalid register `x19`: x19 is used internally by LLVM and cannot be used as an operand for inline asm

        asm!("", in("p0") foo);
        //~^ ERROR register class `preg` can only be used as a clobber, not as an input or output
        //~| ERROR type `i32` cannot be used with this register class
        asm!("", out("p0") _);
        asm!("{}", in(preg) foo);
        //~^ ERROR register class `preg` can only be used as a clobber, not as an input or output
        //~| ERROR type `i32` cannot be used with this register class
        asm!("{}", out(preg) _);
        //~^ ERROR register class `preg` can only be used as a clobber, not as an input or output

        // Explicit register conflicts
        // (except in/lateout which don't conflict)

        asm!("", in("x0") foo, in("w0") bar);
        //~^ ERROR register `x0` conflicts with register `x0`
        asm!("", in("x0") foo, out("x0") bar);
        //~^ ERROR register `x0` conflicts with register `x0`
        asm!("", in("w0") foo, lateout("w0") bar);
        asm!("", in("v0") foo, in("q0") bar);
        //~^ ERROR register `v0` conflicts with register `v0`
        asm!("", in("v0") foo, out("q0") bar);
        //~^ ERROR register `v0` conflicts with register `v0`
        asm!("", in("v0") foo, lateout("q0") bar);
    }
}