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