192 friend class VMStructs;
193
194 // Lots of restrictions on cloning Nodes
195 Node(const Node&); // not defined; linker error to use these
196 Node &operator=(const Node &rhs);
197
198 public:
199 friend class Compile;
200 #if OPTO_DU_ITERATOR_ASSERT
201 friend class DUIterator_Common;
202 friend class DUIterator;
203 friend class DUIterator_Fast;
204 friend class DUIterator_Last;
205 #endif
206
207 // Because Nodes come and go, I define an Arena of Node structures to pull
208 // from. This should allow fast access to node creation & deletion. This
209 // field is a local cache of a value defined in some "program fragment" for
210 // which these Nodes are just a part of.
211
212 // New Operator that takes a Compile pointer, this will eventually
213 // be the "new" New operator.
214 inline void* operator new( size_t x, Compile* C) throw() {
215 Node* n = (Node*)C->node_arena()->Amalloc_D(x);
216 #ifdef ASSERT
217 n->_in = (Node**)n; // magic cookie for assertion check
218 #endif
219 n->_out = (Node**)C;
220 return (void*)n;
221 }
222
223 // Delete is a NOP
224 void operator delete( void *ptr ) {}
225 // Fancy destructor; eagerly attempt to reclaim Node numberings and storage
226 void destruct();
227
228 // Create a new Node. Required is the number is of inputs required for
229 // semantic correctness.
230 Node( uint required );
231
232 // Create a new Node with given input edges.
233 // This version requires use of the "edge-count" new.
234 // E.g. new (C,3) FooNode( C, NULL, left, right );
235 Node( Node *n0 );
236 Node( Node *n0, Node *n1 );
237 Node( Node *n0, Node *n1, Node *n2 );
238 Node( Node *n0, Node *n1, Node *n2, Node *n3 );
239 Node( Node *n0, Node *n1, Node *n2, Node *n3, Node *n4 );
243
244 // Clone an inherited Node given only the base Node type.
245 Node* clone() const;
246
247 // Clone a Node, immediately supplying one or two new edges.
248 // The first and second arguments, if non-null, replace in(1) and in(2),
249 // respectively.
250 Node* clone_with_data_edge(Node* in1, Node* in2 = NULL) const {
251 Node* nn = clone();
252 if (in1 != NULL) nn->set_req(1, in1);
253 if (in2 != NULL) nn->set_req(2, in2);
254 return nn;
255 }
256
257 private:
258 // Shared setup for the above constructors.
259 // Handles all interactions with Compile::current.
260 // Puts initial values in all Node fields except _idx.
261 // Returns the initial value for _idx, which cannot
262 // be initialized by assignment.
263 inline int Init(int req, Compile* C);
264
265 //----------------- input edge handling
266 protected:
267 friend class PhaseCFG; // Access to address of _in array elements
268 Node **_in; // Array of use-def references to Nodes
269 Node **_out; // Array of def-use references to Nodes
270
271 // Input edges are split into two categories. Required edges are required
272 // for semantic correctness; order is important and NULLs are allowed.
273 // Precedence edges are used to help determine execution order and are
274 // added, e.g., for scheduling purposes. They are unordered and not
275 // duplicated; they have no embedded NULLs. Edges from 0 to _cnt-1
276 // are required, from _cnt to _max-1 are precedence edges.
277 node_idx_t _cnt; // Total number of required Node inputs.
278
279 node_idx_t _max; // Actual length of input array.
280
281 // Output edges are an unordered list of def-use edges which exactly
282 // correspond to required input edges which point from other nodes
283 // to this one. Thus the count of the output edges is the number of
|
192 friend class VMStructs;
193
194 // Lots of restrictions on cloning Nodes
195 Node(const Node&); // not defined; linker error to use these
196 Node &operator=(const Node &rhs);
197
198 public:
199 friend class Compile;
200 #if OPTO_DU_ITERATOR_ASSERT
201 friend class DUIterator_Common;
202 friend class DUIterator;
203 friend class DUIterator_Fast;
204 friend class DUIterator_Last;
205 #endif
206
207 // Because Nodes come and go, I define an Arena of Node structures to pull
208 // from. This should allow fast access to node creation & deletion. This
209 // field is a local cache of a value defined in some "program fragment" for
210 // which these Nodes are just a part of.
211
212 inline void* operator new(size_t x) throw() {
213 Compile* C = Compile::current();
214 Node* n = (Node*)C->node_arena()->Amalloc_D(x);
215 #ifdef ASSERT
216 n->_in = (Node**)n; // magic cookie for assertion check
217 #endif
218 return (void*)n;
219 }
220
221 // Delete is a NOP
222 void operator delete( void *ptr ) {}
223 // Fancy destructor; eagerly attempt to reclaim Node numberings and storage
224 void destruct();
225
226 // Create a new Node. Required is the number is of inputs required for
227 // semantic correctness.
228 Node( uint required );
229
230 // Create a new Node with given input edges.
231 // This version requires use of the "edge-count" new.
232 // E.g. new (C,3) FooNode( C, NULL, left, right );
233 Node( Node *n0 );
234 Node( Node *n0, Node *n1 );
235 Node( Node *n0, Node *n1, Node *n2 );
236 Node( Node *n0, Node *n1, Node *n2, Node *n3 );
237 Node( Node *n0, Node *n1, Node *n2, Node *n3, Node *n4 );
241
242 // Clone an inherited Node given only the base Node type.
243 Node* clone() const;
244
245 // Clone a Node, immediately supplying one or two new edges.
246 // The first and second arguments, if non-null, replace in(1) and in(2),
247 // respectively.
248 Node* clone_with_data_edge(Node* in1, Node* in2 = NULL) const {
249 Node* nn = clone();
250 if (in1 != NULL) nn->set_req(1, in1);
251 if (in2 != NULL) nn->set_req(2, in2);
252 return nn;
253 }
254
255 private:
256 // Shared setup for the above constructors.
257 // Handles all interactions with Compile::current.
258 // Puts initial values in all Node fields except _idx.
259 // Returns the initial value for _idx, which cannot
260 // be initialized by assignment.
261 inline int Init(int req);
262
263 //----------------- input edge handling
264 protected:
265 friend class PhaseCFG; // Access to address of _in array elements
266 Node **_in; // Array of use-def references to Nodes
267 Node **_out; // Array of def-use references to Nodes
268
269 // Input edges are split into two categories. Required edges are required
270 // for semantic correctness; order is important and NULLs are allowed.
271 // Precedence edges are used to help determine execution order and are
272 // added, e.g., for scheduling purposes. They are unordered and not
273 // duplicated; they have no embedded NULLs. Edges from 0 to _cnt-1
274 // are required, from _cnt to _max-1 are precedence edges.
275 node_idx_t _cnt; // Total number of required Node inputs.
276
277 node_idx_t _max; // Actual length of input array.
278
279 // Output edges are an unordered list of def-use edges which exactly
280 // correspond to required input edges which point from other nodes
281 // to this one. Thus the count of the output edges is the number of
|