Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ DecodeG8RC_NOX0RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address,
return decodeRegisterClass(Inst, RegNo, XRegsNoX0);
}

#define DecodePointerLikeRegClass0 DecodeGPRCRegisterClass
#define DecodePointerLikeRegClass1 DecodeGPRC_NOR0RegisterClass

static DecodeStatus DecodeSPERCRegisterClass(MCInst &Inst, uint64_t RegNo,
uint64_t Address,
const MCDisassembler *Decoder) {
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/Target/PowerPC/PPC.td
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@ def NotAIX : Predicate<"!Subtarget->isAIXABI()">;
def IsISAFuture : Predicate<"Subtarget->isISAFuture()">;
def IsNotISAFuture : Predicate<"!Subtarget->isISAFuture()">;

//===----------------------------------------------------------------------===//
// HwModes
//===----------------------------------------------------------------------===//

defvar PPC32 = DefaultMode;
def PPC64 : HwMode<[In64BitMode]>;

// Since new processors generally contain a superset of features of those that
// came before them, the idea is to make implementations of new processors
Expand Down
28 changes: 9 additions & 19 deletions llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2142,33 +2142,23 @@ bool PPCInstrInfo::onlyFoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI,
assert(UseIdx < UseMI.getNumOperands() && "Cannot find Reg in UseMI");
assert(UseIdx < UseMCID.getNumOperands() && "No operand description for Reg");

const MCOperandInfo *UseInfo = &UseMCID.operands()[UseIdx];

// We can fold the zero if this register requires a GPRC_NOR0/G8RC_NOX0
// register (which might also be specified as a pointer class kind).
if (UseInfo->isLookupPtrRegClass()) {
if (UseInfo->RegClass /* Kind */ != 1)
return false;
} else {
if (UseInfo->RegClass != PPC::GPRC_NOR0RegClassID &&
UseInfo->RegClass != PPC::G8RC_NOX0RegClassID)
return false;
}

const MCOperandInfo &UseInfo = UseMCID.operands()[UseIdx];
int16_t RegClass = getOpRegClassID(UseInfo);
if (UseInfo.RegClass != PPC::GPRC_NOR0RegClassID &&
UseInfo.RegClass != PPC::G8RC_NOX0RegClassID)
return false;

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

MCRegister ZeroReg;
if (UseInfo->isLookupPtrRegClass()) {
bool isPPC64 = Subtarget.isPPC64();
ZeroReg = isPPC64 ? PPC::ZERO8 : PPC::ZERO;
} else {
ZeroReg = UseInfo->RegClass == PPC::G8RC_NOX0RegClassID ?
PPC::ZERO8 : PPC::ZERO;
}
MCRegister ZeroReg =
RegClass == PPC::G8RC_NOX0RegClassID ? PPC::ZERO8 : PPC::ZERO;

LLVM_DEBUG(dbgs() << "Folded immediate zero for: ");
LLVM_DEBUG(UseMI.dump());
Expand Down
13 changes: 11 additions & 2 deletions llvm/lib/Target/PowerPC/PPCRegisterInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,12 @@ def crbitm: Operand<i8> {
def PPCRegGxRCNoR0Operand : AsmOperandClass {
let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
}
def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {

def ptr_rc_nor0_by_hwmode : RegClassByHwMode<
[PPC32, PPC64],
[GPRC_NOR0, G8RC_NOX0]>;

def ptr_rc_nor0 : RegisterOperand<ptr_rc_nor0_by_hwmode> {
let ParserMatchClass = PPCRegGxRCNoR0Operand;
}

Expand Down Expand Up @@ -902,7 +907,11 @@ def memri34_pcrel : Operand<iPTR> { // memri, imm is a 34-bit value.
def PPCRegGxRCOperand : AsmOperandClass {
let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
}
def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {

def ptr_rc_idx_by_hwmode : RegClassByHwMode<[PPC32, PPC64],
[GPRC, G8RC]>;

def ptr_rc_idx : RegisterOperand<ptr_rc_idx_by_hwmode> {
let ParserMatchClass = PPCRegGxRCOperand;
}

Expand Down