ba1f4dc01bb727a12df703c795fc7607f5095edd
[libfirm] / ir / ir / irnode.c
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irnode.c
4  * Purpose:     Representation of an intermediate operation.
5  * Author:      Martin Trapp, Christian Schaefer
6  * Modified by: Goetz Lindenmaier
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1998-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 #ifdef HAVE_CONFIG_H
14 # include <config.h>
15 #endif
16 #include <string.h>
17
18 #include "ident.h"
19 #include "irnode_t.h"
20 #include "irgraph_t.h"
21 #include "irmode_t.h"
22 #include "typegmod.h"
23 #include "array.h"
24 #include "irbackedge_t.h"
25 #include "irdump.h"
26 #include "irflag.h"
27 #include "irop_t.h"
28
29 #include "irprog_t.h"
30
31 /* some constants fixing the positions of nodes predecessors
32    in the in array */
33 #define CALL_PARAM_OFFSET 2
34 #define SEL_INDEX_OFFSET 2
35 #define RETURN_RESULT_OFFSET 1  /* mem is not a result */
36 #define END_KEEPALIVE_OFFSET 0
37
38 /* Declarations for inlineing */
39 INLINE ir_node ** get_irn_in (const ir_node *node);
40 INLINE ir_mode *get_irn_mode (const ir_node *node);
41 INLINE ir_op *get_irn_op (const ir_node *node);
42 INLINE opcode get_irn_opcode (const ir_node *node);
43 INLINE ident *get_irn_opident (const ir_node *node);
44 INLINE type *get_SymConst_type (ir_node *node);
45 INLINE ir_node *skip_nop (ir_node *node);
46 INLINE int is_Proj (const ir_node *node);
47
48
49 static const char *pnc_name_arr [] = {
50   "False", "Eq", "Lt", "Le",
51   "Gt", "Ge", "Lg", "Leg", "Uo",
52   "Ue", "Ul", "Ule", "Ug", "Uge",
53   "Ne", "True"
54 };
55
56 INLINE const char *get_pnc_string(int pnc) {
57   return pnc_name_arr[pnc];
58 }
59
60
61 int
62 get_negated_pnc(int pnc) {
63   switch (pnc) {
64   case False: return True;  break;
65   case Eq:    return Ne;    break;
66   case Lt:    return Uge;   break;
67   case Le:    return Ug;    break;
68   case Gt:    return Ule;   break;
69   case Ge:    return Ul;    break;
70   case Lg:    return Ue;    break;
71   case Leg:   return Uo;    break;
72   case Uo:    return Leg;   break;
73   case Ue:    return Lg;    break;
74   case Ul:    return Ge;    break;
75   case Ule:   return Gt;    break;
76   case Ug:    return Le;    break;
77   case Uge:   return Lt;    break;
78   case Ne:    return Eq;    break;
79   case True:  return False; break;
80   }
81   return 99; /* to shut up gcc */
82 }
83
84 const char *pns_name_arr [] = {
85   "initial_exec", "global_store",
86   "frame_base", "globals", "args"
87 };
88
89 const char *symconst_name_arr [] = {
90   "type_tag", "size", "linkage_ptr_info"
91 };
92
93 void
94 init_irnode (void)
95 {
96 }
97
98 /* irnode constructor                                             */
99 /* create a new irnode in irg, with an op, mode, arity and        */
100 /* some incoming irnodes                                          */
101 /* this constructor is used in every specified irnode constructor */
102 INLINE ir_node *
103 new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mode,
104              int arity, ir_node **in)
105 {
106   ir_node *res;
107   int node_size = offsetof (ir_node, attr) +  op->attr_size;
108
109   res = (ir_node *) obstack_alloc (irg->obst, node_size);
110
111   res->kind = k_ir_node;
112   res->op = op;
113   res->mode = mode;
114   res->visited = 0;
115   res->link = NULL;
116   if (arity < 0) {
117     res->in = NEW_ARR_F (ir_node *, 1);  /* 1: space for block */
118   } else {
119     res->in = NEW_ARR_D (ir_node *, irg->obst, (arity+1));
120     memcpy (&res->in[1], in, sizeof (ir_node *) * arity);
121   }
122   res->in[0] = block;
123   set_irn_dbg_info(res, db);
124   res->out = NULL;
125
126 #ifdef DEBUG_libfirm
127   res->node_nr = get_irp_new_node_nr();
128 #endif
129
130   return res;
131 }
132
133 /* Copies all attributes stored in the old node to the new node.
134    Assumes both have the same opcode and sufficient size. */
135 void
136 copy_attrs (ir_node *old, ir_node *new) {
137   assert (get_irn_op(old) == get_irn_op(new));
138   memcpy (&new->attr, &old->attr, get_op_attr_size(get_irn_op(old)));
139 }
140
141 /** getting some parameters from ir_nodes **/
142
143 int
144 is_ir_node (void *thing) {
145   assert(thing);
146   if (get_kind(thing) == k_ir_node)
147     return 1;
148   else
149     return 0;
150 }
151
152 /* returns the number of predecessors without the block predecessor. */
153 INLINE int
154 get_irn_intra_arity (const ir_node *node) {
155   assert(node);
156   return ARR_LEN(node->in) - 1;
157 }
158
159 /* returns the number of predecessors without the block predecessor. */
160 INLINE int
161 get_irn_inter_arity (const ir_node *node) {
162   assert(node);
163   if (get_irn_opcode(node) == iro_Filter) {
164     assert(node->attr.filter.in_cg);
165     return ARR_LEN(node->attr.filter.in_cg) - 1;
166   } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
167     return ARR_LEN(node->attr.block.in_cg) - 1;
168   }
169   return get_irn_intra_arity(node);
170 }
171
172 /* returns the number of predecessors without the block predecessor. */
173 INLINE int
174 get_irn_arity (const ir_node *node) {
175   assert(node);
176   if (interprocedural_view) return get_irn_inter_arity(node);
177   return get_irn_intra_arity(node);
178 }
179
180 /* Returns the array with ins. This array is shifted with respect to the
181    array accessed by get_irn_n: The block operand is at position 0 not -1.
182    (@@@ This should be changed.)
183    The order of the predecessors in this array is not guaranteed, except that
184    lists of operands as predecessors of Block or arguments of a Call are
185    consecutive. */
186 INLINE ir_node **
187 get_irn_in (const ir_node *node) {
188   assert(node);
189   if (interprocedural_view) { /* handle Filter and Block specially */
190     if (get_irn_opcode(node) == iro_Filter) {
191       assert(node->attr.filter.in_cg);
192       return node->attr.filter.in_cg;
193     } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
194       return node->attr.block.in_cg;
195     }
196     /* else fall through */
197   }
198   return node->in;
199 }
200
201 INLINE void
202 set_irn_in (ir_node *node, int arity, ir_node **in) {
203   ir_node *** arr;
204   assert(node);
205   if (interprocedural_view) { /* handle Filter and Block specially */
206     if (get_irn_opcode(node) == iro_Filter) {
207       assert(node->attr.filter.in_cg);
208       arr = &node->attr.filter.in_cg;
209     } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
210       arr = &node->attr.block.in_cg;
211     } else {
212       arr = &node->in;
213     }
214   } else {
215     arr = &node->in;
216   }
217   if (arity != ARR_LEN(*arr) - 1) {
218     ir_node * block = (*arr)[0];
219     *arr = NEW_ARR_D(ir_node *, current_ir_graph->obst, arity + 1);
220     (*arr)[0] = block;
221   }
222   fix_backedges(current_ir_graph->obst, node);
223   memcpy((*arr) + 1, in, sizeof(ir_node *) * arity);
224 }
225
226 INLINE ir_node *
227 get_irn_intra_n (ir_node *node, int n) {
228   return (node->in[n + 1] = skip_nop(node->in[n + 1]));
229 }
230
231 INLINE ir_node*
232 get_irn_inter_n (ir_node *node, int n) {
233   /* handle Filter and Block specially */
234   if (get_irn_opcode(node) == iro_Filter) {
235     assert(node->attr.filter.in_cg);
236     return (node->attr.filter.in_cg[n + 1] = skip_nop(node->attr.filter.in_cg[n + 1]));
237   } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
238     return (node->attr.block.in_cg[n + 1] = skip_nop(node->attr.block.in_cg[n + 1]));
239   }
240
241   return get_irn_intra_n (node, n);
242 }
243
244 /* to iterate through the predecessors without touching the array */
245 /* To iterate over the operands iterate from 0 to i < get_irn_arity(),
246    to iterate includind the Block predecessor iterate from i = -1 to
247    i < get_irn_arity.
248    If it is a block, the entry -1 is NULL. */
249 INLINE ir_node *
250 get_irn_n (ir_node *node, int n) {
251   assert(node); assert(-1 <= n && n < get_irn_arity(node));
252   if (interprocedural_view)  return get_irn_inter_n (node, n);
253   return get_irn_intra_n (node, n);
254 }
255
256
257 INLINE void
258 set_irn_n (ir_node *node, int n, ir_node *in) {
259   assert(node && -1 <= n && n < get_irn_arity(node));
260   if ((n == -1) && (get_irn_opcode(node) == iro_Filter)) {
261     /* Change block pred in both views! */
262     node->in[n + 1] = in;
263     assert(node->attr.filter.in_cg);
264     node->attr.filter.in_cg[n + 1] = in;
265     return;
266   }
267   if (interprocedural_view) { /* handle Filter and Block specially */
268     if (get_irn_opcode(node) == iro_Filter) {
269       assert(node->attr.filter.in_cg);
270       node->attr.filter.in_cg[n + 1] = in;
271       return;
272     } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
273       node->attr.block.in_cg[n + 1] = in;
274       return;
275     }
276     /* else fall through */
277   }
278   node->in[n + 1] = in;
279 }
280
281 INLINE ir_mode *
282 get_irn_mode (const ir_node *node)
283 {
284   assert (node);
285   return node->mode;
286 }
287
288 INLINE void
289 set_irn_mode (ir_node *node, ir_mode *mode)
290 {
291   assert (node);
292   node->mode=mode;
293   return;
294 }
295
296 INLINE modecode
297 get_irn_modecode (const ir_node *node)
298 {
299   assert (node);
300   return node->mode->code;
301 }
302
303 /** Gets the string representation of the mode .*/
304 INLINE const char *
305 get_irn_modename (const ir_node *node)
306 {
307   assert(node);
308   return get_mode_name(node->mode);
309 }
310
311 INLINE ident *
312 get_irn_modeident (const ir_node *node)
313 {
314   assert(node);
315   return get_mode_ident(node->mode);
316 }
317
318 INLINE ir_op *
319 get_irn_op (const ir_node *node)
320 {
321   assert (node);
322   return node->op;
323 }
324
325 /* should be private to the library: */
326 INLINE void
327 set_irn_op (ir_node *node, ir_op *op)
328 {
329   assert (node);
330   node->op = op;
331 }
332
333 INLINE opcode
334 get_irn_opcode (const ir_node *node)
335 {
336   assert (node);
337   assert (k_ir_node == get_kind(node));
338   assert (node -> op);
339   return node->op->code;
340 }
341
342 INLINE const char *
343 get_irn_opname (const ir_node *node)
344 {
345   assert(node);
346   return get_id_str(node->op->name);
347 }
348
349 INLINE ident *
350 get_irn_opident (const ir_node *node)
351 {
352   assert(node);
353   return node->op->name;
354 }
355
356 INLINE unsigned long
357 get_irn_visited (const ir_node *node)
358 {
359   assert (node);
360   return node->visited;
361 }
362
363 INLINE void
364 set_irn_visited (ir_node *node, unsigned long visited)
365 {
366   assert (node);
367   node->visited = visited;
368 }
369
370 INLINE void
371 mark_irn_visited (ir_node *node) {
372   assert (node);
373   node->visited = current_ir_graph->visited;
374 }
375
376 INLINE int
377 irn_not_visited  (const ir_node *node) {
378   assert (node);
379   return (node->visited < current_ir_graph->visited);
380 }
381
382 INLINE int
383 irn_visited  (const ir_node *node) {
384   assert (node);
385   return (node->visited >= current_ir_graph->visited);
386 }
387
388 INLINE void
389 set_irn_link (ir_node *node, void *link) {
390   assert (node);
391   /* Link field is used for Phi construction and various optimizations
392      in iropt. */
393   assert(get_irg_phase_state(current_ir_graph) != phase_building);
394
395   node->link = link;
396 }
397
398 INLINE void *
399 get_irn_link (const ir_node *node) {
400   assert (node);
401   return node->link;
402 }
403
404 /* Outputs a unique number for this node */
405 INLINE long
406 get_irn_node_nr(const ir_node *node) {
407   assert(node);
408 #ifdef DEBUG_libfirm
409   return node->node_nr;
410 #else
411   return (long)&node;
412 #endif
413 }
414
415 INLINE const_attr
416 get_irn_const_attr (ir_node *node)
417 {
418   assert (node->op == op_Const);
419   return node->attr.con;
420 }
421
422 INLINE long
423 get_irn_proj_attr (ir_node *node)
424 {
425   assert (node->op == op_Proj);
426   return node->attr.proj;
427 }
428
429 INLINE alloc_attr
430 get_irn_alloc_attr (ir_node *node)
431 {
432   assert (node->op == op_Alloc);
433   return node->attr.a;
434 }
435
436 INLINE type *
437 get_irn_free_attr     (ir_node *node)
438 {
439   assert (node->op == op_Free);
440   return node->attr.f = skip_tid(node->attr.f);
441 }
442
443 INLINE symconst_attr
444 get_irn_symconst_attr (ir_node *node)
445 {
446   assert (node->op == op_SymConst);
447   return node->attr.i;
448 }
449
450 INLINE type *
451 get_irn_call_attr (ir_node *node)
452 {
453   assert (node->op == op_Call);
454   return node->attr.call.cld_tp = skip_tid(node->attr.call.cld_tp);
455 }
456
457 INLINE sel_attr
458 get_irn_sel_attr (ir_node *node)
459 {
460   assert (node->op == op_Sel);
461   return node->attr.s;
462 }
463
464 INLINE int
465 get_irn_phi_attr (ir_node *node)
466 {
467   assert (node->op == op_Phi);
468   return node->attr.phi0_pos;
469 }
470
471 INLINE block_attr
472 get_irn_block_attr (ir_node *node)
473 {
474   assert (node->op == op_Block);
475   return node->attr.block;
476 }
477
478 /** manipulate fields of individual nodes **/
479
480 /* this works for all except Block */
481 ir_node *
482 get_nodes_Block (ir_node *node) {
483   assert (!(node->op == op_Block));
484   return get_irn_n(node, -1);
485 }
486
487 INLINE void
488 set_nodes_Block (ir_node *node, ir_node *block) {
489   assert (!(node->op == op_Block));
490   set_irn_n(node, -1, block);
491 }
492
493 /* Test whether arbitrary node is frame pointer, i.e. Proj(pn_Start_P_frame_base)
494  * from Start.  If so returns frame type, else Null. */
495 type *is_frame_pointer(ir_node *n) {
496   if ((get_irn_op(n) == op_Proj) &&
497       (get_Proj_proj(n) == pn_Start_P_frame_base)) {
498     ir_node *start = get_Proj_pred(n);
499     if (get_irn_op(start) == op_Start) {
500       return get_irg_frame_type(get_irn_irg(start));
501     }
502   }
503   return NULL;
504 }
505
506 /* Test whether arbitrary node is globals pointer, i.e. Proj(pn_Start_P_globals)
507  * from Start.  If so returns global type, else Null. */
508 type *is_globals_pointer(ir_node *n) {
509   if ((get_irn_op(n) == op_Proj) &&
510       (get_Proj_proj(n) == pn_Start_P_globals)) {
511     ir_node *start = get_Proj_pred(n);
512     if (get_irn_op(start) == op_Start) {
513       return get_glob_type();
514     }
515   }
516   return NULL;
517 }
518
519 /* Test whether arbitrary node is value arg base, i.e. Proj(pn_Start_P_value_arg_base)
520  * from Start.  If so returns 1, else 0. */
521 int is_value_arg_pointer(ir_node *n) {
522   if ((get_irn_op(n) == op_Proj) &&
523       (get_Proj_proj(n) == pn_Start_P_value_arg_base) &&
524       (get_irn_op(get_Proj_pred(n)) == op_Start))
525     return 1;
526   return 0;
527 }
528
529 /* Returns an array with the predecessors of the Block. Depending on
530    the implementation of the graph datastructure this can be a copy of
531    the internal representation of predecessors as well as the internal
532    array itself. Therefore writing to this array might obstruct the ir. */
533 INLINE ir_node **
534 get_Block_cfgpred_arr (ir_node *node)
535 {
536   assert ((node->op == op_Block));
537   return (ir_node **)&(get_irn_in(node)[1]);
538 }
539
540
541 INLINE int
542 get_Block_n_cfgpreds (ir_node *node) {
543   assert ((node->op == op_Block));
544   return (get_irn_arity(node));
545 }
546
547 INLINE ir_node *
548 get_Block_cfgpred (ir_node *node, int pos) {
549   assert (node->op == op_Block);
550   /* debug @@@
551   if (-1 > pos || get_irn_arity(node) <= pos) {
552     dump_ir_block_graph(current_ir_graph);
553     printf("pos: %d, arity: %d ", pos, get_irn_arity(node));
554     DDMN(node);
555     } */
556   assert(node); assert(-1 <= pos && pos < get_irn_arity(node));
557   return get_irn_n(node, pos);
558 }
559
560 INLINE void
561 set_Block_cfgpred (ir_node *node, int pos, ir_node *pred) {
562   assert (node->op == op_Block);
563   set_irn_n(node, pos, pred);
564 }
565
566 INLINE bool
567 get_Block_matured (ir_node *node) {
568   assert (node->op == op_Block);
569   return node->attr.block.matured;
570 }
571
572 INLINE void
573 set_Block_matured (ir_node *node, bool matured) {
574   assert (node->op == op_Block);
575   node->attr.block.matured = matured;
576 }
577 INLINE unsigned long
578 get_Block_block_visited (ir_node *node) {
579   assert (node->op == op_Block);
580   return node->attr.block.block_visited;
581 }
582
583 INLINE void
584 set_Block_block_visited (ir_node *node, unsigned long visit) {
585   assert (node->op == op_Block);
586   node->attr.block.block_visited = visit;
587 }
588
589 /* For this current_ir_graph must be set. */
590 INLINE void
591 mark_Block_block_visited (ir_node *node) {
592   assert (node->op == op_Block);
593   node->attr.block.block_visited = get_irg_block_visited(current_ir_graph);
594 }
595
596 INLINE int
597 Block_not_block_visited(ir_node *node) {
598   assert (node->op == op_Block);
599   return (node->attr.block.block_visited < get_irg_block_visited(current_ir_graph));
600 }
601
602 INLINE ir_node *
603 get_Block_graph_arr (ir_node *node, int pos) {
604   assert (node->op == op_Block);
605   return node->attr.block.graph_arr[pos+1];
606 }
607
608 INLINE void
609 set_Block_graph_arr (ir_node *node, int pos, ir_node *value) {
610   assert (node->op == op_Block);
611   node->attr.block.graph_arr[pos+1] = value;
612 }
613
614 /* handler handling for Blocks * /
615 void
616 set_Block_handler (ir_node *block, ir_node *handler)  {
617   assert ((block->op == op_Block));
618   assert ((handler->op == op_Block));
619   block->attr.block.handler_entry = handler;
620 }
621
622 ir_node *
623 get_Block_handler (ir_node *block) {
624   assert ((block->op == op_Block));
625   return (block->attr.block.handler_entry);
626 }
627
628 / * handler handling for Nodes * /
629 void
630 set_Node_handler (ir_node *node, ir_node *handler) {
631   set_Block_handler (get_nodes_Block (node), handler);
632 }
633
634 ir_node *
635 get_Node_handler (ir_node *node) {
636   return (get_Block_handler (get_nodes_Block (node)));
637 }
638
639 / * exc_t handling for Blocks * /
640 void set_Block_exc (ir_node *block, exc_t exc) {
641   assert ((block->op == op_Block));
642   block->attr.block.exc = exc;
643 }
644
645 exc_t get_Block_exc (ir_node *block) {
646   assert ((block->op == op_Block));
647   return (block->attr.block.exc);
648 }
649
650 / * exc_t handling for Nodes * /
651 void set_Node_exc (ir_node *node, exc_t exc) {
652   set_Block_exc (get_nodes_Block (node), exc);
653 }
654
655 exc_t get_Node_exc (ir_node *node) {
656   return (get_Block_exc (get_nodes_Block (node)));
657 }
658 */
659
660 void set_Block_cg_cfgpred_arr(ir_node * node, int arity, ir_node ** in) {
661   assert(node->op == op_Block);
662   if (node->attr.block.in_cg == NULL || arity != ARR_LEN(node->attr.block.in_cg) - 1) {
663     node->attr.block.in_cg = NEW_ARR_D(ir_node *, current_ir_graph->obst, arity + 1);
664     node->attr.block.in_cg[0] = NULL;
665     node->attr.block.cg_backedge = new_backedge_arr(current_ir_graph->obst, arity);
666     {
667       /* Fix backedge array.  fix_backedges operates depending on
668          interprocedural_view. */
669       bool ipv = interprocedural_view;
670       interprocedural_view = true;
671       fix_backedges(current_ir_graph->obst, node);
672       interprocedural_view = ipv;
673     }
674   }
675   memcpy(node->attr.block.in_cg + 1, in, sizeof(ir_node *) * arity);
676 }
677
678 void set_Block_cg_cfgpred(ir_node * node, int pos, ir_node * pred) {
679   assert(node->op == op_Block &&
680          node->attr.block.in_cg &&
681          0 <= pos && pos < ARR_LEN(node->attr.block.in_cg) - 1);
682   node->attr.block.in_cg[pos + 1] = pred;
683 }
684
685 ir_node ** get_Block_cg_cfgpred_arr(ir_node * node) {
686   assert(node->op == op_Block);
687   return node->attr.block.in_cg == NULL ? NULL : node->attr.block.in_cg  + 1;
688 }
689
690 int get_Block_cg_n_cfgpreds(ir_node * node) {
691   assert(node->op == op_Block);
692   return node->attr.block.in_cg == NULL ? 0 : ARR_LEN(node->attr.block.in_cg) - 1;
693 }
694
695 ir_node * get_Block_cg_cfgpred(ir_node * node, int pos) {
696   assert(node->op == op_Block && node->attr.block.in_cg);
697   return node->attr.block.in_cg[pos + 1];
698 }
699
700 void remove_Block_cg_cfgpred_arr(ir_node * node) {
701   assert(node->op == op_Block);
702   node->attr.block.in_cg = NULL;
703 }
704
705 /* Start references the irg it is in. */
706 INLINE ir_graph *
707 get_Start_irg(ir_node *node) {
708   return get_irn_irg(node);
709 }
710
711 INLINE void
712 set_Start_irg(ir_node *node, ir_graph *irg) {
713   assert(node->op == op_Start);
714   assert(is_ir_graph(irg));
715   assert(0 && " Why set irg? ");
716   //node->attr.start.irg = irg;
717 }
718
719 INLINE int
720 get_End_n_keepalives(ir_node *end) {
721   assert (end->op == op_End);
722   return (get_irn_arity(end) - END_KEEPALIVE_OFFSET);
723 }
724
725 INLINE ir_node *
726 get_End_keepalive(ir_node *end, int pos) {
727   assert (end->op == op_End);
728   return get_irn_n(end, pos + END_KEEPALIVE_OFFSET);
729 }
730
731 INLINE void
732 add_End_keepalive (ir_node *end, ir_node *ka) {
733   assert (end->op == op_End);
734   ARR_APP1 (ir_node *, end->in, ka);
735 }
736
737 INLINE void
738 set_End_keepalive(ir_node *end, int pos, ir_node *ka) {
739   assert (end->op == op_End);
740   set_irn_n(end, pos + END_KEEPALIVE_OFFSET, ka);
741 }
742
743 INLINE void
744 free_End (ir_node *end) {
745   assert (end->op == op_End);
746   end->kind = k_BAD;
747   DEL_ARR_F(end->in);  /* GL @@@ tut nicht ! */
748   end->in = NULL;   /* @@@ make sure we get an error if we use the
749                        in array afterwards ... */
750 }
751
752 ir_graph *get_EndReg_irg (ir_node *end) {
753   return get_irn_irg(end);
754 }
755
756 ir_graph *get_EndExcept_irg  (ir_node *end) {
757   return get_irn_irg(end);
758 }
759
760 /*
761 > Implementing the case construct (which is where the constant Proj node is
762 > important) involves far more than simply determining the constant values.
763 > We could argue that this is more properly a function of the translator from
764 > Firm to the target machine.  That could be done if there was some way of
765 > projecting "default" out of the Cond node.
766 I know it's complicated.
767 Basically there are two proglems:
768  - determining the gaps between the projs
769  - determining the biggest case constant to konw the proj number for
770    the default node.
771 I see several solutions:
772 1. Introduce a ProjDefault node.  Solves both problems.
773    This means to extend all optimizations executed during construction.
774 2. Give the Cond node for switch two flavors:
775    a) there are no gaps in the projs  (existing flavor)
776    b) gaps may exist, default proj is still the Proj with the largest
777       projection number.  This covers also the gaps.
778 3. Fix the semantic of the Cond to that of 2b)
779
780 Solution 2 seems to be the best:
781 Computing the gaps in the Firm representation is not too hard, i.e.,
782 libfirm can implement a routine that transforms betweeen the two
783 flavours.  This is also possible for 1) but 2) does not require to
784 change any existing optimization.
785 Further it should be far simpler to determine the biggest constant than
786 to compute all gaps.
787 I don't want to choose 3) as 2a) seems to have advantages for
788 dataflow analysis and 3) does not allow to convert the representation to
789 2a).
790 */
791 INLINE ir_node *
792 get_Cond_selector (ir_node *node) {
793   assert (node->op == op_Cond);
794   return get_irn_n(node, 0);
795 }
796
797 INLINE void
798 set_Cond_selector (ir_node *node, ir_node *selector) {
799   assert (node->op == op_Cond);
800   set_irn_n(node, 0, selector);
801 }
802
803 INLINE cond_kind
804 get_Cond_kind (ir_node *node) {
805   assert (node->op == op_Cond);
806   return node->attr.c.kind;
807 }
808
809 INLINE void
810 set_Cond_kind (ir_node *node, cond_kind kind) {
811   assert (node->op == op_Cond);
812   node->attr.c.kind = kind;
813 }
814
815 INLINE ir_node *
816 get_Return_mem (ir_node *node) {
817   assert (node->op == op_Return);
818   return get_irn_n(node, 0);
819 }
820
821 INLINE void
822 set_Return_mem (ir_node *node, ir_node *mem) {
823   assert (node->op == op_Return);
824   set_irn_n(node, 0, mem);
825 }
826
827 INLINE int
828 get_Return_n_ress (ir_node *node) {
829   assert (node->op == op_Return);
830   return (get_irn_arity(node) - RETURN_RESULT_OFFSET);
831 }
832
833 INLINE ir_node **
834 get_Return_res_arr (ir_node *node)
835 {
836   assert ((node->op == op_Return));
837   if (get_Return_n_ress(node) > 0)
838     return (ir_node **)&(get_irn_in(node)[1 + RETURN_RESULT_OFFSET]);
839   else
840     return NULL;
841 }
842
843 /*
844 INLINE void
845 set_Return_n_res (ir_node *node, int results) {
846   assert (node->op == op_Return);
847 }
848 */
849
850 INLINE ir_node *
851 get_Return_res (ir_node *node, int pos) {
852   assert (node->op == op_Return);
853   assert (get_Return_n_ress(node) > pos);
854   return get_irn_n(node, pos + RETURN_RESULT_OFFSET);
855 }
856
857 INLINE void
858 set_Return_res (ir_node *node, int pos, ir_node *res){
859   assert (node->op == op_Return);
860   set_irn_n(node, pos + RETURN_RESULT_OFFSET, res);
861 }
862
863 INLINE ir_node *
864 get_Raise_mem (ir_node *node) {
865   assert (node->op == op_Raise);
866   return get_irn_n(node, 0);
867 }
868
869 INLINE void
870 set_Raise_mem (ir_node *node, ir_node *mem) {
871   assert (node->op == op_Raise);
872   set_irn_n(node, 0, mem);
873 }
874
875 INLINE ir_node *
876 get_Raise_exo_ptr (ir_node *node) {
877   assert (node->op == op_Raise);
878   return get_irn_n(node, 1);
879 }
880
881 INLINE void
882 set_Raise_exo_ptr (ir_node *node, ir_node *exo_ptr) {
883   assert (node->op == op_Raise);
884   set_irn_n(node, 1, exo_ptr);
885 }
886
887 INLINE tarval *get_Const_tarval (ir_node *node) {
888   assert (node->op == op_Const);
889   return node->attr.con.tv;
890 }
891
892 INLINE void
893 set_Const_tarval (ir_node *node, tarval *con) {
894   assert (node->op == op_Const);
895   node->attr.con.tv = con;
896 }
897
898
899 /* The source language type.  Must be an atomic type.  Mode of type must
900    be mode of node. For tarvals from entities type must be pointer to
901    entity type. */
902 INLINE type *
903 get_Const_type (ir_node *node) {
904   assert (node->op == op_Const);
905   return node->attr.con.tp;
906 }
907
908 INLINE void
909 set_Const_type (ir_node *node, type *tp) {
910   assert (node->op == op_Const);
911   if (tp != unknown_type) {
912     assert (is_atomic_type(tp));
913     assert (get_type_mode(tp) == get_irn_mode(node));
914     assert (!tarval_is_entity(get_Const_tarval(node)) ||
915             (is_pointer_type(tp) &&
916              (get_pointer_points_to_type(tp) ==
917               get_entity_type(get_tarval_entity(get_Const_tarval(node))))));
918   }
919
920   node->attr.con.tp = tp;
921 }
922
923
924 INLINE symconst_kind
925 get_SymConst_kind (const ir_node *node) {
926   assert (node->op == op_SymConst);
927   return node->attr.i.num;
928 }
929
930 INLINE void
931 set_SymConst_kind (ir_node *node, symconst_kind num) {
932   assert (node->op == op_SymConst);
933   node->attr.i.num = num;
934 }
935
936 INLINE type *
937 get_SymConst_type (ir_node *node) {
938   assert (   (node->op == op_SymConst)
939           && (   get_SymConst_kind(node) == type_tag
940               || get_SymConst_kind(node) == size));
941   return node->attr.i.tori.typ = skip_tid(node->attr.i.tori.typ);
942 }
943
944 INLINE void
945 set_SymConst_type (ir_node *node, type *tp) {
946   assert (   (node->op == op_SymConst)
947           && (   get_SymConst_kind(node) == type_tag
948               || get_SymConst_kind(node) == size));
949   node->attr.i.tori.typ = tp;
950 }
951
952 INLINE ident *
953 get_SymConst_ptrinfo (ir_node *node) {
954   assert (   (node->op == op_SymConst)
955           && (get_SymConst_kind(node) == linkage_ptr_info));
956   return node->attr.i.tori.ptrinfo;
957 }
958
959 INLINE void
960 set_SymConst_ptrinfo (ir_node *node, ident *ptrinfo) {
961   assert (   (node->op == op_SymConst)
962           && (get_SymConst_kind(node) == linkage_ptr_info));
963   node->attr.i.tori.ptrinfo = ptrinfo;
964 }
965
966 INLINE type_or_id_p
967 get_SymConst_type_or_id (ir_node *node) {
968   assert (node->op == op_SymConst);
969   return &(node->attr.i.tori);
970 }
971
972 INLINE void
973 set_SymConst_type_or_id (ir_node *node, type_or_id_p tori) {
974   assert (node->op == op_SymConst);
975   memcpy (&(node->attr.i.tori), tori, sizeof(type_or_id));
976 }
977
978 INLINE ir_node *
979 get_Sel_mem (ir_node *node) {
980   assert (node->op == op_Sel);
981   return get_irn_n(node, 0);
982 }
983
984 INLINE void
985 set_Sel_mem (ir_node *node, ir_node *mem) {
986   assert (node->op == op_Sel);
987   set_irn_n(node, 0, mem);
988 }
989
990 INLINE ir_node *
991 get_Sel_ptr (ir_node *node) {
992   assert (node->op == op_Sel);
993   return get_irn_n(node, 1);
994 }
995
996 INLINE void
997 set_Sel_ptr (ir_node *node, ir_node *ptr) {
998   assert (node->op == op_Sel);
999   set_irn_n(node, 1, ptr);
1000 }
1001
1002 INLINE int
1003 get_Sel_n_indexs (ir_node *node) {
1004   assert (node->op == op_Sel);
1005   return (get_irn_arity(node) - SEL_INDEX_OFFSET);
1006 }
1007
1008 INLINE ir_node **
1009 get_Sel_index_arr (ir_node *node)
1010 {
1011   assert ((node->op == op_Sel));
1012   if (get_Sel_n_indexs(node) > 0)
1013     return (ir_node **)& get_irn_in(node)[SEL_INDEX_OFFSET + 1];
1014   else
1015     return NULL;
1016 }
1017
1018 INLINE ir_node *
1019 get_Sel_index (ir_node *node, int pos) {
1020   assert (node->op == op_Sel);
1021   return get_irn_n(node, pos + SEL_INDEX_OFFSET);
1022 }
1023
1024 INLINE void
1025 set_Sel_index (ir_node *node, int pos, ir_node *index) {
1026   assert (node->op == op_Sel);
1027   set_irn_n(node, pos + SEL_INDEX_OFFSET, index);
1028 }
1029
1030 INLINE entity *
1031 get_Sel_entity (ir_node *node) {
1032   assert (node->op == op_Sel);
1033   return node->attr.s.ent;
1034 }
1035
1036 INLINE void
1037 set_Sel_entity (ir_node *node, entity *ent) {
1038   assert (node->op == op_Sel);
1039   node->attr.s.ent = ent;
1040 }
1041
1042 type *
1043 get_InstOf_ent (ir_node *node) {
1044   assert (node->op = op_InstOf);
1045   return (node->attr.io.ent);
1046 }
1047
1048 void
1049 set_InstOf_ent (ir_node *node, type *ent) {
1050   assert (node->op = op_InstOf);
1051   node->attr.io.ent = ent;
1052 }
1053
1054 ir_node *
1055 get_InstOf_store (ir_node *node) {
1056   assert (node->op = op_InstOf);
1057   return (get_irn_n (node, 0));
1058 }
1059
1060 void
1061 set_InstOf_store (ir_node *node, ir_node *obj) {
1062   assert (node->op = op_InstOf);
1063   set_irn_n (node, 0, obj);
1064 }
1065
1066 ir_node *
1067 get_InstOf_obj (ir_node *node) {
1068   assert (node->op = op_InstOf);
1069   return (get_irn_n (node, 1));
1070 }
1071
1072 void
1073 set_InstOf_obj (ir_node *node, ir_node *obj) {
1074   assert (node->op = op_InstOf);
1075   set_irn_n (node, 1, obj);
1076 }
1077
1078
1079 /* For unary and binary arithmetic operations the access to the
1080    operands can be factored out.  Left is the first, right the
1081    second arithmetic value  as listed in tech report 0999-33.
1082    unops are: Minus, Abs, Not, Conv, Cast
1083    binops are: Add, Sub, Mul, Quot, DivMod, Div, Mod, And, Or, Eor, Shl,
1084    Shr, Shrs, Rotate, Cmp */
1085
1086
1087 INLINE ir_node *
1088 get_Call_mem (ir_node *node) {
1089   assert (node->op == op_Call);
1090   return get_irn_n(node, 0);
1091 }
1092
1093 INLINE void
1094 set_Call_mem (ir_node *node, ir_node *mem) {
1095   assert (node->op == op_Call);
1096   set_irn_n(node, 0, mem);
1097 }
1098
1099 INLINE ir_node *
1100 get_Call_ptr (ir_node *node) {
1101   assert (node->op == op_Call);
1102   return get_irn_n(node, 1);
1103 }
1104
1105 INLINE void
1106 set_Call_ptr (ir_node *node, ir_node *ptr) {
1107   assert (node->op == op_Call);
1108   set_irn_n(node, 1, ptr);
1109 }
1110
1111 INLINE ir_node **
1112 get_Call_param_arr (ir_node *node) {
1113   assert (node->op == op_Call);
1114   return (ir_node **)&get_irn_in(node)[CALL_PARAM_OFFSET + 1];
1115 }
1116
1117 INLINE int
1118 get_Call_n_params (ir_node *node)  {
1119   assert (node->op == op_Call);
1120   return (get_irn_arity(node) - CALL_PARAM_OFFSET);
1121 }
1122
1123 INLINE int
1124 get_Call_arity (ir_node *node) {
1125   assert (node->op == op_Call);
1126   return get_Call_n_params(node);
1127 }
1128
1129 /* INLINE void
1130 set_Call_arity (ir_node *node, ir_node *arity) {
1131   assert (node->op == op_Call);
1132 }
1133 */
1134
1135 INLINE ir_node *
1136 get_Call_param (ir_node *node, int pos) {
1137   assert (node->op == op_Call);
1138   return get_irn_n(node, pos + CALL_PARAM_OFFSET);
1139 }
1140
1141 INLINE void
1142 set_Call_param (ir_node *node, int pos, ir_node *param) {
1143   assert (node->op == op_Call);
1144   set_irn_n(node, pos + CALL_PARAM_OFFSET, param);
1145 }
1146
1147 INLINE type *
1148 get_Call_type (ir_node *node) {
1149   assert (node->op == op_Call);
1150   return node->attr.call.cld_tp = skip_tid(node->attr.call.cld_tp);
1151 }
1152
1153 INLINE void
1154 set_Call_type (ir_node *node, type *tp) {
1155   assert (node->op == op_Call);
1156   assert (is_method_type(tp));
1157   node->attr.call.cld_tp = tp;
1158 }
1159
1160 int Call_has_callees(ir_node *node) {
1161   return (node->attr.call.callee_arr != NULL);
1162 }
1163
1164 int get_Call_n_callees(ir_node * node) {
1165   assert(node->op == op_Call && node->attr.call.callee_arr);
1166   return ARR_LEN(node->attr.call.callee_arr);
1167 }
1168
1169 entity * get_Call_callee(ir_node * node, int pos) {
1170   assert(node->op == op_Call && node->attr.call.callee_arr);
1171   return node->attr.call.callee_arr[pos];
1172 }
1173
1174 void set_Call_callee_arr(ir_node * node, int n, entity ** arr) {
1175   assert(node->op == op_Call);
1176   if (node->attr.call.callee_arr == NULL || get_Call_n_callees(node) != n) {
1177     node->attr.call.callee_arr = NEW_ARR_D(entity *, current_ir_graph->obst, n);
1178   }
1179   memcpy(node->attr.call.callee_arr, arr, n * sizeof(entity *));
1180 }
1181
1182 void remove_Call_callee_arr(ir_node * node) {
1183   assert(node->op == op_Call);
1184   node->attr.call.callee_arr = NULL;
1185 }
1186
1187 ir_node * get_CallBegin_ptr (ir_node *node) {
1188   assert(node->op == op_CallBegin);
1189   return get_irn_n(node, 0);
1190 }
1191 void set_CallBegin_ptr (ir_node *node, ir_node *ptr) {
1192   assert(node->op == op_CallBegin);
1193   set_irn_n(node, 0, ptr);
1194 }
1195 ir_graph * get_CallBegin_irg (ir_node *node) {
1196   return get_irn_irg(node);
1197 }
1198 ir_node * get_CallBegin_call (ir_node *node) {
1199   assert(node->op == op_CallBegin);
1200   return node->attr.callbegin.call;
1201 }
1202 void  set_CallBegin_call (ir_node *node, ir_node *call) {
1203   assert(node->op == op_CallBegin);
1204   node->attr.callbegin.call = call;
1205 }
1206
1207 INLINE ir_node *
1208 get_Add_left (ir_node *node) {
1209   assert (node->op == op_Add);
1210   return get_irn_n(node, 0);
1211 }
1212
1213 INLINE void
1214 set_Add_left (ir_node *node, ir_node *left) {
1215   assert (node->op == op_Add);
1216   set_irn_n(node, 0, left);
1217 }
1218
1219 INLINE ir_node *
1220 get_Add_right (ir_node *node) {
1221   assert (node->op == op_Add);
1222   return get_irn_n(node, 1);
1223 }
1224
1225 INLINE void
1226 set_Add_right (ir_node *node, ir_node *right) {
1227   assert (node->op == op_Add);
1228   set_irn_n(node, 1, right);
1229 }
1230
1231 INLINE ir_node *
1232 get_Sub_left (ir_node *node) {
1233   assert (node->op == op_Sub);
1234   return get_irn_n(node, 0);
1235 }
1236
1237 INLINE void
1238 set_Sub_left (ir_node *node, ir_node *left) {
1239   assert (node->op == op_Sub);
1240   set_irn_n(node, 0, left);
1241 }
1242
1243 INLINE ir_node *
1244 get_Sub_right (ir_node *node) {
1245   assert (node->op == op_Sub);
1246   return get_irn_n(node, 1);
1247 }
1248
1249 INLINE void
1250 set_Sub_right (ir_node *node, ir_node *right) {
1251   assert (node->op == op_Sub);
1252   set_irn_n(node, 1, right);
1253 }
1254
1255
1256 INLINE ir_node *
1257 get_Minus_op (ir_node *node) {
1258   assert (node->op == op_Minus);
1259   return get_irn_n(node, 0);
1260 }
1261
1262 INLINE void
1263 set_Minus_op (ir_node *node, ir_node *op) {
1264   assert (node->op == op_Minus);
1265   set_irn_n(node, 0, op);
1266 }
1267
1268
1269 INLINE ir_node *
1270 get_Mul_left (ir_node *node) {
1271   assert (node->op == op_Mul);
1272   return get_irn_n(node, 0);
1273 }
1274
1275 INLINE void
1276 set_Mul_left (ir_node *node, ir_node *left) {
1277   assert (node->op == op_Mul);
1278   set_irn_n(node, 0, left);
1279 }
1280
1281 INLINE ir_node *
1282 get_Mul_right (ir_node *node) {
1283   assert (node->op == op_Mul);
1284   return get_irn_n(node, 1);
1285 }
1286
1287 INLINE void
1288 set_Mul_right (ir_node *node, ir_node *right) {
1289   assert (node->op == op_Mul);
1290   set_irn_n(node, 1, right);
1291 }
1292
1293 INLINE ir_node *
1294 get_Quot_left (ir_node *node) {
1295   assert (node->op == op_Quot);
1296   return get_irn_n(node, 1);
1297 }
1298
1299 INLINE void
1300 set_Quot_left (ir_node *node, ir_node *left) {
1301   assert (node->op == op_Quot);
1302   set_irn_n(node, 1, left);
1303 }
1304
1305 INLINE ir_node *
1306 get_Quot_right (ir_node *node) {
1307   assert (node->op == op_Quot);
1308   return get_irn_n(node, 2);
1309 }
1310
1311 INLINE void
1312 set_Quot_right (ir_node *node, ir_node *right) {
1313   assert (node->op == op_Quot);
1314   set_irn_n(node, 2, right);
1315 }
1316
1317 INLINE ir_node *
1318 get_Quot_mem (ir_node *node) {
1319   assert (node->op == op_Quot);
1320   return get_irn_n(node, 0);
1321 }
1322
1323 INLINE void
1324 set_Quot_mem (ir_node *node, ir_node *mem) {
1325   assert (node->op == op_Quot);
1326   set_irn_n(node, 0, mem);
1327 }
1328
1329 INLINE ir_node *
1330 get_DivMod_left (ir_node *node) {
1331   assert (node->op == op_DivMod);
1332   return get_irn_n(node, 1);
1333 }
1334
1335 INLINE void
1336 set_DivMod_left (ir_node *node, ir_node *left) {
1337   assert (node->op == op_DivMod);
1338   set_irn_n(node, 1, left);
1339 }
1340
1341 INLINE ir_node *
1342 get_DivMod_right (ir_node *node) {
1343   assert (node->op == op_DivMod);
1344   return get_irn_n(node, 2);
1345 }
1346
1347 INLINE void
1348 set_DivMod_right (ir_node *node, ir_node *right) {
1349   assert (node->op == op_DivMod);
1350   set_irn_n(node, 2, right);
1351 }
1352
1353 INLINE ir_node *
1354 get_DivMod_mem (ir_node *node) {
1355   assert (node->op == op_DivMod);
1356   return get_irn_n(node, 0);
1357 }
1358
1359 INLINE void
1360 set_DivMod_mem (ir_node *node, ir_node *mem) {
1361   assert (node->op == op_DivMod);
1362   set_irn_n(node, 0, mem);
1363 }
1364
1365 INLINE ir_node *
1366 get_Div_left (ir_node *node) {
1367   assert (node->op == op_Div);
1368   return get_irn_n(node, 1);
1369 }
1370
1371 INLINE void
1372 set_Div_left (ir_node *node, ir_node *left) {
1373   assert (node->op == op_Div);
1374   set_irn_n(node, 1, left);
1375 }
1376
1377 INLINE ir_node *
1378 get_Div_right (ir_node *node) {
1379   assert (node->op == op_Div);
1380   return get_irn_n(node, 2);
1381 }
1382
1383 INLINE void
1384 set_Div_right (ir_node *node, ir_node *right) {
1385   assert (node->op == op_Div);
1386   set_irn_n(node, 2, right);
1387 }
1388
1389 INLINE ir_node *
1390 get_Div_mem (ir_node *node) {
1391   assert (node->op == op_Div);
1392   return get_irn_n(node, 0);
1393 }
1394
1395 INLINE void
1396 set_Div_mem (ir_node *node, ir_node *mem) {
1397   assert (node->op == op_Div);
1398   set_irn_n(node, 0, mem);
1399 }
1400
1401 INLINE ir_node *
1402 get_Mod_left (ir_node *node) {
1403   assert (node->op == op_Mod);
1404   return get_irn_n(node, 1);
1405 }
1406
1407 INLINE void
1408 set_Mod_left (ir_node *node, ir_node *left) {
1409   assert (node->op == op_Mod);
1410   set_irn_n(node, 1, left);
1411 }
1412
1413 INLINE ir_node *
1414 get_Mod_right (ir_node *node) {
1415   assert (node->op == op_Mod);
1416   return get_irn_n(node, 2);
1417 }
1418
1419 INLINE void
1420 set_Mod_right (ir_node *node, ir_node *right) {
1421   assert (node->op == op_Mod);
1422   set_irn_n(node, 2, right);
1423 }
1424
1425 INLINE ir_node *
1426 get_Mod_mem (ir_node *node) {
1427   assert (node->op == op_Mod);
1428   return get_irn_n(node, 0);
1429 }
1430
1431 INLINE void
1432 set_Mod_mem (ir_node *node, ir_node *mem) {
1433   assert (node->op == op_Mod);
1434   set_irn_n(node, 0, mem);
1435 }
1436
1437 INLINE ir_node *
1438 get_Abs_op (ir_node *node) {
1439   assert (node->op == op_Abs);
1440   return get_irn_n(node, 0);
1441 }
1442
1443 INLINE void
1444 set_Abs_op (ir_node *node, ir_node *op) {
1445   assert (node->op == op_Abs);
1446   set_irn_n(node, 0, op);
1447 }
1448
1449 INLINE ir_node *
1450 get_And_left (ir_node *node) {
1451   assert (node->op == op_And);
1452   return get_irn_n(node, 0);
1453 }
1454
1455 INLINE void
1456 set_And_left (ir_node *node, ir_node *left) {
1457   assert (node->op == op_And);
1458   set_irn_n(node, 0, left);
1459 }
1460
1461 INLINE ir_node *
1462 get_And_right (ir_node *node) {
1463   assert (node->op == op_And);
1464   return get_irn_n(node, 1);
1465 }
1466
1467 INLINE void
1468 set_And_right (ir_node *node, ir_node *right) {
1469   assert (node->op == op_And);
1470   set_irn_n(node, 1, right);
1471 }
1472
1473 INLINE ir_node *
1474 get_Or_left (ir_node *node) {
1475   assert (node->op == op_Or);
1476   return get_irn_n(node, 0);
1477 }
1478
1479 INLINE void
1480 set_Or_left (ir_node *node, ir_node *left) {
1481   assert (node->op == op_Or);
1482   set_irn_n(node, 0, left);
1483 }
1484
1485 INLINE ir_node *
1486 get_Or_right (ir_node *node) {
1487   assert (node->op == op_Or);
1488   return get_irn_n(node, 1);
1489 }
1490
1491 INLINE void
1492 set_Or_right (ir_node *node, ir_node *right) {
1493   assert (node->op == op_Or);
1494   set_irn_n(node, 1, right);
1495 }
1496
1497 INLINE ir_node *
1498 get_Eor_left (ir_node *node) {
1499   assert (node->op == op_Eor);
1500   return get_irn_n(node, 0);
1501 }
1502
1503 INLINE void
1504 set_Eor_left (ir_node *node, ir_node *left) {
1505   assert (node->op == op_Eor);
1506   set_irn_n(node, 0, left);
1507 }
1508
1509 INLINE ir_node *
1510 get_Eor_right (ir_node *node) {
1511   assert (node->op == op_Eor);
1512   return get_irn_n(node, 1);
1513 }
1514
1515 INLINE void
1516 set_Eor_right (ir_node *node, ir_node *right) {
1517   assert (node->op == op_Eor);
1518   set_irn_n(node, 1, right);
1519 }
1520
1521
1522 INLINE ir_node *
1523 get_Not_op (ir_node *node) {
1524   assert (node->op == op_Not);
1525   return get_irn_n(node, 0);
1526 }
1527
1528 INLINE void
1529 set_Not_op (ir_node *node, ir_node *op) {
1530   assert (node->op == op_Not);
1531   set_irn_n(node, 0, op);
1532 }
1533
1534
1535 INLINE ir_node *
1536 get_Shl_left (ir_node *node) {
1537   assert (node->op == op_Shl);
1538   return get_irn_n(node, 0);
1539 }
1540
1541 INLINE void
1542 set_Shl_left (ir_node *node, ir_node *left) {
1543   assert (node->op == op_Shl);
1544   set_irn_n(node, 0, left);
1545 }
1546
1547 INLINE ir_node *
1548 get_Shl_right (ir_node *node) {
1549   assert (node->op == op_Shl);
1550   return get_irn_n(node, 1);
1551 }
1552
1553 INLINE void
1554 set_Shl_right (ir_node *node, ir_node *right) {
1555   assert (node->op == op_Shl);
1556   set_irn_n(node, 1, right);
1557 }
1558
1559 INLINE ir_node *
1560 get_Shr_left (ir_node *node) {
1561   assert (node->op == op_Shr);
1562   return get_irn_n(node, 0);
1563 }
1564
1565 INLINE void
1566 set_Shr_left (ir_node *node, ir_node *left) {
1567   assert (node->op == op_Shr);
1568   set_irn_n(node, 0, left);
1569 }
1570
1571 INLINE ir_node *
1572 get_Shr_right (ir_node *node) {
1573   assert (node->op == op_Shr);
1574   return get_irn_n(node, 1);
1575 }
1576
1577 INLINE void
1578 set_Shr_right (ir_node *node, ir_node *right) {
1579   assert (node->op == op_Shr);
1580   set_irn_n(node, 1, right);
1581 }
1582
1583 INLINE ir_node *
1584 get_Shrs_left (ir_node *node) {
1585   assert (node->op == op_Shrs);
1586   return get_irn_n(node, 0);
1587 }
1588
1589 INLINE void
1590 set_Shrs_left (ir_node *node, ir_node *left) {
1591   assert (node->op == op_Shrs);
1592   set_irn_n(node, 0, left);
1593 }
1594
1595 INLINE ir_node *
1596 get_Shrs_right (ir_node *node) {
1597   assert (node->op == op_Shrs);
1598   return get_irn_n(node, 1);
1599 }
1600
1601 INLINE void
1602 set_Shrs_right (ir_node *node, ir_node *right) {
1603   assert (node->op == op_Shrs);
1604   set_irn_n(node, 1, right);
1605 }
1606
1607 INLINE ir_node *
1608 get_Rot_left (ir_node *node) {
1609   assert (node->op == op_Rot);
1610   return get_irn_n(node, 0);
1611 }
1612
1613 INLINE void
1614 set_Rot_left (ir_node *node, ir_node *left) {
1615   assert (node->op == op_Rot);
1616   set_irn_n(node, 0, left);
1617 }
1618
1619 INLINE ir_node *
1620 get_Rot_right (ir_node *node) {
1621   assert (node->op == op_Rot);
1622   return get_irn_n(node, 1);
1623 }
1624
1625 INLINE void
1626 set_Rot_right (ir_node *node, ir_node *right) {
1627   assert (node->op == op_Rot);
1628   set_irn_n(node, 1, right);
1629 }
1630
1631 INLINE ir_node *
1632 get_Cmp_left (ir_node *node) {
1633   assert (node->op == op_Cmp);
1634   return get_irn_n(node, 0);
1635 }
1636
1637 INLINE void
1638 set_Cmp_left (ir_node *node, ir_node *left) {
1639   assert (node->op == op_Cmp);
1640   set_irn_n(node, 0, left);
1641 }
1642
1643 INLINE ir_node *
1644 get_Cmp_right (ir_node *node) {
1645   assert (node->op == op_Cmp);
1646   return get_irn_n(node, 1);
1647 }
1648
1649 INLINE void
1650 set_Cmp_right (ir_node *node, ir_node *right) {
1651   assert (node->op == op_Cmp);
1652   set_irn_n(node, 1, right);
1653 }
1654
1655 INLINE ir_node *
1656 get_Conv_op (ir_node *node) {
1657   assert (node->op == op_Conv);
1658   return get_irn_n(node, 0);
1659 }
1660
1661 INLINE void
1662 set_Conv_op (ir_node *node, ir_node *op) {
1663   assert (node->op == op_Conv);
1664   set_irn_n(node, 0, op);
1665 }
1666
1667 INLINE ir_node *
1668 get_Cast_op (ir_node *node) {
1669   assert (node->op == op_Cast);
1670   return get_irn_n(node, 0);
1671 }
1672
1673 INLINE void
1674 set_Cast_op (ir_node *node, ir_node *op) {
1675   assert (node->op == op_Cast);
1676   set_irn_n(node, 0, op);
1677 }
1678
1679 INLINE type *
1680 get_Cast_type (ir_node *node) {
1681   assert (node->op == op_Cast);
1682   return node->attr.cast.totype;
1683 }
1684
1685 INLINE void
1686 set_Cast_type (ir_node *node, type *to_tp) {
1687   assert (node->op == op_Cast);
1688   node->attr.cast.totype = to_tp;
1689 }
1690
1691 INLINE int
1692 is_unop (ir_node *node) {
1693   return (node->op->opar == oparity_unary);
1694 }
1695
1696 INLINE ir_node *
1697 get_unop_op (ir_node *node) {
1698   assert (is_unop(node));
1699   switch (get_irn_opcode (node)) {
1700     case iro_Minus: return get_Minus_op(node); break;
1701     case iro_Abs:   return get_Abs_op(node);   break;
1702     case iro_Not:   return get_Not_op(node);   break;
1703     case iro_Conv:  return get_Conv_op(node);  break;
1704     case iro_Cast:  return get_Cast_op(node);  break;
1705     default: return NULL;
1706   }
1707 }
1708
1709 INLINE void
1710 set_unop_op (ir_node *node, ir_node *op) {
1711   assert (is_unop(node));
1712   switch (get_irn_opcode (node)) {
1713     case iro_Minus:   set_Minus_op(node, op); break;
1714     case iro_Abs:     set_Abs_op(node, op);   break;
1715     case iro_Not:     set_Not_op(node, op);   break;
1716     case iro_Conv:    set_Conv_op(node, op);  break;
1717     case iro_Cast:    set_Cast_op(node, op);  break;
1718     default:  ;
1719   }
1720
1721 }
1722
1723 int
1724 is_binop (ir_node *node) {
1725   return (node->op->opar == oparity_binary);
1726   /*  return (node->op == op_Add    ||
1727           node->op == op_Cmp    ||
1728           node->op == op_Sub    ||
1729           node->op == op_Mul    ||
1730           node->op == op_Quot   ||
1731           node->op == op_DivMod ||
1732           node->op == op_Div    ||
1733           node->op == op_Mod    ||
1734           node->op == op_And    ||
1735           node->op == op_Or     ||
1736           node->op == op_Eor    ||
1737           node->op == op_Shl    ||
1738           node->op == op_Shr    ||
1739           node->op == op_Shrs   ||
1740           node->op == op_Rot      );
1741   */
1742 }
1743
1744 INLINE ir_node *
1745 get_binop_left (ir_node *node) {
1746   assert (node->op->opar == oparity_binary);
1747
1748     switch (get_irn_opcode (node)) {
1749       case iro_Add   :     return get_Add_left(node);  break;
1750       case iro_Sub   :     return get_Sub_left(node);  break;
1751       case iro_Mul   :     return get_Mul_left(node);  break;
1752       case iro_Quot  :     return get_Quot_left(node); break;
1753       case iro_DivMod:     return get_DivMod_left(node);  break;
1754       case iro_Div   :     return get_Div_left(node);  break;
1755       case iro_Mod   :     return get_Mod_left(node);  break;
1756       case iro_And   :     return get_And_left(node);  break;
1757       case iro_Or    :     return get_Or_left(node);   break;
1758       case iro_Eor   :     return get_Eor_left(node);  break;
1759       case iro_Shl   :     return get_Shl_left(node);  break;
1760       case iro_Shr   :     return get_Shr_left(node);  break;
1761       case iro_Shrs  :     return get_Shrs_left(node); break;
1762       case iro_Rot   :     return get_Rot_left(node);  break;
1763       case iro_Cmp   :     return get_Cmp_left(node);  break;
1764     default:  return NULL;
1765   };
1766 }
1767
1768 INLINE void
1769 set_binop_left (ir_node *node, ir_node *left) {
1770   assert (node->op->opar == oparity_binary);
1771
1772     switch (get_irn_opcode (node)) {
1773       case iro_Add   :     set_Add_left(node, left);  break;
1774       case iro_Sub   :     set_Sub_left(node, left);  break;
1775       case iro_Mul   :     set_Mul_left(node, left);  break;
1776       case iro_Quot  :     set_Quot_left(node, left); break;
1777       case iro_DivMod:     set_DivMod_left(node, left);  break;
1778       case iro_Div   :     set_Div_left(node, left);  break;
1779       case iro_Mod   :     set_Mod_left(node, left);  break;
1780       case iro_And   :     set_And_left(node, left);  break;
1781       case iro_Or    :     set_Or_left(node, left);   break;
1782       case iro_Eor   :     set_Eor_left(node, left);  break;
1783       case iro_Shl   :     set_Shl_left(node, left);  break;
1784       case iro_Shr   :     set_Shr_left(node, left);  break;
1785       case iro_Shrs  :     set_Shrs_left(node, left); break;
1786       case iro_Rot   :     set_Rot_left(node, left);  break;
1787       case iro_Cmp   :     set_Cmp_left(node, left);  break;
1788     default:  ;
1789   };
1790 }
1791
1792 INLINE ir_node *
1793 get_binop_right (ir_node *node) {
1794   assert (node->op->opar == oparity_binary);
1795
1796     switch (get_irn_opcode (node)) {
1797       case iro_Add   :     return get_Add_right(node);  break;
1798       case iro_Sub   :     return get_Sub_right(node);  break;
1799       case iro_Mul   :     return get_Mul_right(node);  break;
1800       case iro_Quot  :     return get_Quot_right(node); break;
1801       case iro_DivMod:     return get_DivMod_right(node);  break;
1802       case iro_Div   :     return get_Div_right(node);  break;
1803       case iro_Mod   :     return get_Mod_right(node);  break;
1804       case iro_And   :     return get_And_right(node);  break;
1805       case iro_Or    :     return get_Or_right(node);   break;
1806       case iro_Eor   :     return get_Eor_right(node);  break;
1807       case iro_Shl   :     return get_Shl_right(node);  break;
1808       case iro_Shr   :     return get_Shr_right(node);  break;
1809       case iro_Shrs  :     return get_Shrs_right(node); break;
1810       case iro_Rot   :     return get_Rot_right(node);  break;
1811       case iro_Cmp   :     return get_Cmp_right(node);  break;
1812     default:  return NULL;
1813   };
1814 }
1815
1816 INLINE void
1817 set_binop_right (ir_node *node, ir_node *right) {
1818   assert (node->op->opar == oparity_binary);
1819
1820     switch (get_irn_opcode (node)) {
1821       case iro_Add   :     set_Add_right(node, right);  break;
1822       case iro_Sub   :     set_Sub_right(node, right);  break;
1823       case iro_Mul   :     set_Mul_right(node, right);  break;
1824       case iro_Quot  :     set_Quot_right(node, right); break;
1825       case iro_DivMod:     set_DivMod_right(node, right);  break;
1826       case iro_Div   :     set_Div_right(node, right);  break;
1827       case iro_Mod   :     set_Mod_right(node, right);  break;
1828       case iro_And   :     set_And_right(node, right);  break;
1829       case iro_Or    :     set_Or_right(node, right);   break;
1830       case iro_Eor   :     set_Eor_right(node, right);  break;
1831       case iro_Shl   :     set_Shl_right(node, right);  break;
1832       case iro_Shr   :     set_Shr_right(node, right);  break;
1833       case iro_Shrs  :     set_Shrs_right(node, right); break;
1834       case iro_Rot   :     set_Rot_right(node, right);  break;
1835       case iro_Cmp   :     set_Cmp_right(node, right);  break;
1836     default: ;
1837   };
1838 }
1839
1840 INLINE int is_Phi (ir_node *n) {
1841   assert(n);
1842   return ((get_irn_op(n) == op_Phi) ||
1843           (get_irn_op(n) == op_Filter && interprocedural_view));
1844 }
1845
1846 INLINE ir_node **
1847 get_Phi_preds_arr (ir_node *node) {
1848   assert (node->op == op_Phi);
1849   return (ir_node **)&(get_irn_in(node)[1]);
1850 }
1851
1852 INLINE int
1853 get_Phi_n_preds (ir_node *node) {
1854   assert (is_Phi(node));
1855   return (get_irn_arity(node));
1856 }
1857
1858 /*
1859 INLINE void set_Phi_n_preds (ir_node *node, int n_preds) {
1860   assert (node->op == op_Phi);
1861 }
1862 */
1863
1864 INLINE ir_node *
1865 get_Phi_pred (ir_node *node, int pos) {
1866   assert (is_Phi(node));
1867   return get_irn_n(node, pos);
1868 }
1869
1870 INLINE void
1871 set_Phi_pred (ir_node *node, int pos, ir_node *pred) {
1872   assert (is_Phi(node));
1873   set_irn_n(node, pos, pred);
1874 }
1875
1876 INLINE ir_node *
1877 get_Load_mem (ir_node *node) {
1878   assert (node->op == op_Load);
1879   return get_irn_n(node, 0);
1880 }
1881
1882 INLINE void
1883 set_Load_mem (ir_node *node, ir_node *mem) {
1884   assert (node->op == op_Load);
1885   set_irn_n(node, 0, mem);
1886 }
1887
1888 INLINE ir_node *
1889 get_Load_ptr (ir_node *node) {
1890   assert (node->op == op_Load);
1891   return get_irn_n(node, 1);
1892 }
1893
1894 INLINE void
1895 set_Load_ptr (ir_node *node, ir_node *ptr) {
1896   assert (node->op == op_Load);
1897   set_irn_n(node, 1, ptr);
1898 }
1899
1900 INLINE
1901 ir_node *
1902 get_Store_mem (ir_node *node) {
1903   assert (node->op == op_Store);
1904   return get_irn_n(node, 0);
1905 }
1906
1907 INLINE void
1908 set_Store_mem (ir_node *node, ir_node *mem) {
1909   assert (node->op == op_Store);
1910   set_irn_n(node, 0, mem);
1911 }
1912
1913 INLINE ir_node *
1914 get_Store_ptr (ir_node *node) {
1915   assert (node->op == op_Store);
1916   return get_irn_n(node, 1);
1917 }
1918
1919 INLINE void
1920 set_Store_ptr (ir_node *node, ir_node *ptr) {
1921   assert (node->op == op_Store);
1922   set_irn_n(node, 1, ptr);
1923 }
1924
1925 INLINE ir_node *
1926 get_Store_value (ir_node *node) {
1927   assert (node->op == op_Store);
1928   return get_irn_n(node, 2);
1929 }
1930
1931 INLINE void
1932 set_Store_value (ir_node *node, ir_node *value) {
1933   assert (node->op == op_Store);
1934   set_irn_n(node, 2, value);
1935 }
1936
1937 INLINE ir_node *
1938 get_Alloc_mem (ir_node *node) {
1939   assert (node->op == op_Alloc);
1940   return get_irn_n(node, 0);
1941 }
1942
1943 INLINE void
1944 set_Alloc_mem (ir_node *node, ir_node *mem) {
1945   assert (node->op == op_Alloc);
1946   set_irn_n(node, 0, mem);
1947 }
1948
1949 INLINE ir_node *
1950 get_Alloc_size (ir_node *node) {
1951   assert (node->op == op_Alloc);
1952   return get_irn_n(node, 1);
1953 }
1954
1955 INLINE void
1956 set_Alloc_size (ir_node *node, ir_node *size) {
1957   assert (node->op == op_Alloc);
1958   set_irn_n(node, 1, size);
1959 }
1960
1961 INLINE type  *
1962 get_Alloc_type (ir_node *node) {
1963   assert (node->op == op_Alloc);
1964   return node->attr.a.type = skip_tid(node->attr.a.type);
1965 }
1966
1967 INLINE void
1968 set_Alloc_type (ir_node *node, type *tp) {
1969   assert (node->op == op_Alloc);
1970   node->attr.a.type = tp;
1971 }
1972
1973 INLINE where_alloc
1974 get_Alloc_where (ir_node *node) {
1975   assert (node->op == op_Alloc);
1976   return node->attr.a.where;
1977 }
1978
1979 INLINE void
1980 set_Alloc_where (ir_node *node, where_alloc where) {
1981   assert (node->op == op_Alloc);
1982   node->attr.a.where = where;
1983 }
1984
1985
1986 INLINE ir_node *
1987 get_Free_mem (ir_node *node) {
1988   assert (node->op == op_Free);
1989   return get_irn_n(node, 0);
1990 }
1991
1992 INLINE void
1993 set_Free_mem (ir_node *node, ir_node *mem) {
1994   assert (node->op == op_Free);
1995   set_irn_n(node, 0, mem);
1996 }
1997
1998 INLINE ir_node *
1999 get_Free_ptr (ir_node *node) {
2000   assert (node->op == op_Free);
2001   return get_irn_n(node, 1);
2002 }
2003
2004 INLINE void
2005 set_Free_ptr (ir_node *node, ir_node *ptr) {
2006   assert (node->op == op_Free);
2007   set_irn_n(node, 1, ptr);
2008 }
2009
2010 INLINE ir_node *
2011 get_Free_size (ir_node *node) {
2012   assert (node->op == op_Free);
2013   return get_irn_n(node, 2);
2014 }
2015
2016 INLINE void
2017 set_Free_size (ir_node *node, ir_node *size) {
2018   assert (node->op == op_Free);
2019   set_irn_n(node, 2, size);
2020 }
2021
2022 INLINE type  *
2023 get_Free_type (ir_node *node) {
2024   assert (node->op == op_Free);
2025   return node->attr.f = skip_tid(node->attr.f);
2026 }
2027
2028 INLINE void
2029 set_Free_type (ir_node *node, type *tp) {
2030   assert (node->op == op_Free);
2031   node->attr.f = tp;
2032 }
2033
2034 INLINE ir_node **
2035 get_Sync_preds_arr (ir_node *node) {
2036   assert (node->op == op_Sync);
2037   return (ir_node **)&(get_irn_in(node)[1]);
2038 }
2039
2040 INLINE int
2041 get_Sync_n_preds (ir_node *node) {
2042   assert (node->op == op_Sync);
2043   return (get_irn_arity(node));
2044 }
2045
2046 /*
2047 INLINE void
2048 set_Sync_n_preds (ir_node *node, int n_preds) {
2049   assert (node->op == op_Sync);
2050 }
2051 */
2052
2053 INLINE ir_node *
2054 get_Sync_pred (ir_node *node, int pos) {
2055   assert (node->op == op_Sync);
2056   return get_irn_n(node, pos);
2057 }
2058
2059 INLINE void
2060 set_Sync_pred (ir_node *node, int pos, ir_node *pred) {
2061   assert (node->op == op_Sync);
2062   set_irn_n(node, pos, pred);
2063 }
2064
2065 INLINE ir_node *
2066 get_Proj_pred (ir_node *node) {
2067   assert (is_Proj(node));
2068   return get_irn_n(node, 0);
2069 }
2070
2071 INLINE void
2072 set_Proj_pred (ir_node *node, ir_node *pred) {
2073   assert (is_Proj(node));
2074   set_irn_n(node, 0, pred);
2075 }
2076
2077 INLINE long
2078 get_Proj_proj (ir_node *node) {
2079   assert (is_Proj(node));
2080   if (get_irn_opcode(node) == iro_Proj) {
2081     return node->attr.proj;
2082   } else {
2083     assert(get_irn_opcode(node) == iro_Filter);
2084     return node->attr.filter.proj;
2085   }
2086 }
2087
2088 INLINE void
2089 set_Proj_proj (ir_node *node, long proj) {
2090   assert (node->op == op_Proj);
2091   node->attr.proj = proj;
2092 }
2093
2094 INLINE ir_node **
2095 get_Tuple_preds_arr (ir_node *node) {
2096   assert (node->op == op_Tuple);
2097   return (ir_node **)&(get_irn_in(node)[1]);
2098 }
2099
2100 INLINE int
2101 get_Tuple_n_preds (ir_node *node) {
2102   assert (node->op == op_Tuple);
2103   return (get_irn_arity(node));
2104 }
2105
2106 /*
2107 INLINE void
2108 set_Tuple_n_preds (ir_node *node, int n_preds) {
2109   assert (node->op == op_Tuple);
2110 }
2111 */
2112
2113 INLINE ir_node *
2114 get_Tuple_pred (ir_node *node, int pos) {
2115   assert (node->op == op_Tuple);
2116   return get_irn_n(node, pos);
2117 }
2118
2119 INLINE void
2120 set_Tuple_pred (ir_node *node, int pos, ir_node *pred) {
2121   assert (node->op == op_Tuple);
2122   set_irn_n(node, pos, pred);
2123 }
2124
2125 INLINE ir_node *
2126 get_Id_pred (ir_node *node) {
2127   assert (node->op == op_Id);
2128   return get_irn_n(node, 0);
2129 }
2130
2131 INLINE void
2132 set_Id_pred (ir_node *node, ir_node *pred) {
2133   assert (node->op == op_Id);
2134   set_irn_n(node, 0, pred);
2135 }
2136
2137 INLINE ir_node *get_Confirm_value (ir_node *node) {
2138   assert (node->op == op_Confirm);
2139   return get_irn_n(node, 0);
2140 }
2141 INLINE void     set_Confirm_value (ir_node *node, ir_node *value) {
2142   assert (node->op == op_Confirm);
2143   set_irn_n(node, 0, value);
2144 }
2145 INLINE ir_node *get_Confirm_bound (ir_node *node) {
2146   assert (node->op == op_Confirm);
2147   return get_irn_n(node, 1);
2148 }
2149 INLINE void     set_Confirm_bound (ir_node *node, ir_node *bound) {
2150   assert (node->op == op_Confirm);
2151   set_irn_n(node, 0, bound);
2152 }
2153 INLINE pn_Cmp   get_Confirm_cmp   (ir_node *node) {
2154   assert (node->op == op_Confirm);
2155   return node->attr.confirm_cmp;
2156 }
2157 INLINE void     set_Confirm_cmp   (ir_node *node, pn_Cmp cmp) {
2158   assert (node->op == op_Confirm);
2159   node->attr.confirm_cmp = cmp;
2160 }
2161
2162
2163 INLINE ir_node *
2164 get_Filter_pred (ir_node *node) {
2165   assert(node->op == op_Filter);
2166   return node->in[1];
2167 }
2168 INLINE void
2169 set_Filter_pred (ir_node *node, ir_node *pred) {
2170   assert(node->op == op_Filter);
2171   node->in[1] = pred;
2172 }
2173 INLINE long
2174 get_Filter_proj(ir_node *node) {
2175   assert(node->op == op_Filter);
2176   return node->attr.filter.proj;
2177 }
2178 INLINE void
2179 set_Filter_proj (ir_node *node, long proj) {
2180   assert(node->op == op_Filter);
2181   node->attr.filter.proj = proj;
2182 }
2183
2184 /* Don't use get_irn_arity, get_irn_n in implementation as access
2185    shall work independent of view!!! */
2186 void set_Filter_cg_pred_arr(ir_node * node, int arity, ir_node ** in) {
2187   assert(node->op == op_Filter);
2188   if (node->attr.filter.in_cg == NULL || arity != ARR_LEN(node->attr.filter.in_cg) - 1) {
2189     node->attr.filter.in_cg = NEW_ARR_D(ir_node *, current_ir_graph->obst, arity + 1);
2190     node->attr.filter.backedge = NEW_ARR_D (int, current_ir_graph->obst, arity);
2191     memset(node->attr.filter.backedge, 0, sizeof(int) * arity);
2192     node->attr.filter.in_cg[0] = node->in[0];
2193   }
2194   memcpy(node->attr.filter.in_cg + 1, in, sizeof(ir_node *) * arity);
2195 }
2196
2197 void set_Filter_cg_pred(ir_node * node, int pos, ir_node * pred) {
2198   assert(node->op == op_Filter && node->attr.filter.in_cg &&
2199          0 <= pos && pos < ARR_LEN(node->attr.filter.in_cg) - 1);
2200   node->attr.filter.in_cg[pos + 1] = pred;
2201 }
2202 int get_Filter_n_cg_preds(ir_node *node) {
2203   assert(node->op == op_Filter && node->attr.filter.in_cg);
2204   return (ARR_LEN(node->attr.filter.in_cg) - 1);
2205 }
2206 ir_node *get_Filter_cg_pred(ir_node *node, int pos) {
2207   int arity;
2208   assert(node->op == op_Filter && node->attr.filter.in_cg &&
2209          0 <= pos);
2210   arity = ARR_LEN(node->attr.filter.in_cg);
2211   assert(pos <  arity - 1);
2212   return node->attr.filter.in_cg[pos + 1];
2213 }
2214
2215
2216 INLINE ir_graph *
2217 get_irn_irg(ir_node *node) {
2218   if (get_irn_op(node) != op_Block)
2219     node = get_nodes_block(node);
2220   assert(get_irn_op(node) == op_Block);
2221   return node->attr.block.irg;
2222 }
2223
2224
2225 /******************************************************************/
2226 /*  Auxiliary routines                                            */
2227 /******************************************************************/
2228
2229 INLINE ir_node *
2230 skip_Proj (ir_node *node) {
2231   /* don't assert node !!! */
2232   if (node && is_Proj(node)) {
2233     return get_Proj_pred(node);
2234   } else {
2235     return node;
2236   }
2237 }
2238
2239 INLINE ir_node *
2240 skip_Tuple (ir_node *node) {
2241   ir_node *pred;
2242
2243   if (!get_opt_normalize()) return node;
2244
2245   node = skip_nop(node);
2246   if (get_irn_op(node) == op_Proj) {
2247     pred = skip_nop(get_Proj_pred(node));
2248     if (get_irn_op(pred) == op_Proj) /* nested Tuple ? */
2249       pred = skip_nop(skip_Tuple(pred));
2250     if (get_irn_op(pred) == op_Tuple)
2251       return get_Tuple_pred(pred, get_Proj_proj(node));
2252   }
2253   return node;
2254 }
2255
2256 #if 0
2257 /* This should compact Id-cycles to self-cycles. It has the same (or less?) complexity
2258    than any other approach, as Id chains are resolved and all point to the real node, or
2259    all id's are self loops. */
2260 INLINE ir_node *
2261 skip_nop (ir_node *node) {
2262   /* don't assert node !!! */
2263
2264   if (!get_opt_normalize()) return node;
2265
2266   /* Don't use get_Id_pred:  We get into an endless loop for
2267      self-referencing Ids. */
2268   if (node && (node->op == op_Id) && (node != node->in[0+1])) {
2269     ir_node *rem_pred = node->in[0+1];
2270     ir_node *res;
2271
2272     assert (get_irn_arity (node) > 0);
2273
2274     node->in[0+1] = node;
2275     res = skip_nop(rem_pred);
2276     if (res->op == op_Id) /* self-loop */ return node;
2277
2278     node->in[0+1] = res;
2279     return res;
2280   } else {
2281     return node;
2282   }
2283 }
2284 #else
2285 /* This should compact Id-cycles to self-cycles. It has the same (or less?) complexity
2286    than any other approach, as Id chains are resolved and all point to the real node, or
2287    all id's are self loops. */
2288 extern int opt_normalize;
2289 INLINE ir_node *
2290 skip_nop (ir_node *node) {
2291   ir_node *pred;
2292   /* don't assert node !!! */
2293
2294   if (!opt_normalize) return node;
2295
2296   /* Don't use get_Id_pred:  We get into an endless loop for
2297      self-referencing Ids. */
2298   if (node && (node->op == op_Id) && (node != (pred = node->in[0+1]))) {
2299     ir_node *rem_pred, *res;
2300
2301     if (pred->op != op_Id) return pred; /* shortcut */
2302     rem_pred = pred;
2303
2304     assert (get_irn_arity (node) > 0);
2305
2306     node->in[0+1] = node;
2307     res = skip_nop(rem_pred);
2308     if (res->op == op_Id) /* self-loop */ return node;
2309
2310     node->in[0+1] = res;
2311     return res;
2312   } else {
2313     return node;
2314   }
2315 }
2316 #endif
2317
2318
2319
2320 INLINE ir_node *
2321 skip_Id (ir_node *node) {
2322   return skip_nop(node);
2323 }
2324
2325 INLINE int
2326 is_Bad (ir_node *node) {
2327   assert(node);
2328   if ((node) && get_irn_opcode(node) == iro_Bad)
2329     return 1;
2330   return 0;
2331 }
2332
2333 INLINE int
2334 is_no_Block (ir_node *node) {
2335   assert(node);
2336   return (get_irn_opcode(node) != iro_Block);
2337 }
2338
2339 INLINE int
2340 is_Block (ir_node *node) {
2341   assert(node);
2342   return (get_irn_opcode(node) == iro_Block);
2343 }
2344
2345 /* returns true if node is a Unknown node. */
2346 INLINE int
2347 is_Unknown (ir_node *node) {
2348   assert(node);
2349   return (get_irn_opcode(node) == iro_Unknown);
2350 }
2351
2352 INLINE int
2353 is_Proj (const ir_node *node) {
2354   assert(node);
2355   return node->op == op_Proj
2356     || (!interprocedural_view && node->op == op_Filter);
2357 }
2358
2359 /* Returns true if the operation manipulates control flow. */
2360 int
2361 is_cfop(ir_node *node) {
2362   return is_cfopcode(get_irn_op(node));
2363 }
2364
2365 /* Returns true if the operation manipulates interprocedural control flow:
2366    CallBegin, EndReg, EndExcept */
2367 INLINE int is_ip_cfop(ir_node *node) {
2368   return is_ip_cfopcode(get_irn_op(node));
2369 }
2370
2371 ir_graph *get_ip_cfop_irg(ir_node *n) {
2372   return get_irn_irg(n);
2373 }
2374
2375 /* Returns true if the operation can change the control flow because
2376    of an exception. */
2377 int
2378 is_fragile_op(ir_node *node) {
2379   return (   (get_irn_opcode(node) == iro_Call)
2380           || (get_irn_opcode(node) == iro_Quot)
2381           || (get_irn_opcode(node) == iro_DivMod)
2382           || (get_irn_opcode(node) == iro_Div)
2383           || (get_irn_opcode(node) == iro_Mod)
2384           || (get_irn_opcode(node) == iro_Load)
2385           || (get_irn_opcode(node) == iro_Store)
2386           || (get_irn_opcode(node) == iro_Alloc)
2387           || (get_irn_opcode(node) == iro_Bad)
2388           || (get_irn_opcode(node) == iro_Unknown));
2389 }
2390
2391
2392 /* Returns the memory operand of fragile operations. */
2393 ir_node *get_fragile_op_mem(ir_node *node) {
2394   assert(node && is_fragile_op(node));
2395
2396   switch (get_irn_opcode (node)) {
2397   case iro_Call  :
2398   case iro_Quot  :
2399   case iro_DivMod:
2400   case iro_Div   :
2401   case iro_Mod   :
2402   case iro_Load  :
2403   case iro_Store :
2404   case iro_Alloc :
2405     return get_irn_n(node, 0);
2406   case iro_Bad   :
2407   case iro_Unknown:
2408     return node;
2409   default: ;
2410     assert(0 && "not reached");
2411     return NULL;
2412   }
2413 }