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