OpenADFortTk (including Open64 and OpenAnalysis references)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
RIFG.cpp
Go to the documentation of this file.
1 
23 //************************** System Include Files ***************************
24 
25 #ifdef NO_STD_CHEADERS
26 # include <assert.h>
27 # include <limits.h>
28 #else
29 # include <cassert>
30 # include <climits>
31 #endif
32 
33 #include <inttypes.h>
34 
35 //*************************** User Include Files ****************************
36 
39 
40 //*************************** Forward Declarations **************************
41 
42 //***************************************************************************
43 
44 //***************************************************************************
45 // Representation Independent Flowgraph
46 //***************************************************************************
47 
48 namespace OA {
49 
50 unsigned int RIFG::NIL = 0;
51 
55  : graph(graph_), mSource(source), mSink(sink)
56 {
57  // Sanity check
58  assert(graph->getNumNodes() <= UINT_MAX);
59  assert(graph->getNumEdges() <= UINT_MAX);
60 
61  // Initialize the node-id to node map: ids are 1...num_nodes
65  for (NodeId i = 1; it1->isValid(); ++(*it1), ++i) {
67  node_to_id_map[node] = i;
68  id_to_node_map[i] = node;
69  }
70 
71  // Initialize the edge-id to edge map: ids are 1...num_edges
75  for (NodeId i = 1; it2->isValid(); ++(*it2), ++i) {
77  edge_to_id_map[edge] = i;
78  id_to_edge_map[i] = edge;
79  }
80 }
81 
82 
84 {
85  node_to_id_map.clear();
86  id_to_node_map.clear();
87  edge_to_id_map.clear();
88  id_to_edge_map.clear();
89 }
90 
91 
92 bool
94 {
95  return true;
96 }
97 
98 
101 {
102  return (getNodeId(mSource));
103 }
104 
105 
108 {
109  return (getNodeId(mSink));
110 }
111 
114 {
117  return (getNodeId(n));
118 }
119 
120 
123 {
126  return (getNodeId(n));
127 }
128 
129 
132 {
134  it = new NodesIterator(*this);
135  return it;
136 }
137 
138 
141 {
143  it = new IncomingEdgesIterator(*this, nid);
144  return it;
145 }
146 
147 
150 {
152  it = new OutgoingEdgesIterator(*this, nid);
153  return it;
154 }
155 
156 
157 void
158 RIFG::dumpNode(std::ostream& os, RIFG::NodeId nid)
159 {
160  // getNode(nid)->dump(os);
161 }
162 
163 
164 //***************************************************************************
165 //
166 //***************************************************************************
167 
170 {
171  if (graph.isa<OA::CFG::CFGInterface>()) {
174  return n;
175  }
176  else {
178  graph->getEntryNodesIterator();
179  assert(it->isValid());
180  OA_ptr<DGraph::NodeInterface> n = it->current();
181  return n;
182  }
183 }
184 
187 {
188  if (graph.isa<OA::CFG::CFGInterface>()) {
191  return n;
192  }
193  else {
195  graph->getExitNodesIterator();
196  assert(it->isValid());
197  OA_ptr<DGraph::NodeInterface> n = it->current();
198  return n;
199  }
200 }
201 
202 } // end of namespace OA
203