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