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