irdump: Remove the parameter bad from get_mode_name_ex().
[libfirm] / ir / ir / irop_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 opcode of intermediate operation -- private header.
23  * @author   Christian Schaefer, Goetz Lindenmaier, Michael Beck
24  */
25 #ifndef FIRM_IR_IROP_T_H
26 #define FIRM_IR_IROP_T_H
27
28 #include "irop.h"
29
30 #include <stdbool.h>
31
32 #include "irtypes.h"
33 #include "tv.h"
34
35 #define get_op_code(op)         get_op_code_(op)
36 #define get_op_ident(op)        get_op_ident_(op)
37 #define get_op_pinned(op)       get_op_pinned_(op)
38 #define get_op_ops(op)          get_op_ops_(op)
39 #define set_op_tag(op, tag)     set_op_tag_((op), (tag))
40 #define get_op_tag(op)          get_op_tag_(op)
41 #define set_op_attr(op, attr)   set_op_attr_((op), (attr))
42 #define get_op_attr(op)         get_op_attr_(op)
43
44 #define set_generic_function_ptr(op, func) set_generic_function_ptr_((op), (op_func)(func))
45 #define get_generic_function_ptr(type, op) ((type*)get_generic_function_ptr_((op)))
46
47 /**
48  * Frees a newly created ir operation.
49  */
50 void free_ir_op(ir_op *code);
51
52 /** Initialize the irop module. */
53 void firm_init_op(void);
54
55 /** frees memory allocated by irop module */
56 void firm_finish_op(void);
57
58 /**
59  * Returns the attribute size of nodes of this opcode.
60  * @note Use not encouraged, internal feature.
61  */
62 static inline size_t get_op_attr_size (const ir_op *op)
63 {
64         return op->attr_size;
65 }
66
67 /**
68  * Returns non-zero if op is a control flow opcode,
69  * like Start, End, Jmp, Cond, Return, Raise or Bad.
70  */
71 static inline bool is_op_cfopcode(const ir_op *op)
72 {
73         return op->flags & irop_flag_cfopcode;
74 }
75
76 static inline bool is_op_unknown_jump(const ir_op *op)
77 {
78         return op->flags & irop_flag_unknown_jump;
79 }
80
81 /** Returns non-zero if operation is commutative */
82 static inline bool is_op_commutative(const ir_op *op)
83 {
84         return op->flags & irop_flag_commutative;
85 }
86
87 /** Returns non-zero if operation is fragile */
88 static inline bool is_op_fragile(const ir_op *op)
89 {
90         return op->flags & irop_flag_fragile;
91 }
92
93 /** Returns non-zero if operation is forking control flow */
94 static inline bool is_op_forking(const ir_op *op)
95 {
96         return op->flags & irop_flag_forking;
97 }
98
99 /** Returns non-zero if operation is a high-level op */
100 static inline bool is_op_highlevel(const ir_op *op)
101 {
102         return op->flags & irop_flag_highlevel;
103 }
104
105 /** Returns non-zero if operation is a const-like op */
106 static inline bool is_op_constlike(const ir_op *op)
107 {
108         return op->flags & irop_flag_constlike;
109 }
110
111 static inline bool is_op_uses_memory(const ir_op *op)
112 {
113         return op->flags & irop_flag_uses_memory;
114 }
115
116 /** Returns non-zero if operation is a keep-like op */
117 static inline bool is_op_keep(const ir_op *op)
118 {
119         return op->flags & irop_flag_keep;
120 }
121
122 /** Returns non-zero if operation must always be placed in the start block. */
123 static inline bool is_op_start_block_placed(const ir_op *op)
124 {
125         return op->flags & irop_flag_start_block;
126 }
127
128 /** Returns non-zero if operation is CSE neutral */
129 static inline bool is_op_cse_neutral(const ir_op *op)
130 {
131         return op->flags & irop_flag_cse_neutral;
132 }
133
134 static inline unsigned get_op_code_(const ir_op *op)
135 {
136         return op->code;
137 }
138
139 static inline ident *get_op_ident_(const ir_op *op)
140 {
141         return op->name;
142 }
143
144 static inline op_pin_state get_op_pinned_(const ir_op *op)
145 {
146         return op->pin_state;
147 }
148
149 static inline void set_generic_function_ptr_(ir_op *op, op_func func)
150 {
151         op->ops.generic = func;
152 }
153
154 static inline op_func get_generic_function_ptr_(const ir_op *op)
155 {
156         return op->ops.generic;
157 }
158
159 static inline ir_op_ops *get_op_ops_(ir_op *op)
160 {
161         return &op->ops;
162 }
163
164 static inline void set_op_tag_(ir_op *op, unsigned tag)
165 {
166         op->tag = tag;
167 }
168
169 static inline unsigned get_op_tag_(const ir_op *op)
170 {
171         return op->tag;
172 }
173
174 static inline void set_op_attr_(ir_op *op, void *attr)
175 {
176         op->attr = attr;
177 }
178
179 static inline void *get_op_attr_(const ir_op *op)
180 {
181         return op->attr;
182 }
183
184 #endif