diff options
author | Daniel Sanders <daniel_l_sanders@apple.com> | 2018-10-03 02:12:17 +0000 |
---|---|---|
committer | Daniel Sanders <daniel_l_sanders@apple.com> | 2018-10-03 02:12:17 +0000 |
commit | c973ad1878f335fbb90fd1ac421fa6309746fe53 (patch) | |
tree | e7f10b7b21bc3568ee2298ef1fc21803b72829c2 /llvm/lib/CodeGen/GlobalISel/Combiner.cpp | |
parent | a01151294ae34da280379a76b4ba9a8f26c2e538 (diff) | |
download | bcm5719-llvm-c973ad1878f335fbb90fd1ac421fa6309746fe53.tar.gz bcm5719-llvm-c973ad1878f335fbb90fd1ac421fa6309746fe53.zip |
Re-commit: [globalisel] Add a combiner helpers for extending loads and use them in a pre-legalize combiner for AArch64
Summary: Depends on D45541
Reviewers: ab, aditya_nandakumar, bogner, rtereshin, volkan, rovka, javed.absar, aemerson
Subscribers: aemerson, rengolin, mgorny, javed.absar, kristof.beyls, llvm-commits
Differential Revision: https://reviews.llvm.org/D45543
The previous commit failed portions of the test-suite on GreenDragon due to
duplicate COPY instructions and iterator invalidation. Both issues have now
been fixed. To assist with this, a helper (cloneVirtualRegister) has been added
to MachineRegisterInfo that can be used to get another register that has the same
type and class/bank as an existing one.
llvm-svn: 343654
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/Combiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/Combiner.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/Combiner.cpp b/llvm/lib/CodeGen/GlobalISel/Combiner.cpp index 0bc5b87de15..f3f075af486 100644 --- a/llvm/lib/CodeGen/GlobalISel/Combiner.cpp +++ b/llvm/lib/CodeGen/GlobalISel/Combiner.cpp @@ -25,6 +25,34 @@ using namespace llvm; +namespace { +/// This class acts as the glue the joins the CombinerHelper to the overall +/// Combine algorithm. The CombinerHelper is intended to report the +/// modifications it makes to the MIR to the CombinerChangeObserver and the +/// observer subclass will act on these events. In this case, instruction +/// erasure will cancel any future visits to the erased instruction and +/// instruction creation will schedule that instruction for a future visit. +/// Other Combiner implementations may require more complex behaviour from +/// their CombinerChangeObserver subclass. +class WorkListMaintainer : public CombinerChangeObserver { + using WorkListTy = GISelWorkList<512>; + WorkListTy &WorkList; + +public: + WorkListMaintainer(WorkListTy &WorkList) : WorkList(WorkList) {} + virtual ~WorkListMaintainer() {} + + void erasedInstr(MachineInstr &MI) override { + LLVM_DEBUG(dbgs() << "Erased: "; MI.print(dbgs()); dbgs() << "\n"); + WorkList.remove(&MI); + } + void createdInstr(MachineInstr &MI) override { + LLVM_DEBUG(dbgs() << "Created: "; MI.print(dbgs()); dbgs() << "\n"); + WorkList.insert(&MI); + } +}; +} + Combiner::Combiner(CombinerInfo &Info, const TargetPassConfig *TPC) : CInfo(Info), TPC(TPC) { (void)this->TPC; // FIXME: Remove when used. @@ -53,6 +81,7 @@ bool Combiner::combineMachineInstrs(MachineFunction &MF) { // down RPOT. Changed = false; GISelWorkList<512> WorkList; + WorkListMaintainer Observer(WorkList); for (MachineBasicBlock *MBB : post_order(&MF)) { if (MBB->empty()) continue; @@ -72,7 +101,7 @@ bool Combiner::combineMachineInstrs(MachineFunction &MF) { while (!WorkList.empty()) { MachineInstr *CurrInst = WorkList.pop_back_val(); LLVM_DEBUG(dbgs() << "Try combining " << *CurrInst << "\n";); - Changed |= CInfo.combine(*CurrInst, Builder); + Changed |= CInfo.combine(Observer, *CurrInst, Builder); } MFChanged |= Changed; } while (Changed); |