Skip to content
Snippets Groups Projects
Commit 2c127f57 authored by Prakalp Srivastava's avatar Prakalp Srivastava
Browse files

refactored BuildDFG code. Now just addEdgeToDFGraph should be enough to make...

refactored BuildDFG code. Now just addEdgeToDFGraph should be enough to make all the successor and predecessor changes to nodes
parent e318c05c
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,6 @@ class DFTreeTraversal;
class DFEdgeVisitor;
class DFGraph;
//template<> struct GraphTraits
class DFGraph {
......@@ -282,6 +281,9 @@ public:
};
/*****************************************************
* DFInternalNode class implementation
*****************************************************/
class DFInternalNode : public DFNode {
private:
......@@ -315,10 +317,8 @@ public:
childGraph->addChildDFNode(N);
}
void addEdgeToDFGraph(DFEdge* E) {
childGraph->addDFEdge(E);
}
void addEdgeToDFGraph(DFEdge* E);
DFGraph* getChildGraph() {
return childGraph;
}
......@@ -327,6 +327,9 @@ public:
// void applyDFEdgeVisitor(DFEdgeVisitor &V); /*virtual*/
};
/*****************************************************
* DFLeafNode class implementation
*****************************************************/
class DFLeafNode : public DFNode {
private:
......@@ -424,6 +427,26 @@ public:
};
//===--------------------- DFInternalNode Outlined Functions --------------===//
void DFInternalNode::addEdgeToDFGraph(DFEdge* E) {
DFNode* S = E->getSourceDF();
DFNode* D = E->getDestDF();
assert(std::find(childGraph->begin(), childGraph->end(), S)!=childGraph->end()
&& "Source node not found in child dataflow graph!");
assert(std::find(childGraph->begin(), childGraph->end(), D)!=childGraph->end()
&& "Destination node not found in child dataflow graph!");
// Update Graph
childGraph->addDFEdge(E);
// Update source and destination nodes
S->addSuccessor(D);
S->addOutDFEdge(E);
D->addInDFEdge(E);
}
//===-------------------------- Visitor Classes ---------------------------===//
// Visitor for DFNode objects
......@@ -483,51 +506,12 @@ class DFEdgeVisitor {
public:
virtual void visit(DFEdge* E) = 0;
};
*/
//===--------------------------------------------------------------------===//
// GraphTraits specializations for DFNode graph (DFG)
//===--------------------------------------------------------------------===//
// Provide specializations of GraphTraits to be able to treat a DFNode as a
// graph of DFNodes...struct GraphTraits {
// Elements to provide:
// typedef NodeType - Type of Node in the graph
// typedef ChildIteratorType - Type used to iterate over children in graph
// static NodeType *getEntryNode(const GraphType &)
// Return the entry node of the graph
// static ChildIteratorType child_begin(NodeType *)
// static ChildIteratorType child_end (NodeType *)
// Return iterators that point to the beginning and ending of the child
// node list for the specified node.
//
// typedef ...iterator nodes_iterator;
// static nodes_iterator nodes_begin(GraphType *G)
// static nodes_iterator nodes_end (GraphType *G)
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
// static unsigned size (GraphType *G)
// Return total number of nodes in the graph
//
// If anyone tries to use this class without having an appropriate
// specialization, make an error. If you get this error, it's because you
// need to include the appropriate specialization of GraphTraits<> for your
// graph, or you need to define it for a new graph type. Either that or
// your argument to XXX_begin(...) is unknown or needs to have the proper .h
// file #include'd.
//
typedef typename GraphType::UnknownGraphTypeError NodeType;
//};
*/
template <> struct GraphTraits<DFNode*> {
typedef DFNode NodeType;
typedef typename DFNode::successor_iterator ChildIteratorType;
......@@ -580,15 +564,11 @@ struct DOTGraphTraits<DFGraph*> : public DefaultDOTGraphTraits {
}
};
void viewDFGraph(DFGraph *G) {
llvm::WriteGraph(G, "DataflowGrpah");
llvm::ViewGraph(G, "DataflowGraph");
}
} // End llvm namespace
#endif
......@@ -88,46 +88,34 @@ namespace builddfg {
// Returns true if instruction I is a visc launch intrinsic, false otherwise
bool BuildDFG::isViscLaunchIntrinsic(Instruction* I) {
if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(I)) {
if (((II->getCalledFunction()->getName()).equals("llvm.visc.launch"))) {
// It is a visc launch intrinsic
return true;
}
}
return false;
if(!isa<IntrinsicInst>(I))
return false;
IntrinsicInst* II = cast<IntrinsicInst>(I);
return (II->getCalledFunction()->getName()).equals("llvm.visc.launch");
}
// Returns true if instruction I is a visc graph intrinsic, false otherwise
bool BuildDFG::isViscGraphIntrinsic(Instruction* I) {
if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(I)) {
if (((II->getCalledFunction()->getName()).startswith("llvm.visc.create"))) {
// It is a visc graph intrinsic
return true;
}
}
return false;
if(!isa<IntrinsicInst>(I))
return false;
IntrinsicInst* II = cast<IntrinsicInst>(I);
return (II->getCalledFunction()->getName()).startswith("llvm.visc.create");
}
// Returns true if instruction I is a visc query intrinsic, false otherwise
bool BuildDFG::isViscQueryIntrinsic(Instruction* I) {
if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(I)) {
if (((II->getCalledFunction()->getName()).startswith("llvm.visc.get"))) {
// It is a visc query intrinsic
return true;
}
}
return false;
if(!isa<IntrinsicInst>(I))
return false;
IntrinsicInst* II = cast<IntrinsicInst>(I);
return (II->getCalledFunction()->getName()).startswith("llvm.visc.get");
}
// Returns true if instruction I is a visc intrinsic, false otherwise
bool BuildDFG::isViscIntrinsic(Instruction* I) {
if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(I)) {
if (((II->getCalledFunction()->getName()).startswith("llvm.visc"))) {
// It is a visc query intrinsic
return true;
}
}
return false;
if(!isa<IntrinsicInst>(I))
return false;
IntrinsicInst* II = cast<IntrinsicInst>(I);
return (II->getCalledFunction()->getName()).startswith("llvm.visc");
}
// Two types are "congruent" if they are identical, or if they are both
......@@ -233,14 +221,8 @@ namespace builddfg {
HandleToDFEdgeMap[II] = newDFEdge;
// Update parent node
// Add Edge to the dataflow graph associated with the parent node
N->addEdgeToDFGraph(newDFEdge);
// Update source and destination nodes
SrcDF->addSuccessor(DestDF);
SrcDF->addOutDFEdge(newDFEdge);
DestDF->addInDFEdge(newDFEdge);
}
void BuildDFG::BuildGraph (DFInternalNode* N, Function *F) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment