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