avoid _ prefix in identifiers, correct coding style
[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  * @version  $Id$
25  */
26 #ifndef FIRM_IR_IROP_T_H
27 #define FIRM_IR_IROP_T_H
28
29 #include "irop.h"
30
31 #include <stdbool.h>
32
33 #include "irtypes.h"
34 #include "tv.h"
35
36 /**
37  * Frees a newly created ir operation.
38  */
39 void free_ir_op(ir_op *code);
40
41 /** Initialize the irop module. */
42 void init_op(void);
43
44 /** Free memory used by irop module. */
45 void finish_op(void);
46
47 /**
48  * Copies simply all attributes stored in the old node to the new node.
49  * Assumes both have the same opcode and sufficient size.
50  *
51  * @param old_node  the old node from which the attributes are read
52  * @param new_node  the new node to which the attributes are written
53  */
54 void default_copy_attr(ir_graph *irg, const ir_node *old_node,
55                        ir_node *new_node);
56
57 /**
58  * Returns the attribute size of nodes of this opcode.
59  * @note Use not encouraged, internal feature.
60  */
61 static inline size_t get_op_attr_size (const ir_op *op)
62 {
63         return op->attr_size;
64 }
65
66 /**
67  * Returns non-zero if op is a control flow opcode,
68  * like Start, End, Jmp, Cond, Return, Raise or Bad.
69  */
70 static inline bool is_op_cfopcode(const ir_op *op)
71 {
72         return op->flags & irop_flag_cfopcode;
73 }
74
75 static inline bool is_op_unknown_jump(const ir_op *op)
76 {
77         return op->flags & irop_flag_unknown_jump;
78 }
79
80 /** Returns non-zero if operation is commutative */
81 static inline bool is_op_commutative(const ir_op *op)
82 {
83         return op->flags & irop_flag_commutative;
84 }
85
86 /** Returns non-zero if operation is fragile */
87 static inline bool is_op_fragile(const ir_op *op)
88 {
89         return op->flags & irop_flag_fragile;
90 }
91
92 /** Returns non-zero if operation is forking control flow */
93 static inline bool is_op_forking(const ir_op *op)
94 {
95         return op->flags & irop_flag_forking;
96 }
97
98 /** Returns non-zero if operation is a high-level op */
99 static inline bool is_op_highlevel(const ir_op *op)
100 {
101         return op->flags & irop_flag_highlevel;
102 }
103
104 /** Returns non-zero if operation is a const-like op */
105 static inline bool is_op_constlike(const ir_op *op)
106 {
107         return op->flags & irop_flag_constlike;
108 }
109
110 static inline bool is_op_uses_memory(const ir_op *op)
111 {
112         return op->flags & irop_flag_uses_memory;
113 }
114
115 /** Returns non-zero if operation must always be optimized */
116 static inline bool is_op_always_opt(const ir_op *op)
117 {
118         return op->flags & irop_flag_always_opt;
119 }
120
121 /** Returns non-zero if operation is a keep-like op */
122 static inline bool is_op_keep(const ir_op *op)
123 {
124         return op->flags & irop_flag_keep;
125 }
126
127 /** Returns non-zero if operation must always be placed in the start block. */
128 static inline bool is_op_start_block_placed(const ir_op *op)
129 {
130         return op->flags & irop_flag_start_block;
131 }
132
133 /** Returns non-zero if operation is a machine operation */
134 static inline bool is_op_machine(const ir_op *op)
135 {
136         return op->flags & irop_flag_machine;
137 }
138
139 /** Returns non-zero if operation is a machine operand */
140 static inline bool is_op_machine_operand(const ir_op *op)
141 {
142         return op->flags & irop_flag_machine_op;
143 }
144
145 /** Returns non-zero if operation is CSE neutral */
146 static inline bool is_op_cse_neutral(const ir_op *op)
147 {
148         return op->flags & irop_flag_cse_neutral;
149 }
150
151 /** Returns non-zero if operation is a machine user op number n */
152 static inline bool is_op_machine_user(const ir_op *op, unsigned n)
153 {
154         return op->flags & (irop_flag_user << n);
155 }
156
157 static inline unsigned get_op_code_(const ir_op *op)
158 {
159         return op->code;
160 }
161
162 static inline ident *get_op_ident_(const ir_op *op)
163 {
164         return op->name;
165 }
166
167 static inline op_pin_state get_op_pinned_(const ir_op *op)
168 {
169         return op->pin_state;
170 }
171
172 static inline void set_generic_function_ptr_(ir_op *op, op_func func)
173 {
174         op->ops.generic = func;
175 }
176
177 static inline op_func get_generic_function_ptr_(const ir_op *op)
178 {
179         return op->ops.generic;
180 }
181
182 static inline const ir_op_ops *get_op_ops_(const ir_op *op)
183 {
184         return &op->ops;
185 }
186
187 static inline void set_op_tag_(ir_op *op, unsigned tag)
188 {
189         op->tag = tag;
190 }
191
192 static inline unsigned get_op_tag_(const ir_op *op)
193 {
194         return op->tag;
195 }
196
197 static inline void set_op_attr_(ir_op *op, void *attr)
198 {
199         op->attr = attr;
200 }
201
202 static inline void *get_op_attr_(const ir_op *op)
203 {
204         return op->attr;
205 }
206
207 #define get_op_code(op)         get_op_code_(op)
208 #define get_op_ident(op)        get_op_ident_(op)
209 #define get_op_pinned(op)       get_op_pinned_(op)
210 #define get_op_ops(op)          get_op_ops_(op)
211 #define set_op_tag(op, tag)     set_op_tag_((op), (tag))
212 #define get_op_tag(op)          get_op_tag_(op)
213 #define set_op_attr(op, attr)   set_op_attr_((op), (attr))
214 #define get_op_attr(op)         get_op_attr_(op)
215
216 #endif