s/\<\(LC_\)\?INLINE\>/inline/.
[libfirm] / ir / ir / irnode_t.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Representation of an intermediate operation -- private header.
23  * @author  Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
24  * @version $Id$
25  */
26 #ifndef FIRM_IR_IRNODE_T_H
27 #define FIRM_IR_IRNODE_T_H
28
29 #include "irtypes.h"
30 #include "irnode.h"
31 #include "irop_t.h"
32 #include "irgraph_t.h"
33 #include "irflag_t.h"
34 #include "firm_common_t.h"
35 #include "array.h"
36
37 /**
38  * Returns the array with the ins.  The content of the array may not be
39  * changed.
40  * Note that this function returns the whole in array including the
41  * block predecessor. So, it is NOT symmetric with set_irn_in().
42  */
43 ir_node     **get_irn_in            (const ir_node *node);
44
45 /** @{ */
46 /** access attributes directly */
47 const_attr    *get_irn_const_attr    (ir_node *node);
48 long          get_irn_proj_attr      (ir_node *node);
49 alloc_attr    *get_irn_alloc_attr    (ir_node *node);
50 free_attr     *get_irn_free_attr     (ir_node *node);
51 symconst_attr *get_irn_symconst_attr (ir_node *node);
52 ir_type       *get_irn_call_attr     (ir_node *node);
53 ir_type       *get_irn_funccall_attr (ir_node *node);
54 sel_attr      *get_irn_sel_attr      (ir_node *node);
55 phi_attr      *get_irn_phi_attr      (ir_node *node);
56 block_attr    *get_irn_block_attr    (ir_node *node);
57 load_attr     *get_irn_load_attr     (ir_node *node);
58 store_attr    *get_irn_store_attr    (ir_node *node);
59 except_attr   *get_irn_except_attr   (ir_node *node);
60 divmod_attr   *get_irn_divmod_attr   (ir_node *node);
61 /** @} */
62
63 /**
64  * The amount of additional space for custom data to be allocated upon creating a new node.
65  */
66 extern unsigned firm_add_node_size;
67
68 /**
69  * Sets the get_type operation for an ir_op_ops.
70  *
71  * @param code   the opcode for the default operation
72  * @param ops    the operations initialized
73  *
74  * @return
75  *    The operations.
76  */
77 ir_op_ops *firm_set_default_get_type(ir_opcode code, ir_op_ops *ops);
78
79 /**
80  * Sets the get_type_attr operation for an ir_op_ops.
81  *
82  * @param code   the opcode for the default operation
83  * @param ops    the operations initialized
84  *
85  * @return
86  *    The operations.
87  */
88 ir_op_ops *firm_set_default_get_type_attr(ir_opcode code, ir_op_ops *ops);
89
90 /**
91  * Sets the get_entity_attr operation for an ir_op_ops.
92  *
93  * @param code   the opcode for the default operation
94  * @param ops    the operations initialized
95  *
96  * @return
97  *    The operations.
98  */
99 ir_op_ops *firm_set_default_get_entity_attr(ir_opcode code, ir_op_ops *ops);
100
101 /*-------------------------------------------------------------------*/
102 /*  These function are most used in libfirm.  Give them as static    */
103 /*  functions so they can be inlined.                                */
104 /*-------------------------------------------------------------------*/
105
106 /**
107  * Checks whether a pointer points to a ir node.
108  * Intern version for libFirm.
109  */
110 static inline int
111 _is_ir_node(const void *thing) {
112         return (get_kind(thing) == k_ir_node);
113 }
114
115 /**
116  * Gets the op of a node.
117  * Intern version for libFirm.
118  */
119 static inline ir_op *
120 _get_irn_op(const ir_node *node) {
121         assert(node);
122         return node->op;
123 }
124
125 static inline void
126 _set_irn_op(ir_node *node, ir_op *op) {
127         assert(node);
128         node->op = op;
129 }
130
131 /** Copies all attributes stored in the old node  to the new node.
132     Assumes both have the same opcode and sufficient size. */
133 static inline void
134 copy_node_attr(const ir_node *old_node, ir_node *new_node) {
135         ir_op *op = _get_irn_op(old_node);
136
137         /* must always exist */
138         op->ops.copy_attr(old_node, new_node);
139 }
140
141 /**
142  * Gets the opcode of a node.
143  * Intern version for libFirm.
144  */
145 static inline unsigned
146 _get_irn_opcode(const ir_node *node) {
147         assert(k_ir_node == get_kind(node));
148         assert(node->op);
149         return node->op->code;
150 }
151
152 /**
153  * Returns the number of predecessors without the block predecessor.
154  * Intern version for libFirm.
155  */
156 static inline int
157 _get_irn_intra_arity(const ir_node *node) {
158         assert(node);
159         return ARR_LEN(node->in) - 1;
160 }
161
162 /**
163  * Returns the number of predecessors without the block predecessor.
164  * Intern version for libFirm.
165  */
166 static inline int
167 _get_irn_inter_arity(const ir_node *node) {
168         assert(node);
169         if (_get_irn_op(node) == op_Filter) {
170                 assert(node->attr.filter.in_cg);
171                 return ARR_LEN(node->attr.filter.in_cg) - 1;
172         } else if (_get_irn_op(node) == op_Block && node->attr.block.in_cg) {
173                 return ARR_LEN(node->attr.block.in_cg) - 1;
174         }
175         return _get_irn_intra_arity(node);
176 }
177
178 #ifdef INTERPROCEDURAL_VIEW
179 /**
180  * Returns the number of predecessors without the block predecessor.
181  * Intern version for libFirm.
182  */
183 extern int (*_get_irn_arity)(const ir_node *node);
184
185 #else
186
187 #define _get_irn_arity(n) _get_irn_intra_arity(n)
188 #endif
189
190 /**
191  * Intern version for libFirm.
192  */
193 static inline ir_node *
194 _get_irn_intra_n(const ir_node *node, int n) {
195         ir_node *nn;
196
197         assert(node);
198         assert(-1 <= n && n < _get_irn_intra_arity(node));
199
200         nn = node->in[n + 1];
201         if (nn == NULL) {
202                 /* only block and Anchor inputs are allowed to be NULL */
203                 assert((node->op == op_Anchor || n == -1) && "NULL input of a node");
204                 return NULL;
205         }
206         if (nn->op != op_Id) return nn;
207
208         return (node->in[n + 1] = skip_Id(nn));
209 }
210
211 /**
212  * Intern version for libFirm.
213  */
214 static inline ir_node*
215 _get_irn_inter_n(const ir_node *node, int n) {
216         assert(node); assert(-1 <= n && n < _get_irn_inter_arity(node));
217
218         /* handle Filter and Block specially */
219         if (_get_irn_op(node) == op_Filter) {
220                 assert(node->attr.filter.in_cg);
221                 return (node->attr.filter.in_cg[n + 1] = skip_Id(node->attr.filter.in_cg[n + 1]));
222         } else if (_get_irn_op(node) == op_Block && node->attr.block.in_cg) {
223                 return (node->attr.block.in_cg[n + 1] = skip_Id(node->attr.block.in_cg[n + 1]));
224         }
225
226         return _get_irn_intra_n(node, n);
227 }
228
229 /**
230  * returns a hash value for a node
231  */
232 static inline unsigned hash_irn(const ir_node *node)
233 {
234         return (unsigned) get_irn_idx(node);
235 }
236
237 /**
238  * Access to the predecessors of a node.
239  * To iterate over the operands iterate from 0 to i < get_irn_arity(),
240  * to iterate including the Block predecessor iterate from i = -1 to
241  * i < get_irn_arity.
242  * If it is a block, the entry -1 is NULL.
243  * Intern version for libFirm.
244  */
245 #ifdef INTERPROCEDURAL_VIEW
246 extern ir_node *(*_get_irn_n)(const ir_node *node, int n);
247 #else
248 #define _get_irn_n(n,i) _get_irn_intra_n(n,i)
249 #endif
250
251 static inline int _get_irn_deps(const ir_node *node) {
252         return node->deps ? ARR_LEN(node->deps) : 0;
253 }
254
255 static inline ir_node *_get_irn_dep(const ir_node *node, int pos) {
256         assert(node->deps && "dependency array node yet allocated. use add_irn_dep()");
257         assert(pos >= 0 && pos < ARR_LEN(node->deps) && "dependency index out of range");
258         return node->deps[pos];
259 }
260
261 static inline void
262 _set_irn_dep(ir_node *node, int pos, ir_node *dep) {
263         ir_node *old;
264
265         assert(node->deps && "dependency array node yet allocated. use add_irn_dep()");
266         assert(pos >= 0 && pos < ARR_LEN(node->deps) && "dependency index out of range");
267         old = node->deps[pos];
268         node->deps[pos] = dep;
269         edges_notify_edge_kind(node, pos, dep, old, EDGE_KIND_DEP, get_irn_irg(node));
270 }
271
272
273 static inline int
274 _get_irn_ins_or_deps(const ir_node *irn) {
275         return _get_irn_deps(irn) + _get_irn_arity(irn);
276 }
277
278 static inline ir_node *
279 _get_irn_in_or_dep(const ir_node *irn, int pos) {
280         int n_in = get_irn_arity(irn);
281         return pos < n_in ? get_irn_n(irn, pos) : get_irn_dep(irn, pos - n_in);
282 }
283
284 /**
285  * Gets the mode of a node.
286  * Intern version for libFirm.
287  */
288 static inline ir_mode *
289 _get_irn_mode(const ir_node *node) {
290         assert(node);
291         return node->mode;
292 }
293
294 /**
295  * Sets the mode of a node.
296  * Intern version of libFirm.
297  */
298 static inline void
299 _set_irn_mode(ir_node *node, ir_mode *mode) {
300         assert(node);
301         node->mode = mode;
302 }
303
304 /**
305  * Gets the visited counter of a node.
306  * Intern version for libFirm.
307  */
308 static inline ir_visited_t
309 _get_irn_visited(const ir_node *node) {
310         assert(node);
311         return node->visited;
312 }
313
314 /**
315  * Sets the visited counter of a node.
316  * Intern version for libFirm.
317  */
318 static inline void
319 _set_irn_visited(ir_node *node, ir_visited_t visited) {
320         assert(node);
321         node->visited = visited;
322 }
323
324 /**
325  * Mark a node as visited in a graph.
326  * Intern version for libFirm.
327  */
328 static inline void
329 _mark_irn_visited(ir_node *node) {
330         assert(node);
331         node->visited = current_ir_graph->visited;
332 }
333
334 /**
335  * Returns non-zero if a node of was visited.
336  * Intern version for libFirm.
337  */
338 static inline int
339 _irn_visited(const ir_node *node) {
340         assert(node);
341         return (node->visited >= current_ir_graph->visited);
342 }
343
344 static inline int
345 _irn_visited_else_mark(ir_node *node) {
346         if (_irn_visited(node))
347                 return 1;
348         _mark_irn_visited(node);
349         return 0;
350 }
351
352 /**
353  * Sets the link of a node.
354  * Intern version of libFirm.
355  */
356 static inline void
357 _set_irn_link(ir_node *node, void *link) {
358         assert(node);
359         node->link = link;
360 }
361
362 /**
363  * Returns the link of a node.
364  * Intern version of libFirm.
365  */
366 static inline void *
367 _get_irn_link(const ir_node *node) {
368         assert(node && _is_ir_node(node));
369         return node->link;
370 }
371
372 /**
373  * Returns whether the node _always_ must be pinned.
374  * I.e., the node is not floating after global cse.
375  *
376  * Intern version of libFirm.
377  */
378 static inline op_pin_state
379 _get_irn_pinned(const ir_node *node) {
380         op_pin_state state;
381         assert(node && _is_ir_node(node));
382         /* Check opcode */
383         state = _get_op_pinned(_get_irn_op(node));
384
385         if (state >= op_pin_state_exc_pinned)
386                 return get_opt_fragile_ops() ? node->attr.except.pin_state : op_pin_state_pinned;
387         return state;
388 }
389
390 static inline op_pin_state
391 _is_irn_pinned_in_irg(const ir_node *node) {
392         if (get_irg_pinned(get_irn_irg(node)) == op_pin_state_floats)
393                 return get_irn_pinned(node);
394         return op_pin_state_pinned;
395 }
396
397 static inline int
398 _is_unop(const ir_node *node) {
399         assert(node && _is_ir_node(node));
400         return (node->op->opar == oparity_unary);
401 }
402
403 static inline int
404 _is_binop(const ir_node *node) {
405         assert(node && _is_ir_node(node));
406         return (node->op->opar == oparity_binary);
407 }
408
409 static inline int
410 _is_Phi(const ir_node *node) {
411         ir_op *op;
412         assert(node);
413
414         op = get_irn_op(node);
415 #ifdef INTERPROCEDURAL_VIEW
416         if (op == op_Filter) return get_interprocedural_view();
417 #endif
418         return (op == op_Phi);
419 }
420
421 static inline int
422 _is_Proj(const ir_node *node) {
423         ir_op *op;
424         assert(node);
425
426         op = _get_irn_op(node);
427 #ifdef INTERPROCEDURAL_VIEW
428         if (op == op_Filter) return !get_interprocedural_view();
429 #endif
430         return (op == op_Proj);
431 }
432
433 static inline int
434 _is_Filter(const ir_node *node) {
435         assert(node);
436         return (_get_irn_op(node) == op_Filter);
437 }
438
439 static inline int
440 _is_Bad(const ir_node *node) {
441         assert(node);
442         return (_get_irn_op(node) == op_Bad);
443 }
444
445 static inline int
446 _is_NoMem(const ir_node *node) {
447         assert(node);
448         return (_get_irn_op(node) == op_NoMem);
449 }
450
451 static inline int
452 _is_Minus(const ir_node *node) {
453         assert(node);
454         return (_get_irn_op(node) == op_Minus);
455 }
456
457 static inline int
458 _is_Abs(const ir_node *node) {
459         assert(node);
460         return (_get_irn_op(node) == op_Abs);
461 }
462
463 static inline int
464 _is_Mod(const ir_node *node) {
465         assert(node);
466         return (_get_irn_op(node) == op_Mod);
467 }
468
469 static inline int
470 _is_Div(const ir_node *node) {
471         assert(node);
472         return (_get_irn_op(node) == op_Div);
473 }
474
475 static inline int
476 _is_DivMod(const ir_node *node) {
477         assert(node);
478         return (_get_irn_op(node) == op_DivMod);
479 }
480
481 static inline int
482 _is_Quot(const ir_node *node) {
483         assert(node);
484         return (_get_irn_op(node) == op_Quot);
485 }
486
487 static inline int
488 _is_Add(const ir_node *node) {
489         assert(node);
490         return (_get_irn_op(node) == op_Add);
491 }
492
493 static inline int
494 _is_Carry(const ir_node *node) {
495         assert(node);
496         return (_get_irn_op(node) == op_Carry);
497 }
498
499 static inline int
500 _is_And(const ir_node *node) {
501         assert(node);
502         return (_get_irn_op(node) == op_And);
503 }
504
505 static inline int
506 _is_Or(const ir_node *node) {
507         assert(node);
508         return (_get_irn_op(node) == op_Or);
509 }
510
511 static inline int
512 _is_Eor(const ir_node *node) {
513         assert(node);
514         return (_get_irn_op(node) == op_Eor);
515 }
516
517 static inline int
518 _is_Sub(const ir_node *node) {
519         assert(node);
520         return (_get_irn_op(node) == op_Sub);
521 }
522
523 static inline int
524 _is_Not(const ir_node *node) {
525         assert(node);
526         return (_get_irn_op(node) == op_Not);
527 }
528
529 static inline int
530 _is_Shl(const ir_node *node) {
531         assert(node);
532         return (_get_irn_op(node) == op_Shl);
533 }
534
535 static inline int
536 _is_Shr(const ir_node *node) {
537         assert(node);
538         return (_get_irn_op(node) == op_Shr);
539 }
540
541 static inline int
542 _is_Shrs(const ir_node *node) {
543         assert(node);
544         return (_get_irn_op(node) == op_Shrs);
545 }
546
547 static inline int
548 _is_Rotl(const ir_node *node) {
549         assert(node);
550         return (_get_irn_op(node) == op_Rotl);
551 }
552
553 static inline int
554 _is_Id(const ir_node *node) {
555         assert(node);
556         return (_get_irn_op(node) == op_Id);
557 }
558
559 static inline int
560 _is_Tuple(const ir_node *node) {
561         assert(node);
562         return (_get_irn_op(node) == op_Tuple);
563 }
564
565 static inline int
566 _is_Bound(const ir_node *node) {
567         assert(node);
568         return (_get_irn_op(node) == op_Bound);
569 }
570
571 static inline int
572 _is_Start(const ir_node *node) {
573         assert(node);
574         return (_get_irn_op(node) == op_Start);
575 }
576
577 static inline int
578 _is_End(const ir_node *node) {
579         assert(node);
580         return (_get_irn_op(node) == op_End);
581 }
582
583 static inline int
584 _is_Const(const ir_node *node) {
585         assert(node);
586         return (_get_irn_op(node) == op_Const);
587 }
588
589 static inline int
590 _is_Conv(const ir_node *node) {
591         assert(node);
592         return (_get_irn_op(node) == op_Conv);
593 }
594
595 static inline int
596 _is_strictConv(const ir_node *node) {
597         return _is_Conv(node) && get_Conv_strict(node);
598 }
599
600 static inline int
601 _is_Cast(const ir_node *node) {
602         assert(node);
603         return (_get_irn_op(node) == op_Cast);
604 }
605
606 static inline int
607 _is_CopyB(const ir_node *node) {
608         assert(node);
609         return (_get_irn_op(node) == op_CopyB);
610 }
611
612 static inline int
613 _is_Unknown(const ir_node *node) {
614         assert(node);
615         return (_get_irn_op(node) == op_Unknown);
616 }
617
618 static inline int
619 _is_Return(const ir_node *node) {
620         assert(node);
621         return (_get_irn_op(node) == op_Return);
622 }
623
624 static inline int
625 _is_Call(const ir_node *node) {
626         assert(node);
627         return (_get_irn_op(node) == op_Call);
628 }
629
630 static inline int
631 _is_CallBegin(const ir_node *node) {
632         assert(node);
633         return (_get_irn_op(node) == op_CallBegin);
634 }
635
636 static inline int
637 _is_Sel(const ir_node *node) {
638         assert(node);
639         return (_get_irn_op(node) == op_Sel);
640 }
641
642 static inline int
643 _is_Mul(const ir_node *node) {
644         assert(node);
645         return (_get_irn_op(node) == op_Mul);
646 }
647
648 static inline int
649 _is_Mulh(const ir_node *node) {
650         assert(node);
651         return (_get_irn_op(node) == op_Mulh);
652 }
653
654 static inline int
655 _is_Mux(const ir_node *node) {
656         assert(node);
657         return (_get_irn_op(node) == op_Mux);
658 }
659
660 static inline int
661 _is_Load(const ir_node *node) {
662         assert(node);
663         return (_get_irn_op(node) == op_Load);
664 }
665
666 static inline int
667 _is_Store(const ir_node *node) {
668         assert(node);
669         return (_get_irn_op(node) == op_Store);
670 }
671
672 static inline int
673 _is_Sync(const ir_node *node) {
674         assert(node);
675         return (_get_irn_op(node) == op_Sync);
676 }
677
678 static inline int
679 _is_Confirm(const ir_node *node) {
680         assert(node);
681         return (_get_irn_op(node) == op_Confirm);
682 }
683
684 static inline int
685 _is_Pin(const ir_node *node) {
686         assert(node);
687         return (_get_irn_op(node) == op_Pin);
688 }
689
690 static inline int
691 _is_SymConst(const ir_node *node) {
692         assert(node);
693         return (_get_irn_op(node) == op_SymConst);
694 }
695
696 static inline int
697 _is_SymConst_addr_ent(const ir_node *node) {
698         return is_SymConst(node) && get_SymConst_kind(node) == symconst_addr_ent;
699 }
700
701 static inline int
702 _is_Cond(const ir_node *node) {
703         assert(node);
704         return (_get_irn_op(node) == op_Cond);
705 }
706
707 static inline int
708 _is_Cmp(const ir_node *node) {
709         assert(node);
710         return (_get_irn_op(node) == op_Cmp);
711 }
712
713 static inline int
714 _is_Alloc(const ir_node *node) {
715         assert(node);
716         return (_get_irn_op(node) == op_Alloc);
717 }
718
719 static inline int
720 _is_Free(const ir_node *node) {
721         assert(node);
722         return (_get_irn_op(node) == op_Free);
723 }
724
725 static inline int
726 _is_Jmp(const ir_node *node) {
727         assert(node);
728         return (_get_irn_op(node) == op_Jmp);
729 }
730
731 static inline int
732 _is_IJmp(const ir_node *node) {
733         assert(node);
734         return (_get_irn_op(node) == op_IJmp);
735 }
736
737 static inline int
738 _is_Raise(const ir_node *node) {
739         assert(node);
740         return (_get_irn_op(node) == op_Raise);
741 }
742
743 static inline int
744 _is_ASM(const ir_node *node) {
745         assert(node);
746         return (_get_irn_op(node) == op_ASM);
747 }
748
749 static inline int
750 _is_Anchor(const ir_node *node) {
751         return (_get_irn_op(node) == op_Anchor);
752 }
753
754 static inline int
755 _is_no_Block(const ir_node *node) {
756         assert(node && _is_ir_node(node));
757         return (_get_irn_op(node) != op_Block);
758 }
759
760 static inline int
761 _is_Block(const ir_node *node) {
762         assert(node && _is_ir_node(node));
763         return (_get_irn_op(node) == op_Block);
764 }
765
766 static inline int
767 _get_Block_n_cfgpreds(const ir_node *node) {
768         assert(_is_Block(node));
769         return _get_irn_arity(node);
770 }
771
772 static inline ir_node *
773 _get_Block_cfgpred(const ir_node *node, int pos) {
774         assert(0 <= pos && pos < get_irn_arity(node));
775         assert(_is_Block(node));
776         return _get_irn_n(node, pos);
777 }
778
779 /* Get the predecessor block.
780  *
781  *  Returns the block corresponding to the predecessor pos.
782  *
783  *  There are several ambiguities we resolve with this function:
784  *  - The direct predecessor can be a Proj, which is not pinned.
785  *    We walk from the predecessor to the next pinned node
786  *    (skip_Proj) and return the block that node is in.
787  *  - If we encounter the Bad node, this function does not return
788  *    Start, but the Bad node.
789  */
790 static inline ir_node  *
791 _get_Block_cfgpred_block(const ir_node *node, int pos) {
792         ir_node *res = skip_Proj(get_Block_cfgpred(node, pos));
793         if (!is_Bad(res))
794                 res = get_nodes_block(res);
795         return res;
796 }
797
798 static inline ir_visited_t
799 _get_Block_block_visited(const ir_node *node) {
800         assert(node->op == op_Block);
801         return node->attr.block.block_visited;
802 }
803
804 static inline void
805 _set_Block_block_visited(ir_node *node, ir_visited_t visit) {
806         assert(node->op == op_Block);
807         node->attr.block.block_visited = visit;
808 }
809
810 /* For this current_ir_graph must be set. */
811 static inline void
812 _mark_Block_block_visited(ir_node *node) {
813         assert(node->op == op_Block);
814         node->attr.block.block_visited = get_irg_block_visited(current_ir_graph);
815 }
816
817 static inline int
818 _Block_block_visited(const ir_node *node) {
819         assert(node->op == op_Block);
820         return (node->attr.block.block_visited >= get_irg_block_visited(current_ir_graph));
821 }
822
823 static inline ir_node *
824 _set_Block_dead(ir_node *block) {
825         assert(_get_irn_op(block) == op_Block);
826         block->attr.block.dom.dom_depth = -1;
827         block->attr.block.is_dead = 1;
828         return block;
829 }
830
831 static inline int
832 _is_Block_dead(const ir_node *block) {
833         ir_op *op = _get_irn_op(block);
834
835         if (op == op_Bad)
836                 return 1;
837         else {
838                 assert(op == op_Block);
839                 return block->attr.block.is_dead;
840         }
841 }
842
843 static inline tarval *_get_Const_tarval(const ir_node *node) {
844         assert(_get_irn_op(node) == op_Const);
845         return node->attr.con.tv;
846 }
847
848 static inline int _is_Const_null(const ir_node *node) {
849         return tarval_is_null(_get_Const_tarval(node));
850 }
851
852 static inline int _is_Const_one(const ir_node *node) {
853         return tarval_is_one(_get_Const_tarval(node));
854 }
855
856 static inline int _is_Const_all_one(const ir_node *node) {
857         return tarval_is_all_one(_get_Const_tarval(node));
858 }
859
860 static inline int _is_irn_forking(const ir_node *node) {
861         return is_op_forking(_get_irn_op(node));
862 }
863
864 static inline ir_type *_get_irn_type(ir_node *node) {
865         return _get_irn_op(node)->ops.get_type(node);
866 }
867
868 static inline ir_type *_get_irn_type_attr(ir_node *node) {
869         return _get_irn_op(node)->ops.get_type_attr(node);
870 }
871
872 static inline ir_entity *_get_irn_entity_attr(ir_node *node) {
873   return _get_irn_op(node)->ops.get_entity_attr(node);
874 }
875
876 static inline int _is_irn_constlike(const ir_node *node) {
877         return is_op_constlike(_get_irn_op(node));
878 }
879
880 static inline int _is_irn_always_opt(const ir_node *node) {
881         return is_op_always_opt(_get_irn_op(node));
882 }
883
884 static inline int _is_irn_keep(const ir_node *node) {
885         return is_op_keep(_get_irn_op(node));
886 }
887
888 static inline int _is_irn_start_block_placed(const ir_node *node) {
889         return is_op_start_block_placed(_get_irn_op(node));
890 }
891
892 static inline int _is_irn_machine_op(const ir_node *node) {
893         return is_op_machine(_get_irn_op(node));
894 }
895
896 static inline int _is_irn_machine_operand(const ir_node *node) {
897         return is_op_machine_operand(_get_irn_op(node));
898 }
899
900 static inline int _is_irn_machine_user(const ir_node *node, unsigned n) {
901         return is_op_machine_user(_get_irn_op(node), n);
902 }
903
904 static inline cond_jmp_predicate _get_Cond_jmp_pred(const ir_node *node) {
905         assert(_get_irn_op(node) == op_Cond);
906         return node->attr.cond.pred;
907 }
908
909 static inline void _set_Cond_jmp_pred(ir_node *node, cond_jmp_predicate pred) {
910         assert(_get_irn_op(node) == op_Cond);
911         node->attr.cond.pred = pred;
912 }
913
914 static inline void *_get_irn_generic_attr(ir_node *node) {
915         return &node->attr;
916 }
917
918 static inline const void *_get_irn_generic_attr_const(const ir_node *node) {
919         return &node->attr;
920 }
921
922 static inline unsigned _get_irn_idx(const ir_node *node) {
923         return node->node_idx;
924 }
925
926 static inline dbg_info *_get_irn_dbg_info(const ir_node *n) {
927         return n->dbi;
928 }  /* get_irn_dbg_info */
929
930 static inline void _set_irn_dbg_info(ir_node *n, dbg_info *db) {
931         n->dbi = db;
932 }
933
934 /**
935  * Sets the Phi list of a block.
936  */
937 static inline void
938 _set_Block_phis(ir_node *block, ir_node *phi) {
939         assert(_is_Block(block));
940         assert(phi == NULL || _is_Phi(phi));
941         block->attr.block.phis = phi;
942 }
943
944 /**
945  * Returns the link of a node.
946  * Intern version of libFirm.
947  */
948 static inline ir_node *
949 _get_Block_phis(const ir_node *block) {
950         assert(_is_Block(block));
951         return block->attr.block.phis;
952 }
953
954 /**
955  * Sets the next link of a Phi.
956  */
957 static inline void
958 _set_Phi_next(ir_node *phi, ir_node *next) {
959         assert(_is_Phi(phi));
960         phi->attr.phi.next = next;
961 }
962
963 /**
964  * Returns the link of a node.
965  * Intern version of libFirm.
966  */
967 static inline ir_node *
968 _get_Phi_next(const ir_node *phi) {
969         assert(_is_Phi(phi));
970         return phi->attr.phi.next;
971 }
972
973 /** Add a Phi node to the list of Block Phi's. */
974 static inline void
975 _add_Block_phi(ir_node *block, ir_node *phi) {
976         _set_Phi_next(phi, _get_Block_phis(block));
977         _set_Block_phis(block, phi);
978 }
979
980 /** Get the Block mark (single bit). */
981 static inline unsigned
982 _get_Block_mark(const ir_node *block) {
983         assert(_is_Block(block));
984         return block->attr.block.marked;
985 }
986
987 /** Set the Block mark (single bit). */
988 static inline void
989 _set_Block_mark(ir_node *block, unsigned mark) {
990         assert(_is_Block(block));
991         block->attr.block.marked = mark;
992 }
993
994 /** Returns non-zero if a node is a routine parameter. */
995 static inline int
996 _is_arg_Proj(const ir_node *node) {
997         if (! is_Proj(node))
998                 return 0;
999         node = get_Proj_pred(node);
1000         if (! is_Proj(node))
1001                 return 0;
1002         return pn_Start_T_args == get_Proj_proj(node) && is_Start(get_Proj_pred(node));
1003 }
1004
1005
1006 /* this section MUST contain all inline functions */
1007 #define is_ir_node(thing)                     _is_ir_node(thing)
1008 #define get_irn_intra_arity(node)             _get_irn_intra_arity(node)
1009 #define get_irn_inter_arity(node)             _get_irn_inter_arity(node)
1010 #define get_irn_arity(node)                   _get_irn_arity(node)
1011 #define get_irn_intra_n(node, n)              _get_irn_intra_n(node, n)
1012 #define get_irn_inter_n(node, n)              _get_irn_inter_n(node, n)
1013 #define get_irn_n(node, n)                    _get_irn_n(node, n)
1014 #define get_irn_mode(node)                    _get_irn_mode(node)
1015 #define set_irn_mode(node, mode)              _set_irn_mode(node, mode)
1016 #define get_irn_op(node)                      _get_irn_op(node)
1017 #define set_irn_op(node, op)                  _set_irn_op(node, op)
1018 #define get_irn_opcode(node)                  _get_irn_opcode(node)
1019 #define get_irn_visited(node)                 _get_irn_visited(node)
1020 #define set_irn_visited(node, v)              _set_irn_visited(node, v)
1021 #define mark_irn_visited(node)                _mark_irn_visited(node)
1022 #define irn_visited(node)                     _irn_visited(node)
1023 #define irn_visited_else_mark(node)           _irn_visited_else_mark(node)
1024 #define set_irn_link(node, link)              _set_irn_link(node, link)
1025 #define get_irn_link(node)                    _get_irn_link(node)
1026 #define get_irn_pinned(node)                  _get_irn_pinned(node)
1027 #define is_irn_pinned_in_irg(node)            _is_irn_pinned_in_irg(node)
1028 #define is_unop(node)                         _is_unop(node)
1029 #define is_binop(node)                        _is_binop(node)
1030 #define is_Proj(node)                         _is_Proj(node)
1031 #define is_Filter(node)                       _is_Filter(node)
1032 #define is_Phi(node)                          _is_Phi(node)
1033 #define is_Const(node)                        _is_Const(node)
1034 #define is_Conv(node)                         _is_Conv(node)
1035 #define is_strictConv(node)                   _is_strictConv(node)
1036 #define is_Cast(node)                         _is_Cast(node)
1037 #define is_Unknown(node)                      _is_Unknown(node)
1038 #define is_Return(node)                       _is_Return(node)
1039 #define is_Call(node)                         _is_Call(node)
1040 #define is_CallBegin(node)                    _is_CallBegin(node)
1041 #define is_Sel(node)                          _is_Sel(node)
1042 #define is_Mul(node)                          _is_Mul(node)
1043 #define is_Mulh(node)                         _is_Mulh(node)
1044 #define is_Mux(node)                          _is_Mux(node)
1045 #define is_Load(node)                         _is_Load(node)
1046 #define is_Sync(node)                         _is_Sync(node)
1047 #define is_Confirm(node)                      _is_Confirm(node)
1048 #define is_Pin(node)                          _is_Pin(node)
1049 #define is_SymConst(node)                     _is_SymConst(node)
1050 #define is_SymConst_addr_ent(node)            _is_SymConst_addr_ent(node)
1051 #define is_Cond(node)                         _is_Cond(node)
1052 #define is_CopyB(node)                        _is_CopyB(node)
1053 #define is_Cmp(node)                          _is_Cmp(node)
1054 #define is_Alloc(node)                        _is_Alloc(node)
1055 #define is_Free(node)                         _is_Free(node)
1056 #define is_Jmp(node)                          _is_Jmp(node)
1057 #define is_IJmp(node)                         _is_IJmp(node)
1058 #define is_Raise(node)                        _is_Raise(node)
1059 #define is_ASM(node)                          _is_ASM(node)
1060 #define is_Anchor(node)                       _is_Anchor(node)
1061 #define is_Bad(node)                          _is_Bad(node)
1062 #define is_NoMem(node)                        _is_NoMem(node)
1063 #define is_Start(node)                        _is_Start(node)
1064 #define is_End(node)                          _is_End(node)
1065 #define is_Minus(node)                        _is_Minus(node)
1066 #define is_Abs(node)                          _is_Abs(node)
1067 #define is_Mod(node)                          _is_Mod(node)
1068 #define is_Div(node)                          _is_Div(node)
1069 #define is_DivMod(node)                       _is_DivMod(node)
1070 #define is_Quot(node)                         _is_Quot(node)
1071 #define is_Add(node)                          _is_Add(node)
1072 #define is_Carry(node)                        _is_Carry(node)
1073 #define is_And(node)                          _is_And(node)
1074 #define is_Or(node)                           _is_Or(node)
1075 #define is_Eor(node)                          _is_Eor(node)
1076 #define is_Sub(node)                          _is_Sub(node)
1077 #define is_Not(node)                          _is_Not(node)
1078 #define is_Shl(node)                          _is_Shl(node)
1079 #define is_Shr(node)                          _is_Shr(node)
1080 #define is_Shrs(node)                         _is_Shrs(node)
1081 #define is_Rotl(node)                         _is_Rotl(node)
1082 #define is_Id(node)                           _is_Id(node)
1083 #define is_Tuple(node)                        _is_Tuple(node)
1084 #define is_Bound(node)                        _is_Bound(node)
1085 #define is_no_Block(node)                     _is_no_Block(node)
1086 #define is_Block(node)                        _is_Block(node)
1087 #define get_Block_n_cfgpreds(node)            _get_Block_n_cfgpreds(node)
1088 #define get_Block_cfgpred(node, pos)          _get_Block_cfgpred(node, pos)
1089 #define get_Block_cfgpred_block(node, pos)    _get_Block_cfgpred_block(node, pos)
1090 #define get_Block_block_visited(node)         _get_Block_block_visited(node)
1091 #define set_Block_block_visited(node, visit)  _set_Block_block_visited(node, visit)
1092 #define mark_Block_block_visited(node)        _mark_Block_block_visited(node)
1093 #define Block_block_visited(node)             _Block_block_visited(node)
1094 #define set_Block_dead(block)                 _set_Block_dead(block)
1095 #define is_Block_dead(block)                  _is_Block_dead(block)
1096 #define get_Const_tarval(node)                _get_Const_tarval(node)
1097 #define is_Const_null(node)                   _is_Const_null(node)
1098 #define is_Const_one(node)                    _is_Const_one(node)
1099 #define is_Const_all_one(node)                _is_Const_all_one(node)
1100 #define is_irn_forking(node)                  _is_irn_forking(node)
1101 #define get_irn_type(node)                    _get_irn_type(node)
1102 #define get_irn_type_attr(node)               _get_irn_type_attr(node)
1103 #define get_irn_entity_attr(node)             _get_irn_entity_attr(node)
1104 #define is_irn_constlike(node)                _is_irn_constlike(node)
1105 #define is_irn_always_opt(node)               _is_irn_always_opt(node)
1106 #define is_irn_keep(node)                     _is_irn_keep(node)
1107 #define is_irn_start_block_placed(node)       _is_irn_start_block_placed(node)
1108 #define is_irn_machine_op(node)               _is_irn_machine_op(node)
1109 #define is_irn_machine_operand(node)          _is_irn_machine_operand(node)
1110 #define is_irn_machine_user(node, n)          _is_irn_machine_user(node, n)
1111 #define get_Cond_jmp_pred(node)               _get_Cond_jmp_pred(node)
1112 #define set_Cond_jmp_pred(node, pred)         _set_Cond_jmp_pred(node, pred)
1113 #define get_irn_generic_attr(node)            _get_irn_generic_attr(node)
1114 #define get_irn_generic_attr_const(node)      _get_irn_generic_attr_const(node)
1115 #define get_irn_idx(node)                     _get_irn_idx(node)
1116
1117 #define get_irn_deps(node)                    _get_irn_deps(node)
1118 #define set_irn_dep(node, pos, dep)           _set_irn_dep(node, pos, dep)
1119 #define get_irn_dep(node, pos)                _get_irn_dep(node, pos)
1120
1121 #define get_irn_ins_or_deps(node)             _get_irn_ins_or_deps(node)
1122 #define get_irn_in_or_dep(node, pos)          _get_irn_in_or_dep(node, pos)
1123
1124 #define get_irn_dbg_info(node)                _get_irn_dbg_info(node)
1125 #define set_irn_dbg_info(node, db)            _set_irn_dbg_info(node, db)
1126
1127 #define set_Block_phis(block, phi)            _set_Block_phis(block, phi)
1128 #define get_Block_phis(block)                 _get_Block_phis(block)
1129 #define add_Block_phi(block, phi)             _add_Block_phi(block, phi)
1130 #define get_Block_mark(block)                 _get_Block_mark(block)
1131 #define set_Block_mark(block, mark)           _set_Block_mark(block, mark)
1132
1133 #define set_Phi_next(node, phi)               _set_Phi_next(node, phi)
1134 #define get_Phi_next(node)                    _get_Phi_next(node)
1135
1136 #define is_arg_Proj(node)                     _is_arg_Proj(node)
1137
1138 #endif