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