mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-23 20:44:51 +00:00
[GraphWriter] Change GraphWriter to use NodeRef in GraphTraits
Summary: This is part of the "NodeType* -> NodeRef" migration. Notice that since GraphWriter prints object address as identity, I added a static_assert on NodeRef to be a pointer type. Reviewers: dblaikie Subscribers: llvm-commits, MatzeB Differential Revision: https://reviews.llvm.org/D23580 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278966 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4da2d32371
commit
172174fbd3
@ -680,6 +680,7 @@ namespace llvm {
|
||||
|
||||
template <> struct GraphTraits<SUnit*> {
|
||||
typedef SUnit NodeType;
|
||||
typedef SUnit *NodeRef;
|
||||
typedef SUnitIterator ChildIteratorType;
|
||||
static inline NodeType *getEntryNode(SUnit *N) { return N; }
|
||||
static inline ChildIteratorType child_begin(NodeType *N) {
|
||||
|
@ -2056,6 +2056,7 @@ public:
|
||||
|
||||
template <> struct GraphTraits<SDNode*> {
|
||||
typedef SDNode NodeType;
|
||||
typedef SDNode *NodeRef;
|
||||
typedef SDNodeIterator ChildIteratorType;
|
||||
static inline NodeType *getEntryNode(SDNode *N) { return N; }
|
||||
static inline ChildIteratorType child_begin(NodeType *N) {
|
||||
|
@ -59,14 +59,19 @@ class GraphWriter {
|
||||
|
||||
typedef DOTGraphTraits<GraphType> DOTTraits;
|
||||
typedef GraphTraits<GraphType> GTraits;
|
||||
typedef typename GTraits::NodeType NodeType;
|
||||
typedef typename GTraits::NodeRef NodeRef;
|
||||
typedef typename GTraits::nodes_iterator node_iterator;
|
||||
typedef typename GTraits::ChildIteratorType child_iterator;
|
||||
DOTTraits DTraits;
|
||||
|
||||
static_assert(std::is_pointer<NodeRef>::value,
|
||||
"FIXME: Currently GraphWriter requires the NodeRef type to be "
|
||||
"a pointer.\nThe pointer usage should be moved to "
|
||||
"DOTGraphTraits, and removed from GraphWriter itself.");
|
||||
|
||||
// Writes the edge labels of the node to O and returns true if there are any
|
||||
// edge labels not equal to the empty string "".
|
||||
bool getEdgeSourceLabels(raw_ostream &O, NodeType *Node) {
|
||||
bool getEdgeSourceLabels(raw_ostream &O, NodeRef Node) {
|
||||
child_iterator EI = GTraits::child_begin(Node);
|
||||
child_iterator EE = GTraits::child_end(Node);
|
||||
bool hasEdgeSourceLabels = false;
|
||||
@ -140,31 +145,23 @@ public:
|
||||
// Loop over the graph, printing it out...
|
||||
for (node_iterator I = GTraits::nodes_begin(G), E = GTraits::nodes_end(G);
|
||||
I != E; ++I)
|
||||
if (!isNodeHidden(*I))
|
||||
writeNode(*I);
|
||||
if (!isNodeHidden(&*I))
|
||||
writeNode(&*I);
|
||||
}
|
||||
|
||||
bool isNodeHidden(NodeType &Node) {
|
||||
return isNodeHidden(&Node);
|
||||
}
|
||||
|
||||
bool isNodeHidden(NodeType *const *Node) {
|
||||
bool isNodeHidden(NodeRef const *Node) {
|
||||
return isNodeHidden(*Node);
|
||||
}
|
||||
|
||||
bool isNodeHidden(NodeType *Node) {
|
||||
bool isNodeHidden(NodeRef Node) {
|
||||
return DTraits.isNodeHidden(Node);
|
||||
}
|
||||
|
||||
void writeNode(NodeType& Node) {
|
||||
writeNode(&Node);
|
||||
}
|
||||
|
||||
void writeNode(NodeType *const *Node) {
|
||||
void writeNode(NodeRef const *Node) {
|
||||
writeNode(*Node);
|
||||
}
|
||||
|
||||
void writeNode(NodeType *Node) {
|
||||
void writeNode(NodeRef Node) {
|
||||
std::string NodeAttributes = DTraits.getNodeAttributes(Node, G);
|
||||
|
||||
O << "\tNode" << static_cast<const void*>(Node) << " [shape=record,";
|
||||
@ -237,8 +234,8 @@ public:
|
||||
writeEdge(Node, 64, EI);
|
||||
}
|
||||
|
||||
void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) {
|
||||
if (NodeType *TargetNode = *EI) {
|
||||
void writeEdge(NodeRef Node, unsigned edgeidx, child_iterator EI) {
|
||||
if (NodeRef TargetNode = *EI) {
|
||||
int DestPort = -1;
|
||||
if (DTraits.edgeTargetsEdgeSource(Node, EI)) {
|
||||
child_iterator TargetIt = DTraits.getEdgeTarget(Node, EI);
|
||||
|
@ -61,6 +61,7 @@ namespace llvm {
|
||||
template <>
|
||||
struct GraphTraits<BlockFrequencyInfo *> {
|
||||
typedef const BasicBlock NodeType;
|
||||
typedef const BasicBlock *NodeRef;
|
||||
typedef succ_const_iterator ChildIteratorType;
|
||||
typedef Function::const_iterator nodes_iterator;
|
||||
|
||||
|
@ -53,6 +53,7 @@ namespace llvm {
|
||||
|
||||
template <> struct GraphTraits<MachineBlockFrequencyInfo *> {
|
||||
typedef const MachineBasicBlock NodeType;
|
||||
typedef const MachineBasicBlock *NodeRef;
|
||||
typedef MachineBasicBlock::const_succ_iterator ChildIteratorType;
|
||||
typedef MachineFunction::const_iterator nodes_iterator;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user