BugFix: works again for RAW with non twos-complement
[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 static INLINE int
346 _irn_visited_else_mark(ir_node *node) {
347         if (_irn_visited(node))
348                 return 1;
349         _mark_irn_visited(node);
350         return 0;
351 }
352
353 /**
354  * Sets the link of a node.
355  * Intern version of libFirm.
356  */
357 static INLINE void
358 _set_irn_link(ir_node *node, void *link) {
359         assert(node);
360         node->link = link;
361 }
362
363 /**
364  * Returns the link of a node.
365  * Intern version of libFirm.
366  */
367 static INLINE void *
368 _get_irn_link(const ir_node *node) {
369         assert(node && _is_ir_node(node));
370         return node->link;
371 }
372
373 /**
374  * Returns whether the node _always_ must be pinned.
375  * I.e., the node is not floating after global cse.
376  *
377  * Intern version of libFirm.
378  */
379 static INLINE op_pin_state
380 _get_irn_pinned(const ir_node *node) {
381         op_pin_state state;
382         assert(node && _is_ir_node(node));
383         /* Check opcode */
384         state = _get_op_pinned(_get_irn_op(node));
385
386         if (state >= op_pin_state_exc_pinned)
387                 return get_opt_fragile_ops() ? node->attr.except.pin_state : op_pin_state_pinned;
388         return state;
389 }
390
391 static INLINE op_pin_state
392 _is_irn_pinned_in_irg(const ir_node *node) {
393         if (get_irg_pinned(get_irn_irg(node)) == op_pin_state_floats)
394                 return get_irn_pinned(node);
395         return op_pin_state_pinned;
396 }
397
398 static INLINE int
399 _is_unop(const ir_node *node) {
400         assert(node && _is_ir_node(node));
401         return (node->op->opar == oparity_unary);
402 }
403
404 static INLINE int
405 _is_binop(const ir_node *node) {
406         assert(node && _is_ir_node(node));
407         return (node->op->opar == oparity_binary);
408 }
409
410 static INLINE int
411 _is_Phi(const ir_node *node) {
412         ir_op *op;
413         assert(node);
414
415         op = get_irn_op(node);
416 #ifdef INTERPROCEDURAL_VIEW
417         if (op == op_Filter) return get_interprocedural_view();
418 #endif
419         return (op == op_Phi);
420 }
421
422 static INLINE int
423 _is_Proj(const ir_node *node) {
424         ir_op *op;
425         assert(node);
426
427         op = _get_irn_op(node);
428 #ifdef INTERPROCEDURAL_VIEW
429         if (op == op_Filter) return !get_interprocedural_view();
430 #endif
431         return (op == op_Proj);
432 }
433
434 static INLINE int
435 _is_Filter(const ir_node *node) {
436         assert(node);
437         return (_get_irn_op(node) == op_Filter);
438 }
439
440 static INLINE int
441 _is_Bad(const ir_node *node) {
442         assert(node);
443         return (_get_irn_op(node) == op_Bad);
444 }
445
446 static INLINE int
447 _is_NoMem(const ir_node *node) {
448         assert(node);
449         return (_get_irn_op(node) == op_NoMem);
450 }
451
452 static INLINE int
453 _is_Minus(const ir_node *node) {
454         assert(node);
455         return (_get_irn_op(node) == op_Minus);
456 }
457
458 static INLINE int
459 _is_Abs(const ir_node *node) {
460         assert(node);
461         return (_get_irn_op(node) == op_Abs);
462 }
463
464 static INLINE int
465 _is_Mod(const ir_node *node) {
466         assert(node);
467         return (_get_irn_op(node) == op_Mod);
468 }
469
470 static INLINE int
471 _is_Div(const ir_node *node) {
472         assert(node);
473         return (_get_irn_op(node) == op_Div);
474 }
475
476 static INLINE int
477 _is_DivMod(const ir_node *node) {
478         assert(node);
479         return (_get_irn_op(node) == op_DivMod);
480 }
481
482 static INLINE int
483 _is_Quot(const ir_node *node) {
484         assert(node);
485         return (_get_irn_op(node) == op_Quot);
486 }
487
488 static INLINE int
489 _is_Add(const ir_node *node) {
490         assert(node);
491         return (_get_irn_op(node) == op_Add);
492 }
493
494 static INLINE int
495 _is_Carry(const ir_node *node) {
496         assert(node);
497         return (_get_irn_op(node) == op_Carry);
498 }
499
500 static INLINE int
501 _is_And(const ir_node *node) {
502         assert(node);
503         return (_get_irn_op(node) == op_And);
504 }
505
506 static INLINE int
507 _is_Or(const ir_node *node) {
508         assert(node);
509         return (_get_irn_op(node) == op_Or);
510 }
511
512 static INLINE int
513 _is_Eor(const ir_node *node) {
514         assert(node);
515         return (_get_irn_op(node) == op_Eor);
516 }
517
518 static INLINE int
519 _is_Sub(const ir_node *node) {
520         assert(node);
521         return (_get_irn_op(node) == op_Sub);
522 }
523
524 static INLINE int
525 _is_Not(const ir_node *node) {
526         assert(node);
527         return (_get_irn_op(node) == op_Not);
528 }
529
530 static INLINE int
531 _is_Shl(const ir_node *node) {
532         assert(node);
533         return (_get_irn_op(node) == op_Shl);
534 }
535
536 static INLINE int
537 _is_Shr(const ir_node *node) {
538         assert(node);
539         return (_get_irn_op(node) == op_Shr);
540 }
541
542 static INLINE int
543 _is_Shrs(const ir_node *node) {
544         assert(node);
545         return (_get_irn_op(node) == op_Shrs);
546 }
547
548 static INLINE int
549 _is_Rotl(const ir_node *node) {
550         assert(node);
551         return (_get_irn_op(node) == op_Rotl);
552 }
553
554 static INLINE int
555 _is_Id(const ir_node *node) {
556         assert(node);
557         return (_get_irn_op(node) == op_Id);
558 }
559
560 static INLINE int
561 _is_Tuple(const ir_node *node) {
562         assert(node);
563         return (_get_irn_op(node) == op_Tuple);
564 }
565
566 static INLINE int
567 _is_Bound(const ir_node *node) {
568         assert(node);
569         return (_get_irn_op(node) == op_Bound);
570 }
571
572 static INLINE int
573 _is_Start(const ir_node *node) {
574         assert(node);
575         return (_get_irn_op(node) == op_Start);
576 }
577
578 static INLINE int
579 _is_End(const ir_node *node) {
580         assert(node);
581         return (_get_irn_op(node) == op_End);
582 }
583
584 static INLINE int
585 _is_Const(const ir_node *node) {
586         assert(node);
587         return (_get_irn_op(node) == op_Const);
588 }
589
590 static INLINE int
591 _is_Conv(const ir_node *node) {
592         assert(node);
593         return (_get_irn_op(node) == op_Conv);
594 }
595
596 static INLINE int
597 _is_strictConv(const ir_node *node) {
598         return _is_Conv(node) && get_Conv_strict(node);
599 }
600
601 static INLINE int
602 _is_Cast(const ir_node *node) {
603         assert(node);
604         return (_get_irn_op(node) == op_Cast);
605 }
606
607 static INLINE int
608 _is_CopyB(const ir_node *node) {
609         assert(node);
610         return (_get_irn_op(node) == op_CopyB);
611 }
612
613 static INLINE int
614 _is_Unknown(const ir_node *node) {
615         assert(node);
616         return (_get_irn_op(node) == op_Unknown);
617 }
618
619 static INLINE int
620 _is_Return(const ir_node *node) {
621         assert(node);
622         return (_get_irn_op(node) == op_Return);
623 }
624
625 static INLINE int
626 _is_Call(const ir_node *node) {
627         assert(node);
628         return (_get_irn_op(node) == op_Call);
629 }
630
631 static INLINE int
632 _is_CallBegin(const ir_node *node) {
633         assert(node);
634         return (_get_irn_op(node) == op_CallBegin);
635 }
636
637 static INLINE int
638 _is_Sel(const ir_node *node) {
639         assert(node);
640         return (_get_irn_op(node) == op_Sel);
641 }
642
643 static INLINE int
644 _is_Mul(const ir_node *node) {
645         assert(node);
646         return (_get_irn_op(node) == op_Mul);
647 }
648
649 static INLINE int
650 _is_Mulh(const ir_node *node) {
651         assert(node);
652         return (_get_irn_op(node) == op_Mulh);
653 }
654
655 static INLINE int
656 _is_Mux(const ir_node *node) {
657         assert(node);
658         return (_get_irn_op(node) == op_Mux);
659 }
660
661 static INLINE int
662 _is_Load(const ir_node *node) {
663         assert(node);
664         return (_get_irn_op(node) == op_Load);
665 }
666
667 static INLINE int
668 _is_Store(const ir_node *node) {
669         assert(node);
670         return (_get_irn_op(node) == op_Store);
671 }
672
673 static INLINE int
674 _is_Sync(const ir_node *node) {
675         assert(node);
676         return (_get_irn_op(node) == op_Sync);
677 }
678
679 static INLINE int
680 _is_Confirm(const ir_node *node) {
681         assert(node);
682         return (_get_irn_op(node) == op_Confirm);
683 }
684
685 static INLINE int
686 _is_Pin(const ir_node *node) {
687         assert(node);
688         return (_get_irn_op(node) == op_Pin);
689 }
690
691 static INLINE int
692 _is_SymConst(const ir_node *node) {
693         assert(node);
694         return (_get_irn_op(node) == op_SymConst);
695 }
696
697 static INLINE int
698 _is_SymConst_addr_ent(const ir_node *node) {
699         return is_SymConst(node) && get_SymConst_kind(node) == symconst_addr_ent;
700 }
701
702 static INLINE int
703 _is_Cond(const ir_node *node) {
704         assert(node);
705         return (_get_irn_op(node) == op_Cond);
706 }
707
708 static INLINE int
709 _is_Cmp(const ir_node *node) {
710         assert(node);
711         return (_get_irn_op(node) == op_Cmp);
712 }
713
714 static INLINE int
715 _is_Alloc(const ir_node *node) {
716         assert(node);
717         return (_get_irn_op(node) == op_Alloc);
718 }
719
720 static INLINE int
721 _is_Free(const ir_node *node) {
722         assert(node);
723         return (_get_irn_op(node) == op_Free);
724 }
725
726 static INLINE int
727 _is_Jmp(const ir_node *node) {
728         assert(node);
729         return (_get_irn_op(node) == op_Jmp);
730 }
731
732 static INLINE int
733 _is_IJmp(const ir_node *node) {
734         assert(node);
735         return (_get_irn_op(node) == op_IJmp);
736 }
737
738 static INLINE int
739 _is_Raise(const ir_node *node) {
740         assert(node);
741         return (_get_irn_op(node) == op_Raise);
742 }
743
744 static INLINE int
745 _is_ASM(const ir_node *node) {
746         assert(node);
747         return (_get_irn_op(node) == op_ASM);
748 }
749
750 static INLINE int
751 _is_Anchor(const ir_node *node) {
752         return (_get_irn_op(node) == op_Anchor);
753 }
754
755 static INLINE int
756 _is_no_Block(const ir_node *node) {
757         assert(node && _is_ir_node(node));
758         return (_get_irn_op(node) != op_Block);
759 }
760
761 static INLINE int
762 _is_Block(const ir_node *node) {
763         assert(node && _is_ir_node(node));
764         return (_get_irn_op(node) == op_Block);
765 }
766
767 static INLINE int
768 _get_Block_n_cfgpreds(const ir_node *node) {
769         assert(_is_Block(node));
770         return _get_irn_arity(node);
771 }
772
773 static INLINE ir_node *
774 _get_Block_cfgpred(const ir_node *node, int pos) {
775         assert(0 <= pos && pos < get_irn_arity(node));
776         assert(_is_Block(node));
777         return _get_irn_n(node, pos);
778 }
779
780 /* Get the predecessor block.
781  *
782  *  Returns the block corresponding to the predecessor pos.
783  *
784  *  There are several ambiguities we resolve with this function:
785  *  - The direct predecessor can be a Proj, which is not pinned.
786  *    We walk from the predecessor to the next pinned node
787  *    (skip_Proj) and return the block that node is in.
788  *  - If we encounter the Bad node, this function does not return
789  *    Start, but the Bad node.
790  */
791 static INLINE ir_node  *
792 _get_Block_cfgpred_block(const ir_node *node, int pos) {
793         ir_node *res = skip_Proj(get_Block_cfgpred(node, pos));
794         if (!is_Bad(res))
795                 res = get_nodes_block(res);
796         return res;
797 }
798
799 static INLINE ir_visited_t
800 _get_Block_block_visited(const ir_node *node) {
801         assert(node->op == op_Block);
802         return node->attr.block.block_visited;
803 }
804
805 static INLINE void
806 _set_Block_block_visited(ir_node *node, ir_visited_t visit) {
807         assert(node->op == op_Block);
808         node->attr.block.block_visited = visit;
809 }
810
811 /* For this current_ir_graph must be set. */
812 static INLINE void
813 _mark_Block_block_visited(ir_node *node) {
814         assert(node->op == op_Block);
815         node->attr.block.block_visited = get_irg_block_visited(current_ir_graph);
816 }
817
818 static INLINE int
819 _Block_block_visited(const ir_node *node) {
820         assert(node->op == op_Block);
821         return (node->attr.block.block_visited >= get_irg_block_visited(current_ir_graph));
822 }
823
824 static INLINE ir_node *
825 _set_Block_dead(ir_node *block) {
826         assert(_get_irn_op(block) == op_Block);
827         block->attr.block.dom.dom_depth = -1;
828         block->attr.block.is_dead = 1;
829         return block;
830 }
831
832 static INLINE int
833 _is_Block_dead(const ir_node *block) {
834         ir_op *op = _get_irn_op(block);
835
836         if (op == op_Bad)
837                 return 1;
838         else {
839                 assert(op == op_Block);
840                 return block->attr.block.is_dead;
841         }
842 }
843
844 static INLINE tarval *_get_Const_tarval(const ir_node *node) {
845         assert(_get_irn_op(node) == op_Const);
846         return node->attr.con.tv;
847 }
848
849 static INLINE int _is_Const_null(const ir_node *node) {
850         return tarval_is_null(_get_Const_tarval(node));
851 }
852
853 static INLINE int _is_Const_one(const ir_node *node) {
854         return tarval_is_one(_get_Const_tarval(node));
855 }
856
857 static INLINE int _is_Const_all_one(const ir_node *node) {
858         return tarval_is_all_one(_get_Const_tarval(node));
859 }
860
861 static INLINE int _is_irn_forking(const ir_node *node) {
862         return is_op_forking(_get_irn_op(node));
863 }
864
865 static INLINE ir_type *_get_irn_type(ir_node *node) {
866         return _get_irn_op(node)->ops.get_type(node);
867 }
868
869 static INLINE ir_type *_get_irn_type_attr(ir_node *node) {
870         return _get_irn_op(node)->ops.get_type_attr(node);
871 }
872
873 static INLINE ir_entity *_get_irn_entity_attr(ir_node *node) {
874   return _get_irn_op(node)->ops.get_entity_attr(node);
875 }
876
877 static INLINE int _is_irn_constlike(const ir_node *node) {
878         return is_op_constlike(_get_irn_op(node));
879 }
880
881 static INLINE int _is_irn_always_opt(const ir_node *node) {
882         return is_op_always_opt(_get_irn_op(node));
883 }
884
885 static INLINE int _is_irn_keep(const ir_node *node) {
886         return is_op_keep(_get_irn_op(node));
887 }
888
889 static INLINE int _is_irn_start_block_placed(const ir_node *node) {
890         return is_op_start_block_placed(_get_irn_op(node));
891 }
892
893 static INLINE int _is_irn_machine_op(const ir_node *node) {
894         return is_op_machine(_get_irn_op(node));
895 }
896
897 static INLINE int _is_irn_machine_operand(const ir_node *node) {
898         return is_op_machine_operand(_get_irn_op(node));
899 }
900
901 static INLINE int _is_irn_machine_user(const ir_node *node, unsigned n) {
902         return is_op_machine_user(_get_irn_op(node), n);
903 }
904
905 static INLINE cond_jmp_predicate _get_Cond_jmp_pred(const ir_node *node) {
906         assert(_get_irn_op(node) == op_Cond);
907         return node->attr.cond.pred;
908 }
909
910 static INLINE void _set_Cond_jmp_pred(ir_node *node, cond_jmp_predicate pred) {
911         assert(_get_irn_op(node) == op_Cond);
912         node->attr.cond.pred = pred;
913 }
914
915 static INLINE void *_get_irn_generic_attr(ir_node *node) {
916         return &node->attr;
917 }
918
919 static INLINE const void *_get_irn_generic_attr_const(const ir_node *node) {
920         return &node->attr;
921 }
922
923 static INLINE unsigned _get_irn_idx(const ir_node *node) {
924         return node->node_idx;
925 }
926
927 static INLINE dbg_info *_get_irn_dbg_info(const ir_node *n) {
928         return n->dbi;
929 }  /* get_irn_dbg_info */
930
931 static INLINE void _set_irn_dbg_info(ir_node *n, dbg_info *db) {
932         n->dbi = db;
933 }
934
935 /**
936  * Sets the Phi list of a block.
937  */
938 static INLINE void
939 _set_Block_phis(ir_node *block, ir_node *phi) {
940         assert(_is_Block(block));
941         assert(phi == NULL || _is_Phi(phi));
942         block->attr.block.phis = phi;
943 }
944
945 /**
946  * Returns the link of a node.
947  * Intern version of libFirm.
948  */
949 static INLINE ir_node *
950 _get_Block_phis(const ir_node *block) {
951         assert(_is_Block(block));
952         return block->attr.block.phis;
953 }
954
955 /**
956  * Sets the next link of a Phi.
957  */
958 static INLINE void
959 _set_Phi_next(ir_node *phi, ir_node *next) {
960         assert(_is_Phi(phi));
961         phi->attr.phi.next = next;
962 }
963
964 /**
965  * Returns the link of a node.
966  * Intern version of libFirm.
967  */
968 static INLINE ir_node *
969 _get_Phi_next(const ir_node *phi) {
970         assert(_is_Phi(phi));
971         return phi->attr.phi.next;
972 }
973
974 /** Add a Phi node to the list of Block Phi's. */
975 static INLINE void
976 _add_Block_phi(ir_node *block, ir_node *phi) {
977         _set_Phi_next(phi, _get_Block_phis(block));
978         _set_Block_phis(block, phi);
979 }
980
981 /** Get the Block mark (single bit). */
982 static INLINE unsigned
983 _get_Block_mark(const ir_node *block) {
984         assert(_is_Block(block));
985         return block->attr.block.marked;
986 }
987
988 /** Set the Block mark (single bit). */
989 static INLINE void
990 _set_Block_mark(ir_node *block, unsigned mark) {
991         assert(_is_Block(block));
992         block->attr.block.marked = mark;
993 }
994
995 /** Returns non-zero if a node is a routine parameter. */
996 static INLINE int
997 _is_arg_Proj(const ir_node *node) {
998         if (! is_Proj(node))
999                 return 0;
1000         node = get_Proj_pred(node);
1001         if (! is_Proj(node))
1002                 return 0;
1003         return pn_Start_T_args == get_Proj_proj(node) && is_Start(get_Proj_pred(node));
1004 }
1005
1006
1007 /* this section MUST contain all inline functions */
1008 #define is_ir_node(thing)                     _is_ir_node(thing)
1009 #define get_irn_intra_arity(node)             _get_irn_intra_arity(node)
1010 #define get_irn_inter_arity(node)             _get_irn_inter_arity(node)
1011 #define get_irn_arity(node)                   _get_irn_arity(node)
1012 #define get_irn_intra_n(node, n)              _get_irn_intra_n(node, n)
1013 #define get_irn_inter_n(node, n)              _get_irn_inter_n(node, n)
1014 #define get_irn_n(node, n)                    _get_irn_n(node, n)
1015 #define get_irn_mode(node)                    _get_irn_mode(node)
1016 #define set_irn_mode(node, mode)              _set_irn_mode(node, mode)
1017 #define get_irn_op(node)                      _get_irn_op(node)
1018 #define set_irn_op(node, op)                  _set_irn_op(node, op)
1019 #define get_irn_opcode(node)                  _get_irn_opcode(node)
1020 #define get_irn_visited(node)                 _get_irn_visited(node)
1021 #define set_irn_visited(node, v)              _set_irn_visited(node, v)
1022 #define mark_irn_visited(node)                _mark_irn_visited(node)
1023 #define irn_visited(node)                     _irn_visited(node)
1024 #define irn_visited_else_mark(node)           _irn_visited_else_mark(node)
1025 #define set_irn_link(node, link)              _set_irn_link(node, link)
1026 #define get_irn_link(node)                    _get_irn_link(node)
1027 #define get_irn_pinned(node)                  _get_irn_pinned(node)
1028 #define is_irn_pinned_in_irg(node)            _is_irn_pinned_in_irg(node)
1029 #define is_unop(node)                         _is_unop(node)
1030 #define is_binop(node)                        _is_binop(node)
1031 #define is_Proj(node)                         _is_Proj(node)
1032 #define is_Filter(node)                       _is_Filter(node)
1033 #define is_Phi(node)                          _is_Phi(node)
1034 #define is_Const(node)                        _is_Const(node)
1035 #define is_Conv(node)                         _is_Conv(node)
1036 #define is_strictConv(node)                   _is_strictConv(node)
1037 #define is_Cast(node)                         _is_Cast(node)
1038 #define is_Unknown(node)                      _is_Unknown(node)
1039 #define is_Return(node)                       _is_Return(node)
1040 #define is_Call(node)                         _is_Call(node)
1041 #define is_CallBegin(node)                    _is_CallBegin(node)
1042 #define is_Sel(node)                          _is_Sel(node)
1043 #define is_Mul(node)                          _is_Mul(node)
1044 #define is_Mulh(node)                         _is_Mulh(node)
1045 #define is_Mux(node)                          _is_Mux(node)
1046 #define is_Load(node)                         _is_Load(node)
1047 #define is_Sync(node)                         _is_Sync(node)
1048 #define is_Confirm(node)                      _is_Confirm(node)
1049 #define is_Pin(node)                          _is_Pin(node)
1050 #define is_SymConst(node)                     _is_SymConst(node)
1051 #define is_SymConst_addr_ent(node)            _is_SymConst_addr_ent(node)
1052 #define is_Cond(node)                         _is_Cond(node)
1053 #define is_CopyB(node)                        _is_CopyB(node)
1054 #define is_Cmp(node)                          _is_Cmp(node)
1055 #define is_Alloc(node)                        _is_Alloc(node)
1056 #define is_Free(node)                         _is_Free(node)
1057 #define is_Jmp(node)                          _is_Jmp(node)
1058 #define is_IJmp(node)                         _is_IJmp(node)
1059 #define is_Raise(node)                        _is_Raise(node)
1060 #define is_ASM(node)                          _is_ASM(node)
1061 #define is_Anchor(node)                       _is_Anchor(node)
1062 #define is_Bad(node)                          _is_Bad(node)
1063 #define is_NoMem(node)                        _is_NoMem(node)
1064 #define is_Start(node)                        _is_Start(node)
1065 #define is_End(node)                          _is_End(node)
1066 #define is_Minus(node)                        _is_Minus(node)
1067 #define is_Abs(node)                          _is_Abs(node)
1068 #define is_Mod(node)                          _is_Mod(node)
1069 #define is_Div(node)                          _is_Div(node)
1070 #define is_DivMod(node)                       _is_DivMod(node)
1071 #define is_Quot(node)                         _is_Quot(node)
1072 #define is_Add(node)                          _is_Add(node)
1073 #define is_Carry(node)                        _is_Carry(node)
1074 #define is_And(node)                          _is_And(node)
1075 #define is_Or(node)                           _is_Or(node)
1076 #define is_Eor(node)                          _is_Eor(node)
1077 #define is_Sub(node)                          _is_Sub(node)
1078 #define is_Not(node)                          _is_Not(node)
1079 #define is_Shl(node)                          _is_Shl(node)
1080 #define is_Shr(node)                          _is_Shr(node)
1081 #define is_Shrs(node)                         _is_Shrs(node)
1082 #define is_Rotl(node)                         _is_Rotl(node)
1083 #define is_Id(node)                           _is_Id(node)
1084 #define is_Tuple(node)                        _is_Tuple(node)
1085 #define is_Bound(node)                        _is_Bound(node)
1086 #define is_no_Block(node)                     _is_no_Block(node)
1087 #define is_Block(node)                        _is_Block(node)
1088 #define get_Block_n_cfgpreds(node)            _get_Block_n_cfgpreds(node)
1089 #define get_Block_cfgpred(node, pos)          _get_Block_cfgpred(node, pos)
1090 #define get_Block_cfgpred_block(node, pos)    _get_Block_cfgpred_block(node, pos)
1091 #define get_Block_block_visited(node)         _get_Block_block_visited(node)
1092 #define set_Block_block_visited(node, visit)  _set_Block_block_visited(node, visit)
1093 #define mark_Block_block_visited(node)        _mark_Block_block_visited(node)
1094 #define Block_block_visited(node)             _Block_block_visited(node)
1095 #define set_Block_dead(block)                 _set_Block_dead(block)
1096 #define is_Block_dead(block)                  _is_Block_dead(block)
1097 #define get_Const_tarval(node)                _get_Const_tarval(node)
1098 #define is_Const_null(node)                   _is_Const_null(node)
1099 #define is_Const_one(node)                    _is_Const_one(node)
1100 #define is_Const_all_one(node)                _is_Const_all_one(node)
1101 #define is_irn_forking(node)                  _is_irn_forking(node)
1102 #define get_irn_type(node)                    _get_irn_type(node)
1103 #define get_irn_type_attr(node)               _get_irn_type_attr(node)
1104 #define get_irn_entity_attr(node)             _get_irn_entity_attr(node)
1105 #define is_irn_constlike(node)                _is_irn_constlike(node)
1106 #define is_irn_always_opt(node)               _is_irn_always_opt(node)
1107 #define is_irn_keep(node)                     _is_irn_keep(node)
1108 #define is_irn_start_block_placed(node)       _is_irn_start_block_placed(node)
1109 #define is_irn_machine_op(node)               _is_irn_machine_op(node)
1110 #define is_irn_machine_operand(node)          _is_irn_machine_operand(node)
1111 #define is_irn_machine_user(node, n)          _is_irn_machine_user(node, n)
1112 #define get_Cond_jmp_pred(node)               _get_Cond_jmp_pred(node)
1113 #define set_Cond_jmp_pred(node, pred)         _set_Cond_jmp_pred(node, pred)
1114 #define get_irn_generic_attr(node)            _get_irn_generic_attr(node)
1115 #define get_irn_generic_attr_const(node)      _get_irn_generic_attr_const(node)
1116 #define get_irn_idx(node)                     _get_irn_idx(node)
1117
1118 #define get_irn_deps(node)                    _get_irn_deps(node)
1119 #define set_irn_dep(node, pos, dep)           _set_irn_dep(node, pos, dep)
1120 #define get_irn_dep(node, pos)                _get_irn_dep(node, pos)
1121
1122 #define get_irn_ins_or_deps(node)             _get_irn_ins_or_deps(node)
1123 #define get_irn_in_or_dep(node, pos)          _get_irn_in_or_dep(node, pos)
1124
1125 #define get_irn_dbg_info(node)                _get_irn_dbg_info(node)
1126 #define set_irn_dbg_info(node, db)            _set_irn_dbg_info(node, db)
1127
1128 #define set_Block_phis(block, phi)            _set_Block_phis(block, phi)
1129 #define get_Block_phis(block)                 _get_Block_phis(block)
1130 #define add_Block_phi(block, phi)             _add_Block_phi(block, phi)
1131 #define get_Block_mark(block)                 _get_Block_mark(block)
1132 #define set_Block_mark(block, mark)           _set_Block_mark(block, mark)
1133
1134 #define set_Phi_next(node, phi)               _set_Phi_next(node, phi)
1135 #define get_Phi_next(node)                    _get_Phi_next(node)
1136
1137 #define is_arg_Proj(node)                     _is_arg_Proj(node)
1138
1139 #endif