[llvm] r297491 - [GlobalISel] Make LegalizerInfo accessible in LegalizerHelper
Volkan Keles via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 10 10:34:58 PST 2017
Author: volkan
Date: Fri Mar 10 12:34:57 2017
New Revision: 297491
URL: http://llvm.org/viewvc/llvm-project?rev=297491&view=rev
Log:
[GlobalISel] Make LegalizerInfo accessible in LegalizerHelper
Summary:
We don’t actually use LegalizerInfo in Legalizer pass, it’s just passed
as an argument.
In order to check if an instruction is legal or not, we need to get LegalizerInfo
by calling `MI.getParent()->getParent()->getSubtarget().getLegalizerInfo()`.
Instead, make LegalizerInfo accessible in LegalizerHelper.
Reviewers: qcolombet, aditya_nandakumar, dsanders, ab, t.p.northover, kristof.beyls
Reviewed By: qcolombet
Subscribers: dberris, llvm-commits, rovka
Differential Revision: https://reviews.llvm.org/D30838
Modified:
llvm/trunk/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
llvm/trunk/lib/CodeGen/GlobalISel/Legalizer.cpp
llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h?rev=297491&r1=297490&r2=297491&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h Fri Mar 10 12:34:57 2017
@@ -55,11 +55,9 @@ public:
///
/// Considered as an opaque blob, the legal code will use and define the same
/// registers as \p MI.
- LegalizeResult legalizeInstrStep(MachineInstr &MI,
- const LegalizerInfo &LegalizerInfo);
+ LegalizeResult legalizeInstrStep(MachineInstr &MI);
- LegalizeResult legalizeInstr(MachineInstr &MI,
- const LegalizerInfo &LegalizerInfo);
+ LegalizeResult legalizeInstr(MachineInstr &MI);
/// Legalize an instruction by emiting a runtime library call instead.
LegalizeResult libcall(MachineInstr &MI);
@@ -97,6 +95,7 @@ private:
MachineIRBuilder MIRBuilder;
MachineRegisterInfo &MRI;
+ const LegalizerInfo &LI;
};
} // End namespace llvm.
Modified: llvm/trunk/lib/CodeGen/GlobalISel/Legalizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/Legalizer.cpp?rev=297491&r1=297490&r2=297491&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/Legalizer.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/Legalizer.cpp Fri Mar 10 12:34:57 2017
@@ -151,7 +151,6 @@ bool Legalizer::runOnMachineFunction(Mac
DEBUG(dbgs() << "Legalize Machine IR for: " << MF.getName() << '\n');
init(MF);
const TargetPassConfig &TPC = getAnalysis<TargetPassConfig>();
- const LegalizerInfo &LegalizerInfo = *MF.getSubtarget().getLegalizerInfo();
MachineOptimizationRemarkEmitter MORE(MF, /*MBFI=*/nullptr);
LegalizerHelper Helper(MF);
@@ -173,7 +172,7 @@ bool Legalizer::runOnMachineFunction(Mac
if (!isPreISelGenericOpcode(MI->getOpcode()))
continue;
- auto Res = Helper.legalizeInstr(*MI, LegalizerInfo);
+ auto Res = Helper.legalizeInstr(*MI);
// Error out if we couldn't legalize this instruction. We may want to fall
// back to DAG ISel instead in the future.
Modified: llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp?rev=297491&r1=297490&r2=297491&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp Fri Mar 10 12:34:57 2017
@@ -29,14 +29,13 @@
using namespace llvm;
LegalizerHelper::LegalizerHelper(MachineFunction &MF)
- : MRI(MF.getRegInfo()) {
+ : MRI(MF.getRegInfo()), LI(*MF.getSubtarget().getLegalizerInfo()) {
MIRBuilder.setMF(MF);
}
LegalizerHelper::LegalizeResult
-LegalizerHelper::legalizeInstrStep(MachineInstr &MI,
- const LegalizerInfo &LegalizerInfo) {
- auto Action = LegalizerInfo.getAction(MI, MRI);
+LegalizerHelper::legalizeInstrStep(MachineInstr &MI) {
+ auto Action = LI.getAction(MI, MRI);
switch (std::get<0>(Action)) {
case LegalizerInfo::Legal:
return AlreadyLegal;
@@ -51,16 +50,15 @@ LegalizerHelper::legalizeInstrStep(Machi
case LegalizerInfo::FewerElements:
return fewerElementsVector(MI, std::get<1>(Action), std::get<2>(Action));
case LegalizerInfo::Custom:
- return LegalizerInfo.legalizeCustom(MI, MRI, MIRBuilder) ? Legalized
- : UnableToLegalize;
+ return LI.legalizeCustom(MI, MRI, MIRBuilder) ? Legalized
+ : UnableToLegalize;
default:
return UnableToLegalize;
}
}
LegalizerHelper::LegalizeResult
-LegalizerHelper::legalizeInstr(MachineInstr &MI,
- const LegalizerInfo &LegalizerInfo) {
+LegalizerHelper::legalizeInstr(MachineInstr &MI) {
SmallVector<MachineInstr *, 4> WorkList;
MIRBuilder.recordInsertions(
[&](MachineInstr *MI) { WorkList.push_back(MI); });
@@ -70,7 +68,7 @@ LegalizerHelper::legalizeInstr(MachineIn
LegalizeResult Res;
unsigned Idx = 0;
do {
- Res = legalizeInstrStep(*WorkList[Idx], LegalizerInfo);
+ Res = legalizeInstrStep(*WorkList[Idx]);
if (Res == UnableToLegalize) {
MIRBuilder.stopRecordingInsertions();
return UnableToLegalize;
More information about the llvm-commits
mailing list