[PATCH] D85487: GlobalISel: Add TargetLowering member to LegalizerHelper
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 6 16:53:34 PDT 2020
arsenm created this revision.
arsenm added reviewers: paquette, aemerson, dsanders, aditya_nandakumar.
Herald added subscribers: hiraditya, rovka.
Herald added a project: LLVM.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
https://reviews.llvm.org/D85487
Files:
llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
Index: llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -90,14 +90,16 @@
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
@@ -5559,7 +5561,6 @@
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);
@@ -5929,8 +5930,6 @@
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;
@@ -5941,7 +5940,7 @@
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;
Index: llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
+++ llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
@@ -32,6 +32,7 @@
class Legalizer;
class MachineRegisterInfo;
class GISelChangeObserver;
+class TargetLowering;
class LegalizerHelper {
public:
@@ -45,6 +46,7 @@
private:
MachineRegisterInfo &MRI;
const LegalizerInfo &LI;
+ const TargetLowering &TLI;
public:
enum LegalizeResult {
@@ -62,6 +64,7 @@
/// 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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85487.283768.patch
Type: text/x-patch
Size: 3066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200806/7db7e9dd/attachment.bin>
More information about the llvm-commits
mailing list