2004-03-01 02:50:57 +00:00
|
|
|
//===-- MSchedGraph.h - Scheduling Graph ------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2005-03-23 01:47:20 +00:00
|
|
|
// A graph class for dependencies. This graph only contains true, anti, and
|
|
|
|
// output data dependencies for a given MachineBasicBlock. Dependencies
|
|
|
|
// across iterations are also computed. Unless data dependence analysis
|
|
|
|
// is provided, a conservative approach of adding dependencies between all
|
|
|
|
// loads and stores is taken.
|
2004-03-01 02:50:57 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_MSCHEDGRAPH_H
|
|
|
|
#define LLVM_MSCHEDGRAPH_H
|
2005-03-29 20:35:10 +00:00
|
|
|
#include "DependenceAnalyzer.h"
|
2005-03-23 01:47:20 +00:00
|
|
|
#include "llvm/Analysis/AliasAnalysis.h"
|
2004-03-01 02:50:57 +00:00
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2005-03-23 01:47:20 +00:00
|
|
|
#include "llvm/Target/TargetData.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/ADT/GraphTraits.h"
|
|
|
|
#include "llvm/ADT/STLExtras.h"
|
|
|
|
#include "llvm/ADT/iterator"
|
2004-03-01 02:50:57 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llvm {
|
2005-03-23 01:47:20 +00:00
|
|
|
|
2004-03-01 02:50:57 +00:00
|
|
|
class MSchedGraph;
|
|
|
|
class MSchedGraphNode;
|
|
|
|
template<class IteratorType, class NodeType>
|
|
|
|
class MSchedGraphNodeIterator;
|
|
|
|
|
2005-03-23 01:47:20 +00:00
|
|
|
//MSchedGraphEdge encapsulates the data dependence between nodes. It
|
|
|
|
//identifies the dependence type, on what, and the iteration
|
|
|
|
//difference
|
2004-03-01 02:50:57 +00:00
|
|
|
struct MSchedGraphEdge {
|
|
|
|
enum DataDepOrderType {
|
|
|
|
TrueDep, AntiDep, OutputDep, NonDataDep
|
|
|
|
};
|
|
|
|
|
|
|
|
enum MSchedGraphEdgeType {
|
2005-03-23 01:47:20 +00:00
|
|
|
MemoryDep, ValueDep, MachineRegister, BranchDep
|
2004-03-01 02:50:57 +00:00
|
|
|
};
|
|
|
|
|
2005-03-23 01:47:20 +00:00
|
|
|
//Get or set edge data
|
2004-03-01 02:50:57 +00:00
|
|
|
MSchedGraphNode *getDest() const { return dest; }
|
|
|
|
unsigned getIteDiff() { return iteDiff; }
|
|
|
|
unsigned getDepOrderType() { return depOrderType; }
|
2005-02-10 17:02:58 +00:00
|
|
|
void setDest(MSchedGraphNode *newDest) { dest = newDest; }
|
2004-03-01 02:50:57 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class MSchedGraphNode;
|
|
|
|
MSchedGraphEdge(MSchedGraphNode *destination, MSchedGraphEdgeType type,
|
|
|
|
unsigned deptype, unsigned diff)
|
|
|
|
: dest(destination), depType(type), depOrderType(deptype), iteDiff(diff) {}
|
|
|
|
|
|
|
|
MSchedGraphNode *dest;
|
|
|
|
MSchedGraphEdgeType depType;
|
|
|
|
unsigned depOrderType;
|
|
|
|
unsigned iteDiff;
|
|
|
|
};
|
|
|
|
|
2005-03-23 01:47:20 +00:00
|
|
|
//MSchedGraphNode represents a machine instruction and its
|
|
|
|
//corresponding latency. Each node also contains a list of its
|
|
|
|
//predecessors and sucessors.
|
2004-03-01 02:50:57 +00:00
|
|
|
class MSchedGraphNode {
|
|
|
|
|
|
|
|
const MachineInstr* Inst; //Machine Instruction
|
|
|
|
MSchedGraph* Parent; //Graph this node belongs to
|
2004-11-28 23:36:15 +00:00
|
|
|
unsigned index; //Index in BB
|
2004-03-01 02:50:57 +00:00
|
|
|
unsigned latency; //Latency of Instruction
|
2004-05-26 06:27:18 +00:00
|
|
|
bool isBranchInstr; //Is this node the branch instr or not
|
2004-11-28 23:36:15 +00:00
|
|
|
|
2004-03-01 02:50:57 +00:00
|
|
|
std::vector<MSchedGraphNode*> Predecessors; //Predecessor Nodes
|
2005-03-23 01:47:20 +00:00
|
|
|
std::vector<MSchedGraphEdge> Successors; //Successor edges
|
2004-03-01 02:50:57 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
MSchedGraphNode(const MachineInstr *inst, MSchedGraph *graph,
|
2004-11-28 23:36:15 +00:00
|
|
|
unsigned index, unsigned late=0, bool isBranch=false);
|
2004-03-01 02:50:57 +00:00
|
|
|
|
2005-02-10 17:02:58 +00:00
|
|
|
MSchedGraphNode(const MSchedGraphNode &N);
|
|
|
|
|
2005-03-23 01:47:20 +00:00
|
|
|
//Iterators - Predecessor and Succussor
|
2004-03-01 02:50:57 +00:00
|
|
|
typedef std::vector<MSchedGraphNode*>::iterator pred_iterator;
|
|
|
|
pred_iterator pred_begin() { return Predecessors.begin(); }
|
|
|
|
pred_iterator pred_end() { return Predecessors.end(); }
|
2005-02-10 17:02:58 +00:00
|
|
|
unsigned pred_size() { return Predecessors.size(); }
|
|
|
|
|
2004-03-01 02:50:57 +00:00
|
|
|
typedef std::vector<MSchedGraphNode*>::const_iterator pred_const_iterator;
|
|
|
|
pred_const_iterator pred_begin() const { return Predecessors.begin(); }
|
|
|
|
pred_const_iterator pred_end() const { return Predecessors.end(); }
|
2005-02-10 17:02:58 +00:00
|
|
|
|
2004-03-01 02:50:57 +00:00
|
|
|
typedef MSchedGraphNodeIterator<std::vector<MSchedGraphEdge>::const_iterator,
|
|
|
|
const MSchedGraphNode> succ_const_iterator;
|
|
|
|
succ_const_iterator succ_begin() const;
|
|
|
|
succ_const_iterator succ_end() const;
|
|
|
|
|
|
|
|
typedef MSchedGraphNodeIterator<std::vector<MSchedGraphEdge>::iterator,
|
|
|
|
MSchedGraphNode> succ_iterator;
|
|
|
|
succ_iterator succ_begin();
|
|
|
|
succ_iterator succ_end();
|
2005-02-10 17:02:58 +00:00
|
|
|
unsigned succ_size() { return Successors.size(); }
|
|
|
|
|
2005-03-23 01:47:20 +00:00
|
|
|
//Get or set predecessor nodes, or successor edges
|
2005-02-10 17:02:58 +00:00
|
|
|
void setPredecessor(unsigned index, MSchedGraphNode *dest) {
|
|
|
|
Predecessors[index] = dest;
|
|
|
|
}
|
2005-03-23 01:47:20 +00:00
|
|
|
|
2005-02-10 17:02:58 +00:00
|
|
|
MSchedGraphNode* getPredecessor(unsigned index) {
|
|
|
|
return Predecessors[index];
|
|
|
|
}
|
2005-03-23 01:47:20 +00:00
|
|
|
|
2005-02-10 17:02:58 +00:00
|
|
|
MSchedGraphEdge* getSuccessor(unsigned index) {
|
|
|
|
return &Successors[index];
|
|
|
|
}
|
2005-03-23 01:47:20 +00:00
|
|
|
|
2005-02-10 17:02:58 +00:00
|
|
|
void deleteSuccessor(MSchedGraphNode *node) {
|
|
|
|
for (unsigned i = 0; i != Successors.size(); ++i)
|
|
|
|
if (Successors[i].getDest() == node) {
|
|
|
|
Successors.erase(Successors.begin()+i);
|
|
|
|
node->Predecessors.erase(std::find(node->Predecessors.begin(),
|
|
|
|
node->Predecessors.end(), this));
|
2005-03-23 01:47:20 +00:00
|
|
|
--i; //Decrease index var since we deleted a node
|
2005-02-10 17:02:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-01 02:50:57 +00:00
|
|
|
void addOutEdge(MSchedGraphNode *destination,
|
|
|
|
MSchedGraphEdge::MSchedGraphEdgeType type,
|
|
|
|
unsigned deptype, unsigned diff=0) {
|
|
|
|
Successors.push_back(MSchedGraphEdge(destination, type, deptype,diff));
|
|
|
|
destination->Predecessors.push_back(this);
|
|
|
|
}
|
2005-03-23 01:47:20 +00:00
|
|
|
|
|
|
|
//General methods to get and set data for the node
|
2004-03-01 02:50:57 +00:00
|
|
|
const MachineInstr* getInst() { return Inst; }
|
|
|
|
MSchedGraph* getParent() { return Parent; }
|
|
|
|
bool hasPredecessors() { return (Predecessors.size() > 0); }
|
|
|
|
bool hasSuccessors() { return (Successors.size() > 0); }
|
2004-10-30 00:39:07 +00:00
|
|
|
unsigned getLatency() { return latency; }
|
|
|
|
unsigned getLatency() const { return latency; }
|
2004-11-28 23:36:15 +00:00
|
|
|
unsigned getIndex() { return index; }
|
2005-02-10 17:02:58 +00:00
|
|
|
unsigned getIteDiff(MSchedGraphNode *succ);
|
2004-03-01 02:50:57 +00:00
|
|
|
MSchedGraphEdge getInEdge(MSchedGraphNode *pred);
|
2004-05-08 16:12:10 +00:00
|
|
|
unsigned getInEdgeNum(MSchedGraphNode *pred);
|
|
|
|
bool isSuccessor(MSchedGraphNode *);
|
|
|
|
bool isPredecessor(MSchedGraphNode *);
|
2004-05-26 06:27:18 +00:00
|
|
|
bool isBranch() { return isBranchInstr; }
|
2005-03-23 01:47:20 +00:00
|
|
|
|
2004-03-01 02:50:57 +00:00
|
|
|
//Debug support
|
|
|
|
void print(std::ostream &os) const;
|
2005-02-10 17:02:58 +00:00
|
|
|
void setParent(MSchedGraph *p) { Parent = p; }
|
2004-03-01 02:50:57 +00:00
|
|
|
};
|
|
|
|
|
2005-03-23 01:47:20 +00:00
|
|
|
//Node iterator for graph generation
|
2004-03-01 02:50:57 +00:00
|
|
|
template<class IteratorType, class NodeType>
|
|
|
|
class MSchedGraphNodeIterator : public forward_iterator<NodeType*, ptrdiff_t> {
|
|
|
|
IteratorType I; // std::vector<MSchedGraphEdge>::iterator or const_iterator
|
|
|
|
public:
|
|
|
|
MSchedGraphNodeIterator(IteratorType i) : I(i) {}
|
|
|
|
|
|
|
|
bool operator==(const MSchedGraphNodeIterator RHS) const { return I == RHS.I; }
|
|
|
|
bool operator!=(const MSchedGraphNodeIterator RHS) const { return I != RHS.I; }
|
|
|
|
|
|
|
|
const MSchedGraphNodeIterator &operator=(const MSchedGraphNodeIterator &RHS) {
|
|
|
|
I = RHS.I;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
NodeType* operator*() const {
|
|
|
|
return I->getDest();
|
|
|
|
}
|
|
|
|
NodeType* operator->() const { return operator*(); }
|
|
|
|
|
|
|
|
MSchedGraphNodeIterator& operator++() { // Preincrement
|
|
|
|
++I;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
MSchedGraphNodeIterator operator++(int) { // Postincrement
|
|
|
|
MSchedGraphNodeIterator tmp = *this; ++*this; return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
MSchedGraphEdge &getEdge() {
|
|
|
|
return *I;
|
|
|
|
}
|
|
|
|
const MSchedGraphEdge &getEdge() const {
|
|
|
|
return *I;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
inline MSchedGraphNode::succ_const_iterator MSchedGraphNode::succ_begin() const {
|
|
|
|
return succ_const_iterator(Successors.begin());
|
|
|
|
}
|
|
|
|
inline MSchedGraphNode::succ_const_iterator MSchedGraphNode::succ_end() const {
|
|
|
|
return succ_const_iterator(Successors.end());
|
|
|
|
}
|
|
|
|
inline MSchedGraphNode::succ_iterator MSchedGraphNode::succ_begin() {
|
|
|
|
return succ_iterator(Successors.begin());
|
|
|
|
}
|
|
|
|
inline MSchedGraphNode::succ_iterator MSchedGraphNode::succ_end() {
|
|
|
|
return succ_iterator(Successors.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
// ostream << operator for MSGraphNode class
|
|
|
|
inline std::ostream &operator<<(std::ostream &os,
|
|
|
|
const MSchedGraphNode &node) {
|
|
|
|
node.print(os);
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-10 17:02:58 +00:00
|
|
|
// Provide specializations of GraphTraits to be able to use graph
|
|
|
|
// iterators on the scheduling graph!
|
|
|
|
//
|
|
|
|
template <> struct GraphTraits<MSchedGraphNode*> {
|
|
|
|
typedef MSchedGraphNode NodeType;
|
|
|
|
typedef MSchedGraphNode::succ_iterator ChildIteratorType;
|
|
|
|
|
|
|
|
static inline ChildIteratorType child_begin(NodeType *N) {
|
|
|
|
return N->succ_begin();
|
|
|
|
}
|
|
|
|
static inline ChildIteratorType child_end(NodeType *N) {
|
|
|
|
return N->succ_end();
|
|
|
|
}
|
|
|
|
|
|
|
|
static NodeType *getEntryNode(NodeType* N) { return N; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-03-01 02:50:57 +00:00
|
|
|
|
2005-03-23 01:47:20 +00:00
|
|
|
//Graph class to represent dependence graph
|
2004-03-01 02:50:57 +00:00
|
|
|
class MSchedGraph {
|
|
|
|
|
|
|
|
const MachineBasicBlock *BB; //Machine basic block
|
|
|
|
const TargetMachine &Target; //Target Machine
|
|
|
|
|
|
|
|
//Nodes
|
|
|
|
std::map<const MachineInstr*, MSchedGraphNode*> GraphMap;
|
|
|
|
|
|
|
|
//Add Nodes and Edges to this graph for our BB
|
|
|
|
typedef std::pair<int, MSchedGraphNode*> OpIndexNodePair;
|
2005-03-29 20:35:10 +00:00
|
|
|
void buildNodesAndEdges(AliasAnalysis &AA, TargetData &TD, std::map<const MachineInstr*, unsigned> &ignoreInstrs, DependenceAnalyzer &DA, std::map<MachineInstr*, Instruction*> &machineTollvm);
|
2004-03-01 02:50:57 +00:00
|
|
|
void addValueEdges(std::vector<OpIndexNodePair> &NodesInMap,
|
|
|
|
MSchedGraphNode *node,
|
2005-03-23 01:47:20 +00:00
|
|
|
bool nodeIsUse, bool nodeIsDef, std::vector<const MachineInstr*> &phiInstrs, int diff=0);
|
2004-03-01 02:50:57 +00:00
|
|
|
void addMachRegEdges(std::map<int,
|
|
|
|
std::vector<OpIndexNodePair> >& regNumtoNodeMap);
|
2005-03-29 20:35:10 +00:00
|
|
|
void addMemEdges(const std::vector<MSchedGraphNode*>& memInst, AliasAnalysis &AA, TargetData &TD,
|
|
|
|
DependenceAnalyzer &DA, std::map<MachineInstr*, Instruction*> &machineTollvm);
|
2005-03-23 01:47:20 +00:00
|
|
|
void addBranchEdges();
|
2004-03-01 02:50:57 +00:00
|
|
|
|
|
|
|
public:
|
2005-03-29 20:35:10 +00:00
|
|
|
MSchedGraph(const MachineBasicBlock *bb, const TargetMachine &targ, AliasAnalysis &AA,
|
|
|
|
TargetData &TD, std::map<const MachineInstr*, unsigned> &ignoreInstrs,
|
|
|
|
DependenceAnalyzer &DA, std::map<MachineInstr*, Instruction*> &machineTollvm);
|
2005-03-23 01:47:20 +00:00
|
|
|
|
|
|
|
//Copy constructor with maps to link old nodes to new nodes
|
2005-02-10 17:02:58 +00:00
|
|
|
MSchedGraph(const MSchedGraph &G, std::map<MSchedGraphNode*, MSchedGraphNode*> &newNodes);
|
2005-03-23 01:47:20 +00:00
|
|
|
|
|
|
|
//Deconstructor!
|
2004-03-01 02:50:57 +00:00
|
|
|
~MSchedGraph();
|
|
|
|
|
2005-03-23 01:47:20 +00:00
|
|
|
//Add or delete nodes from the Graph
|
2004-03-01 02:50:57 +00:00
|
|
|
void addNode(const MachineInstr* MI, MSchedGraphNode *node);
|
2005-02-10 17:02:58 +00:00
|
|
|
void deleteNode(MSchedGraphNode *node);
|
|
|
|
|
2004-03-01 02:50:57 +00:00
|
|
|
//iterators
|
|
|
|
typedef std::map<const MachineInstr*, MSchedGraphNode*>::iterator iterator;
|
|
|
|
typedef std::map<const MachineInstr*, MSchedGraphNode*>::const_iterator const_iterator;
|
|
|
|
typedef std::map<const MachineInstr*, MSchedGraphNode*>::reverse_iterator reverse_iterator;
|
|
|
|
iterator find(const MachineInstr* I) { return GraphMap.find(I); }
|
|
|
|
iterator end() { return GraphMap.end(); }
|
|
|
|
iterator begin() { return GraphMap.begin(); }
|
2005-02-10 17:02:58 +00:00
|
|
|
unsigned size() { return GraphMap.size(); }
|
2004-03-01 02:50:57 +00:00
|
|
|
reverse_iterator rbegin() { return GraphMap.rbegin(); }
|
|
|
|
reverse_iterator rend() { return GraphMap.rend(); }
|
2005-03-23 01:47:20 +00:00
|
|
|
|
|
|
|
//Get Target or original machine basic block
|
2004-05-26 06:27:18 +00:00
|
|
|
const TargetMachine* getTarget() { return &Target; }
|
2005-02-10 17:02:58 +00:00
|
|
|
const MachineBasicBlock* getBB() { return BB; }
|
2004-03-01 02:50:57 +00:00
|
|
|
};
|
|
|
|
|
2005-03-23 01:47:20 +00:00
|
|
|
|
2004-03-01 02:50:57 +00:00
|
|
|
|
2005-03-23 01:47:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Provide specializations of GraphTraits to be able to use graph
|
|
|
|
// iterators on the scheduling graph
|
2004-03-01 02:50:57 +00:00
|
|
|
static MSchedGraphNode& getSecond(std::pair<const MachineInstr* const,
|
2005-03-23 01:47:20 +00:00
|
|
|
MSchedGraphNode*> &Pair) {
|
2004-03-01 02:50:57 +00:00
|
|
|
return *Pair.second;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <> struct GraphTraits<MSchedGraph*> {
|
|
|
|
typedef MSchedGraphNode NodeType;
|
|
|
|
typedef MSchedGraphNode::succ_iterator ChildIteratorType;
|
|
|
|
|
|
|
|
static inline ChildIteratorType child_begin(NodeType *N) {
|
|
|
|
return N->succ_begin();
|
|
|
|
}
|
|
|
|
static inline ChildIteratorType child_end(NodeType *N) {
|
|
|
|
return N->succ_end();
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef std::pointer_to_unary_function<std::pair<const MachineInstr* const,
|
|
|
|
MSchedGraphNode*>&, MSchedGraphNode&> DerefFun;
|
|
|
|
|
|
|
|
typedef mapped_iterator<MSchedGraph::iterator, DerefFun> nodes_iterator;
|
|
|
|
static nodes_iterator nodes_begin(MSchedGraph *G) {
|
|
|
|
return map_iterator(((MSchedGraph*)G)->begin(), DerefFun(getSecond));
|
|
|
|
}
|
|
|
|
static nodes_iterator nodes_end(MSchedGraph *G) {
|
|
|
|
return map_iterator(((MSchedGraph*)G)->end(), DerefFun(getSecond));
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
template <> struct GraphTraits<const MSchedGraph*> {
|
|
|
|
typedef const MSchedGraphNode NodeType;
|
|
|
|
typedef MSchedGraphNode::succ_const_iterator ChildIteratorType;
|
2005-02-10 17:02:58 +00:00
|
|
|
|
2004-03-01 02:50:57 +00:00
|
|
|
static inline ChildIteratorType child_begin(NodeType *N) {
|
|
|
|
return N->succ_begin();
|
|
|
|
}
|
|
|
|
static inline ChildIteratorType child_end(NodeType *N) {
|
|
|
|
return N->succ_end();
|
|
|
|
}
|
|
|
|
typedef std::pointer_to_unary_function<std::pair<const MachineInstr* const,
|
|
|
|
MSchedGraphNode*>&, MSchedGraphNode&> DerefFun;
|
|
|
|
|
|
|
|
typedef mapped_iterator<MSchedGraph::iterator, DerefFun> nodes_iterator;
|
|
|
|
static nodes_iterator nodes_begin(MSchedGraph *G) {
|
|
|
|
return map_iterator(((MSchedGraph*)G)->begin(), DerefFun(getSecond));
|
|
|
|
}
|
|
|
|
static nodes_iterator nodes_end(MSchedGraph *G) {
|
|
|
|
return map_iterator(((MSchedGraph*)G)->end(), DerefFun(getSecond));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <> struct GraphTraits<Inverse<MSchedGraph*> > {
|
|
|
|
typedef MSchedGraphNode NodeType;
|
|
|
|
typedef MSchedGraphNode::pred_iterator ChildIteratorType;
|
|
|
|
|
|
|
|
static inline ChildIteratorType child_begin(NodeType *N) {
|
|
|
|
return N->pred_begin();
|
|
|
|
}
|
|
|
|
static inline ChildIteratorType child_end(NodeType *N) {
|
|
|
|
return N->pred_end();
|
|
|
|
}
|
|
|
|
typedef std::pointer_to_unary_function<std::pair<const MachineInstr* const,
|
|
|
|
MSchedGraphNode*>&, MSchedGraphNode&> DerefFun;
|
|
|
|
|
|
|
|
typedef mapped_iterator<MSchedGraph::iterator, DerefFun> nodes_iterator;
|
|
|
|
static nodes_iterator nodes_begin(MSchedGraph *G) {
|
|
|
|
return map_iterator(((MSchedGraph*)G)->begin(), DerefFun(getSecond));
|
|
|
|
}
|
|
|
|
static nodes_iterator nodes_end(MSchedGraph *G) {
|
|
|
|
return map_iterator(((MSchedGraph*)G)->end(), DerefFun(getSecond));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <> struct GraphTraits<Inverse<const MSchedGraph*> > {
|
|
|
|
typedef const MSchedGraphNode NodeType;
|
|
|
|
typedef MSchedGraphNode::pred_const_iterator ChildIteratorType;
|
|
|
|
|
|
|
|
static inline ChildIteratorType child_begin(NodeType *N) {
|
|
|
|
return N->pred_begin();
|
|
|
|
}
|
|
|
|
static inline ChildIteratorType child_end(NodeType *N) {
|
|
|
|
return N->pred_end();
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef std::pointer_to_unary_function<std::pair<const MachineInstr* const,
|
|
|
|
MSchedGraphNode*>&, MSchedGraphNode&> DerefFun;
|
|
|
|
|
|
|
|
typedef mapped_iterator<MSchedGraph::iterator, DerefFun> nodes_iterator;
|
|
|
|
static nodes_iterator nodes_begin(MSchedGraph *G) {
|
|
|
|
return map_iterator(((MSchedGraph*)G)->begin(), DerefFun(getSecond));
|
|
|
|
}
|
|
|
|
static nodes_iterator nodes_end(MSchedGraph *G) {
|
|
|
|
return map_iterator(((MSchedGraph*)G)->end(), DerefFun(getSecond));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|