Skip to content

Commit 2331fbb

Browse files
authored
CodeGen: Remove MachineFunction argument from getPointerRegClass (#158185)
getPointerRegClass is a layering violation. Its primary purpose is to determine how to interpret an MCInstrDesc's operands RegClass fields. This should be context free, and only depend on the subtarget. The model of this is also wrong, since this should be an instruction / operand specific property, not a global pointer class. Remove the the function argument to help stage removal of this hook and avoid introducing any new obstacles to replacing it. The remaining uses of the function were to get the subtarget, which TargetRegisterInfo already belongs to. A few targets needed new subtarget derived properties copied there.
1 parent 47b490b commit 2331fbb

Some content is hidden

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

46 files changed

+94
-103
lines changed

llvm/include/llvm/CodeGen/TargetRegisterInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ class LLVM_ABI TargetRegisterInfo : public MCRegisterInfo {
883883
/// If a target supports multiple different pointer register classes,
884884
/// kind specifies which one is indicated.
885885
virtual const TargetRegisterClass *
886-
getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const {
886+
getPointerRegClass(unsigned Kind = 0) const {
887887
llvm_unreachable("Target didn't implement getPointerRegClass!");
888888
}
889889

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ bool IRTranslator::translateVectorDeinterleave2Intrinsic(
18631863
void IRTranslator::getStackGuard(Register DstReg,
18641864
MachineIRBuilder &MIRBuilder) {
18651865
const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
1866-
MRI->setRegClass(DstReg, TRI->getPointerRegClass(*MF));
1866+
MRI->setRegClass(DstReg, TRI->getPointerRegClass());
18671867
auto MIB =
18681868
MIRBuilder.buildInstr(TargetOpcode::LOAD_STACK_GUARD, {DstReg}, {});
18691869

llvm/lib/CodeGen/MachineInstr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ MachineInstr::getRegClassConstraint(unsigned OpIdx,
10031003

10041004
// Assume that all registers in a memory operand are pointers.
10051005
if (F.isMemKind())
1006-
return TRI->getPointerRegClass(MF);
1006+
return TRI->getPointerRegClass();
10071007

10081008
return nullptr;
10091009
}

llvm/lib/CodeGen/TargetInstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ TargetInstrInfo::getRegClass(const MCInstrDesc &MCID, unsigned OpNum,
6767

6868
short RegClass = MCID.operands()[OpNum].RegClass;
6969
if (MCID.operands()[OpNum].isLookupPtrRegClass())
70-
return TRI->getPointerRegClass(MF, RegClass);
70+
return TRI->getPointerRegClass(RegClass);
7171

7272
// Instructions like INSERT_SUBREG do not have fixed register classes.
7373
if (RegClass < 0)

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ bool AArch64DAGToDAGISel::SelectInlineAsmMemoryOperand(
574574
// We need to make sure that this one operand does not end up in XZR, thus
575575
// require the address to be in a PointerRegClass register.
576576
const TargetRegisterInfo *TRI = Subtarget->getRegisterInfo();
577-
const TargetRegisterClass *TRC = TRI->getPointerRegClass(*MF);
577+
const TargetRegisterClass *TRC = TRI->getPointerRegClass();
578578
SDLoc dl(Op);
579579
SDValue RC = CurDAG->getTargetConstant(TRC->getID(), dl, MVT::i64);
580580
SDValue NewOp =

llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,7 @@ bool AArch64RegisterInfo::isAsmClobberable(const MachineFunction &MF,
610610
}
611611

612612
const TargetRegisterClass *
613-
AArch64RegisterInfo::getPointerRegClass(const MachineFunction &MF,
614-
unsigned Kind) const {
613+
AArch64RegisterInfo::getPointerRegClass(unsigned Kind) const {
615614
return &AArch64::GPR64spRegClass;
616615
}
617616

llvm/lib/Target/AArch64/AArch64RegisterInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ class AArch64RegisterInfo final : public AArch64GenRegisterInfo {
102102
bool isAsmClobberable(const MachineFunction &MF,
103103
MCRegister PhysReg) const override;
104104
const TargetRegisterClass *
105-
getPointerRegClass(const MachineFunction &MF,
106-
unsigned Kind = 0) const override;
105+
getPointerRegClass(unsigned Kind = 0) const override;
107106
const TargetRegisterClass *
108107
getCrossCopyRegClass(const TargetRegisterClass *RC) const override;
109108

llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,8 @@ bool SIRegisterInfo::isFrameOffsetLegal(const MachineInstr *MI,
11081108
SIInstrFlags::FlatScratch);
11091109
}
11101110

1111-
const TargetRegisterClass *SIRegisterInfo::getPointerRegClass(
1112-
const MachineFunction &MF, unsigned Kind) const {
1111+
const TargetRegisterClass *
1112+
SIRegisterInfo::getPointerRegClass(unsigned Kind) const {
11131113
// This is inaccurate. It depends on the instruction and address space. The
11141114
// only place where we should hit this is for dealing with frame indexes /
11151115
// private accesses, so this is correct in that case.

llvm/lib/Target/AMDGPU/SIRegisterInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ class SIRegisterInfo final : public AMDGPUGenRegisterInfo {
154154
bool isFrameOffsetLegal(const MachineInstr *MI, Register BaseReg,
155155
int64_t Offset) const override;
156156

157-
const TargetRegisterClass *getPointerRegClass(
158-
const MachineFunction &MF, unsigned Kind = 0) const override;
157+
const TargetRegisterClass *
158+
getPointerRegClass(unsigned Kind = 0) const override;
159159

160160
/// Returns a legal register class to copy a register in the specified class
161161
/// to or from. If it is possible to copy the register directly without using

llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ ARMBaseRegisterInfo::getLargestLegalSuperClass(const TargetRegisterClass *RC,
310310
}
311311

312312
const TargetRegisterClass *
313-
ARMBaseRegisterInfo::getPointerRegClass(const MachineFunction &MF, unsigned Kind)
314-
const {
313+
ARMBaseRegisterInfo::getPointerRegClass(unsigned Kind) const {
315314
return &ARM::GPRRegClass;
316315
}
317316

0 commit comments

Comments
 (0)