fixed is_Cmp()
[libfirm] / ir / ir / irnode_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irnode_t.h
4  * Purpose:     Representation of an intermediate operation -- private header.
5  * Author:      Martin Trapp, Christian Schaefer
6  * Modified by: Goetz Lindenmaier, Michael Beck
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 /**
14  * @file irnode_t.h
15  *
16  * Declarations of an ir node.
17  *
18  * @author Martin Trapp, Christian Schaefer
19  */
20 #ifndef _IRNODE_T_H_
21 #define _IRNODE_T_H_
22
23 #include "firm_config.h"
24 #include "irnode.h"
25 #include "irop_t.h"
26 #include "irgraph_t.h"
27 #include "irflag_t.h"
28 #include "firm_common_t.h"
29 #include "irdom_t.h" /* For size of struct dom_info. */
30 #include "dbginfo.h"
31 #include "irloop.h"
32 #include "array.h"
33
34 #include "set.h"
35 #include "list.h"
36 #include "entity_t.h"
37 #include "type_t.h"
38 #include "tv_t.h"
39 #include "irextbb_t.h"
40
41
42 /** ir node attributes **/
43
44 /** Block attributes */
45 typedef struct {
46   /* General attributes */
47   ir_graph *irg;
48   unsigned long block_visited;  /**< for the walker that walks over all blocks. */
49   /* Attributes private to construction: */
50   unsigned matured:1;         /**< if set, all in-nodes of the block are fixed */
51   unsigned dead:1;            /**< if set, the block is dead (and could be replace by a Bad */
52   ir_node **graph_arr;        /**< array to store all parameters */
53   /* Attributes holding analyses information */
54   dom_info dom;               /**< Datastructure that holds information about dominators.
55                                    @@@ @todo
56                                    Eventually overlay with graph_arr as only valid
57                                    in different phases.  Eventually inline the whole
58                                    datastructure. */
59   dom_info pdom;              /**< Datastructure that holds information about post-dominators. */
60   ir_node ** in_cg;           /**< array with predecessors in
61                                * interprocedural_view, if they differ
62                                * from intraprocedural predecessors */
63   int *backedge;              /**< Field n set to true if pred n is backedge.
64                                    @@@ @todo Ev. replace by bit field! */
65   int *cg_backedge;           /**< Field n set to true if pred n is interprocedural backedge.
66                                    @@@ @todo Ev. replace by bit field! */
67   ir_extblk *extblk;          /**< the extended basic block this block belongs to */
68
69   struct list_head succ_head; /**< A list head for all successor edges of a block. */
70
71 } block_attr;
72
73 /** Cond attributes. */
74 typedef struct {
75   cond_kind kind;           /**< flavor of Cond */
76   long default_proj;        /**< only for non-binary Conds: biggest Proj number, i.e. the one used for default. */
77   cond_jmp_predicate pred;  /**< only for binary Conds: The jump predication. */
78 } cond_attr;
79
80 /** Const attributes. */
81 typedef struct {
82   tarval  *tv;       /**< the target value */
83   ir_type *tp;       /**< the source type, for analyses. default: type_unknown. */
84 } const_attr;
85
86 /** SymConst attributes. */
87 typedef struct {
88   symconst_symbol sym;  // old tori
89   symconst_kind num;
90   ir_type *tp;       /**< the source type, for analyses. default: type_unknown. */
91 } symconst_attr;
92
93 /** Sel attributes. */
94 typedef struct {
95   entity *ent;          /**< entity to select */
96 } sel_attr;
97
98 /** Exception attributes. */
99 typedef struct {
100   op_pin_state   pin_state;     /**< the pin state for operations that might generate a exception:
101                                      If it's know that no exception will be generated, could be set to
102                                      op_pin_state_floats. */
103 #if PRECISE_EXC_CONTEXT
104   struct ir_node **frag_arr;    /**< For Phi node construction in case of exception */
105 #endif
106 } except_attr;
107
108 /** Call attributes. */
109 typedef struct {
110   except_attr    exc;           /**< the exception attribute. MUST be the first one. */
111   ir_type *cld_tp;              /**< type of called procedure */
112   entity ** callee_arr;         /**< result of callee analysis */
113 } call_attr;
114
115 /** Alloc attributes. */
116 typedef struct {
117   except_attr    exc;           /**< the exception attribute. MUST be the first one. */
118   ir_type *type;                /**< Type of the allocated object.  */
119   where_alloc where;            /**< stack, heap or other managed part of memory */
120 } alloc_attr;
121
122 /** Free attributes. */
123 typedef struct {
124   ir_type *type;                /**< Type of the allocated object.  */
125   where_alloc where;            /**< stack, heap or other managed part of memory */
126 } free_attr;
127
128 /** InstOf attributes. */
129 typedef struct {
130   except_attr    exc;           /**< the exception attribute. MUST be the first one. */
131   ir_type *type;                /**< the type of which the object pointer must be */
132 } io_attr;
133
134 /** Filter attributes. */
135 typedef struct {
136   long proj;                 /**< contains the result position to project (Proj) */
137   ir_node ** in_cg;          /**< array with interprocedural predecessors (Phi) */
138   int *backedge;              /**< Field n set to true if pred n is backedge.
139                      @todo Ev. replace by bitfield! */
140 } filter_attr;
141
142 /** EndReg/EndExcept attributes. */
143 typedef struct {
144   char dummy;
145 } end_attr;
146
147 /** CallBegin attributes. */
148 typedef struct {
149   ir_node * call;               /**< Associated Call-operation. */
150 } callbegin_attr;
151
152 /** Cast attributes. */
153 typedef struct {
154   ir_type *totype;              /**< Type of the casted node. */
155 } cast_attr;
156
157 /** Load attributes. */
158 typedef struct {
159   except_attr    exc;           /**< The exception attribute. MUST be the first one. */
160   ir_mode        *load_mode;    /**< The mode of this Load operation. */
161   ent_volatility volatility;      /**< The volatility of a Load/Store operation. */
162 } load_attr;
163
164 /** Store attributes. */
165 typedef struct {
166   except_attr    exc;           /**< the exception attribute. MUST be the first one. */
167   ent_volatility volatility;      /**< the volatility of a Store operation */
168 } store_attr;
169
170 typedef pn_Cmp confirm_attr;    /**< Attribute to hold compare operation */
171
172 /** CopyB attribute. */
173 typedef struct {
174   except_attr    exc;           /**< The exception attribute. MUST be the first one. */
175   ir_type        *data_type;    /**< Type of the copied entity. */
176 } copyb_attr;
177
178 /** Bound attribute. */
179 typedef struct {
180   except_attr    exc;           /**< The exception attribute. MUST be the first one. */
181 } bound_attr;
182
183 /** Conv attribute. */
184 typedef struct {
185   char           strict;        /**< If set, this is a strict Conv that cannot be removed. */
186 } conv_attr;
187
188 /**
189  * Edge info to put into an irn.
190  */
191 typedef struct _irn_edge_info_t {
192   struct list_head outs_head;  /**< The list of all outs. */
193   int out_count;               /**< Number of outs in the list. */
194 } irn_edge_info_t;
195
196
197 /** Some IR-nodes just have one attribute, these are stored here,
198    some have more. Their name is 'irnodename_attr' */
199 typedef union {
200   block_attr     block;   /**< For Block: Fields needed to construct it */
201   cond_attr      cond;    /**< For Cond. */
202   const_attr     con;     /**< For Const: contains the value of the constant and a type */
203   symconst_attr  symc;    /**< For SymConst. */
204   sel_attr       sel;     /**< For Sel. */
205   call_attr      call;    /**< For Call: pointer to the type of the method to call */
206   callbegin_attr callbegin; /**< For CallBegin */
207   alloc_attr     alloc;  /**< For Alloc. */
208   free_attr      free;   /**< For Free. */
209   io_attr        instof; /**< For InstOf */
210   cast_attr      cast;   /**< For Cast. */
211   load_attr      load;   /**< For Load. */
212   store_attr     store;  /**< For Store. */
213   int            phi0_pos;  /**< For Phi. Used to remember the value defined by
214                    this Phi node.  Needed when the Phi is completed
215                    to call get_r_internal_value to find the
216                    predecessors. If this attribute is set, the Phi
217                    node takes the role of the obsolete Phi0 node,
218                    therefore the name. */
219   int *phi_backedge;    /**< For Phi after construction.
220                            Field n set to true if pred n is backedge.
221                            @todo Ev. replace by bitfield! */
222   long           proj;          /**< For Proj: contains the result position to project */
223   confirm_attr   confirm_cmp;   /**< For Confirm: compare operation */
224   filter_attr    filter;        /**< For Filter */
225   end_attr       end;           /**< For EndReg, EndExcept */
226   except_attr    except;        /**< For Phi node construction in case of exceptions */
227   copyb_attr     copyb;         /**< For CopyB operation */
228   bound_attr     bound;         /**< For Bound operation */
229   conv_attr      conv;          /**< For Conv operation */
230 } attr;
231
232
233 /** common structure of an irnode
234     if the node has some attributes, they are stored in attr */
235 struct ir_node {
236   /* ------- Basics of the representation  ------- */
237   firm_kind kind;          /**< distinguishes this node from others */
238   ir_op *op;               /**< Opcode of this node. */
239   ir_mode *mode;           /**< Mode of this node. */
240   struct ir_node **in;     /**< The array of predecessors / operands. */
241   unsigned long visited;   /**< Visited counter for walks of the graph. */
242   unsigned node_idx;       /**< The node index of this node in its graph. */
243   void *link;              /**< To attach additional information to the node, e.g.
244                               used while construction to link Phi0 nodes and
245                               during optimization to link to nodes that
246                               shall replace a node. */
247   /* ------- Fields for optimizations / analysis information ------- */
248   struct ir_node **out;    /**< @deprecated array of out edges. */
249   struct dbg_info* dbi;    /**< A pointer to information for debug support. */
250   /* ------- For debugging ------- */
251 #ifdef DEBUG_libfirm
252   int out_valid;
253   long node_nr;            /**< A unique node number for each node to make output
254                                 readable. */
255 #endif
256   /* ------- For analyses -------- */
257   ir_loop *loop;           /**< the loop the node is in. Access routines in irloop.h */
258 #ifdef DO_HEAPANALYSIS
259   struct abstval *av;      /**< the abstract value of this node */
260   struct section *sec;
261 #endif
262   irn_edge_info_t edge_info;  /**< everlasting out edges */
263   /* ------- Opcode depending fields -------- */
264   attr attr;               /**< attribute of this node. Depends on opcode.
265                               Must be last field of struct ir_node. */
266 };
267
268
269 /**
270  * Returns the array with the ins.  The content of the array may not be
271  * changed.
272  * Note that this function returns the whole in array including the
273  * block predecessor. So, it is NOT symmetric with set_irn_in().
274  */
275 ir_node     **get_irn_in            (const ir_node *node);
276
277 /** @{ */
278 /** access attributes directly */
279 const_attr    get_irn_const_attr    (ir_node *node);
280 long          get_irn_proj_attr     (ir_node *node);
281 alloc_attr    get_irn_alloc_attr    (ir_node *node);
282 free_attr     get_irn_free_attr     (ir_node *node);
283 symconst_attr get_irn_symconst_attr (ir_node *node);
284 ir_type      *get_irn_call_attr     (ir_node *node);
285 ir_type      *get_irn_funccall_attr (ir_node *node);
286 sel_attr      get_irn_sel_attr      (ir_node *node);
287 int           get_irn_phi_attr      (ir_node *node);
288 block_attr    get_irn_block_attr    (ir_node *node);
289 load_attr     get_irn_load_attr     (ir_node *node);
290 store_attr    get_irn_store_attr    (ir_node *node);
291 except_attr   get_irn_except_attr   (ir_node *node);
292 /** @} */
293
294 /**
295  * The amount of additional space for custom data to be allocated upon creating a new node.
296  */
297 extern unsigned firm_add_node_size;
298
299 /**
300  * Sets the get_type operation for an ir_op_ops.
301  *
302  * @param code   the opcode for the default operation
303  * @param ops    the operations initialized
304  *
305  * @return
306  *    The operations.
307  */
308 ir_op_ops *firm_set_default_get_type(opcode code, ir_op_ops *ops);
309
310 /**
311  * Sets the get_type_attr operation for an ir_op_ops.
312  *
313  * @param code   the opcode for the default operation
314  * @param ops    the operations initialized
315  *
316  * @return
317  *    The operations.
318  */
319 ir_op_ops *firm_set_default_get_type_attr(opcode code, ir_op_ops *ops);
320
321 /**
322  * Sets the get_entity_attr operation for an ir_op_ops.
323  *
324  * @param code   the opcode for the default operation
325  * @param ops    the operations initialized
326  *
327  * @return
328  *    The operations.
329  */
330 ir_op_ops *firm_set_default_get_entity_attr(opcode code, ir_op_ops *ops);
331
332 /*-------------------------------------------------------------------*/
333 /*  These function are most used in libfirm.  Give them as static    */
334 /*  functions so they can be inlined.                                */
335 /*-------------------------------------------------------------------*/
336
337 /**
338  * Checks whether a pointer points to a ir node.
339  * Intern version for libFirm.
340  */
341 static INLINE int
342 _is_ir_node(const void *thing) {
343   return (get_kind(thing) == k_ir_node);
344 }
345
346 /**
347  * Gets the op of a node.
348  * Intern version for libFirm.
349  */
350 static INLINE ir_op *
351 _get_irn_op(const ir_node *node) {
352   assert(node);
353   return node->op;
354 }
355
356 static INLINE void
357 _set_irn_op(ir_node *node, ir_op *op) {
358   assert(node);
359   node->op = op;
360 }
361
362 /** Copies all attributes stored in the old node  to the new node.
363     Assumes both have the same opcode and sufficient size. */
364 static INLINE void
365 copy_node_attr(const ir_node *old_node, ir_node *new_node) {
366   ir_op *op = _get_irn_op(old_node);
367
368   /* must always exist */
369   op->ops.copy_attr(old_node, new_node);
370 }
371
372 /**
373  * Gets the opcode of a node.
374  * Intern version for libFirm.
375  */
376 static INLINE opcode
377 _get_irn_opcode(const ir_node *node) {
378   assert(k_ir_node == get_kind(node));
379   assert(node->op);
380   return node->op->code;
381 }
382
383 /**
384  * Returns the number of predecessors without the block predecessor.
385  * Intern version for libFirm.
386  */
387 static INLINE int
388 _get_irn_intra_arity(const ir_node *node) {
389   assert(node);
390   return ARR_LEN(node->in) - 1;
391 }
392
393 /**
394  * Returns the number of predecessors without the block predecessor.
395  * Intern version for libFirm.
396  */
397 static INLINE int
398 _get_irn_inter_arity(const ir_node *node) {
399   assert(node);
400   if (_get_irn_op(node) == op_Filter) {
401     assert(node->attr.filter.in_cg);
402     return ARR_LEN(node->attr.filter.in_cg) - 1;
403   } else if (_get_irn_op(node) == op_Block && node->attr.block.in_cg) {
404     return ARR_LEN(node->attr.block.in_cg) - 1;
405   }
406   return _get_irn_intra_arity(node);
407 }
408
409 /**
410  * Returns the number of predecessors without the block predecessor.
411  * Intern version for libFirm.
412  */
413 extern int (*_get_irn_arity)(const ir_node *node);
414
415 /**
416  * Intern version for libFirm.
417  */
418 static INLINE ir_node *
419 _get_irn_intra_n(const ir_node *node, int n) {
420   ir_node *nn;
421
422   assert(node); assert(-1 <= n && n < _get_irn_intra_arity(node));
423
424   nn = node->in[n + 1];
425   if (!nn || (nn->op != op_Id)) return nn;
426
427   return (node->in[n + 1] = skip_Id(nn));
428 }
429
430 /**
431  * Intern version for libFirm.
432  */
433 static INLINE ir_node*
434 _get_irn_inter_n(const ir_node *node, int n) {
435   assert(node); assert(-1 <= n && n < _get_irn_inter_arity(node));
436
437   /* handle Filter and Block specially */
438   if (_get_irn_op(node) == op_Filter) {
439     assert(node->attr.filter.in_cg);
440     return (node->attr.filter.in_cg[n + 1] = skip_Id(node->attr.filter.in_cg[n + 1]));
441   } else if (_get_irn_op(node) == op_Block && node->attr.block.in_cg) {
442     return (node->attr.block.in_cg[n + 1] = skip_Id(node->attr.block.in_cg[n + 1]));
443   }
444
445   return _get_irn_intra_n(node, n);
446 }
447
448 /**
449  * Access to the predecessors of a node.
450  * To iterate over the operands iterate from 0 to i < get_irn_arity(),
451  * to iterate including the Block predecessor iterate from i = -1 to
452  * i < get_irn_arity.
453  * If it is a block, the entry -1 is NULL.
454  * Intern version for libFirm.
455  */
456 extern ir_node *(*_get_irn_n)(const ir_node *node, int n);
457
458 /**
459  * Gets the mode of a node.
460  * Intern version for libFirm.
461  */
462 static INLINE ir_mode *
463 _get_irn_mode(const ir_node *node) {
464   assert(node);
465   return node->mode;
466 }
467
468 /**
469  * Sets the mode of a node.
470  * Intern version of libFirm.
471  */
472 static INLINE void
473 _set_irn_mode(ir_node *node, ir_mode *mode) {
474   assert(node);
475   node->mode = mode;
476 }
477
478 /**
479  * Gets the visited counter of a node.
480  * Intern version for libFirm.
481  */
482 static INLINE unsigned long
483 _get_irn_visited(const ir_node *node) {
484   assert(node);
485   return node->visited;
486 }
487
488 /**
489  * Sets the visited counter of a node.
490  * Intern version for libFirm.
491  */
492 static INLINE void
493 _set_irn_visited(ir_node *node, unsigned long visited) {
494   assert(node);
495   node->visited = visited;
496 }
497
498 /**
499  * Mark a node as visited in a graph.
500  * Intern version for libFirm.
501  */
502 static INLINE void
503 _mark_irn_visited(ir_node *node) {
504   assert(node);
505   node->visited = current_ir_graph->visited;
506 }
507
508 /**
509  * Returns non-zero if a node of was visited.
510  * Intern version for libFirm.
511  */
512 static INLINE int
513 _irn_visited(const ir_node *node) {
514   assert(node);
515   return (node->visited >= current_ir_graph->visited);
516 }
517
518 /**
519  * Returns non-zero if a node of was NOT visited.
520  * Intern version for libFirm.
521  */
522 static INLINE int
523 _irn_not_visited(const ir_node *node) {
524   assert(node);
525   return (node->visited < current_ir_graph->visited);
526 }
527
528 /**
529  * Sets the link of a node.
530  * Intern version of libFirm.
531  */
532 static INLINE void
533 _set_irn_link(ir_node *node, void *link) {
534   assert(node);
535   /* Link field is used for Phi construction and various optimizations
536      in iropt. */
537   assert(get_irg_phase_state(get_irn_irg(node)) != phase_building);
538
539   node->link = link;
540 }
541
542 /**
543  * Returns the link of a node.
544  * Intern version of libFirm.
545  */
546 static INLINE void *
547 _get_irn_link(const ir_node *node) {
548   assert(node && _is_ir_node(node));
549   return node->link;
550 }
551
552 /**
553  * Returns whether the node _always_ must be pinned.
554  * I.e., the node is not floating after global cse.
555  *
556  * Intern version of libFirm.
557  */
558 static INLINE op_pin_state
559 _get_irn_pinned(const ir_node *node) {
560   op_pin_state state;
561   assert(node && _is_ir_node(node));
562   /* Check opcode */
563   state = _get_op_pinned(_get_irn_op(node));
564
565   if (state >= op_pin_state_exc_pinned)
566     return get_opt_fragile_ops() ? node->attr.except.pin_state : op_pin_state_pinned;
567   return state;
568 }
569
570 static INLINE op_pin_state
571 _is_irn_pinned_in_irg(const ir_node *node) {
572   if (get_irg_pinned(get_irn_irg(node)) == op_pin_state_floats)
573     return get_irn_pinned(node);
574   return op_pin_state_pinned;
575 }
576
577 static INLINE int
578 _is_unop(const ir_node *node) {
579   assert(node && _is_ir_node(node));
580   return (node->op->opar == oparity_unary);
581 }
582
583 static INLINE int
584 _is_binop(const ir_node *node) {
585   assert(node && _is_ir_node(node));
586   return (node->op->opar == oparity_binary);
587 }
588
589 static INLINE int
590 _is_Bad(const ir_node *node) {
591   assert(node);
592   return (_get_irn_op(node) == op_Bad);
593 }
594
595 static INLINE int
596 _is_Const(const ir_node *node) {
597   assert(node);
598   return (_get_irn_op(node) == op_Const);
599 }
600
601 static INLINE int
602 _is_Unknown(const ir_node *node) {
603   assert(node);
604   return (_get_irn_op(node) == op_Unknown);
605 }
606
607 static INLINE int
608 _is_Return(const ir_node *node) {
609   assert(node);
610   return (_get_irn_op(node) == op_Return);
611 }
612
613 static INLINE int
614 _is_Call(const ir_node *node) {
615   assert(node);
616   return (_get_irn_op(node) == op_Call);
617 }
618
619 static INLINE int
620 _is_Sel(const ir_node *node) {
621   assert(node);
622   return (_get_irn_op(node) == op_Sel);
623 }
624
625 static INLINE int
626 _is_Mux(const ir_node *node) {
627   assert(node);
628   if (node) {
629     ir_op *op = _get_irn_op(node);
630     return (op == op_Mux || ((op == op_Psi) && _get_irn_arity(node) == 3));
631   }
632   return 0;
633 }
634
635 static INLINE int
636 _is_Load(const ir_node *node) {
637   assert(node);
638   return (_get_irn_op(node) == op_Load);
639 }
640
641 static INLINE int
642 _is_Sync(const ir_node *node) {
643   assert(node);
644   return (_get_irn_op(node) == op_Sync);
645 }
646
647 static INLINE int
648 _is_Confirm(const ir_node *node) {
649   assert(node);
650   return (_get_irn_op(node) == op_Confirm);
651 }
652
653 static INLINE int
654 _is_SymConst(const ir_node *node) {
655   assert(node);
656   return (_get_irn_op(node) == op_SymConst);
657 }
658
659 static INLINE int
660 _is_Cond(const ir_node *node) {
661   assert(node);
662   return (_get_irn_op(node) == op_Cond);
663 }
664
665 static INLINE int
666 _is_Cmp(const ir_node *node) {
667   assert(node);
668   return (_get_irn_op(node) == op_Cmp);
669 }
670
671 static INLINE int
672 _is_Alloc(const ir_node *node) {
673   assert(node);
674   return (_get_irn_op(node) == op_Alloc);
675 }
676
677 static INLINE int
678 _is_no_Block(const ir_node *node) {
679   assert(node && _is_ir_node(node));
680   return (_get_irn_op(node) != op_Block);
681 }
682
683 static INLINE int
684 _is_Block(const ir_node *node) {
685   assert(node && _is_ir_node(node));
686   return (_get_irn_op(node) == op_Block);
687 }
688
689 static INLINE int
690 _get_Block_n_cfgpreds(const ir_node *node) {
691   assert(_is_Block(node));
692   return _get_irn_arity(node);
693 }
694
695 static INLINE ir_node *
696 _get_Block_cfgpred(ir_node *node, int pos) {
697   assert(0 <= pos && pos < get_irn_arity(node));
698   assert(_is_Block(node));
699   return _get_irn_n(node, pos);
700 }
701
702 /* Get the predecessor block.
703  *
704  *  Returns the block corresponding to the predecessor pos.
705  *
706  *  There are several ambiguities we resolve with this function:
707  *  - The direct predecessor can be a Proj, which is not pinned.
708  *    We walk from the predecessor to the next pinned node
709  *    (skip_Proj) and return the block that node is in.
710  *  - If we encounter the Bad node, this function does not return
711  *    Start, but the Bad node.
712  */
713 static INLINE ir_node  *
714 _get_Block_cfgpred_block(ir_node *node, int pos) {
715   ir_node *res = skip_Proj(get_Block_cfgpred(node, pos));
716   if (!is_Bad(res))
717     res = get_nodes_block(res);
718   return res;
719 }
720
721 static INLINE unsigned long
722 _get_Block_block_visited(ir_node *node) {
723   assert(node->op == op_Block);
724   return node->attr.block.block_visited;
725 }
726
727 static INLINE void
728 _set_Block_block_visited(ir_node *node, unsigned long visit) {
729   assert(node->op == op_Block);
730   node->attr.block.block_visited = visit;
731 }
732
733 /* For this current_ir_graph must be set. */
734 static INLINE void
735 _mark_Block_block_visited(ir_node *node) {
736   assert(node->op == op_Block);
737   node->attr.block.block_visited = get_irg_block_visited(current_ir_graph);
738 }
739
740 static INLINE int
741 _Block_not_block_visited(ir_node *node) {
742   assert(node->op == op_Block);
743   return (node->attr.block.block_visited < get_irg_block_visited(current_ir_graph));
744 }
745
746 static INLINE ir_node *
747 _set_Block_dead(ir_node *block) {
748   assert(_get_irn_op(block) == op_Block);
749   block->attr.block.dead = 1;
750   return block;
751 }
752
753 static INLINE int
754 _is_Block_dead(const ir_node *block) {
755   ir_op *op = _get_irn_op(block);
756
757   if (op == op_Bad)
758     return 1;
759   else {
760     assert(op == op_Block);
761     return block->attr.block.dead;
762   }
763 }
764
765 static INLINE tarval *_get_Const_tarval(ir_node *node) {
766   assert(_get_irn_op(node) == op_Const);
767   return node->attr.con.tv;
768 }
769
770 static INLINE cnst_classify_t _classify_Const(ir_node *node) {
771   ir_op *op;
772   assert(_is_ir_node(node));
773
774   op = _get_irn_op(node);
775
776   if (op == op_Const)
777     return classify_tarval(_get_Const_tarval(node));
778   else if(op == op_SymConst)
779     return CNST_SYMCONST;
780
781   return CNST_NO_CONST;
782 }
783
784 static INLINE int _is_irn_forking(const ir_node *node) {
785   return is_op_forking(_get_irn_op(node));
786 }
787
788 static INLINE ir_type *_get_irn_type(ir_node *node) {
789   return _get_irn_op(node)->ops.get_type(node);
790 }
791
792 static INLINE ir_type *_get_irn_type_attr(ir_node *node) {
793   return _get_irn_op(node)->ops.get_type_attr(node);
794 }
795
796 static INLINE entity *_get_irn_entity_attr(ir_node *node) {
797   return _get_irn_op(node)->ops.get_entity_attr(node);
798 }
799
800 static INLINE int _is_irn_constlike(const ir_node *node) {
801   return is_op_constlike(_get_irn_op(node));
802 }
803
804 static INLINE int _is_irn_always_opt(const ir_node *node) {
805   return is_op_always_opt(_get_irn_op(node));
806 }
807
808 static INLINE int _is_irn_keep(const ir_node *node) {
809   return is_op_keep(_get_irn_op(node));
810 }
811
812 static INLINE int _is_irn_machine_op(const ir_node *node) {
813   return is_op_machine(_get_irn_op(node));
814 }
815
816 static INLINE int _is_irn_machine_operand(const ir_node *node) {
817   return is_op_machine_operand(_get_irn_op(node));
818 }
819
820 static INLINE int _is_irn_machine_user(const ir_node *node, unsigned n) {
821   return is_op_machine_user(_get_irn_op(node), n);
822 }
823
824 static INLINE cond_jmp_predicate _get_Cond_jmp_pred(ir_node *node) {
825   assert(_get_irn_op(node) == op_Cond);
826   return node->attr.cond.pred;
827 }
828
829 static INLINE void _set_Cond_jmp_pred(ir_node *node, cond_jmp_predicate pred) {
830   assert(_get_irn_op(node) == op_Cond);
831   node->attr.cond.pred = pred;
832 }
833
834 static INLINE int _get_Psi_n_conds(ir_node *node) {
835   assert(_get_irn_op(node) == op_Psi);
836   return _get_irn_arity(node) >> 1;
837 }
838
839 static INLINE unsigned _get_irn_idx(const ir_node *node) {
840   return node->node_idx;
841 }
842
843 /* this section MUST contain all inline functions */
844 #define is_ir_node(thing)                     _is_ir_node(thing)
845 #define get_irn_intra_arity(node)             _get_irn_intra_arity(node)
846 #define get_irn_inter_arity(node)             _get_irn_inter_arity(node)
847 #define get_irn_arity(node)                   _get_irn_arity(node)
848 #define get_irn_intra_n(node, n)              _get_irn_intra_n(node, n)
849 #define get_irn_inter_n(node, n)              _get_irn_inter_n(node, n)
850 #define get_irn_n(node, n)                    _get_irn_n(node, n)
851 #define get_irn_mode(node)                    _get_irn_mode(node)
852 #define set_irn_mode(node, mode)              _set_irn_mode(node, mode)
853 #define get_irn_op(node)                      _get_irn_op(node)
854 #define set_irn_op(node, op)                  _set_irn_op(node, op)
855 #define get_irn_opcode(node)                  _get_irn_opcode(node)
856 #define get_irn_visited(node)                 _get_irn_visited(node)
857 #define set_irn_visited(node, v)              _set_irn_visited(node, v)
858 #define mark_irn_visited(node)                _mark_irn_visited(node)
859 #define irn_visited(node)                     _irn_visited(node)
860 #define irn_not_visited(node)                 _irn_not_visited(node)
861 #define set_irn_link(node, link)              _set_irn_link(node, link)
862 #define get_irn_link(node)                    _get_irn_link(node)
863 #define get_irn_pinned(node)                  _get_irn_pinned(node)
864 #define is_irn_pinned_in_irg(node)            _is_irn_pinned_in_irg(node)
865 #define is_unop(node)                         _is_unop(node)
866 #define is_binop(node)                        _is_binop(node)
867 #define is_Const(node)                        _is_Const(node)
868 #define is_Unknown(node)                      _is_Unknown(node)
869 #define is_Return(node)                       _is_Return(node)
870 #define is_Call(node)                         _is_Call(node)
871 #define is_Sel(node)                          _is_Sel(node)
872 #define is_Mux(node)                          _is_Mux(node)
873 #define is_Load(node)                         _is_Load(node)
874 #define is_Sync(node)                         _is_Sync(node)
875 #define is_Confirm(node)                      _is_Confirm(node)
876 #define is_SymConst(node)                     _is_SymConst(node)
877 #define is_Cond(node)                         _is_Cond(node)
878 #define is_Cmp(node)                          _is_Cmp(node)
879 #define is_Alloc(node)                        _is_Alloc(node)
880 #define is_Bad(node)                          _is_Bad(node)
881 #define is_no_Block(node)                     _is_no_Block(node)
882 #define is_Block(node)                        _is_Block(node)
883 #define get_Block_n_cfgpreds(node)            _get_Block_n_cfgpreds(node)
884 #define get_Block_cfgpred(node, pos)          _get_Block_cfgpred(node, pos)
885 #define get_Block_cfgpred_block(node, pos)    _get_Block_cfgpred_block(node, pos)
886 #define get_Block_block_visited(node)         _get_Block_block_visited(node)
887 #define set_Block_block_visited(node, visit)  _set_Block_block_visited(node, visit)
888 #define mark_Block_block_visited(node)        _mark_Block_block_visited(node)
889 #define Block_not_block_visited(node)         _Block_not_block_visited(node)
890 #define set_Block_dead(block)                 _set_Block_dead(block)
891 #define is_Block_dead(block)                  _is_Block_dead(block)
892 #define get_Const_tarval(node)                _get_Const_tarval(node)
893 #define classify_Const(node)                  _classify_Const(node)
894 #define is_irn_forking(node)                  _is_irn_forking(node)
895 #define get_irn_type(node)                    _get_irn_type(node)
896 #define get_irn_type_attr(node)               _get_irn_type_attr(node)
897 #define get_irn_entity_attr(node)             _get_irn_entity_attr(node)
898 #define is_irn_constlike(node)                _is_irn_constlike(node)
899 #define is_irn_always_opt(node)               _is_irn_always_opt(node)
900 #define is_irn_keep(node)                     _is_irn_keep(node)
901 #define is_irn_machine_op(node)               _is_irn_machine_op(node)
902 #define is_irn_machine_operand(node)          _is_irn_machine_operand(node)
903 #define is_irn_machine_user(node, n)          _is_irn_machine_user(node, n)
904 #define get_Cond_jmp_pred(node)               _get_Cond_jmp_pred(node)
905 #define set_Cond_jmp_pred(node, pred)         _set_Cond_jmp_pred(node, pred)
906 #define get_Psi_n_conds(node)                 _get_Psi_n_conds(node)
907 #define get_irn_idx(node)                     _get_irn_idx(node)
908
909 #endif /* _IRNODE_T_H_ */