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