Skip to content

Commit 3e5d2a7

Browse files
authored
Unrolled build for rust-lang#132516
Rollup merge of rust-lang#132516 - taiki-e:asm-ui, r=workingjubilee Add bad-reg inline assembly ui test for RISC-V and s390x rust-lang#131341 (comment) > Btw, such unsupported registers are present in most architectures, but only aarch64/arm64ec, x86_64, and not yet merged [sparc/sparc64](https://github.com/rust-lang/rust/pull/132472/files#diff-02aebda3376c2b020265137f9ce2c387669ca5cfecd7d60494275c2387db5114) (and powerpc/powerpc64 by this PR) currently have ui tests for them. I plan to add tests for other arches later. Starting with RISC-V and s390x, which I'm familiar with and relatively easy to check for correctness. (Relevant rustc code are supported_types/def_regs/overlapping_regs in [compiler/rustc_target/src/asm/riscv.rs](https://github.com/rust-lang/rust/blob/588a4203508ed7c76750c96b482641261630ed36/compiler/rustc_target/src/asm/riscv.rs) and [compiler/rustc_target/src/asm/s390x.rs](https://github.com/rust-lang/rust/blob/588a4203508ed7c76750c96b482641261630ed36/compiler/rustc_target/src/asm/s390x.rs).) r? workingjubilee `@rustbot` label +A-inline-assembly
2 parents 42188c3 + b07232d commit 3e5d2a7

14 files changed

+1387
-50
lines changed

tests/auxiliary/minicore.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
//!
77
//! - `minicore` is **only** intended for `core` items, and the stubs should match the actual `core`
88
//! items.
9+
//! - Be careful of adding new features and things that are only available for a subset of targets.
910
//!
1011
//! # References
1112
//!
1213
//! This is partially adapted from `rustc_codegen_cranelift`:
1314
//! <https://github.com/rust-lang/rust/blob/c0b5cc9003f6464c11ae1c0662c6a7e06f6f5cab/compiler/rustc_codegen_cranelift/example/mini_core.rs>.
1415
// ignore-tidy-linelength
1516

16-
#![feature(no_core, lang_items, rustc_attrs)]
17+
#![feature(no_core, lang_items, rustc_attrs, decl_macro)]
1718
#![allow(unused, improper_ctypes_definitions, internal_features)]
19+
#![feature(asm_experimental_arch)]
1820
#![no_std]
1921
#![no_core]
2022

@@ -37,7 +39,9 @@ impl<T: ?Sized> LegacyReceiver for &mut T {}
3739
#[lang = "copy"]
3840
pub trait Copy: Sized {}
3941

