Skip to content

Commit 7289f2c

Browse files
authored
CodeGen: Remove MachineFunction argument from getRegClass (#158188)
This is a low level utility to parse the MCInstrInfo and should not depend on the state of the function.
1 parent 83b48b1 commit 7289f2c

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

+107
-133
lines changed

llvm/include/llvm/CodeGen/TargetInstrInfo.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,9 @@ class LLVM_ABI TargetInstrInfo : public MCInstrInfo {
135135

136136
/// Given a machine instruction descriptor, returns the register
137137
/// class constraint for OpNum, or NULL.
138-
virtual
139-
const TargetRegisterClass *getRegClass(const MCInstrDesc &MCID, unsigned OpNum,
140-
const TargetRegisterInfo *TRI,
141-
const MachineFunction &MF) const;
138+
virtual const TargetRegisterClass *
139+
getRegClass(const MCInstrDesc &MCID, unsigned OpNum,
140+
const TargetRegisterInfo *TRI) const;
142141

143142
/// Returns true if MI is an instruction we are unable to reason about
144143
/// (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, MF);
398+
RC = TII->getRegClass(MI.getDesc(), i, TRI);
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, MF);
482+
RC = TII->getRegClass(MI.getDesc(), i, TRI);
483483
AggressiveAntiDepState::RegisterReference RR = { &MO, RC };
484484
RegRefs.emplace(Reg.asMCReg(), RR);
485485
}

llvm/lib/CodeGen/BreakFalseDeps.cpp

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

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

140139
// 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, MF);
190+
NewRC = TII->getRegClass(MI.getDesc(), i, TRI);
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, MF);
319+
NewRC = TII->getRegClass(MI.getDesc(), i, TRI);
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, MF);
117+
const TargetRegisterClass *OpRC = TII.getRegClass(II, OpIdx, &TRI);
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, MF);
235+
TII->getRegClass(MI.getDesc(), UseOpIdx, TRI);
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,11 +976,9 @@ MachineInstr::getRegClassConstraint(unsigned OpIdx,
976976
const TargetRegisterInfo *TRI) const {
977977
assert(getParent() && "Can't have an MBB reference here!");
978978
assert(getMF() && "Can't have an MF reference here!");
979-
const MachineFunction &MF = *getMF();
980-
981979
// Most opcodes have fixed constraints in their MCInstrDesc.
982980
if (!isInlineAsm())
983-
return TII->getRegClass(getDesc(), OpIdx, TRI, MF);
981+
return TII->getRegClass(getDesc(), OpIdx, TRI);
984982

985983
if (!getOperand(OpIdx).isReg())
986984
return nullptr;

llvm/lib/CodeGen/MachineLICM.cpp

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

llvm/lib/CodeGen/MachineVerifier.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,7 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
26362636
}
26372637
if (MONum < MCID.getNumOperands()) {
26382638
if (const TargetRegisterClass *DRC =
2639-
TII->getRegClass(MCID, MONum, TRI, *MF)) {
2639+
TII->getRegClass(MCID, MONum, TRI)) {
26402640
if (!DRC->contains(Reg)) {
26412641
report("Illegal physical register for instruction", MO, MONum);
26422642
OS << printReg(Reg, TRI) << " is not a "
@@ -2721,11 +2721,11 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
27212721
// comply to it.
27222722
if (!isPreISelGenericOpcode(MCID.getOpcode()) &&
27232723
MONum < MCID.getNumOperands() &&
2724-
TII->getRegClass(MCID, MONum, TRI, *MF)) {
2724+
TII->getRegClass(MCID, MONum, TRI)) {
27252725
report("Virtual register does not match instruction constraint", MO,
27262726
MONum);
27272727
OS << "Expect register class "
2728-
<< TRI->getRegClassName(TII->getRegClass(MCID, MONum, TRI, *MF))
2728+
<< TRI->getRegClassName(TII->getRegClass(MCID, MONum, TRI))
27292729
<< " but got nothing\n";
27302730
return;
27312731
}
@@ -2752,7 +2752,7 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
27522752
}
27532753
if (MONum < MCID.getNumOperands()) {
27542754
if (const TargetRegisterClass *DRC =
2755-
TII->getRegClass(MCID, MONum, TRI, *MF)) {
2755+
TII->getRegClass(MCID, MONum, TRI)) {
27562756
if (SubIdx) {
27572757
const TargetRegisterClass *SuperRC =
27582758
TRI->getLargestLegalSuperClass(RC, *MF);

llvm/lib/CodeGen/RegisterCoalescer.cpp

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

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

0 commit comments

Comments
 (0)