Skip to content

Commit a477a44

Browse files
committed
PPC: Replace PointerLikeRegClass with RegClassByHwMode
1 parent 084872a commit a477a44

File tree

4 files changed

+23
-24
lines changed

4 files changed

+23
-24
lines changed

llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ DecodeG8RC_NOX0RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address,
185185
return decodeRegisterClass(Inst, RegNo, XRegsNoX0);
186186
}
187187

188-
#define DecodePointerLikeRegClass0 DecodeGPRCRegisterClass
189-
#define DecodePointerLikeRegClass1 DecodeGPRC_NOR0RegisterClass
190-
191188
static DecodeStatus DecodeSPERCRegisterClass(MCInst &Inst, uint64_t RegNo,
192189
uint64_t Address,
193190
const MCDisassembler *Decoder) {

llvm/lib/Target/PowerPC/PPC.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,12 @@ def NotAIX : Predicate<"!Subtarget->isAIXABI()">;
394394
def IsISAFuture : Predicate<"Subtarget->isISAFuture()">;
395395
def IsNotISAFuture : Predicate<"!Subtarget->isISAFuture()">;
396396

397+
//===----------------------------------------------------------------------===//
398+
// HwModes
399+
//===----------------------------------------------------------------------===//
400+
401+
defvar PPC32 = DefaultMode;
402+
def PPC64 : HwMode<[In64BitMode]>;
397403

398404
// Since new processors generally contain a superset of features of those that
399405
// came before them, the idea is to make implementations of new processors

llvm/lib/Target/PowerPC/PPCInstrInfo.cpp

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,33 +2142,23 @@ bool PPCInstrInfo::onlyFoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI,
21422142
assert(UseIdx < UseMI.getNumOperands() && "Cannot find Reg in UseMI");
21432143
assert(UseIdx < UseMCID.getNumOperands() && "No operand description for Reg");
21442144

2145-
const MCOperandInfo *UseInfo = &UseMCID.operands()[UseIdx];
2146-
21472145
// We can fold the zero if this register requires a GPRC_NOR0/G8RC_NOX0
21482146
// register (which might also be specified as a pointer class kind).
2149-
if (UseInfo->isLookupPtrRegClass()) {
2150-
if (UseInfo->RegClass /* Kind */ != 1)
2151-
return false;
2152-
} else {
2153-
if (UseInfo->RegClass != PPC::GPRC_NOR0RegClassID &&
2154-
UseInfo->RegClass != PPC::G8RC_NOX0RegClassID)
2155-
return false;
2156-
}
2147+
2148+
const MCOperandInfo &UseInfo = UseMCID.operands()[UseIdx];
2149+
int16_t RegClass = getOpRegClassID(UseInfo);
2150+
if (UseInfo.RegClass != PPC::GPRC_NOR0RegClassID &&
2151+
UseInfo.RegClass != PPC::G8RC_NOX0RegClassID)
2152+
return false;
21572153

21582154
// Make sure this is not tied to an output register (or otherwise
21592155
// constrained). This is true for ST?UX registers, for example, which
21602156
// are tied to their output registers.
2161-
if (UseInfo->Constraints != 0)
2157+
if (UseInfo.Constraints != 0)
21622158
return false;
21632159

2164-
MCRegister ZeroReg;
2165-
if (UseInfo->isLookupPtrRegClass()) {
2166-
bool isPPC64 = Subtarget.isPPC64();
2167-
ZeroReg = isPPC64 ? PPC::ZERO8 : PPC::ZERO;
2168-
} else {
2169-
ZeroReg = UseInfo->RegClass == PPC::G8RC_NOX0RegClassID ?
2170-
PPC::ZERO8 : PPC::ZERO;
2171-
}
2160+
MCRegister ZeroReg =
2161+
RegClass == PPC::G8RC_NOX0RegClassID ? PPC::ZERO8 : PPC::ZERO;
21722162

21732163
LLVM_DEBUG(dbgs() << "Folded immediate zero for: ");
21742164
LLVM_DEBUG(UseMI.dump());

llvm/lib/Target/PowerPC/PPCRegisterInfo.td

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,11 @@ def crbitm: Operand<i8> {
868868
def PPCRegGxRCNoR0Operand : AsmOperandClass {
869869
let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
870870
}
871-
def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
871+
872+
def ptr_rc_nor0 : Operand<iPTR>,
873+
RegClassByHwMode<
874+
[PPC32, PPC64],
875+
[GPRC_NOR0, G8RC_NOX0]> {
872876
let ParserMatchClass = PPCRegGxRCNoR0Operand;
873877
}
874878

@@ -902,7 +906,9 @@ def memri34_pcrel : Operand<iPTR> { // memri, imm is a 34-bit value.
902906
def PPCRegGxRCOperand : AsmOperandClass {
903907
let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
904908
}
905-
def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
909+
def ptr_rc_idx : Operand<iPTR>,
910+
RegClassByHwMode<[PPC32, PPC64],
911+
[GPRC, G8RC]> {
906912
let ParserMatchClass = PPCRegGxRCOperand;
907913
}
908914

0 commit comments

Comments
 (0)