aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2020-07-31 11:41:05 -0400
committerMatt Arsenault <Matthew.Arsenault@amd.com>2020-08-19 14:50:35 -0400
commitadbcc8e73321dffac403af55bc2978f9794fb09b (patch)
tree296f2faa61344881308dced6eded8bb7823caf0a
parente5d08fcbac722d487973d9c96838c0589f1953c3 (diff)
downloadllvm-adbcc8e73321dffac403af55bc2978f9794fb09b.zip
llvm-adbcc8e73321dffac403af55bc2978f9794fb09b.tar.gz
llvm-adbcc8e73321dffac403af55bc2978f9794fb09b.tar.bz2
GlobalISel: Add TargetLowering member to LegalizerHelper
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h3
-rw-r--r--llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp11
2 files changed, 8 insertions, 6 deletions
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
index d0e7419..f857d1d 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
@@ -32,6 +32,7 @@ class LegalizerInfo;
class Legalizer;
class MachineRegisterInfo;
class GISelChangeObserver;
+class TargetLowering;
class LegalizerHelper {
public:
@@ -45,6 +46,7 @@ public:
private:
MachineRegisterInfo &MRI;
const LegalizerInfo &LI;
+ const TargetLowering &TLI;
public:
enum LegalizeResult {
@@ -62,6 +64,7 @@ public:
/// Expose LegalizerInfo so the clients can re-use.
const LegalizerInfo &getLegalizerInfo() const { return LI; }
+ const TargetLowering &getTargetLowering() const { return TLI; }
LegalizerHelper(MachineFunction &MF, GISelChangeObserver &Observer,
MachineIRBuilder &B);
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index 2f722d0..9999d26 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -90,14 +90,16 @@ LegalizerHelper::LegalizerHelper(MachineFunction &MF,
GISelChangeObserver &Observer,
MachineIRBuilder &Builder)
: MIRBuilder(Builder), Observer(Observer), MRI(MF.getRegInfo()),
- LI(*MF.getSubtarget().getLegalizerInfo()) {
+ LI(*MF.getSubtarget().getLegalizerInfo()),
+ TLI(*MF.getSubtarget().getTargetLowering()) {
MIRBuilder.setChangeObserver(Observer);
}
LegalizerHelper::LegalizerHelper(MachineFunction &MF, const LegalizerInfo &LI,
GISelChangeObserver &Observer,
MachineIRBuilder &B)
- : MIRBuilder(B), Observer(Observer), MRI(MF.getRegInfo()), LI(LI) {
+ : MIRBuilder(B), Observer(Observer), MRI(MF.getRegInfo()), LI(LI),
+ TLI(*MF.getSubtarget().getTargetLowering()) {
MIRBuilder.setChangeObserver(Observer);
}
LegalizerHelper::LegalizeResult
@@ -5714,7 +5716,6 @@ LegalizerHelper::lowerDynStackAlloc(MachineInstr &MI) {
LLT PtrTy = MRI.getType(Dst);
LLT IntPtrTy = LLT::scalar(PtrTy.getSizeInBits());
- const auto &TLI = *MF.getSubtarget().getTargetLowering();
Register SPReg = TLI.getStackPointerRegisterToSaveRestore();
auto SPTmp = MIRBuilder.buildCopy(PtrTy, SPReg);
SPTmp = MIRBuilder.buildCast(IntPtrTy, SPTmp);
@@ -6118,8 +6119,6 @@ LegalizerHelper::lowerBitreverse(MachineInstr &MI) {
LegalizerHelper::LegalizeResult
LegalizerHelper::lowerReadWriteRegister(MachineInstr &MI) {
MachineFunction &MF = MIRBuilder.getMF();
- const TargetSubtargetInfo &STI = MF.getSubtarget();
- const TargetLowering *TLI = STI.getTargetLowering();
bool IsRead = MI.getOpcode() == TargetOpcode::G_READ_REGISTER;
int NameOpIdx = IsRead ? 1 : 0;
@@ -6130,7 +6129,7 @@ LegalizerHelper::lowerReadWriteRegister(MachineInstr &MI) {
const MDString *RegStr = cast<MDString>(
cast<MDNode>(MI.getOperand(NameOpIdx).getMetadata())->getOperand(0));
- Register PhysReg = TLI->getRegisterByName(RegStr->getString().data(), Ty, MF);
+ Register PhysReg = TLI.getRegisterByName(RegStr->getString().data(), Ty, MF);
if (!PhysReg.isValid())
return UnableToLegalize;