File: bad-reg.rs

package info (click to toggle)
rustc 1.87.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 925,564 kB
  • sloc: xml: 158,127; python: 36,039; javascript: 19,761; sh: 19,737; cpp: 18,981; ansic: 13,133; asm: 4,376; makefile: 710; perl: 29; lisp: 28; ruby: 19; sql: 11
file content (170 lines) | stat: -rw-r--r-- 10,498 bytes parent folder | download | duplicates (15)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//@ add-core-stubs
//@ needs-asm-support
//@ revisions: s390x s390x_vector s390x_vector_stable
//@[s390x] compile-flags: --target s390x-unknown-linux-gnu
//@[s390x] needs-llvm-components: systemz
//@[s390x_vector] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=+vector
//@[s390x_vector] needs-llvm-components: systemz
//@[s390x_vector_stable] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=+vector
//@[s390x_vector_stable] needs-llvm-components: systemz

#![crate_type = "rlib"]
#![feature(no_core, repr_simd)]
#![cfg_attr(not(s390x_vector_stable), feature(asm_experimental_reg))]
#![no_core]
#![allow(non_camel_case_types)]

extern crate minicore;
use minicore::*;

#[repr(simd)]
pub struct i64x2([i64; 2]);

impl Copy for i64x2 {}

fn f() {
    let mut x = 0;
    let mut b = 0u8;
    let mut v = i64x2([0; 2]);
    unsafe {
        // Unsupported registers
        asm!("", out("r11") _);
        //~^ ERROR invalid register `r11`: The frame pointer cannot be used as an operand for inline asm
        asm!("", out("r15") _);
        //~^ ERROR invalid register `r15`: The stack pointer cannot be used as an operand for inline asm
        asm!("", out("c0") _);
        //~^ ERROR invalid register `c0`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c1") _);
        //~^ ERROR invalid register `c1`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c2") _);
        //~^ ERROR invalid register `c2`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c3") _);
        //~^ ERROR invalid register `c3`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c4") _);
        //~^ ERROR invalid register `c4`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c5") _);
        //~^ ERROR invalid register `c5`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c6") _);
        //~^ ERROR invalid register `c6`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c7") _);
        //~^ ERROR invalid register `c7`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c8") _);
        //~^ ERROR invalid register `c8`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c9") _);
        //~^ ERROR invalid register `c9`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c10") _);
        //~^ ERROR invalid register `c10`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c11") _);
        //~^ ERROR invalid register `c11`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c12") _);
        //~^ ERROR invalid register `c12`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c13") _);
        //~^ ERROR invalid register `c13`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c14") _);
        //~^ ERROR invalid register `c14`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("c15") _);
        //~^ ERROR invalid register `c15`: control registers are reserved by the kernel and cannot be used as operands for inline asm
        asm!("", out("a0") _);
        //~^ ERROR invalid register `a0`: a0 and a1 are reserved for system use and cannot be used as operands for inline asm
        asm!("", out("a1") _);
        //~^ ERROR invalid register `a1`: a0 and a1 are reserved for system use and cannot be used as operands for inline asm

        // vreg
        asm!("", out("v0") _); // always ok
        asm!("", in("v0") v); // requires vector & asm_experimental_reg
        //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
        //[s390x_vector_stable]~^^ ERROR register class `vreg` can only be used as a clobber in stable [E0658]
        //[s390x_vector_stable]~| ERROR type `i64x2` cannot be used with this register class in stable [E0658]
        asm!("", out("v0") v); // requires vector & asm_experimental_reg
        //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
        //[s390x_vector_stable]~^^ ERROR register class `vreg` can only be used as a clobber in stable [E0658]
        //[s390x_vector_stable]~| ERROR type `i64x2` cannot be used with this register class in stable [E0658]
        asm!("", in("v0") x); // requires vector & asm_experimental_reg
        //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
        //[s390x_vector_stable]~^^ ERROR register class `vreg` can only be used as a clobber in stable [E0658]
        //[s390x_vector_stable]~| ERROR type `i32` cannot be used with this register class in stable [E0658]
        asm!("", out("v0") x); // requires vector & asm_experimental_reg
        //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
        //[s390x_vector_stable]~^^ ERROR register class `vreg` can only be used as a clobber in stable [E0658]
        //[s390x_vector_stable]~| ERROR type `i32` cannot be used with this register class in stable [E0658]
        asm!("", in("v0") b);
        //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
        //[s390x_vector]~^^ ERROR type `u8` cannot be used with this register class
        //[s390x_vector_stable]~^^^ ERROR register class `vreg` can only be used as a clobber in stable [E0658]
        //[s390x_vector_stable]~| ERROR type `u8` cannot be used with this register class
        asm!("", out("v0") b);
        //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
        //[s390x_vector]~^^ ERROR type `u8` cannot be used with this register class
        //[s390x_vector_stable]~^^^ ERROR register class `vreg` can only be used as a clobber in stable [E0658]
        //[s390x_vector_stable]~| ERROR type `u8` cannot be used with this register class
        asm!("/* {} */", in(vreg) v); // requires vector & asm_experimental_reg
        //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
        //[s390x_vector_stable]~^^ ERROR register class `vreg` can only be used as a clobber in stable [E0658]
        //[s390x_vector_stable]~| ERROR type `i64x2` cannot be used with this register class in stable [E0658]
        asm!("/* {} */", in(vreg) x); // requires vector & asm_experimental_reg
        //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
        //[s390x_vector_stable]~^^ ERROR register class `vreg` can only be used as a clobber in stable [E0658]
        //[s390x_vector_stable]~| ERROR type `i32` cannot be used with this register class in stable [E0658]
        asm!("/* {} */", in(vreg) b);
        //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
        //[s390x_vector]~^^ ERROR type `u8` cannot be used with this register class
        //[s390x_vector_stable]~^^^ ERROR register class `vreg` can only be used as a clobber in stable [E0658]
        //[s390x_vector_stable]~| ERROR type `u8` cannot be used with this register class
        asm!("/* {} */", out(vreg) _); // requires vector & asm_experimental_reg
        //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
        //[s390x_vector_stable]~^^ ERROR register class `vreg` can only be used as a clobber in stable [E0658]

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

        // Overlapping registers
        // vreg/freg
        asm!("", out("v0") _, out("f0") _);
        //~^ ERROR register `f0` conflicts with register `v0`
        asm!("", out("v1") _, out("f1") _);
        //~^ ERROR register `f1` conflicts with register `v1`
        asm!("", out("v2") _, out("f2") _);
        //~^ ERROR register `f2` conflicts with register `v2`
        asm!("", out("v3") _, out("f3") _);
        //~^ ERROR register `f3` conflicts with register `v3`
        asm!("", out("v4") _, out("f4") _);
        //~^ ERROR register `f4` conflicts with register `v4`
        asm!("", out("v5") _, out("f5") _);
        //~^ ERROR register `f5` conflicts with register `v5`
        asm!("", out("v6") _, out("f6") _);
        //~^ ERROR register `f6` conflicts with register `v6`
        asm!("", out("v7") _, out("f7") _);
        //~^ ERROR register `f7` conflicts with register `v7`
        asm!("", out("v8") _, out("f8") _);
        //~^ ERROR register `f8` conflicts with register `v8`
        asm!("", out("v9") _, out("f9") _);
        //~^ ERROR register `f9` conflicts with register `v9`
        asm!("", out("v10") _, out("f10") _);
        //~^ ERROR register `f10` conflicts with register `v10`
        asm!("", out("v11") _, out("f11") _);
        //~^ ERROR register `f11` conflicts with register `v11`
        asm!("", out("v12") _, out("f12") _);
        //~^ ERROR register `f12` conflicts with register `v12`
        asm!("", out("v13") _, out("f13") _);
        //~^ ERROR register `f13` conflicts with register `v13`
        asm!("", out("v14") _, out("f14") _);
        //~^ ERROR register `f14` conflicts with register `v14`
        asm!("", out("v15") _, out("f15") _);
        //~^ ERROR register `f15` conflicts with register `v15`
        // no %f16
        asm!("", out("v16") _, out("f16") _);
        //~^ ERROR invalid register `f16`: unknown register
    }
}