mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-14 15:39:06 +00:00
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297491 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b30be7321e
commit
56bf757d2e
@ -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.
|
||||
|
@ -151,7 +151,6 @@ bool Legalizer::runOnMachineFunction(MachineFunction &MF) {
|
||||
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(MachineFunction &MF) {
|
||||
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.
|
||||
|
@ -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(MachineInstr &MI,
|
||||
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(MachineInstr &MI,
|
||||
LegalizeResult Res;
|
||||
unsigned Idx = 0;
|
||||
do {
|
||||
Res = legalizeInstrStep(*WorkList[Idx], LegalizerInfo);
|
||||
Res = legalizeInstrStep(*WorkList[Idx]);
|
||||
if (Res == UnableToLegalize) {
|
||||
MIRBuilder.stopRecordingInsertions();
|
||||
return UnableToLegalize;
|
||||
|
Loading…
Reference in New Issue
Block a user