Skip to content

Commit 5fef14b

Browse files
committed
CodeGen: Remove TRI argument from getRegClass
TargetInstrInfo now directly holds a reference to TargetRegisterInfo and does not need TRI passed in anywhere.
1 parent 5d621c5 commit 5fef14b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+97
-120
lines changed

llvm/include/llvm/CodeGen/TargetInstrInfo.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,8 @@ class LLVM_ABI TargetInstrInfo : public MCInstrInfo {
159159

160160
/// Given a machine instruction descriptor, returns the register
161161
/// class constraint for OpNum, or NULL.
162-
virtual const TargetRegisterClass *
163-
getRegClass(const MCInstrDesc &MCID, unsigned OpNum,
164-
const TargetRegisterInfo *TRI) const;
162+
virtual const TargetRegisterClass *getRegClass(const MCInstrDesc &MCID,
163+
unsigned OpNum) const;
165164

166165
/// Returns true if MI is an instruction we are unable to reason about
167166
/// (like a call or something with unmodeled side effects).

llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ void AggressiveAntiDepBreaker::PrescanInstruction(
395395
// Note register reference...
396396
const TargetRegisterClass *RC = nullptr;
397397
if (i < MI.getDesc().getNumOperands())
398-
RC = TII->getRegClass(MI.getDesc(), i, TRI);
398+
RC = TII->getRegClass(MI.getDesc(), i);
399399
AggressiveAntiDepState::RegisterReference RR = { &MO, RC };
400400
RegRefs.emplace(Reg.asMCReg(), RR);
401401
}
@@ -479,7 +479,7 @@ void AggressiveAntiDepBreaker::ScanInstruction(MachineInstr &MI,
479479
// Note register reference...
480480
const TargetRegisterClass *RC = nullptr;
481481
if (i < MI.getDesc().getNumOperands())
482-
RC = TII->getRegClass(MI.getDesc(), i, TRI);
482+
RC = TII->getRegClass(MI.getDesc(), i);
483483
AggressiveAntiDepState::RegisterReference RR = { &MO, RC };
484484
RegRefs.emplace(Reg.asMCReg(), RR);
485485
}

llvm/lib/CodeGen/BreakFalseDeps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ bool BreakFalseDeps::pickBestRegisterForUndef(MachineInstr *MI, unsigned OpIdx,
133133
}
134134

135135
// Get the undef operand's register class
136-
const TargetRegisterClass *OpRC = TII->getRegClass(MI->getDesc(), OpIdx, TRI);
136+
const TargetRegisterClass *OpRC = TII->getRegClass(MI->getDesc(), OpIdx);
137137
assert(OpRC && "Not a valid register class");
138138

139139
// If the instruction has a true dependency, we can hide the false depdency

llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void CriticalAntiDepBreaker::PrescanInstruction(MachineInstr &MI) {
187187
const TargetRegisterClass *NewRC = nullptr;
188188

189189
if (i < MI.getDesc().getNumOperands())
190-
NewRC = TII->getRegClass(MI.getDesc(), i, TRI);
190+
NewRC = TII->getRegClass(MI.getDesc(), i);
191191

192192
// For now, only allow the register to be changed if its register
193193
// class is consistent across all uses.
@@ -316,7 +316,7 @@ void CriticalAntiDepBreaker::ScanInstruction(MachineInstr &MI, unsigned Count) {
316316

317317
const TargetRegisterClass *NewRC = nullptr;
318318
if (i < MI.getDesc().getNumOperands())
319-
NewRC = TII->getRegClass(MI.getDesc(), i, TRI);
319+
NewRC = TII->getRegClass(MI.getDesc(), i);
320320

321321
// For now, only allow the register to be changed if its register
322322
// class is consistent across all uses.

llvm/lib/CodeGen/GlobalISel/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Register llvm::constrainOperandRegClass(
114114
// Assume physical registers are properly constrained.
115115
assert(Reg.isVirtual() && "PhysReg not implemented");
116116

117-
const TargetRegisterClass *OpRC = TII.getRegClass(II, OpIdx, &TRI);
117+
const TargetRegisterClass *OpRC = TII.getRegClass(II, OpIdx);
118118
// Some of the target independent instructions, like COPY, may not impose any
119119
// register class constraints on some of their operands: If it's a use, we can
120120
// skip constraining as the instruction defining the register would constrain

llvm/lib/CodeGen/InitUndef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ bool InitUndef::processBasicBlock(MachineFunction &MF, MachineBasicBlock &MBB,
232232
MachineOperand &UseMO = MI.getOperand(UseOpIdx);
233233
if (UseMO.getReg() == MCRegister::NoRegister) {
234234
const TargetRegisterClass *RC =
235-
TII->getRegClass(MI.getDesc(), UseOpIdx, TRI);
235+
TII->getRegClass(MI.getDesc(), UseOpIdx);
236236
Register NewDest = MRI->createVirtualRegister(RC);
237237
// We don't have a way to update dead lanes, so keep track of the
238238
// new register so that we avoid querying it later.

llvm/lib/CodeGen/MachineInstr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ MachineInstr::getRegClassConstraint(unsigned OpIdx,
978978
assert(getMF() && "Can't have an MF reference here!");
979979
// Most opcodes have fixed constraints in their MCInstrDesc.
980980
if (!isInlineAsm())
981-
return TII->getRegClass(getDesc(), OpIdx, TRI);
981+
return TII->getRegClass(getDesc(), OpIdx);
982982

983983
if (!getOperand(OpIdx).isReg())
984984
return nullptr;

llvm/lib/CodeGen/MachineLICM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ MachineInstr *MachineLICMImpl::ExtractHoistableLoad(MachineInstr *MI,
13991399
if (NewOpc == 0) return nullptr;
14001400
const MCInstrDesc &MID = TII->get(NewOpc);
14011401
MachineFunction &MF = *MI->getMF();
1402-
const TargetRegisterClass *RC = TII->getRegClass(MID, LoadRegIndex, TRI);
1402+
const TargetRegisterClass *RC = TII->getRegClass(MID, LoadRegIndex);
14031403
// Ok, we're unfolding. Create a temporary register and do the unfold.
14041404
Register Reg = MRI->createVirtualRegister(RC);
14051405

llvm/lib/CodeGen/MachineVerifier.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,8 +2649,7 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
26492649
return;
26502650
}
26512651
if (MONum < MCID.getNumOperands()) {
2652-
if (const TargetRegisterClass *DRC =
2653-
TII->getRegClass(MCID, MONum, TRI)) {
2652+
if (const TargetRegisterClass *DRC = TII->getRegClass(MCID, MONum)) {
26542653
if (!DRC->contains(Reg)) {
26552654
report("Illegal physical register for instruction", MO, MONum);
26562655
OS << printReg(Reg, TRI) << " is not a "
@@ -2734,12 +2733,11 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
27342733
// has register class constraint, the virtual register must
27352734
// comply to it.
27362735
if (!isPreISelGenericOpcode(MCID.getOpcode()) &&
2737-
MONum < MCID.getNumOperands() &&
2738-
TII->getRegClass(MCID, MONum, TRI)) {
2736+
MONum < MCID.getNumOperands() && TII->getRegClass(MCID, MONum)) {
27392737
report("Virtual register does not match instruction constraint", MO,
27402738
MONum);
27412739
OS << "Expect register class "
2742-
<< TRI->getRegClassName(TII->getRegClass(MCID, MONum, TRI))
2740+
<< TRI->getRegClassName(TII->getRegClass(MCID, MONum))
27432741
<< " but got nothing\n";
27442742
return;
27452743
}
@@ -2765,8 +2763,7 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
27652763
}
27662764
}
27672765
if (MONum < MCID.getNumOperands()) {
2768-
if (const TargetRegisterClass *DRC =
2769-
TII->getRegClass(MCID, MONum, TRI)) {
2766+
if (const TargetRegisterClass *DRC = TII->getRegClass(MCID, MONum)) {
27702767
if (SubIdx) {
27712768
const TargetRegisterClass *SuperRC =
27722769
TRI->getLargestLegalSuperClass(RC, *MF);

llvm/lib/CodeGen/RegisterCoalescer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ bool RegisterCoalescer::reMaterializeDef(const CoalescerPair &CP,
13731373
}
13741374

13751375
const unsigned DefSubIdx = DefMI->getOperand(0).getSubReg();
1376-
const TargetRegisterClass *DefRC = TII->getRegClass(MCID, 0, TRI);
1376+
const TargetRegisterClass *DefRC = TII->getRegClass(MCID, 0);
13771377
if (!DefMI->isImplicitDef()) {
13781378
if (DstReg.isPhysical()) {
13791379
Register NewDstReg = DstReg;

0 commit comments

Comments
 (0)