File: bad-reg.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 893,176 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (58 lines) | stat: -rw-r--r-- 2,500 bytes parent folder | download | duplicates (4)
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
//@ add-core-stubs
//@ revisions: sparc sparcv8plus sparc64
//@[sparc] compile-flags: --target sparc-unknown-none-elf
//@[sparc] needs-llvm-components: sparc
//@[sparcv8plus] compile-flags: --target sparc-unknown-linux-gnu
//@[sparcv8plus] needs-llvm-components: sparc
//@[sparc64] compile-flags: --target sparc64-unknown-linux-gnu
//@[sparc64] needs-llvm-components: sparc
//@ needs-asm-support

#![crate_type = "rlib"]
#![feature(no_core, asm_experimental_arch)]
#![no_core]

extern crate minicore;
use minicore::*;

fn f() {
    let mut x = 0;
    unsafe {
        // Unsupported registers
        asm!("", out("g0") _);
        //~^ ERROR invalid register `g0`: g0 is always zero and cannot be used as an operand for inline asm
        // FIXME: see FIXME in compiler/rustc_target/src/asm/sparc.rs.
        asm!("", out("g1") _);
        //~^ ERROR invalid register `g1`: reserved by LLVM and cannot be used as an operand for inline asm
        asm!("", out("g2") _);
        asm!("", out("g3") _);
        asm!("", out("g4") _);
        asm!("", out("g5") _);
        //[sparc,sparcv8plus]~^ ERROR cannot use register `r5`: g5 is reserved for system on SPARC32
        asm!("", out("g6") _);
        //~^ ERROR invalid register `g6`: reserved for system and cannot be used as an operand for inline asm
        asm!("", out("g7") _);
        //~^ ERROR invalid register `g7`: reserved for system and cannot be used as an operand for inline asm
        asm!("", out("sp") _);
        //~^ ERROR invalid register `sp`: the stack pointer cannot be used as an operand for inline asm
        asm!("", out("fp") _);
        //~^ ERROR invalid register `fp`: the frame pointer cannot be used as an operand for inline asm
        asm!("", out("i7") _);
        //~^ ERROR invalid register `i7`: the return address register cannot be used as an operand for inline asm

        // Clobber-only registers
        // yreg
        asm!("", out("y") _); // ok
        asm!("", in("y") x);
        //~^ ERROR can only be used as a clobber
        //~| ERROR type `i32` cannot be used with this register class
        asm!("", out("y") x);
        //~^ ERROR can only be used as a clobber
        //~| ERROR type `i32` cannot be used with this register class
        asm!("/* {} */", in(yreg) x);
        //~^ ERROR can only be used as a clobber
        //~| ERROR type `i32` cannot be used with this register class
        asm!("/* {} */", out(yreg) _);
        //~^ ERROR can only be used as a clobber
    }
}