Skip to content

Commit 5c467cb

Browse files
committed
Allow PowerPC spe_acc as clobber-only register
This register is only supported on the *powerpc*spe targets. It is only recognized by LLVM. gcc does not accept this as a clobber, nor does it support these targets. This is a volatile register, thus it is included with clobber_abi.
1 parent 1c89fe9 commit 5c467cb

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/asm.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,16 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
209209
}
210210
("r", dummy_output_type(self.cx, reg.reg_class()))
211211
} else {
212-
// `clobber_abi` can add lots of clobbers that are not supported by the target,
213-
// such as AVX-512 registers, so we just ignore unsupported registers
214-
let is_target_supported =
215-
reg.reg_class().supported_types(asm_arch, true).iter().any(
212+
let is_target_supported = match reg.reg_class() {
213+
// `clobber_abi` clobbers spe_acc on all PowerPC targets. This
214+
// register is unique to the powerpc*spe target, and the target
215+
// is not supported by gcc. Ignore it.
216+
InlineAsmRegClass::PowerPC(
217+
PowerPCInlineAsmRegClass::spe_acc,
218+
) => false,
219+
// `clobber_abi` can add lots of clobbers that are not supported by the target,
220+
// such as AVX-512 registers, so we just ignore unsupported registers
221+
x => x.supported_types(asm_arch, true).iter().any(
216222
|&(_, feature)| {
217223
if let Some(feature) = feature {
218224
self.tcx
@@ -222,7 +228,8 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
222228
true // Register class is unconditionally supported
223229
}
224230
},
225-
);
231+
),
232+
};
226233

227234
if is_target_supported && !clobbers.contains(&reg_name) {
228235
clobbers.push(reg_name);
@@ -710,7 +717,8 @@ fn reg_class_to_gcc(reg_class: InlineAsmRegClass) -> &'static str {
710717
PowerPCInlineAsmRegClass::cr
711718
| PowerPCInlineAsmRegClass::ctr
712719
| PowerPCInlineAsmRegClass::lr
713-
| PowerPCInlineAsmRegClass::xer,
720+
| PowerPCInlineAsmRegClass::xer
721+
| PowerPCInlineAsmRegClass::spe_acc,
714722
) => {
715723
unreachable!("clobber-only")
716724
}
@@ -793,7 +801,8 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
793801
PowerPCInlineAsmRegClass::cr
794802
| PowerPCInlineAsmRegClass::ctr
795803
| PowerPCInlineAsmRegClass::lr
796-
| PowerPCInlineAsmRegClass::xer,
804+
| PowerPCInlineAsmRegClass::xer
805+
| PowerPCInlineAsmRegClass::spe_acc,
797806
) => {
798807
unreachable!("clobber-only")
799808
}

0 commit comments

Comments
 (0)