OpenASIP
2.0
|
#include <MachineInstrDDG.hh>
Public Types | |
typedef unsigned | Register |
typedef std::set< Register > | RegisterSet |
Public Types inherited from BoostGraph< MIDDGNode, MIDDGEdge > | |
typedef std::set< MIDDGNode *, typename MIDDGNode ::Comparator > | NodeSet |
typedef std::set< MIDDGEdge *, typename MIDDGEdge ::Comparator > | EdgeSet |
typedef MIDDGNode | Node |
The (base) node type managed by this graph. More... | |
typedef MIDDGEdge | Edge |
The (base) edge type managed by this graph. More... | |
Public Types inherited from GraphBase< MIDDGNode, MIDDGEdge > | |
typedef std::set< MIDDGNode *, typename MIDDGNode ::Comparator > | NodeSet |
typedef std::set< MIDDGEdge *, typename MIDDGEdge ::Comparator > | EdgeSet |
typedef MIDDGNode | Node |
Node type of this graph (possibly, a base class). More... | |
typedef MIDDGEdge | Edge |
Edge type of this graph (possibly, a base class). More... | |
Public Member Functions | |
MachineInstrDDG (const MachineInstrDDG &parent) | |
MachineInstrDDG (llvm::MachineFunction &mf, bool onlyTrueDeps=true) | |
virtual | ~MachineInstrDDG () |
RegisterSet | allRegisters () const |
MIDDGNode * | vregDefiner (Register vreg) const |
MIDDGNode * | lastVregUser (Register vreg) const |
int | falseDepHeightDelta (Register vreg, Register physReg) const |
void | assignPhysReg (Register vreg, Register physReg) |
bool | preceedingNodeUsesOrDefinesReg (const MIDDGNode &node, Register physReg) const |
void | computeOptimalSchedule () |
TCEString | dotString () const |
void | setPrintOnlyCriticalPath (bool flag) |
Public Member Functions inherited from BoostGraph< MIDDGNode, MIDDGEdge > | |
BoostGraph (bool allowLoopEdges=true) | |
BoostGraph (const TCEString &name, bool allowLoopEdges=true) | |
BoostGraph (const BoostGraph &other, bool allowLoopEdges=true) | |
~BoostGraph () | |
int | nodeCount () const |
int | edgeCount () const |
Node & | node (const int index) const |
Node & | node (const int index, bool cacheResult) const |
virtual Edge & | edge (const int index) const |
virtual void | addNode (Node &node) |
virtual Edge & | outEdge (const Node &node, const int index) const |
virtual Edge & | inEdge (const Node &node, const int index) const |
virtual EdgeSet | outEdges (const Node &node) const |
virtual EdgeSet | inEdges (const Node &node) const |
virtual EdgeSet | rootGraphOutEdges (const Node &node) const |
virtual EdgeSet | rootGraphInEdges (const Node &node) const |
virtual Edge & | rootGraphInEdge (const Node &node, const int index) const |
virtual Edge & | rootGraphOutEdge (const Node &node, const int index) const |
virtual int | rootGraphInDegree (const Node &node) const |
virtual int | rootGraphOutDegree (const Node &node) const |
virtual int | outDegree (const Node &node) const |
virtual int | inDegree (const Node &node) const |
virtual Node & | tailNode (const Edge &edge) const |
virtual Node & | headNode (const Edge &edge) const |
virtual void | connectNodes (const Node &nTail, const Node &nHead, Edge &e) |
virtual void | disconnectNodes (const Node &nTail, const Node &nHead) |
virtual void | moveInEdges (const Node &source, const Node &destination) |
virtual void | moveOutEdges (const Node &source, const Node &destination) |
virtual void | moveInEdge (const Node &source, const Node &destination, Edge &edge, const Node *tail=NULL, bool childs=false) |
virtual void | moveOutEdge (const Node &source, const Node &destination, Edge &edge, const Node *head=NULL, bool childs=false) |
virtual void | copyInEdge (const Node &destination, Edge &edge, const Node *tail=NULL) |
virtual void | copyOutEdge (const Node &destination, Edge &edge, const Node *head=NULL) |
virtual void | removeNode (Node &node) |
virtual void | removeEdge (Edge &e) |
virtual void | dropNode (Node &node) |
virtual void | dropEdge (Edge &edge) |
virtual bool | hasEdge (const Node &nTail, const Node &nHead) const |
virtual NodeSet | rootNodes () const |
useful utility functions More... | |
virtual NodeSet | sinkNodes () const |
virtual NodeSet | successors (const Node &node, bool ignoreBackEdges=false, bool ignoreForwardEdges=false) const |
virtual NodeSet | predecessors (const Node &node, bool ignoreBackEdges=false, bool ignoreForwardEdges=false) const |
int | maxPathLength (const MIDDGNode &node) const |
int | maxSinkDistance (const MIDDGNode &node) const |
int | maxSourceDistance (const MIDDGNode &node) const |
bool | isInCriticalPath (const MIDDGNode &node) const |
int | height () const |
void | findAllPaths () const |
void | detachSubgraph (BoostGraph &subGraph) |
BoostGraph * | parentGraph () |
BoostGraph * | rootGraph () |
const BoostGraph * | rootGraph () const |
bool | hasNode (const Node &) const |
virtual const TCEString & | name () const |
void | setName (const TCEString &newName) |
bool | hasPath (MIDDGNode &src, const MIDDGNode &dest) const |
void | restoreNodeFromParent (MIDDGNode &node) |
bool | detectIllegalCycles () const |
EdgeSet | connectingEdges (const Node &nTail, const Node &nHead) const |
Public Member Functions inherited from GraphBase< MIDDGNode, MIDDGEdge > | |
GraphBase () | |
virtual | ~GraphBase () |
virtual TCEString | dotString () const |
virtual void | writeToDotFile (const TCEString &fileName) const |
Private Types | |
typedef std::map< Register, MIDDGNode * > | DefinerMap |
typedef std::map< Register, NodeSet > | UserMap |
typedef std::map< Register, Register > | RegisterMap |
Private Member Functions | |
std::pair< MIDDGNode *, MIDDGNode * > | createFalseDepEdge (Register vreg, Register physReg) const |
Private Attributes | |
RegisterSet | allRegisters_ |
DefinerMap | definers_ |
UserMap | users_ |
NodeSet | nodes_ |
std::set< MIDDGEdge * > | edges_ |
std::map< Register, MIDDGNode * > | lastPhysRegUsers_ |
std::map< Register, MIDDGNode * > | lastPhysRegDefiners_ |
RegisterMap | regAssignments_ |
const bool | onlyTrueDeps_ |
int | smallestCycle_ |
int | largestCycle_ |
std::map< int, std::list< MIDDGNode * > > | schedule_ |
llvm::MachineFunction & | mf_ |
const llvm::TargetRegisterInfo * | regInfo_ |
bool | printOnlyCriticalPath_ |
Additional Inherited Members | |
Protected Types inherited from BoostGraph< MIDDGNode, MIDDGEdge > | |
typedef std::set< RemovedEdgeDatum > | RemovedEdgeMap |
typedef boost::adjacency_list< boost::listS, boost::vecS, boost::bidirectionalS, Node *, Edge * > | Graph |
Internal graph type, providing actual graph-like operations. This type definition relies on bundled properties of boost library, which need the host compiler to support partial template specialisation. More... | |
typedef boost::graph_traits< Graph > | GraphTraits |
Traits characterising the internal graph type. More... | |
typedef GraphTraits::out_edge_iterator | OutEdgeIter |
Output edge iterator type. More... | |
typedef GraphTraits::in_edge_iterator | InEdgeIter |
Input edge iterator type. More... | |
typedef GraphTraits::edge_iterator | EdgeIter |
Iterator type for the list of all edges in the graph. More... | |
typedef GraphTraits::vertex_iterator | NodeIter |
Iterator type for the list of all nodes in the graph. More... | |
typedef GraphTraits::edge_descriptor | EdgeDescriptor |
Type with which edges of the graph are seen internally. More... | |
typedef GraphTraits::vertex_descriptor | NodeDescriptor |
Type with which nodes of the graph are seen internally. More... | |
typedef hash_map< const Edge *, EdgeDescriptor, GraphHashFunctions > | EdgeDescMap |
typedef hash_map< const Node *, NodeDescriptor, GraphHashFunctions > | NodeDescMap |
typedef std::vector< std::vector< int > > | PathCache |
Protected Member Functions inherited from BoostGraph< MIDDGNode, MIDDGEdge > | |
Node & | tailNode (const Edge &edge, const NodeDescriptor &headNode) const |
Node & | headNode (const Edge &edge, const NodeDescriptor &tailNode) const |
virtual void | connectNodes (const Node &nTail, const Node &nHead, Edge &e, GraphBase< MIDDGNode, MIDDGEdge > *modifier, bool creatingSG=false) |
void | moveInEdges (const Node &source, const Node &destination, BoostGraph *modifierGraph) |
virtual void | moveOutEdges (const Node &source, const Node &destination, BoostGraph *modifierGraph) |
virtual void | removeNode (Node &node, BoostGraph *modifierGraph) |
virtual void | removeEdge (Edge &e, const MIDDGNode *tailNode, const MIDDGNode *headNode, BoostGraph *modifierGraph=NULL) |
bool | hasEdge (const Node &nTail, const Node &nHead, const Edge &edge) const |
bool | hasEdge (const Edge &edge, const Node *nTail=NULL, const Node *nHead=NULL) const |
void | restoreRemovedEdges (RemovedEdgeMap removedEdges) |
EdgeDescriptor | descriptor (const Edge &e) const |
NodeDescriptor | descriptor (const Node &n) const |
EdgeDescriptor | edgeDescriptor (const NodeDescriptor &tailNode, const Edge &e) const |
EdgeDescriptor | edgeDescriptor (const Edge &e, const NodeDescriptor &headNode) const |
EdgeDescriptor | connectingEdge (const Node &nTail, const Node &nHead) const |
void | replaceNodeWithLastNode (MIDDGNode &dest) |
void | calculatePathLengths () const |
void | calculatePathLengthsFast () const |
void | calculateSinkDistance (const MIDDGNode &node, int len, bool looping=false) const |
void | calculateSourceDistances (const MIDDGNode *startNode=NULL, int startingLength=0, bool looping=false) const |
void | calculatePathLengthsOnConnect (const MIDDGNode &nTail, const MIDDGNode &nHead, MIDDGEdge &e) |
void | sinkDistDecreased (const MIDDGNode &n) const |
void | sourceDistDecreased (const MIDDGNode &n) const |
virtual int | edgeWeight (MIDDGEdge &e, const MIDDGNode &n) const |
void | clearDescriptorCache (EdgeSet edges) |
void | constructSubGraph (BoostGraph &subGraph, NodeSet &nodes) |
Protected Attributes inherited from BoostGraph< MIDDGNode, MIDDGEdge > | |
std::map< const MIDDGNode *, int, typename MIDDGNode ::Comparator > | sourceDistances_ |
std::map< const MIDDGNode *, int, typename MIDDGNode ::Comparator > | sinkDistances_ |
std::map< const MIDDGNode *, int, typename MIDDGNode ::Comparator > | loopingSourceDistances_ |
std::map< const MIDDGNode *, int, typename MIDDGNode ::Comparator > | loopingSinkDistances_ |
int | height_ |
Graph | graph_ |
The internal graph structure. More... | |
EdgeDescMap | edgeDescriptors_ |
NodeDescMap | nodeDescriptors_ |
BoostGraph< MIDDGNode, MIDDGEdge > * | parentGraph_ |
std::vector< BoostGraph< MIDDGNode, MIDDGEdge > * > | childGraphs_ |
TCEString | name_ |
int | sgCounter_ |
std::set< Edge * > | ownedEdges_ |
bool | allowLoopEdges_ |
PathCache * | pathCache_ |
Data Dependence Graph constructed from non-register allocated LLVM MachineInstructions.
Only true dependencies supported at the moment. Later we can might add support for adding the false dependencies introduced by the register allocator, if needed.
Definition at line 140 of file MachineInstrDDG.hh.
|
private |
Definition at line 173 of file MachineInstrDDG.hh.
typedef unsigned MachineInstrDDG::Register |
Definition at line 143 of file MachineInstrDDG.hh.
|
private |
Definition at line 175 of file MachineInstrDDG.hh.
typedef std::set<Register> MachineInstrDDG::RegisterSet |
Definition at line 144 of file MachineInstrDDG.hh.
|
private |
Definition at line 174 of file MachineInstrDDG.hh.
|
explicit |
POP_COMPILER_DIAGS MachineInstrDDG::MachineInstrDDG | ( | llvm::MachineFunction & | mf, |
bool | onlyTrueDeps = true |
||
) |
Constructs a DDG out of MachineInstructions.
Only true dependencies are supported at the moment.
Definition at line 66 of file MachineInstrDDG.cc.
References BoostGraph< MIDDGNode, MIDDGEdge >::addNode(), allRegisters_, assert, BoostGraph< MIDDGNode, MIDDGEdge >::connectNodes(), definers_, BoostGraph< MIDDGNode, MIDDGEdge >::edge(), edges_, BoostGraph< MIDDGNode, MIDDGEdge >::hasNode(), BoostGraph< MIDDGNode, MIDDGEdge >::hasPath(), Application::logStream(), BoostGraph< MIDDGNode, MIDDGEdge >::node(), nodes_, and users_.
|
virtual |
Definition at line 188 of file MachineInstrDDG.cc.
|
inline |
Definition at line 154 of file MachineInstrDDG.hh.
References allRegisters_.
Referenced by VirtRegIndependenceGraph::VirtRegIndependenceGraph().
Assigns the given physical register to the given virtual register.
Does not yet add false dependence edges, just updates the last phys reg use bookkeeping.
Definition at line 506 of file MachineInstrDDG.cc.
References BoostGraph< MIDDGNode, MIDDGEdge >::connectNodes(), createFalseDepEdge(), MIDDGEdge::DEP_WAR, BoostGraph< MIDDGNode, MIDDGEdge >::edge(), edges_, lastPhysRegDefiners_, lastPhysRegUsers_, lastVregUser(), Application::logStream(), regAssignments_, MIDDGNode::sequentialAddress(), MIDDGEdge::toString(), and vregDefiner().
void MachineInstrDDG::computeOptimalSchedule | ( | ) |
Computes optimal top-down schedule assuming infinite resources and that each operation completes in one cycle.
Definition at line 356 of file MachineInstrDDG.cc.
References largestCycle_, BoostGraph< MIDDGNode, MIDDGEdge >::maxSourceDistance(), BoostGraph< MIDDGNode, MIDDGEdge >::node(), BoostGraph< MIDDGNode, MIDDGEdge >::nodeCount(), schedule_, MIDDGNode::setOptimalCycle(), and smallestCycle_.
Referenced by InstructionPatternAnalyzer::runOnMachineFunction().
|
private |
Creates a false dependency edge introduced when the given virtual reg is assigned the given physical register.
Does not add the edge to the graph. Note, only creates a single edge although in a multi-BB DDG there is usually many in case edge spans CFG branch points. Returns a pair with NULLs in case no false dep is introduced.
Definition at line 202 of file MachineInstrDDG.cc.
References assert, BoostGraph< MIDDGNode, MIDDGEdge >::hasPath(), lastPhysRegDefiners_, lastPhysRegUsers_, lastVregUser(), MIDDGNode::sequentialAddress(), and vregDefiner().
Referenced by assignPhysReg(), and falseDepHeightDelta().
TCEString MachineInstrDDG::dotString | ( | ) | const |
Definition at line 370 of file MachineInstrDDG.cc.
References definers_, MIDDGNode::dotString(), MIDDGEdge::dotString(), BoostGraph< MIDDGNode, MIDDGEdge >::edge(), BoostGraph< MIDDGNode, MIDDGEdge >::edgeCount(), BoostGraph< MIDDGNode, MIDDGEdge >::headNode(), BoostGraph< MIDDGNode, MIDDGEdge >::isInCriticalPath(), largestCycle_, BoostGraph< MIDDGNode, MIDDGEdge >::name(), BoostGraph< MIDDGNode, MIDDGEdge >::node(), BoostGraph< MIDDGNode, MIDDGEdge >::nodeCount(), GraphNode::nodeID(), MIDDGNode::optimalCycle(), MIDDGNode::osalOperationName(), printOnlyCriticalPath_, schedule_, smallestCycle_, and BoostGraph< MIDDGNode, MIDDGEdge >::tailNode().
Returns the "height delta" of an antidep edge created in case the given virtual register is assigned the given physical register.
Height delta is the difference between the DDG height of the source definer node and the DDG height of the latest read node of the physReg. The direction of the introduced false dep edge is determined from the sequential instruction order, direction is assumed to be from the earlier instruction to the later. Thus, an edge with 0 or greater height dep potentially constraints the schedule by potentially heightening the DDG. However, this is not generally the case in case the critical path length is not increased by the assignment.
vreg | The virtual register to test. |
physReg | The physical register assigment to test. |
Definition at line 281 of file MachineInstrDDG.cc.
References createFalseDepEdge(), and BoostGraph< MIDDGNode, MIDDGEdge >::maxSourceDistance().
Definition at line 297 of file MachineInstrDDG.cc.
References BoostGraph< MIDDGNode, MIDDGEdge >::node(), MIDDGNode::sequentialAddress(), and users_.
Referenced by assignPhysReg(), and createFalseDepEdge().
bool MachineInstrDDG::preceedingNodeUsesOrDefinesReg | ( | const MIDDGNode & | node, |
Register | physReg | ||
) | const |
Checks if there is at least one preceeding node to the given node that defines or uses the given physical register.
Also the uses in the same node are considered.
Definition at line 322 of file MachineInstrDDG.cc.
References MIDDGNode::machineInstr(), BoostGraph< MIDDGNode, MIDDGEdge >::node(), BoostGraph< MIDDGNode, MIDDGEdge >::predecessors(), regAssignments_, and regInfo_.
|
inline |
Definition at line 170 of file MachineInstrDDG.hh.
References printOnlyCriticalPath_.
Referenced by InstructionPatternAnalyzer::runOnMachineFunction().
Definition at line 156 of file MachineInstrDDG.hh.
References definers_.
Referenced by assignPhysReg(), createFalseDepEdge(), and VirtRegIndependenceGraph::VirtRegIndependenceGraph().
|
private |
Definition at line 181 of file MachineInstrDDG.hh.
Referenced by allRegisters(), and MachineInstrDDG().
|
mutableprivate |
Definition at line 183 of file MachineInstrDDG.hh.
Referenced by dotString(), MachineInstrDDG(), and vregDefiner().
|
private |
Definition at line 187 of file MachineInstrDDG.hh.
Referenced by assignPhysReg(), and MachineInstrDDG().
|
private |
Definition at line 197 of file MachineInstrDDG.hh.
Referenced by computeOptimalSchedule(), and dotString().
Definition at line 189 of file MachineInstrDDG.hh.
Referenced by assignPhysReg(), and createFalseDepEdge().
Definition at line 188 of file MachineInstrDDG.hh.
Referenced by assignPhysReg(), and createFalseDepEdge().
|
private |
Definition at line 200 of file MachineInstrDDG.hh.
|
private |
Definition at line 186 of file MachineInstrDDG.hh.
Referenced by MachineInstrDDG().
|
private |
Definition at line 193 of file MachineInstrDDG.hh.
|
private |
Definition at line 203 of file MachineInstrDDG.hh.
Referenced by dotString(), and setPrintOnlyCriticalPath().
|
private |
Definition at line 190 of file MachineInstrDDG.hh.
Referenced by assignPhysReg(), and preceedingNodeUsesOrDefinesReg().
|
private |
Definition at line 201 of file MachineInstrDDG.hh.
Referenced by preceedingNodeUsesOrDefinesReg().
|
mutableprivate |
Definition at line 198 of file MachineInstrDDG.hh.
Referenced by computeOptimalSchedule(), and dotString().
|
private |
Definition at line 196 of file MachineInstrDDG.hh.
Referenced by computeOptimalSchedule(), and dotString().
|
mutableprivate |
Definition at line 184 of file MachineInstrDDG.hh.
Referenced by lastVregUser(), and MachineInstrDDG().