Skip to content

Commit e78bccf

Browse files
committed
Auto merge of rust-lang#85279 - DrChat:asm_powerpc64, r=Amanieu
Add asm!() support for PowerPC64 I was anticipating this to be difficult so I didn't do it as part of rust-lang#84732... but this was pretty easy to do 👀
2 parents 6d525d5 + 69acee3 commit e78bccf

File tree

4 files changed

+47
-7
lines changed

4 files changed

+47
-7
lines changed

compiler/rustc_codegen_llvm/src/asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
283283
}
284284
InlineAsmArch::RiscV32 | InlineAsmArch::RiscV64 => {}
285285
InlineAsmArch::Nvptx64 => {}
286-
InlineAsmArch::PowerPC => {}
286+
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {}
287287
InlineAsmArch::Hexagon => {}
288288
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {}
289289
InlineAsmArch::SpirV => {}

compiler/rustc_target/src/asm/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ pub enum InlineAsmArch {
184184
Mips,
185185
Mips64,
186186
PowerPC,
187+
PowerPC64,
187188
SpirV,
188189
Wasm32,
189190
}
@@ -201,6 +202,7 @@ impl FromStr for InlineAsmArch {
201202
"riscv64" => Ok(Self::RiscV64),
202203
"nvptx64" => Ok(Self::Nvptx64),
203204
"powerpc" => Ok(Self::PowerPC),
205+
"powerpc64" => Ok(Self::PowerPC64),
204206
"hexagon" => Ok(Self::Hexagon),
205207
"mips" => Ok(Self::Mips),
206208
"mips64" => Ok(Self::Mips64),
@@ -290,7 +292,7 @@ impl InlineAsmReg {
290292
InlineAsmArch::Nvptx64 => {
291293
Self::Nvptx(NvptxInlineAsmReg::parse(arch, has_feature, target, &name)?)
292294
}
293-
InlineAsmArch::PowerPC => {
295+
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {
294296
Self::PowerPC(PowerPCInlineAsmReg::parse(arch, has_feature, target, &name)?)
295297
}
296298
InlineAsmArch::Hexagon => {
@@ -485,7 +487,9 @@ impl InlineAsmRegClass {
485487
Self::RiscV(RiscVInlineAsmRegClass::parse(arch, name)?)
486488
}
487489
InlineAsmArch::Nvptx64 => Self::Nvptx(NvptxInlineAsmRegClass::parse(arch, name)?),
488-
InlineAsmArch::PowerPC => Self::PowerPC(PowerPCInlineAsmRegClass::parse(arch, name)?),
490+
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {
491+
Self::PowerPC(PowerPCInlineAsmRegClass::parse(arch, name)?)
492+
}
489493
InlineAsmArch::Hexagon => Self::Hexagon(HexagonInlineAsmRegClass::parse(arch, name)?),
490494
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {
491495
Self::Mips(MipsInlineAsmRegClass::parse(arch, name)?)
@@ -653,7 +657,7 @@ pub fn allocatable_registers(
653657
nvptx::fill_reg_map(arch, has_feature, target, &mut map);
654658
map
655659
}
656-
InlineAsmArch::PowerPC => {
660+
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {
657661
let mut map = powerpc::regclass_map();
658662
powerpc::fill_reg_map(arch, has_feature, target, &mut map);
659663
map

compiler/rustc_target/src/asm/powerpc.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@ impl PowerPCInlineAsmRegClass {
3333

3434
pub fn supported_types(
3535
self,
36-
_arch: InlineAsmArch,
36+
arch: InlineAsmArch,
3737
) -> &'static [(InlineAsmType, Option<&'static str>)] {
3838
match self {
39-
Self::reg | Self::reg_nonzero => types! { _: I8, I16, I32; },
39+
Self::reg | Self::reg_nonzero => {
40+
if arch == InlineAsmArch::PowerPC {
41+
types! { _: I8, I16, I32; }
42+
} else {
43+
types! { _: I8, I16, I32, I64; }
44+
}
45+
}
4046
Self::freg => types! { _: F32, F64; },
4147
}
4248
}

src/test/assembly/asm/powerpc-types.rs

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// min-llvm-version: 10.0.1
2+
// revisions: powerpc powerpc64
23
// assembly-output: emit-asm
3-
// compile-flags: --target powerpc-unknown-linux-gnu
4+
//[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
5+
//[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
46
// needs-llvm-components: powerpc
57

68
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
@@ -86,6 +88,13 @@ check!(reg_i16, i16, reg, "mr");
8688
// CHECK: #NO_APP
8789
check!(reg_i32, i32, reg, "mr");
8890

91+
// powerpc64-LABEL: reg_i64:
92+
// powerpc64: #APP
93+
// powerpc64: mr {{[0-9]+}}, {{[0-9]+}}
94+
// powerpc64: #NO_APP
95+
#[cfg(powerpc64)]
96+
check!(reg_i64, i64, reg, "mr");
97+
8998
// CHECK-LABEL: reg_i8_nz:
9099
// CHECK: #APP
91100
// CHECK: mr {{[0-9]+}}, {{[0-9]+}}
@@ -104,6 +113,13 @@ check!(reg_i16_nz, i16, reg_nonzero, "mr");
104113
// CHECK: #NO_APP
105114
check!(reg_i32_nz, i32, reg_nonzero, "mr");
106115

116+
// powerpc64-LABEL: reg_i64_nz:
117+
// powerpc64: #APP
118+
// powerpc64: mr {{[0-9]+}}, {{[0-9]+}}
119+
// powerpc64: #NO_APP
120+
#[cfg(powerpc64)]
121+
check!(reg_i64_nz, i64, reg_nonzero, "mr");
122+
107123
// CHECK-LABEL: reg_f32:
108124
// CHECK: #APP
109125
// CHECK: fmr {{[0-9]+}}, {{[0-9]+}}
@@ -134,6 +150,13 @@ check_reg!(reg_i16_r0, i16, "0", "0", "mr");
134150
// CHECK: #NO_APP
135151
check_reg!(reg_i32_r0, i32, "0", "0", "mr");
136152

153+
// powerpc64-LABEL: reg_i64_r0:
154+
// powerpc64: #APP
155+
// powerpc64: mr 0, 0
156+
// powerpc64: #NO_APP
157+
#[cfg(powerpc64)]
158+
check_reg!(reg_i64_r0, i64, "0", "0", "mr");
159+
137160
// CHECK-LABEL: reg_i8_r18:
138161
// CHECK: #APP
139162
// CHECK: mr 18, 18
@@ -152,6 +175,13 @@ check_reg!(reg_i16_r18, i16, "18", "18", "mr");
152175
// CHECK: #NO_APP
153176
check_reg!(reg_i32_r18, i32, "18", "18", "mr");
154177

178+
// powerpc64-LABEL: reg_i64_r18:
179+
// powerpc64: #APP
180+
// powerpc64: mr 18, 18
181+
// powerpc64: #NO_APP
182+
#[cfg(powerpc64)]
183+
check_reg!(reg_i64_r18, i64, "18", "18", "mr");
184+
155185
// CHECK-LABEL: reg_f32_f0:
156186
// CHECK: #APP
157187
// CHECK: fmr 0, 0

0 commit comments

Comments
 (0)