40-
impl_marker_trait!(Copy => [ bool, char, isize, usize, i8, i16, i32, i64, u8, u16, u32, u64 ]);
42+
impl_marker_trait!(
43+
Copy => [ bool, char, isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64 ]
44+
);
4145
impl<'a, T: ?Sized> Copy for &'a T {}
4246
impl<T: ?Sized> Copy for *const T {}
4347
impl<T: ?Sized> Copy for *mut T {}
@@ -70,3 +74,8 @@ impl<T: Copy + ?Sized> Copy for ManuallyDrop<T> {}
7074
pub struct UnsafeCell<T: ?Sized> {
7175
value: T,
7276
}
77+
78+
#[rustc_builtin_macro]
79+
pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
80+
/* compiler built-in */
81+
}
+212
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
error: invalid register `s1`: s1 is used internally by LLVM and cannot be used as an operand for inline asm
2+
--> $DIR/bad-reg.rs:34:18
3+
|
4+
LL | asm!("", out("s1") _);
5+
| ^^^^^^^^^^^
6+
7+
error: invalid register `fp`: the frame pointer cannot be used as an operand for inline asm
8+
--> $DIR/bad-reg.rs:36:18
9+
|
10+
LL | asm!("", out("fp") _);
11+
| ^^^^^^^^^^^
12+
13+
error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm
14+
--> $DIR/bad-reg.rs:38:18
15+
|
16+
LL | asm!("", out("sp") _);
17+
| ^^^^^^^^^^^
18+
19+
error: invalid register `gp`: the global pointer cannot be used as an operand for inline asm
20+
--> $DIR/bad-reg.rs:40:18
21+
|
22+
LL | asm!("", out("gp") _);
23+
| ^^^^^^^^^^^
24+
25+
error: invalid register `gp`: the global pointer cannot be used as an operand for inline asm
26+
--> $DIR/bad-reg.rs:42:18
27+
|
28+
LL | asm!("", out("gp") _);
29+
| ^^^^^^^^^^^
30+
31+
error: invalid register `tp`: the thread pointer cannot be used as an operand for inline asm
32+
--> $DIR/bad-reg.rs:44:18
33+
|
34+
LL | asm!("", out("tp") _);
35+
| ^^^^^^^^^^^
36+
37+
error: invalid register `zero`: the zero register cannot be used as an operand for inline asm
38+
--> $DIR/bad-reg.rs:46:18
39+
|
40+
LL | asm!("", out("zero") _);
41+
| ^^^^^^^^^^^^^
42+
43+
error: register class `vreg` can only be used as a clobber, not as an input or output
44+
--> $DIR/bad-reg.rs:97:18
45+
|
46+
LL | asm!("", in("v0") x);
47+
| ^^^^^^^^^^
48+
49+
error: register class `vreg` can only be used as a clobber, not as an input or output
50+
--> $DIR/bad-reg.rs:100:18
51+
|
52+
LL | asm!("", out("v0") x);
53+
| ^^^^^^^^^^^
54+
55+
error: register class `vreg` can only be used as a clobber, not as an input or output
56+
--> $DIR/bad-reg.rs:103:26
57+
|
58+
LL | asm!("/* {} */", in(vreg) x);
59+
| ^^^^^^^^^^
60+
61+
error: register class `vreg` can only be used as a clobber, not as an input or output
62+
--> $DIR/bad-reg.rs:106:26
63+
|
64+
LL | asm!("/* {} */", out(vreg) _);
65+
| ^^^^^^^^^^^
66+
67+
error: cannot use register `x16`: register can't be used with the `e` target feature
68+
--> $DIR/bad-reg.rs:49:18
69+
|
70+
LL | asm!("", out("x16") _);
71+
| ^^^^^^^^^^^^
72+
73+
error: cannot use register `x17`: register can't be used with the `e` target feature
74+
--> $DIR/bad-reg.rs:51:18
75+
|
76+
LL | asm!("", out("x17") _);
77+
| ^^^^^^^^^^^^
78+
79+
error: cannot use register `x18`: register can't be used with the `e` target feature
80+
--> $DIR/bad-reg.rs:53:18
81+
|
82+
LL | asm!("", out("x18") _);
83+
| ^^^^^^^^^^^^
84+
85+
error: cannot use register `x19`: register can't be used with the `e` target feature
86+
--> $DIR/bad-reg.rs:55:18
87+
|
88+
LL | asm!("", out("x19") _);
89+
| ^^^^^^^^^^^^
90+
91+
error: cannot use register `x20`: register can't be used with the `e` target feature
92+
--> $DIR/bad-reg.rs:57:18
93+
|
94+
LL | asm!("", out("x20") _);
95+
| ^^^^^^^^^^^^
96+
97+
error: cannot use register `x21`: register can't be used with the `e` target feature
98+
--> $DIR/bad-reg.rs:59:18
99+
|
100+
LL | asm!("", out("x21") _);
101+
| ^^^^^^^^^^^^
102+
103+
error: cannot use register `x22`: register can't be used with the `e` target feature
104+
--> $DIR/bad-reg.rs:61:18
105+
|
106+
LL | asm!("", out("x22") _);
107+
| ^^^^^^^^^^^^
108+
109+
error: cannot use register `x23`: register can't be used with the `e` target feature
110+
--> $DIR/bad-reg.rs:63:18
111+
|
112+
LL | asm!("", out("x23") _);
113+
| ^^^^^^^^^^^^
114+
115+
error: cannot use register `x24`: register can't be used with the `e` target feature
116+
--> $DIR/bad-reg.rs:65:18
117+
|
118+
LL | asm!("", out("x24") _);
119+
| ^^^^^^^^^^^^
120+
121+
error: cannot use register `x25`: register can't be used with the `e` target feature
122+
--> $DIR/bad-reg.rs:67:18
123+
|
124+
LL | asm!("", out("x25") _);
125+
| ^^^^^^^^^^^^
126+
127+
error: cannot use register `x26`: register can't be used with the `e` target feature
128+
--> $DIR/bad-reg.rs:69:18
129+
|
130+
LL | asm!("", out("x26") _);
131+
| ^^^^^^^^^^^^
132+
133+
error: cannot use register `x27`: register can't be used with the `e` target feature
134+
--> $DIR/bad-reg.rs:71:18
135+
|
136+
LL | asm!("", out("x27") _);
137+
| ^^^^^^^^^^^^
138+
139+
error: cannot use register `x28`: register can't be used with the `e` target feature
140+
--> $DIR/bad-reg.rs:73:18
141+
|
142+
LL | asm!("", out("x28") _);
143+
| ^^^^^^^^^^^^
144+
145+
error: cannot use register `x29`: register can't be used with the `e` target feature
146+
--> $DIR/bad-reg.rs:75:18
147+
|
148+
LL | asm!("", out("x29") _);
149+
| ^^^^^^^^^^^^
150+
151+
error: cannot use register `x30`: register can't be used with the `e` target feature
152+
--> $DIR/bad-reg.rs:77:18
153+
|
154+
LL | asm!("", out("x30") _);
155+
| ^^^^^^^^^^^^
156+
157+
error: cannot use register `x31`: register can't be used with the `e` target feature
158+
--> $DIR/bad-reg.rs:79:18
159+
|
160+
LL | asm!("", out("x31") _);
161+
| ^^^^^^^^^^^^
162+
163+
error: register class `freg` requires at least one of the following target features: d, f
164+
--> $DIR/bad-reg.rs:83:26
165+
|
166+
LL | asm!("/* {} */", in(freg) f);
167+
| ^^^^^^^^^^
168+
169+
error: register class `freg` requires at least one of the following target features: d, f
170+
--> $DIR/bad-reg.rs:85:26
171+
|
172+
LL | asm!("/* {} */", out(freg) _);
173+
| ^^^^^^^^^^^
174+
175+
error: register class `freg` requires at least one of the following target features: d, f
176+
--> $DIR/bad-reg.rs:87:26
177+
|
178+
LL | asm!("/* {} */", in(freg) d);
179+
| ^^^^^^^^^^
180+
181+
error: register class `freg` requires at least one of the following target features: d, f
182+
--> $DIR/bad-reg.rs:90:26
183+
|
184+
LL | asm!("/* {} */", out(freg) d);
185+
| ^^^^^^^^^^^
186+
187+
error: type `i32` cannot be used with this register class
188+
--> $DIR/bad-reg.rs:97:27
189+
|
190+
LL | asm!("", in("v0") x);
191+
| ^
192+
|
193+
= note: register class `vreg` supports these types:
194+
195+
error: type `i32` cannot be used with this register class
196+
--> $DIR/bad-reg.rs:100:28
197+
|
198+
LL | asm!("", out("v0") x);
199+
| ^
200+
|
201+
= note: register class `vreg` supports these types:
202+
203+
error: type `i32` cannot be used with this register class
204+
--> $DIR/bad-reg.rs:103:35
205+
|
206+
LL | asm!("/* {} */", in(vreg) x);
207+
| ^
208+
|
209+
= note: register class `vreg` supports these types:
210+
211+
error: aborting due to 34 previous errors
212+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
error: invalid register `s1`: s1 is used internally by LLVM and cannot be used as an operand for inline asm
2+
--> $DIR/bad-reg.rs:34:18
3+
|
4+
LL | asm!("", out("s1") _);
5+
| ^^^^^^^^^^^
6+
7+
error: invalid register `fp`: the frame pointer cannot be used as an operand for inline asm
8+
--> $DIR/bad-reg.rs:36:18
9+
|
10+
LL | asm!("", out("fp") _);
11+
| ^^^^^^^^^^^
12+
13+
error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm
14+
--> $DIR/bad-reg.rs:38:18
15+
|
16+
LL | asm!("", out("sp") _);
17+
| ^^^^^^^^^^^
18+
19+
error: invalid register `gp`: the global pointer cannot be used as an operand for inline asm
20+
--> $DIR/bad-reg.rs:40:18
21+
|
22+
LL | asm!("", out("gp") _);
23+
| ^^^^^^^^^^^
24+
25+
error: invalid register `gp`: the global pointer cannot be used as an operand for inline asm
26+
--> $DIR/bad-reg.rs:42:18
27+
|
28+
LL | asm!("", out("gp") _);
29+
| ^^^^^^^^^^^
30+
31+
error: invalid register `tp`: the thread pointer cannot be used as an operand for inline asm
32+
--> $DIR/bad-reg.rs:44:18
33+
|
34+
LL | asm!("", out("tp") _);
35+
| ^^^^^^^^^^^
36+
37+
error: invalid register `zero`: the zero register cannot be used as an operand for inline asm
38+
--> $DIR/bad-reg.rs:46:18
39+
|
40+
LL | asm!("", out("zero") _);
41+
| ^^^^^^^^^^^^^
42+
43+
error: register class `vreg` can only be used as a clobber, not as an input or output
44+
--> $DIR/bad-reg.rs:97:18
45+
|
46+
LL | asm!("", in("v0") x);
47+
| ^^^^^^^^^^
48+
49+
error: register class `vreg` can only be used as a clobber, not as an input or output
50+
--> $DIR/bad-reg.rs:100:18
51+
|
52+
LL | asm!("", out("v0") x);
53+
| ^^^^^^^^^^^
54+
55+
error: register class `vreg` can only be used as a clobber, not as an input or output
56+
--> $DIR/bad-reg.rs:103:26
57+
|
58+
LL | asm!("/* {} */", in(vreg) x);
59+
| ^^^^^^^^^^
60+
61+
error: register class `vreg` can only be used as a clobber, not as an input or output
62+
--> $DIR/bad-reg.rs:106:26
63+
|
64+
LL | asm!("/* {} */", out(vreg) _);
65+
| ^^^^^^^^^^^
66+
67+
error: type `i32` cannot be used with this register class
68+
--> $DIR/bad-reg.rs:97:27
69+
|
70+
LL | asm!("", in("v0") x);
71+
| ^
72+
|
73+
= note: register class `vreg` supports these types:
74+
75+
error: type `i32` cannot be used with this register class
76+
--> $DIR/bad-reg.rs:100:28
77+
|
78+
LL | asm!("", out("v0") x);
79+
| ^
80+
|
81+
= note: register class `vreg` supports these types:
82+
83+
error: type `i32` cannot be used with this register class
84+
--> $DIR/bad-reg.rs:103:35
85+
|
86+
LL | asm!("/* {} */", in(vreg) x);
87+
| ^
88+
|
89+
= note: register class `vreg` supports these types:
90+
91+
error: aborting due to 14 previous errors
92+

0 commit comments

Comments
 (0)