Skip to content

Commit

Permalink
Add DAG mutation interface to the DFA packetizer
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262930 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Krzysztof Parzyszek committed Mar 8, 2016
1 parent 0fb75e4 commit 9653264
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/llvm/CodeGen/DFAPacketizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "llvm/ADT/DenseMap.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/ScheduleDAGMutation.h"
#include <map>

namespace llvm {
Expand Down Expand Up @@ -199,6 +200,9 @@ class VLIWPacketizerList {
virtual bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) {
return false;
}

// Add a DAG mutation to be done before the packetization begins.
void addMutation(std::unique_ptr<ScheduleDAGMutation> Mutation);
};

} // namespace llvm
Expand Down
24 changes: 24 additions & 0 deletions lib/CodeGen/DFAPacketizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,20 @@ namespace llvm {
class DefaultVLIWScheduler : public ScheduleDAGInstrs {
private:
AliasAnalysis *AA;
/// Ordered list of DAG postprocessing steps.
std::vector<std::unique_ptr<ScheduleDAGMutation>> Mutations;
public:
DefaultVLIWScheduler(MachineFunction &MF, MachineLoopInfo &MLI,
AliasAnalysis *AA);
// Actual scheduling work.
void schedule() override;

/// DefaultVLIWScheduler takes ownership of the Mutation object.
void addMutation(std::unique_ptr<ScheduleDAGMutation> Mutation) {
Mutations.push_back(std::move(Mutation));
}
protected:
void postprocessDAG();
};
}

Expand All @@ -172,9 +181,17 @@ DefaultVLIWScheduler::DefaultVLIWScheduler(MachineFunction &MF,
}


/// Apply each ScheduleDAGMutation step in order.
void DefaultVLIWScheduler::postprocessDAG() {
for (auto &M : Mutations)
M->apply(this);
}


void DefaultVLIWScheduler::schedule() {
// Build the scheduling graph.
buildSchedGraph(AA);
postprocessDAG();
}


Expand Down Expand Up @@ -272,3 +289,10 @@ void VLIWPacketizerList::PacketizeMIs(MachineBasicBlock *MBB,
VLIWScheduler->exitRegion();
VLIWScheduler->finishBlock();
}


// Add a DAG mutation object to the ordered list.
void VLIWPacketizerList::addMutation(
std::unique_ptr<ScheduleDAGMutation> Mutation) {
VLIWScheduler->addMutation(std::move(Mutation));
}

0 comments on commit 9653264

Please sign in to comment.