Skip to content

Commit d19517d

Browse files
committedNov 2, 2024·
Support clobber_abi and vector registers (clobber-only) in PowerPC inline assembly
·
1.90.01.84.0
1 parent 7c7bb7d commit d19517d

File tree

11 files changed

+1332
-18
lines changed

11 files changed

+1332
-18
lines changed
 

‎compiler/rustc_codegen_gcc/src/asm.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,8 @@ fn reg_to_gcc(reg: InlineAsmRegOrRegClass) -> ConstraintOrRegister {
654654
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => "b",
655655
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => "f",
656656
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::cr)
657-
| InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer) => {
657+
| InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer)
658+
| InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => {
658659
unreachable!("clobber-only")
659660
}
660661
InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => "r",
@@ -729,7 +730,8 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
729730
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => cx.type_i32(),
730731
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => cx.type_f64(),
731732
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::cr)
732-
| InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer) => {
733+
| InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer)
734+
| InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => {
733735
unreachable!("clobber-only")
734736
}
735737
InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => cx.type_i32(),

‎compiler/rustc_codegen_llvm/src/asm.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,9 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
638638
PowerPC(PowerPCInlineAsmRegClass::reg) => "r",
639639
PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => "b",
640640
PowerPC(PowerPCInlineAsmRegClass::freg) => "f",
641-
PowerPC(PowerPCInlineAsmRegClass::cr) | PowerPC(PowerPCInlineAsmRegClass::xer) => {
641+
PowerPC(PowerPCInlineAsmRegClass::cr)
642+
| PowerPC(PowerPCInlineAsmRegClass::xer)
643+
| PowerPC(PowerPCInlineAsmRegClass::vreg) => {
642644
unreachable!("clobber-only")
643645
}
644646
RiscV(RiscVInlineAsmRegClass::reg) => "r",
@@ -800,7 +802,9 @@ fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'
800802
PowerPC(PowerPCInlineAsmRegClass::reg) => cx.type_i32(),
801803
PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => cx.type_i32(),
802804
PowerPC(PowerPCInlineAsmRegClass::freg) => cx.type_f64(),
803-
PowerPC(PowerPCInlineAsmRegClass::cr) | PowerPC(PowerPCInlineAsmRegClass::xer) => {
805+
PowerPC(PowerPCInlineAsmRegClass::cr)
806+
| PowerPC(PowerPCInlineAsmRegClass::xer)
807+
| PowerPC(PowerPCInlineAsmRegClass::vreg) => {
804808
unreachable!("clobber-only")
805809
}
806810
RiscV(RiscVInlineAsmRegClass::reg) => cx.type_i32(),

‎compiler/rustc_target/src/asm/mod.rs‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ pub enum InlineAsmClobberAbi {
893893
Arm64EC,
894894
RiscV,
895895
LoongArch,
896+
PowerPC,
896897
S390x,
897898
Msp430,
898899
}
@@ -944,6 +945,10 @@ impl InlineAsmClobberAbi {
944945
"C" | "system" => Ok(InlineAsmClobberAbi::LoongArch),
945946
_ => Err(&["C", "system"]),
946947
},
948+
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => match name {
949+
"C" | "system" => Ok(InlineAsmClobberAbi::PowerPC),
950+
_ => Err(&["C", "system"]),
951+
},
947952
InlineAsmArch::S390x => match name {
948953
"C" | "system" => Ok(InlineAsmClobberAbi::S390x),
949954
_ => Err(&["C", "system"]),
@@ -1121,6 +1126,31 @@ impl InlineAsmClobberAbi {
11211126
f16, f17, f18, f19, f20, f21, f22, f23,
11221127
}
11231128
},
1129+
InlineAsmClobberAbi::PowerPC => clobbered_regs! {
1130+
PowerPC PowerPCInlineAsmReg {
1131+
// r0, r3-r12
1132+
r0,
1133+
r3, r4, r5, r6, r7,
1134+
r8, r9, r10, r11, r12,
1135+
1136+
// f0-f13
1137+
f0, f1, f2, f3, f4, f5, f6, f7,
1138+
f8, f9, f10, f11, f12, f13,
1139+
1140+
// v0-v19
1141+
// FIXME: PPC32 SysV ABI does not mention vector registers processing.
1142+
// https://refspecs.linuxfoundation.org/elf/elfspec_ppc.pdf
1143+
v0, v1, v2, v3, v4, v5, v6, v7,
1144+
v8, v9, v10, v11, v12, v13, v14,
1145+
v15, v16, v17, v18, v19,
1146+
1147+
// cr0-cr1, cr5-cr7, xer
1148+
cr0, cr1,
1149+
cr5, cr6, cr7,
1150+
xer,
1151+
// lr and ctr are reserved
1152+
}
1153+
},
11241154
InlineAsmClobberAbi::S390x => clobbered_regs! {
11251155
S390x S390xInlineAsmReg {
11261156
r0, r1, r2, r3, r4, r5,

‎compiler/rustc_target/src/asm/powerpc.rs‎

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
use std::fmt;
22

3+
use rustc_data_structures::fx::FxIndexSet;
34
use rustc_span::Symbol;
45

56
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
7+
use crate::spec::{RelocModel, Target};
68

79
def_reg_class! {
810
PowerPC PowerPCInlineAsmRegClass {
911
reg,
1012
reg_nonzero,
1113
freg,
14+
vreg,
1215
cr,
1316
xer,
1417
}
@@ -48,11 +51,44 @@ impl PowerPCInlineAsmRegClass {
4851
}
4952
}
5053
Self::freg => types! { _: F32, F64; },
54+
Self::vreg => &[],
5155
Self::cr | Self::xer => &[],
5256
}
5357
}
5458
}
5559

60+
fn reserved_r13(
61+
arch: InlineAsmArch,
62+
_reloc_model: RelocModel,
63+
_target_features: &FxIndexSet<Symbol>,
64+
target: &Target,
65+
_is_clobber: bool,
66+
) -> Result<(), &'static str> {
67+
if target.is_like_aix && arch == InlineAsmArch::PowerPC {
68+
Ok(())
69+
} else {
70+
Err("r13 is a reserved register on this target")
71+
}
72+
}
73+
74+
fn reserved_v20to31(
75+
_arch: InlineAsmArch,
76+
_reloc_model: RelocModel,
77+
_target_features: &FxIndexSet<Symbol>,
78+
target: &Target,
79+
_is_clobber: bool,
80+
) -> Result<(), &'static str> {
81+
if target.is_like_aix {
82+
match &*target.options.abi {
83+
"vec-default" => Err("v20-v31 are reserved on vec-default ABI"),
84+
"vec-extabi" => Ok(()),
85+
_ => unreachable!("unrecognized AIX ABI"),
86+
}
87+
} else {
88+
Ok(())
89+
}
90+
}
91+
5692
def_regs! {
5793
PowerPC PowerPCInlineAsmReg PowerPCInlineAsmRegClass {
5894
r0: reg = ["r0", "0"],
@@ -66,6 +102,7 @@ def_regs! {
66102
r10: reg, reg_nonzero = ["r10", "10"],
67103
r11: reg, reg_nonzero = ["r11", "11"],
68104
r12: reg, reg_nonzero = ["r12", "12"],
105+
r13: reg, reg_nonzero = ["r13", "13"] % reserved_r13,
69106
r14: reg, reg_nonzero = ["r14", "14"],
70107
r15: reg, reg_nonzero = ["r15", "15"],
71108
r16: reg, reg_nonzero = ["r16", "16"],
@@ -113,6 +150,38 @@ def_regs! {
113150
f29: freg = ["f29", "fr29"],
114151
f30: freg = ["f30", "fr30"],
115152
f31: freg = ["f31", "fr31"],
153+
v0: vreg = ["v0"],
154+
v1: vreg = ["v1"],
155+
v2: vreg = ["v2"],
156+
v3: vreg = ["v3"],
157+
v4: vreg = ["v4"],
158+
v5: vreg = ["v5"],
159+
v6: vreg = ["v6"],
160+
v7: vreg = ["v7"],
161+
v8: vreg = ["v8"],
162+
v9: vreg = ["v9"],
163+
v10: vreg = ["v10"],
164+
v11: vreg = ["v11"],
165+
v12: vreg = ["v12"],
166+
v13: vreg = ["v13"],
167+
v14: vreg = ["v14"],
168+
v15: vreg = ["v15"],
169+
v16: vreg = ["v16"],
170+
v17: vreg = ["v17"],
171+
v18: vreg = ["v18"],
172+
v19: vreg = ["v19"],
173+
v20: vreg = ["v20"] % reserved_v20to31,
174+
v21: vreg = ["v21"] % reserved_v20to31,
175+
v22: vreg = ["v22"] % reserved_v20to31,
176+
v23: vreg = ["v23"] % reserved_v20to31,
177+
v24: vreg = ["v24"] % reserved_v20to31,
178+
v25: vreg = ["v25"] % reserved_v20to31,
179+
v26: vreg = ["v26"] % reserved_v20to31,
180+
v27: vreg = ["v27"] % reserved_v20to31,
181+
v28: vreg = ["v28"] % reserved_v20to31,
182+
v29: vreg = ["v29"] % reserved_v20to31,
183+
v30: vreg = ["v30"] % reserved_v20to31,
184+
v31: vreg = ["v31"] % reserved_v20to31,
116185
cr: cr = ["cr"],
117186
cr0: cr = ["cr0"],
118187
cr1: cr = ["cr1"],
@@ -127,8 +196,6 @@ def_regs! {
127196
"the stack pointer cannot be used as an operand for inline asm",
128197
#error = ["r2", "2"] =>
129198
"r2 is a system reserved register and cannot be used as an operand for inline asm",
130-
#error = ["r13", "13"] =>
131-
"r13 is a system reserved register and cannot be used as an operand for inline asm",
132199
#error = ["r29", "29"] =>
133200
"r29 is used internally by LLVM and cannot be used as an operand for inline asm",
134201
#error = ["r30", "30"] =>
@@ -163,13 +230,17 @@ impl PowerPCInlineAsmReg {
163230
// Strip off the leading prefix.
164231
do_emit! {
165232
(r0, "0"), (r3, "3"), (r4, "4"), (r5, "5"), (r6, "6"), (r7, "7");
166-
(r8, "8"), (r9, "9"), (r10, "10"), (r11, "11"), (r12, "12"), (r14, "14"), (r15, "15");
233+
(r8, "8"), (r9, "9"), (r10, "10"), (r11, "11"), (r12, "12"), (r13, "13"), (r14, "14"), (r15, "15");
167234
(r16, "16"), (r17, "17"), (r18, "18"), (r19, "19"), (r20, "20"), (r21, "21"), (r22, "22"), (r23, "23");
168235
(r24, "24"), (r25, "25"), (r26, "26"), (r27, "27"), (r28, "28");
169236
(f0, "0"), (f1, "1"), (f2, "2"), (f3, "3"), (f4, "4"), (f5, "5"), (f6, "6"), (f7, "7");
170237
(f8, "8"), (f9, "9"), (f10, "10"), (f11, "11"), (f12, "12"), (f13, "13"), (f14, "14"), (f15, "15");
171238
(f16, "16"), (f17, "17"), (f18, "18"), (f19, "19"), (f20, "20"), (f21, "21"), (f22, "22"), (f23, "23");
172239
(f24, "24"), (f25, "25"), (f26, "26"), (f27, "27"), (f28, "28"), (f29, "29"), (f30, "30"), (f31, "31");
240+
(v0, "0"), (v1, "1"), (v2, "2"), (v3, "3"), (v4, "4"), (v5, "5"), (v6, "6"), (v7, "7");
241+
(v8, "8"), (v9, "9"), (v10, "10"), (v11, "11"), (v12, "12"), (v13, "13"), (v14, "14"), (v15, "15");
242+
(v16, "16"), (v17, "17"), (v18, "18"), (v19, "19"), (v20, "20"), (v21, "21"), (v22, "22"), (v23, "23");
243+
(v24, "24"), (v25, "25"), (v26, "26"), (v27, "27"), (v28, "28"), (v29, "29"), (v30, "30"), (v31, "31");
173244
(cr, "cr");
174245
(cr0, "0"), (cr1, "1"), (cr2, "2"), (cr3, "3"), (cr4, "4"), (cr5, "5"), (cr6, "6"), (cr7, "7");
175246
(xer, "xer");
@@ -201,5 +272,6 @@ impl PowerPCInlineAsmReg {
201272
reg_conflicts! {
202273
cr : cr0 cr1 cr2 cr3 cr4 cr5 cr6 cr7;
203274
}
275+
// f0-f31 (vsr0-vsr31) and v0-v31 (vsr32-vsr63) do not conflict.
204276
}
205277
}

‎src/doc/unstable-book/src/language-features/asm-experimental-arch.md‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
3131
| NVPTX | `reg32` | None\* | `r` |
3232
| NVPTX | `reg64` | None\* | `l` |
3333
| Hexagon | `reg` | `r[0-28]` | `r` |
34-
| PowerPC | `reg` | `r[0-31]` | `r` |
35-
| PowerPC | `reg_nonzero` | `r[1-31]` | `b` |
34+
| PowerPC | `reg` | `r0`, `r[3-12]`, `r[14-28]` | `r` |
35+
| PowerPC | `reg_nonzero` | `r[3-12]`, `r[14-28]` | `b` |
3636
| PowerPC | `freg` | `f[0-31]` | `f` |
37+
| PowerPC | `vreg` | `v[0-31]` | Only clobbers |
3738
| PowerPC | `cr` | `cr[0-7]`, `cr` | Only clobbers |
3839
| PowerPC | `xer` | `xer` | Only clobbers |
3940
| wasm32 | `local` | None\* | `r` |
@@ -76,9 +77,10 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
7677
| NVPTX | `reg32` | None | `i8`, `i16`, `i32`, `f32` |
7778
| NVPTX | `reg64` | None | `i8`, `i16`, `i32`, `f32`, `i64`, `f64` |
7879
| Hexagon | `reg` | None | `i8`, `i16`, `i32`, `f32` |
79-
| PowerPC | `reg` | None | `i8`, `i16`, `i32` |
80-
| PowerPC | `reg_nonzero` | None | `i8`, `i16`, `i32` |
80+
| PowerPC | `reg` | None | `i8`, `i16`, `i32`, `i64` (powerpc64 only) |
81+
| PowerPC | `reg_nonzero` | None | `i8`, `i16`, `i32`, `i64` (powerpc64 only) |
8182
| PowerPC | `freg` | None | `f32`, `f64` |
83+
| PowerPC | `vreg` | N/A | Only clobbers |
8284
| PowerPC | `cr` | N/A | Only clobbers |
8385
| PowerPC | `xer` | N/A | Only clobbers |
8486
| wasm32 | `local` | None | `i8` `i16` `i32` `i64` `f32` `f64` |
@@ -105,6 +107,10 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
105107
| Hexagon | `r29` | `sp` |
106108
| Hexagon | `r30` | `fr` |
107109
| Hexagon | `r31` | `lr` |
110+
| PowerPC | `r1` | `sp` |
111+
| PowerPC | `r31` | `fp` |
112+
| PowerPC | `r[0-31]` | `[0-31]` |
113+
| PowerPC | `f[0-31]` | `fr[0-31]`|
108114
| BPF | `r[0-10]` | `w[0-10]` |
109115
| AVR | `XH` | `r27` |
110116
| AVR | `XL` | `r26` |
@@ -145,14 +151,18 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
145151
| Architecture | Unsupported register | Reason |
146152
| ------------ | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
147153
| All | `sp`, `r15` (s390x) | The stack pointer must be restored to its original value at the end of an asm code block. |
148-
| All | `fr` (Hexagon), `$fp` (MIPS), `Y` (AVR), `r4` (MSP430), `a6` (M68k), `r11` (s390x), `x29` (Arm64EC) | The frame pointer cannot be used as an input or output. |
149-
| All | `r19` (Hexagon), `x19` (Arm64EC) | This is used internally by LLVM as a "base pointer" for functions with complex stack frames. |
154+
| All | `fr` (Hexagon), `fp` (PowerPC), `$fp` (MIPS), `Y` (AVR), `r4` (MSP430), `a6` (M68k), `r11` (s390x), `x29` (Arm64EC) | The frame pointer cannot be used as an input or output. |
155+
| All | `r19` (Hexagon), `r29` (PowerPC), `r30` (PowerPC), `x19` (Arm64EC) | These are used internally by LLVM as "base pointer" for functions with complex stack frames. |
150156
| MIPS | `$0` or `$zero` | This is a constant zero register which can't be modified. |
151157
| MIPS | `$1` or `$at` | Reserved for assembler. |
152158
| MIPS | `$26`/`$k0`, `$27`/`$k1` | OS-reserved registers. |
153159
| MIPS | `$28`/`$gp` | Global pointer cannot be used as inputs or outputs. |
154160
| MIPS | `$ra` | Return address cannot be used as inputs or outputs. |
155161
| Hexagon | `lr` | This is the link register which cannot be used as an input or output. |
162+
| PowerPC | `r2`, `r13` | These are system reserved registers. |
163+
| PowerPC | `lr` | The link register cannot be used as an input or output. |
164+
| PowerPC | `ctr` | The counter register cannot be used as an input or output. |
165+
| PowerPC | `vrsave` | The vrsave register cannot be used as an input or output. |
156166
| AVR | `r0`, `r1`, `r1r0` | Due to an issue in LLVM, the `r0` and `r1` registers cannot be used as inputs or outputs. If modified, they must be restored to their original values before the end of the block. |
157167
|MSP430 | `r0`, `r2`, `r3` | These are the program counter, status register, and constant generator respectively. Neither the status register nor constant generator can be written to. |
158168
| M68k | `a4`, `a5` | Used internally by LLVM for the base pointer and global base pointer. |

‎tests/codegen/asm/powerpc-clobbers.rs‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
//@ revisions: powerpc powerpc64 powerpc64le
1+
//@ revisions: powerpc powerpc64 powerpc64le aix64
22
//@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
33
//@[powerpc] needs-llvm-components: powerpc
44
//@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
55
//@[powerpc64] needs-llvm-components: powerpc
66
//@[powerpc64le] compile-flags: --target powerpc64le-unknown-linux-gnu
77
//@[powerpc64le] needs-llvm-components: powerpc
8+
//@[aix64] compile-flags: --target powerpc64-ibm-aix
9+
//@[aix64] needs-llvm-components: powerpc
810

911
#![crate_type = "rlib"]
1012
#![feature(no_core, rustc_attrs, lang_items, asm_experimental_arch)]
@@ -22,26 +24,40 @@ macro_rules! asm {
2224
// CHECK: call void asm sideeffect "", "~{cr}"()
2325
#[no_mangle]
2426
pub unsafe fn cr_clobber() {
25-
asm!("", out("cr") _, options(nostack, nomem));
27+
asm!("", out("cr") _, options(nostack, nomem, preserves_flags));
2628
}
2729

2830
// CHECK-LABEL: @cr0_clobber
2931
// CHECK: call void asm sideeffect "", "~{cr0}"()
3032
#[no_mangle]
3133
pub unsafe fn cr0_clobber() {
32-
asm!("", out("cr0") _, options(nostack, nomem));
34+
asm!("", out("cr0") _, options(nostack, nomem, preserves_flags));
3335
}
3436

3537
// CHECK-LABEL: @cr5_clobber
3638
// CHECK: call void asm sideeffect "", "~{cr5}"()
3739
#[no_mangle]
3840
pub unsafe fn cr5_clobber() {
39-
asm!("", out("cr5") _, options(nostack, nomem));
41+
asm!("", out("cr5") _, options(nostack, nomem, preserves_flags));
4042
}
4143

4244
// CHECK-LABEL: @xer_clobber
4345
// CHECK: call void asm sideeffect "", "~{xer}"()
4446
#[no_mangle]
4547
pub unsafe fn xer_clobber() {
46-
asm!("", out("xer") _, options(nostack, nomem));
48+
asm!("", out("xer") _, options(nostack, nomem, preserves_flags));
49+
}
50+
51+
// CHECK-LABEL: @v0_clobber
52+
// CHECK: call void asm sideeffect "", "~{v0}"()
53+
#[no_mangle]
54+
pub unsafe fn v0_clobber() {
55+
asm!("", out("v0") _, options(nostack, nomem, preserves_flags));
56+
}
57+
58+
// CHECK-LABEL: @clobber_abi
59+
// CHECK: asm sideeffect "", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},~{v0},~{v1},~{v2},~{v3},~{v4},~{v5},~{v6},~{v7},~{v8},~{v9},~{v10},~{v11},~{v12},~{v13},~{v14},~{v15},~{v16},~{v17},~{v18},~{v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{xer}"()
60+
#[no_mangle]
61+
pub unsafe fn clobber_abi() {
62+
asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags));
4763
}
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm
2+
--> $DIR/bad-reg.rs:32:18
3+
|
4+
LL | asm!("", out("sp") _);
5+
| ^^^^^^^^^^^
6+
7+
error: invalid register `r2`: r2 is a system reserved register and cannot be used as an operand for inline asm
8+
--> $DIR/bad-reg.rs:34:18
9+
|
10+
LL | asm!("", out("r2") _);
11+
| ^^^^^^^^^^^
12+
13+
error: invalid register `r29`: r29 is used internally by LLVM and cannot be used as an operand for inline asm
14+
--> $DIR/bad-reg.rs:38:18
15+
|
16+
LL | asm!("", out("r29") _);
17+
| ^^^^^^^^^^^^
18+
19+
error: invalid register `r30`: r30 is used internally by LLVM and cannot be used as an operand for inline asm
20+
--> $DIR/bad-reg.rs:40:18
21+
|
22+
LL | asm!("", out("r30") _);
23+
| ^^^^^^^^^^^^
24+
25+
error: invalid register `fp`: the frame pointer cannot be used as an operand for inline asm
26+
--> $DIR/bad-reg.rs:42:18
27+
|
28+
LL | asm!("", out("fp") _);
29+
| ^^^^^^^^^^^
30+
31+
error: invalid register `lr`: the link register cannot be used as an operand for inline asm
32+
--> $DIR/bad-reg.rs:44:18
33+
|
34+
LL | asm!("", out("lr") _);
35+
| ^^^^^^^^^^^
36+
37+
error: invalid register `ctr`: the counter register cannot be used as an operand for inline asm
38+
--> $DIR/bad-reg.rs:46:18
39+
|
40+
LL | asm!("", out("ctr") _);
41+
| ^^^^^^^^^^^^
42+
43+
error: invalid register `vrsave`: the vrsave register cannot be used as an operand for inline asm
44+
--> $DIR/bad-reg.rs:48:18
45+
|
46+
LL | asm!("", out("vrsave") _);
47+
| ^^^^^^^^^^^^^^^
48+
49+
error: register class `cr` can only be used as a clobber, not as an input or output
50+
--> $DIR/bad-reg.rs:66:18
51+
|
52+
LL | asm!("", in("cr") x);
53+
| ^^^^^^^^^^
54+
55+
error: register class `cr` can only be used as a clobber, not as an input or output
56+
--> $DIR/bad-reg.rs:69:18
57+
|
58+
LL | asm!("", out("cr") x);
59+
| ^^^^^^^^^^^
60+
61+
error: register class `cr` can only be used as a clobber, not as an input or output
62+
--> $DIR/bad-reg.rs:72:26
63+
|
64+
LL | asm!("/* {} */", in(cr) x);
65+
| ^^^^^^^^
66+
67+
error: register class `cr` can only be used as a clobber, not as an input or output
68+
--> $DIR/bad-reg.rs:75:26
69+
|
70+
LL | asm!("/* {} */", out(cr) _);
71+
| ^^^^^^^^^
72+
73+
error: register class `xer` can only be used as a clobber, not as an input or output
74+
--> $DIR/bad-reg.rs:79:18
75+
|
76+
LL | asm!("", in("xer") x);
77+
| ^^^^^^^^^^^
78+
79+
error: register class `xer` can only be used as a clobber, not as an input or output
80+
--> $DIR/bad-reg.rs:82:18
81+
|
82+
LL | asm!("", out("xer") x);
83+
| ^^^^^^^^^^^^
84+
85+
error: register class `xer` can only be used as a clobber, not as an input or output
86+
--> $DIR/bad-reg.rs:85:26
87+
|
88+
LL | asm!("/* {} */", in(xer) x);
89+
| ^^^^^^^^^
90+
91+
error: register class `xer` can only be used as a clobber, not as an input or output
92+
--> $DIR/bad-reg.rs:88:26
93+
|
94+
LL | asm!("/* {} */", out(xer) _);
95+
| ^^^^^^^^^^
96+
97+
error: register class `vreg` can only be used as a clobber, not as an input or output
98+
--> $DIR/bad-reg.rs:93:18
99+
|
100+
LL | asm!("", in("v0") x);
101+
| ^^^^^^^^^^
102+
103+
error: register class `vreg` can only be used as a clobber, not as an input or output
104+
--> $DIR/bad-reg.rs:96:18
105+
|
106+
LL | asm!("", out("v0") x);
107+
| ^^^^^^^^^^^
108+
109+
error: register class `vreg` can only be used as a clobber, not as an input or output
110+
--> $DIR/bad-reg.rs:99:26
111+
|
112+
LL | asm!("/* {} */", in(vreg) x);
113+
| ^^^^^^^^^^
114+
115+
error: register class `vreg` can only be used as a clobber, not as an input or output
116+
--> $DIR/bad-reg.rs:102:26
117+
|
118+
LL | asm!("/* {} */", out(vreg) _);
119+
| ^^^^^^^^^^^
120+
121+
error: register `cr0` conflicts with register `cr`
122+
--> $DIR/bad-reg.rs:106:31
123+
|
124+
LL | asm!("", out("cr") _, out("cr0") _);
125+
| ----------- ^^^^^^^^^^^^ register `cr0`
126+
| |
127+
| register `cr`
128+
129+
error: register `cr1` conflicts with register `cr`
130+
--> $DIR/bad-reg.rs:108:31
131+
|
132+
LL | asm!("", out("cr") _, out("cr1") _);
133+
| ----------- ^^^^^^^^^^^^ register `cr1`
134+
| |
135+
| register `cr`
136+
137+
error: register `cr2` conflicts with register `cr`
138+
--> $DIR/bad-reg.rs:110:31
139+
|
140+
LL | asm!("", out("cr") _, out("cr2") _);
141+
| ----------- ^^^^^^^^^^^^ register `cr2`
142+
| |
143+
| register `cr`
144+
145+
error: register `cr3` conflicts with register `cr`
146+
--> $DIR/bad-reg.rs:112:31
147+
|
148+
LL | asm!("", out("cr") _, out("cr3") _);
149+
| ----------- ^^^^^^^^^^^^ register `cr3`
150+
| |
151+
| register `cr`
152+
153+
error: register `cr4` conflicts with register `cr`
154+
--> $DIR/bad-reg.rs:114:31
155+
|
156+
LL | asm!("", out("cr") _, out("cr4") _);
157+
| ----------- ^^^^^^^^^^^^ register `cr4`
158+
| |
159+
| register `cr`
160+
161+
error: register `cr5` conflicts with register `cr`
162+
--> $DIR/bad-reg.rs:116:31
163+
|
164+
LL | asm!("", out("cr") _, out("cr5") _);
165+
| ----------- ^^^^^^^^^^^^ register `cr5`
166+
| |
167+
| register `cr`
168+
169+
error: register `cr6` conflicts with register `cr`
170+
--> $DIR/bad-reg.rs:118:31
171+
|
172+
LL | asm!("", out("cr") _, out("cr6") _);
173+
| ----------- ^^^^^^^^^^^^ register `cr6`
174+
| |
175+
| register `cr`
176+
177+
error: register `cr7` conflicts with register `cr`
178+
--> $DIR/bad-reg.rs:120:31
179+
|
180+
LL | asm!("", out("cr") _, out("cr7") _);
181+
| ----------- ^^^^^^^^^^^^ register `cr7`
182+
| |
183+
| register `cr`
184+
185+
error: cannot use register `r13`: r13 is a reserved register on this target
186+
--> $DIR/bad-reg.rs:36:18
187+
|
188+
LL | asm!("", out("r13") _);
189+
| ^^^^^^^^^^^^
190+
191+
error: type `i32` cannot be used with this register class
192+
--> $DIR/bad-reg.rs:66:27
193+
|
194+
LL | asm!("", in("cr") x);
195+
| ^
196+
|
197+
= note: register class `cr` supports these types:
198+
199+
error: type `i32` cannot be used with this register class
200+
--> $DIR/bad-reg.rs:69:28
201+
|
202+
LL | asm!("", out("cr") x);
203+
| ^
204+
|
205+
= note: register class `cr` supports these types:
206+
207+
error: type `i32` cannot be used with this register class
208+
--> $DIR/bad-reg.rs:72:33
209+
|
210+
LL | asm!("/* {} */", in(cr) x);
211+
| ^
212+
|
213+
= note: register class `cr` supports these types:
214+
215+
error: type `i32` cannot be used with this register class
216+
--> $DIR/bad-reg.rs:79:28
217+
|
218+
LL | asm!("", in("xer") x);
219+
| ^
220+
|
221+
= note: register class `xer` supports these types:
222+
223+
error: type `i32` cannot be used with this register class
224+
--> $DIR/bad-reg.rs:82:29
225+
|
226+
LL | asm!("", out("xer") x);
227+
| ^
228+
|
229+
= note: register class `xer` supports these types:
230+
231+
error: type `i32` cannot be used with this register class
232+
--> $DIR/bad-reg.rs:85:34
233+
|
234+
LL | asm!("/* {} */", in(xer) x);
235+
| ^
236+
|
237+
= note: register class `xer` supports these types:
238+
239+
error: type `i32` cannot be used with this register class
240+
--> $DIR/bad-reg.rs:93:27
241+
|
242+
LL | asm!("", in("v0") x);
243+
| ^
244+
|
245+
= note: register class `vreg` supports these types:
246+
247+
error: type `i32` cannot be used with this register class
248+
--> $DIR/bad-reg.rs:96:28
249+
|
250+
LL | asm!("", out("v0") x);
251+
| ^
252+
|
253+
= note: register class `vreg` supports these types:
254+
255+
error: type `i32` cannot be used with this register class
256+
--> $DIR/bad-reg.rs:99:35
257+
|
258+
LL | asm!("/* {} */", in(vreg) x);
259+
| ^
260+
|
261+
= note: register class `vreg` supports these types:
262+
263+
error: aborting due to 38 previous errors
264+
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm
2+
--> $DIR/bad-reg.rs:32:18
3+
|
4+
LL | asm!("", out("sp") _);
5+
| ^^^^^^^^^^^
6+
7+
error: invalid register `r2`: r2 is a system reserved register and cannot be used as an operand for inline asm
8+
--> $DIR/bad-reg.rs:34:18
9+
|
10+
LL | asm!("", out("r2") _);
11+
| ^^^^^^^^^^^
12+
13+
error: invalid register `r29`: r29 is used internally by LLVM and cannot be used as an operand for inline asm
14+
--> $DIR/bad-reg.rs:38:18
15+
|
16+
LL | asm!("", out("r29") _);
17+
| ^^^^^^^^^^^^
18+
19+
error: invalid register `r30`: r30 is used internally by LLVM and cannot be used as an operand for inline asm
20+
--> $DIR/bad-reg.rs:40:18
21+
|
22+
LL | asm!("", out("r30") _);
23+
| ^^^^^^^^^^^^
24+
25+
error: invalid register `fp`: the frame pointer cannot be used as an operand for inline asm
26+
--> $DIR/bad-reg.rs:42:18
27+
|
28+
LL | asm!("", out("fp") _);
29+
| ^^^^^^^^^^^
30+
31+
error: invalid register `lr`: the link register cannot be used as an operand for inline asm
32+
--> $DIR/bad-reg.rs:44:18
33+
|
34+
LL | asm!("", out("lr") _);
35+
| ^^^^^^^^^^^
36+
37+
error: invalid register `ctr`: the counter register cannot be used as an operand for inline asm
38+
--> $DIR/bad-reg.rs:46:18
39+
|
40+
LL | asm!("", out("ctr") _);
41+
| ^^^^^^^^^^^^
42+
43+
error: invalid register `vrsave`: the vrsave register cannot be used as an operand for inline asm
44+
--> $DIR/bad-reg.rs:48:18
45+
|
46+
LL | asm!("", out("vrsave") _);
47+
| ^^^^^^^^^^^^^^^
48+
49+
error: register class `cr` can only be used as a clobber, not as an input or output
50+
--> $DIR/bad-reg.rs:66:18
51+
|
52+
LL | asm!("", in("cr") x);
53+
| ^^^^^^^^^^
54+
55+
error: register class `cr` can only be used as a clobber, not as an input or output
56+
--> $DIR/bad-reg.rs:69:18
57+
|
58+
LL | asm!("", out("cr") x);
59+
| ^^^^^^^^^^^
60+
61+
error: register class `cr` can only be used as a clobber, not as an input or output
62+
--> $DIR/bad-reg.rs:72:26
63+
|
64+
LL | asm!("/* {} */", in(cr) x);
65+
| ^^^^^^^^
66+
67+
error: register class `cr` can only be used as a clobber, not as an input or output
68+
--> $DIR/bad-reg.rs:75:26
69+
|
70+
LL | asm!("/* {} */", out(cr) _);
71+
| ^^^^^^^^^
72+
73+
error: register class `xer` can only be used as a clobber, not as an input or output
74+
--> $DIR/bad-reg.rs:79:18
75+
|
76+
LL | asm!("", in("xer") x);
77+
| ^^^^^^^^^^^
78+
79+
error: register class `xer` can only be used as a clobber, not as an input or output
80+
--> $DIR/bad-reg.rs:82:18
81+
|
82+
LL | asm!("", out("xer") x);
83+
| ^^^^^^^^^^^^
84+
85+
error: register class `xer` can only be used as a clobber, not as an input or output
86+
--> $DIR/bad-reg.rs:85:26
87+
|
88+
LL | asm!("/* {} */", in(xer) x);
89+
| ^^^^^^^^^
90+
91+
error: register class `xer` can only be used as a clobber, not as an input or output
92+
--> $DIR/bad-reg.rs:88:26
93+
|
94+
LL | asm!("/* {} */", out(xer) _);
95+
| ^^^^^^^^^^
96+
97+
error: register class `vreg` can only be used as a clobber, not as an input or output
98+
--> $DIR/bad-reg.rs:93:18
99+
|
100+
LL | asm!("", in("v0") x);
101+
| ^^^^^^^^^^
102+
103+
error: register class `vreg` can only be used as a clobber, not as an input or output
104+
--> $DIR/bad-reg.rs:96:18
105+
|
106+
LL | asm!("", out("v0") x);
107+
| ^^^^^^^^^^^
108+
109+
error: register class `vreg` can only be used as a clobber, not as an input or output
110+
--> $DIR/bad-reg.rs:99:26
111+
|
112+
LL | asm!("/* {} */", in(vreg) x);
113+
| ^^^^^^^^^^
114+
115+
error: register class `vreg` can only be used as a clobber, not as an input or output
116+
--> $DIR/bad-reg.rs:102:26
117+
|
118+
LL | asm!("/* {} */", out(vreg) _);
119+
| ^^^^^^^^^^^
120+
121+
error: register `cr0` conflicts with register `cr`
122+
--> $DIR/bad-reg.rs:106:31
123+
|
124+
LL | asm!("", out("cr") _, out("cr0") _);
125+
| ----------- ^^^^^^^^^^^^ register `cr0`
126+
| |
127+
| register `cr`
128+
129+
error: register `cr1` conflicts with register `cr`
130+
--> $DIR/bad-reg.rs:108:31
131+
|
132+
LL | asm!("", out("cr") _, out("cr1") _);
133+
| ----------- ^^^^^^^^^^^^ register `cr1`
134+
| |
135+
| register `cr`
136+
137+
error: register `cr2` conflicts with register `cr`
138+
--> $DIR/bad-reg.rs:110:31
139+
|
140+
LL | asm!("", out("cr") _, out("cr2") _);
141+
| ----------- ^^^^^^^^^^^^ register `cr2`
142+
| |
143+
| register `cr`
144+
145+
error: register `cr3` conflicts with register `cr`
146+
--> $DIR/bad-reg.rs:112:31
147+
|
148+
LL | asm!("", out("cr") _, out("cr3") _);
149+
| ----------- ^^^^^^^^^^^^ register `cr3`
150+
| |
151+
| register `cr`
152+
153+
error: register `cr4` conflicts with register `cr`
154+
--> $DIR/bad-reg.rs:114:31
155+
|
156+
LL | asm!("", out("cr") _, out("cr4") _);
157+
| ----------- ^^^^^^^^^^^^ register `cr4`
158+
| |
159+
| register `cr`
160+
161+
error: register `cr5` conflicts with register `cr`
162+
--> $DIR/bad-reg.rs:116:31
163+
|
164+
LL | asm!("", out("cr") _, out("cr5") _);
165+
| ----------- ^^^^^^^^^^^^ register `cr5`
166+
| |
167+
| register `cr`
168+
169+
error: register `cr6` conflicts with register `cr`
170+
--> $DIR/bad-reg.rs:118:31
171+
|
172+
LL | asm!("", out("cr") _, out("cr6") _);
173+
| ----------- ^^^^^^^^^^^^ register `cr6`
174+
| |
175+
| register `cr`
176+
177+
error: register `cr7` conflicts with register `cr`
178+
--> $DIR/bad-reg.rs:120:31
179+
|
180+
LL | asm!("", out("cr") _, out("cr7") _);
181+
| ----------- ^^^^^^^^^^^^ register `cr7`
182+
| |
183+
| register `cr`
184+
185+
error: cannot use register `r13`: r13 is a reserved register on this target
186+
--> $DIR/bad-reg.rs:36:18
187+
|
188+
LL | asm!("", out("r13") _);
189+
| ^^^^^^^^^^^^
190+
191+
error: type `i32` cannot be used with this register class
192+
--> $DIR/bad-reg.rs:66:27
193+
|
194+
LL | asm!("", in("cr") x);
195+
| ^
196+
|
197+
= note: register class `cr` supports these types:
198+
199+
error: type `i32` cannot be used with this register class
200+
--> $DIR/bad-reg.rs:69:28
201+
|
202+
LL | asm!("", out("cr") x);
203+
| ^
204+
|
205+
= note: register class `cr` supports these types:
206+
207+
error: type `i32` cannot be used with this register class
208+
--> $DIR/bad-reg.rs:72:33
209+
|
210+
LL | asm!("/* {} */", in(cr) x);
211+
| ^
212+
|
213+
= note: register class `cr` supports these types:
214+
215+
error: type `i32` cannot be used with this register class
216+
--> $DIR/bad-reg.rs:79:28
217+
|
218+
LL | asm!("", in("xer") x);
219+
| ^
220+
|
221+
= note: register class `xer` supports these types:
222+
223+
error: type `i32` cannot be used with this register class
224+
--> $DIR/bad-reg.rs:82:29
225+
|
226+
LL | asm!("", out("xer") x);
227+
| ^
228+
|
229+
= note: register class `xer` supports these types:
230+
231+
error: type `i32` cannot be used with this register class
232+
--> $DIR/bad-reg.rs:85:34
233+
|
234+
LL | asm!("/* {} */", in(xer) x);
235+
| ^
236+
|
237+
= note: register class `xer` supports these types:
238+
239+
error: type `i32` cannot be used with this register class
240+
--> $DIR/bad-reg.rs:93:27
241+
|
242+
LL | asm!("", in("v0") x);
243+
| ^
244+
|
245+
= note: register class `vreg` supports these types:
246+
247+
error: type `i32` cannot be used with this register class
248+
--> $DIR/bad-reg.rs:96:28
249+
|
250+
LL | asm!("", out("v0") x);
251+
| ^
252+
|
253+
= note: register class `vreg` supports these types:
254+
255+
error: type `i32` cannot be used with this register class
256+
--> $DIR/bad-reg.rs:99:35
257+
|
258+
LL | asm!("/* {} */", in(vreg) x);
259+
| ^
260+
|
261+
= note: register class `vreg` supports these types:
262+
263+
error: aborting due to 38 previous errors
264+
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm
2+
--> $DIR/bad-reg.rs:32:18
3+
|
4+
LL | asm!("", out("sp") _);
5+
| ^^^^^^^^^^^
6+
7+
error: invalid register `r2`: r2 is a system reserved register and cannot be used as an operand for inline asm
8+
--> $DIR/bad-reg.rs:34:18
9+
|
10+
LL | asm!("", out("r2") _);
11+
| ^^^^^^^^^^^
12+
13+
error: invalid register `r29`: r29 is used internally by LLVM and cannot be used as an operand for inline asm
14+
--> $DIR/bad-reg.rs:38:18
15+
|
16+
LL | asm!("", out("r29") _);
17+
| ^^^^^^^^^^^^
18+
19+
error: invalid register `r30`: r30 is used internally by LLVM and cannot be used as an operand for inline asm
20+
--> $DIR/bad-reg.rs:40:18
21+
|
22+
LL | asm!("", out("r30") _);
23+
| ^^^^^^^^^^^^
24+
25+
error: invalid register `fp`: the frame pointer cannot be used as an operand for inline asm
26+
--> $DIR/bad-reg.rs:42:18
27+
|
28+
LL | asm!("", out("fp") _);
29+
| ^^^^^^^^^^^
30+
31+
error: invalid register `lr`: the link register cannot be used as an operand for inline asm
32+
--> $DIR/bad-reg.rs:44:18
33+
|
34+
LL | asm!("", out("lr") _);
35+
| ^^^^^^^^^^^
36+
37+
error: invalid register `ctr`: the counter register cannot be used as an operand for inline asm
38+
--> $DIR/bad-reg.rs:46:18
39+
|
40+
LL | asm!("", out("ctr") _);
41+
| ^^^^^^^^^^^^
42+
43+
error: invalid register `vrsave`: the vrsave register cannot be used as an operand for inline asm
44+
--> $DIR/bad-reg.rs:48:18
45+
|
46+
LL | asm!("", out("vrsave") _);
47+
| ^^^^^^^^^^^^^^^
48+
49+
error: register class `cr` can only be used as a clobber, not as an input or output
50+
--> $DIR/bad-reg.rs:66:18
51+
|
52+
LL | asm!("", in("cr") x);
53+
| ^^^^^^^^^^
54+
55+
error: register class `cr` can only be used as a clobber, not as an input or output
56+
--> $DIR/bad-reg.rs:69:18
57+
|
58+
LL | asm!("", out("cr") x);
59+
| ^^^^^^^^^^^
60+
61+
error: register class `cr` can only be used as a clobber, not as an input or output
62+
--> $DIR/bad-reg.rs:72:26
63+
|
64+
LL | asm!("/* {} */", in(cr) x);
65+
| ^^^^^^^^
66+
67+
error: register class `cr` can only be used as a clobber, not as an input or output
68+
--> $DIR/bad-reg.rs:75:26
69+
|
70+
LL | asm!("/* {} */", out(cr) _);
71+
| ^^^^^^^^^
72+
73+
error: register class `xer` can only be used as a clobber, not as an input or output
74+
--> $DIR/bad-reg.rs:79:18
75+
|
76+
LL | asm!("", in("xer") x);
77+
| ^^^^^^^^^^^
78+
79+
error: register class `xer` can only be used as a clobber, not as an input or output
80+
--> $DIR/bad-reg.rs:82:18
81+
|
82+
LL | asm!("", out("xer") x);
83+
| ^^^^^^^^^^^^
84+
85+
error: register class `xer` can only be used as a clobber, not as an input or output
86+
--> $DIR/bad-reg.rs:85:26
87+
|
88+
LL | asm!("/* {} */", in(xer) x);
89+
| ^^^^^^^^^
90+
91+
error: register class `xer` can only be used as a clobber, not as an input or output
92+
--> $DIR/bad-reg.rs:88:26
93+
|
94+
LL | asm!("/* {} */", out(xer) _);
95+
| ^^^^^^^^^^
96+
97+
error: register class `vreg` can only be used as a clobber, not as an input or output
98+
--> $DIR/bad-reg.rs:93:18
99+
|
100+
LL | asm!("", in("v0") x);
101+
| ^^^^^^^^^^
102+
103+
error: register class `vreg` can only be used as a clobber, not as an input or output
104+
--> $DIR/bad-reg.rs:96:18
105+
|
106+
LL | asm!("", out("v0") x);
107+
| ^^^^^^^^^^^
108+
109+
error: register class `vreg` can only be used as a clobber, not as an input or output
110+
--> $DIR/bad-reg.rs:99:26
111+
|
112+
LL | asm!("/* {} */", in(vreg) x);
113+
| ^^^^^^^^^^
114+
115+
error: register class `vreg` can only be used as a clobber, not as an input or output
116+
--> $DIR/bad-reg.rs:102:26
117+
|
118+
LL | asm!("/* {} */", out(vreg) _);
119+
| ^^^^^^^^^^^
120+
121+
error: register `cr0` conflicts with register `cr`
122+
--> $DIR/bad-reg.rs:106:31
123+
|
124+
LL | asm!("", out("cr") _, out("cr0") _);
125+
| ----------- ^^^^^^^^^^^^ register `cr0`
126+
| |
127+
| register `cr`
128+
129+
error: register `cr1` conflicts with register `cr`
130+
--> $DIR/bad-reg.rs:108:31
131+
|
132+
LL | asm!("", out("cr") _, out("cr1") _);
133+
| ----------- ^^^^^^^^^^^^ register `cr1`
134+
| |
135+
| register `cr`
136+
137+
error: register `cr2` conflicts with register `cr`
138+
--> $DIR/bad-reg.rs:110:31
139+
|
140+
LL | asm!("", out("cr") _, out("cr2") _);
141+
| ----------- ^^^^^^^^^^^^ register `cr2`
142+
| |
143+
| register `cr`
144+
145+
error: register `cr3` conflicts with register `cr`
146+
--> $DIR/bad-reg.rs:112:31
147+
|
148+
LL | asm!("", out("cr") _, out("cr3") _);
149+
| ----------- ^^^^^^^^^^^^ register `cr3`
150+
| |
151+
| register `cr`
152+
153+
error: register `cr4` conflicts with register `cr`
154+
--> $DIR/bad-reg.rs:114:31
155+
|
156+
LL | asm!("", out("cr") _, out("cr4") _);
157+
| ----------- ^^^^^^^^^^^^ register `cr4`
158+
| |
159+
| register `cr`
160+
161+
error: register `cr5` conflicts with register `cr`
162+
--> $DIR/bad-reg.rs:116:31
163+
|
164+
LL | asm!("", out("cr") _, out("cr5") _);
165+
| ----------- ^^^^^^^^^^^^ register `cr5`
166+
| |
167+
| register `cr`
168+
169+
error: register `cr6` conflicts with register `cr`
170+
--> $DIR/bad-reg.rs:118:31
171+
|
172+
LL | asm!("", out("cr") _, out("cr6") _);
173+
| ----------- ^^^^^^^^^^^^ register `cr6`
174+
| |
175+
| register `cr`
176+
177+
error: register `cr7` conflicts with register `cr`
178+
--> $DIR/bad-reg.rs:120:31
179+
|
180+
LL | asm!("", out("cr") _, out("cr7") _);
181+
| ----------- ^^^^^^^^^^^^ register `cr7`
182+
| |
183+
| register `cr`
184+
185+
error: cannot use register `r13`: r13 is a reserved register on this target
186+
--> $DIR/bad-reg.rs:36:18
187+
|
188+
LL | asm!("", out("r13") _);
189+
| ^^^^^^^^^^^^
190+
191+
error: type `i32` cannot be used with this register class
192+
--> $DIR/bad-reg.rs:66:27
193+
|
194+
LL | asm!("", in("cr") x);
195+
| ^
196+
|
197+
= note: register class `cr` supports these types:
198+
199+
error: type `i32` cannot be used with this register class
200+
--> $DIR/bad-reg.rs:69:28
201+
|
202+
LL | asm!("", out("cr") x);
203+
| ^
204+
|
205+
= note: register class `cr` supports these types:
206+
207+
error: type `i32` cannot be used with this register class
208+
--> $DIR/bad-reg.rs:72:33
209+
|
210+
LL | asm!("/* {} */", in(cr) x);
211+
| ^
212+
|
213+
= note: register class `cr` supports these types:
214+
215+
error: type `i32` cannot be used with this register class
216+
--> $DIR/bad-reg.rs:79:28
217+
|
218+
LL | asm!("", in("xer") x);
219+
| ^
220+
|
221+
= note: register class `xer` supports these types:
222+
223+
error: type `i32` cannot be used with this register class
224+
--> $DIR/bad-reg.rs:82:29
225+
|
226+
LL | asm!("", out("xer") x);
227+
| ^
228+
|
229+
= note: register class `xer` supports these types:
230+
231+
error: type `i32` cannot be used with this register class
232+
--> $DIR/bad-reg.rs:85:34
233+
|
234+
LL | asm!("/* {} */", in(xer) x);
235+
| ^
236+
|
237+
= note: register class `xer` supports these types:
238+
239+
error: type `i32` cannot be used with this register class
240+
--> $DIR/bad-reg.rs:93:27
241+
|
242+
LL | asm!("", in("v0") x);
243+
| ^
244+
|
245+
= note: register class `vreg` supports these types:
246+
247+
error: type `i32` cannot be used with this register class
248+
--> $DIR/bad-reg.rs:96:28
249+
|
250+
LL | asm!("", out("v0") x);
251+
| ^
252+
|
253+
= note: register class `vreg` supports these types:
254+
255+
error: type `i32` cannot be used with this register class
256+
--> $DIR/bad-reg.rs:99:35
257+
|
258+
LL | asm!("/* {} */", in(vreg) x);
259+
| ^
260+
|
261+
= note: register class `vreg` supports these types:
262+
263+
error: aborting due to 38 previous errors
264+
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm
2+
--> $DIR/bad-reg.rs:32:18
3+
|
4+
LL | asm!("", out("sp") _);
5+
| ^^^^^^^^^^^
6+
7+
error: invalid register `r2`: r2 is a system reserved register and cannot be used as an operand for inline asm
8+
--> $DIR/bad-reg.rs:34:18
9+
|
10+
LL | asm!("", out("r2") _);
11+
| ^^^^^^^^^^^
12+
13+
error: invalid register `r29`: r29 is used internally by LLVM and cannot be used as an operand for inline asm
14+
--> $DIR/bad-reg.rs:38:18
15+
|
16+
LL | asm!("", out("r29") _);
17+
| ^^^^^^^^^^^^
18+
19+
error: invalid register `r30`: r30 is used internally by LLVM and cannot be used as an operand for inline asm
20+
--> $DIR/bad-reg.rs:40:18
21+
|
22+
LL | asm!("", out("r30") _);
23+
| ^^^^^^^^^^^^
24+
25+
error: invalid register `fp`: the frame pointer cannot be used as an operand for inline asm
26+
--> $DIR/bad-reg.rs:42:18
27+
|
28+
LL | asm!("", out("fp") _);
29+
| ^^^^^^^^^^^
30+
31+
error: invalid register `lr`: the link register cannot be used as an operand for inline asm
32+
--> $DIR/bad-reg.rs:44:18
33+
|
34+
LL | asm!("", out("lr") _);
35+
| ^^^^^^^^^^^
36+
37+
error: invalid register `ctr`: the counter register cannot be used as an operand for inline asm
38+
--> $DIR/bad-reg.rs:46:18
39+
|
40+
LL | asm!("", out("ctr") _);
41+
| ^^^^^^^^^^^^
42+
43+
error: invalid register `vrsave`: the vrsave register cannot be used as an operand for inline asm
44+
--> $DIR/bad-reg.rs:48:18
45+
|
46+
LL | asm!("", out("vrsave") _);
47+
| ^^^^^^^^^^^^^^^
48+
49+
error: register class `cr` can only be used as a clobber, not as an input or output
50+
--> $DIR/bad-reg.rs:66:18
51+
|
52+
LL | asm!("", in("cr") x);
53+
| ^^^^^^^^^^
54+
55+
error: register class `cr` can only be used as a clobber, not as an input or output
56+
--> $DIR/bad-reg.rs:69:18
57+
|
58+
LL | asm!("", out("cr") x);
59+
| ^^^^^^^^^^^
60+
61+
error: register class `cr` can only be used as a clobber, not as an input or output
62+
--> $DIR/bad-reg.rs:72:26
63+
|
64+
LL | asm!("/* {} */", in(cr) x);
65+
| ^^^^^^^^
66+
67+
error: register class `cr` can only be used as a clobber, not as an input or output
68+
--> $DIR/bad-reg.rs:75:26
69+
|
70+
LL | asm!("/* {} */", out(cr) _);
71+
| ^^^^^^^^^
72+
73+
error: register class `xer` can only be used as a clobber, not as an input or output
74+
--> $DIR/bad-reg.rs:79:18
75+
|
76+
LL | asm!("", in("xer") x);
77+
| ^^^^^^^^^^^
78+
79+
error: register class `xer` can only be used as a clobber, not as an input or output
80+
--> $DIR/bad-reg.rs:82:18
81+
|
82+
LL | asm!("", out("xer") x);
83+
| ^^^^^^^^^^^^
84+
85+
error: register class `xer` can only be used as a clobber, not as an input or output
86+
--> $DIR/bad-reg.rs:85:26
87+
|
88+
LL | asm!("/* {} */", in(xer) x);
89+
| ^^^^^^^^^
90+
91+
error: register class `xer` can only be used as a clobber, not as an input or output
92+
--> $DIR/bad-reg.rs:88:26
93+
|
94+
LL | asm!("/* {} */", out(xer) _);
95+
| ^^^^^^^^^^
96+
97+
error: register class `vreg` can only be used as a clobber, not as an input or output
98+
--> $DIR/bad-reg.rs:93:18
99+
|
100+
LL | asm!("", in("v0") x);
101+
| ^^^^^^^^^^
102+
103+
error: register class `vreg` can only be used as a clobber, not as an input or output
104+
--> $DIR/bad-reg.rs:96:18
105+
|
106+
LL | asm!("", out("v0") x);
107+
| ^^^^^^^^^^^
108+
109+
error: register class `vreg` can only be used as a clobber, not as an input or output
110+
--> $DIR/bad-reg.rs:99:26
111+
|
112+
LL | asm!("/* {} */", in(vreg) x);
113+
| ^^^^^^^^^^
114+
115+
error: register class `vreg` can only be used as a clobber, not as an input or output
116+
--> $DIR/bad-reg.rs:102:26
117+
|
118+
LL | asm!("/* {} */", out(vreg) _);
119+
| ^^^^^^^^^^^
120+
121+
error: register `cr0` conflicts with register `cr`
122+
--> $DIR/bad-reg.rs:106:31
123+
|
124+
LL | asm!("", out("cr") _, out("cr0") _);
125+
| ----------- ^^^^^^^^^^^^ register `cr0`
126+
| |
127+
| register `cr`
128+
129+
error: register `cr1` conflicts with register `cr`
130+
--> $DIR/bad-reg.rs:108:31
131+
|
132+
LL | asm!("", out("cr") _, out("cr1") _);
133+
| ----------- ^^^^^^^^^^^^ register `cr1`
134+
| |
135+
| register `cr`
136+
137+
error: register `cr2` conflicts with register `cr`
138+
--> $DIR/bad-reg.rs:110:31
139+
|
140+
LL | asm!("", out("cr") _, out("cr2") _);
141+
| ----------- ^^^^^^^^^^^^ register `cr2`
142+
| |
143+
| register `cr`
144+
145+
error: register `cr3` conflicts with register `cr`
146+
--> $DIR/bad-reg.rs:112:31
147+
|
148+
LL | asm!("", out("cr") _, out("cr3") _);
149+
| ----------- ^^^^^^^^^^^^ register `cr3`
150+
| |
151+
| register `cr`
152+
153+
error: register `cr4` conflicts with register `cr`
154+
--> $DIR/bad-reg.rs:114:31
155+
|
156+
LL | asm!("", out("cr") _, out("cr4") _);
157+
| ----------- ^^^^^^^^^^^^ register `cr4`
158+
| |
159+
| register `cr`
160+
161+
error: register `cr5` conflicts with register `cr`
162+
--> $DIR/bad-reg.rs:116:31
163+
|
164+
LL | asm!("", out("cr") _, out("cr5") _);
165+
| ----------- ^^^^^^^^^^^^ register `cr5`
166+
| |
167+
| register `cr`
168+
169+
error: register `cr6` conflicts with register `cr`
170+
--> $DIR/bad-reg.rs:118:31
171+
|
172+
LL | asm!("", out("cr") _, out("cr6") _);
173+
| ----------- ^^^^^^^^^^^^ register `cr6`
174+
| |
175+
| register `cr`
176+
177+
error: register `cr7` conflicts with register `cr`
178+
--> $DIR/bad-reg.rs:120:31
179+
|
180+
LL | asm!("", out("cr") _, out("cr7") _);
181+
| ----------- ^^^^^^^^^^^^ register `cr7`
182+
| |
183+
| register `cr`
184+
185+
error: cannot use register `r13`: r13 is a reserved register on this target
186+
--> $DIR/bad-reg.rs:36:18
187+
|
188+
LL | asm!("", out("r13") _);
189+
| ^^^^^^^^^^^^
190+
191+
error: type `i32` cannot be used with this register class
192+
--> $DIR/bad-reg.rs:66:27
193+
|
194+
LL | asm!("", in("cr") x);
195+
| ^
196+
|
197+
= note: register class `cr` supports these types:
198+
199+
error: type `i32` cannot be used with this register class
200+
--> $DIR/bad-reg.rs:69:28
201+
|
202+
LL | asm!("", out("cr") x);
203+
| ^
204+
|
205+
= note: register class `cr` supports these types:
206+
207+
error: type `i32` cannot be used with this register class
208+
--> $DIR/bad-reg.rs:72:33
209+
|
210+
LL | asm!("/* {} */", in(cr) x);
211+
| ^
212+
|
213+
= note: register class `cr` supports these types:
214+
215+
error: type `i32` cannot be used with this register class
216+
--> $DIR/bad-reg.rs:79:28
217+
|
218+
LL | asm!("", in("xer") x);
219+
| ^
220+
|
221+
= note: register class `xer` supports these types:
222+
223+
error: type `i32` cannot be used with this register class
224+
--> $DIR/bad-reg.rs:82:29
225+
|
226+
LL | asm!("", out("xer") x);
227+
| ^
228+
|
229+
= note: register class `xer` supports these types:
230+
231+
error: type `i32` cannot be used with this register class
232+
--> $DIR/bad-reg.rs:85:34
233+
|
234+
LL | asm!("/* {} */", in(xer) x);
235+
| ^
236+
|
237+
= note: register class `xer` supports these types:
238+
239+
error: type `i32` cannot be used with this register class
240+
--> $DIR/bad-reg.rs:93:27
241+
|
242+
LL | asm!("", in("v0") x);
243+
| ^
244+
|
245+
= note: register class `vreg` supports these types:
246+
247+
error: type `i32` cannot be used with this register class
248+
--> $DIR/bad-reg.rs:96:28
249+
|
250+
LL | asm!("", out("v0") x);
251+
| ^
252+
|
253+
= note: register class `vreg` supports these types:
254+
255+
error: type `i32` cannot be used with this register class
256+
--> $DIR/bad-reg.rs:99:35
257+
|
258+
LL | asm!("/* {} */", in(vreg) x);
259+
| ^
260+
|
261+
= note: register class `vreg` supports these types:
262+
263+
error: aborting due to 38 previous errors
264+

‎tests/ui/asm/powerpc/bad-reg.rs‎

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
//@ revisions: powerpc powerpc64 powerpc64le aix64
2+
//@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
3+
//@[powerpc] needs-llvm-components: powerpc
4+
//@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
5+
//@[powerpc64] needs-llvm-components: powerpc
6+
//@[powerpc64le] compile-flags: --target powerpc64le-unknown-linux-gnu
7+
//@[powerpc64le] needs-llvm-components: powerpc
8+
//@[aix64] compile-flags: --target powerpc64-ibm-aix
9+
//@[aix64] needs-llvm-components: powerpc
10+
//@ needs-asm-support
11+
12+
#![crate_type = "rlib"]
13+
#![feature(no_core, rustc_attrs, lang_items, asm_experimental_arch)]
14+
#![no_core]
15+
16+
#[lang = "sized"]
17+
trait Sized {}
18+
#[lang = "copy"]
19+
trait Copy {}
20+
21+
impl Copy for i32 {}
22+
23+
#[rustc_builtin_macro]
24+
macro_rules! asm {
25+
() => {};
26+
}
27+
28+
fn f() {
29+
let mut x = 0;
30+
unsafe {
31+
// Unsupported registers
32+
asm!("", out("sp") _);
33+
//~^ ERROR invalid register `sp`: the stack pointer cannot be used as an operand for inline asm
34+
asm!("", out("r2") _);
35+
//~^ ERROR invalid register `r2`: r2 is a system reserved register and cannot be used as an operand for inline asm
36+
asm!("", out("r13") _);
37+
//~^ ERROR cannot use register `r13`: r13 is a reserved register on this target
38+
asm!("", out("r29") _);
39+
//~^ ERROR invalid register `r29`: r29 is used internally by LLVM and cannot be used as an operand for inline asm
40+
asm!("", out("r30") _);
41+
//~^ ERROR invalid register `r30`: r30 is used internally by LLVM and cannot be used as an operand for inline asm
42+
asm!("", out("fp") _);
43+
//~^ ERROR invalid register `fp`: the frame pointer cannot be used as an operand for inline asm
44+
asm!("", out("lr") _);
45+
//~^ ERROR invalid register `lr`: the link register cannot be used as an operand for inline asm
46+
asm!("", out("ctr") _);
47+
//~^ ERROR invalid register `ctr`: the counter register cannot be used as an operand for inline asm
48+
asm!("", out("vrsave") _);
49+
//~^ ERROR invalid register `vrsave`: the vrsave register cannot be used as an operand for inline asm
50+
asm!("", out("v20") _);
51+
asm!("", out("v21") _);
52+
asm!("", out("v22") _);
53+
asm!("", out("v23") _);
54+
asm!("", out("v24") _);
55+
asm!("", out("v25") _);
56+
asm!("", out("v26") _);
57+
asm!("", out("v27") _);
58+
asm!("", out("v28") _);
59+
asm!("", out("v29") _);
60+
asm!("", out("v30") _);
61+
asm!("", out("v31") _);
62+
63+
// Clobber-only registers
64+
// cr
65+
asm!("", out("cr") _); // ok
66+
asm!("", in("cr") x);
67+
//~^ ERROR can only be used as a clobber
68+
//~| ERROR type `i32` cannot be used with this register class
69+
asm!("", out("cr") x);
70+
//~^ ERROR can only be used as a clobber
71+
//~| ERROR type `i32` cannot be used with this register class
72+
asm!("/* {} */", in(cr) x);
73+
//~^ ERROR can only be used as a clobber
74+
//~| ERROR type `i32` cannot be used with this register class
75+
asm!("/* {} */", out(cr) _);
76+
//~^ ERROR can only be used as a clobber
77+
// xer
78+
asm!("", out("xer") _); // ok
79+
asm!("", in("xer") x);
80+
//~^ ERROR can only be used as a clobber
81+
//~| ERROR type `i32` cannot be used with this register class
82+
asm!("", out("xer") x);
83+
//~^ ERROR can only be used as a clobber
84+
//~| ERROR type `i32` cannot be used with this register class
85+
asm!("/* {} */", in(xer) x);
86+
//~^ ERROR can only be used as a clobber
87+
//~| ERROR type `i32` cannot be used with this register class
88+
asm!("/* {} */", out(xer) _);
89+
//~^ ERROR can only be used as a clobber
90+
// vreg
91+
asm!("", out("v0") _); // ok
92+
// FIXME: will be supported in the subsequent patch: https://github.com/rust-lang/rust/pull/131551
93+
asm!("", in("v0") x);
94+
//~^ ERROR can only be used as a clobber
95+
//~| ERROR type `i32` cannot be used with this register class
96+
asm!("", out("v0") x);
97+
//~^ ERROR can only be used as a clobber
98+
//~| ERROR type `i32` cannot be used with this register class
99+
asm!("/* {} */", in(vreg) x);
100+
//~^ ERROR can only be used as a clobber
101+
//~| ERROR type `i32` cannot be used with this register class
102+
asm!("/* {} */", out(vreg) _);
103+
//~^ ERROR can only be used as a clobber
104+
105+
// Overlapping-only registers
106+
asm!("", out("cr") _, out("cr0") _);
107+
//~^ ERROR register `cr0` conflicts with register `cr`
108+
asm!("", out("cr") _, out("cr1") _);
109+
//~^ ERROR register `cr1` conflicts with register `cr`
110+
asm!("", out("cr") _, out("cr2") _);
111+
//~^ ERROR register `cr2` conflicts with register `cr`
112+
asm!("", out("cr") _, out("cr3") _);
113+
//~^ ERROR register `cr3` conflicts with register `cr`
114+
asm!("", out("cr") _, out("cr4") _);
115+
//~^ ERROR register `cr4` conflicts with register `cr`
116+
asm!("", out("cr") _, out("cr5") _);
117+
//~^ ERROR register `cr5` conflicts with register `cr`
118+
asm!("", out("cr") _, out("cr6") _);
119+
//~^ ERROR register `cr6` conflicts with register `cr`
120+
asm!("", out("cr") _, out("cr7") _);
121+
//~^ ERROR register `cr7` conflicts with register `cr`
122+
asm!("", out("f0") _, out("v0") _); // ok
123+
}
124+
}

0 commit comments

Comments
 (0)
Please sign in to comment.