6c296dfee1d4356d946817895c301e9dda64c59f
[libfirm] / ir / be / ia32 / ia32_new_nodes.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       Handling of ia32 specific firm opcodes.
23  * @author      Christian Wuerdig
24  *
25  * This file implements the creation of the achitecture specific firm opcodes
26  * and the coresponding node constructors for the ia32 assembler irg.
27  */
28 #ifndef FIRM_BE_IA32_IA32_NEW_NODES_H
29 #define FIRM_BE_IA32_IA32_NEW_NODES_H
30
31 #include "ia32_nodes_attr.h"
32
33 /** indices for AM inputs */
34 enum {
35         n_ia32_base         = 0,
36         n_ia32_index        = 1,
37         n_ia32_mem          = 2,
38         n_ia32_unary_op     = 3,
39         n_ia32_binary_left  = 3,
40         n_ia32_binary_right = 4
41 };
42
43 /** proj numbers for "normal" one-result nodes (for the complicated cases where we not only
44  * need the result) */
45 enum {
46         pn_ia32_res   = 0,
47         pn_ia32_flags = 1,
48         pn_ia32_mem   = 2
49 };
50
51
52 /**
53  * returns true if a node has x87 registers
54  */
55 int ia32_has_x87_register(const ir_node *n);
56
57 /**
58  * Returns the attributes of an ia32 node.
59  */
60 ia32_attr_t *get_ia32_attr(ir_node *node);
61 const ia32_attr_t *get_ia32_attr_const(const ir_node *node);
62
63 ia32_x87_attr_t *get_ia32_x87_attr(ir_node *node);
64 const ia32_x87_attr_t *get_ia32_x87_attr_const(const ir_node *node);
65
66 ia32_immediate_attr_t *get_ia32_immediate_attr(ir_node *node);
67 const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node);
68
69 const ia32_asm_attr_t *get_ia32_asm_attr_const(const ir_node *node);
70
71 /**
72  * Gets the condcode attributes of a node.
73  */
74 ia32_condcode_attr_t *get_ia32_condcode_attr(ir_node *node);
75 const ia32_condcode_attr_t *get_ia32_condcode_attr_const(const ir_node *node);
76
77 /**
78  * Gets the Call node attributes.
79  */
80 ia32_call_attr_t *get_ia32_call_attr(ir_node *node);
81 const ia32_call_attr_t *get_ia32_call_attr_const(const ir_node *node);
82
83 /**
84  * Gets the CopyB node attributes.
85  */
86 ia32_copyb_attr_t *get_ia32_copyb_attr(ir_node *node);
87 const ia32_copyb_attr_t *get_ia32_copyb_attr_const(const ir_node *node);
88
89 /**
90  * Gets the ClimbFrame node attributes.
91  */
92 ia32_climbframe_attr_t *get_ia32_climbframe_attr(ir_node *node);
93 const ia32_climbframe_attr_t *get_ia32_climbframe_attr_const(const ir_node *node);
94
95 ia32_switch_attr_t *get_ia32_switch_attr(ir_node *node);
96 const ia32_switch_attr_t *get_ia32_switch_attr_const(const ir_node *node);
97
98 /**
99  * Gets the type of an ia32 node.
100  */
101 ia32_op_type_t get_ia32_op_type(const ir_node *node);
102
103 /**
104  * Sets the type of an ia32 node.
105  */
106 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
107
108 /**
109  * Gets the supported address mode of an ia32 node
110  */
111 ia32_am_type_t get_ia32_am_support(const ir_node *node);
112
113 /**
114  * Sets the supported addrmode of an ia32 node
115  */
116 void set_ia32_am_support(ir_node *node, ia32_am_type_t am_arity);
117
118 /**
119  * Gets the addressmode offset as long.
120  */
121 int get_ia32_am_offs_int(const ir_node *node);
122
123 /**
124  * Sets the addressmode offset
125  */
126 void set_ia32_am_offs_int(ir_node *node, int offset);
127
128 void add_ia32_am_offs_int(ir_node *node, int offset);
129
130 /**
131  * Returns the symconst entity associated to addrmode.
132  */
133 ir_entity *get_ia32_am_sc(const ir_node *node);
134
135 /**
136  * Sets the symconst entity associated to addrmode.
137  */
138 void set_ia32_am_sc(ir_node *node, ir_entity *sc);
139
140 /**
141  * Sets the sign bit for address mode symconst.
142  */
143 void set_ia32_am_sc_sign(ir_node *node);
144
145 /**
146  * Clears the sign bit for address mode symconst.
147  */
148 void clear_ia32_am_sc_sign(ir_node *node);
149
150 /**
151  * Returns the sign bit for address mode symconst.
152  */
153 int is_ia32_am_sc_sign(const ir_node *node);
154
155 void set_ia32_am_tls_segment(ir_node *node, bool value);
156
157 bool get_ia32_am_tls_segment(const ir_node *node);
158
159 /**
160  * Gets the addr mode const.
161  */
162 unsigned get_ia32_am_scale(const ir_node *node);
163
164 /**
165  * Sets the const for addr mode.
166  */
167 void set_ia32_am_scale(ir_node *node, unsigned scale);
168
169 /**
170  * Sets the uses_frame flag.
171  */
172 void set_ia32_use_frame(ir_node *node);
173
174 /**
175  * Clears the uses_frame flag.
176  */
177 void clear_ia32_use_frame(ir_node *node);
178
179 /**
180  * Gets the uses_frame flag.
181  */
182 int is_ia32_use_frame(const ir_node *node);
183
184 /**
185  * copies all address-mode attributes from one node to the other
186  */
187 void ia32_copy_am_attrs(ir_node *to, const ir_node *from);
188
189 /**
190  * Sets node to commutative.
191  */
192 void set_ia32_commutative(ir_node *node);
193
194 /**
195  * Sets node to non-commutative.
196  */
197 void clear_ia32_commutative(ir_node *node);
198
199 /**
200  * Checks if node is commutative.
201  */
202 int is_ia32_commutative(const ir_node *node);
203
204 /**
205  * Sets node needs_stackent
206  */
207 void set_ia32_need_stackent(ir_node *node);
208
209 /**
210  * Clears node needs_stackent
211  */
212 void clear_ia32_need_stackent(ir_node *node);
213
214 /**
215  * Checks if node needs a stack entity assigned
216  */
217 int is_ia32_need_stackent(const ir_node *node);
218
219 void set_ia32_is_reload(ir_node *node);
220 int is_ia32_is_reload(const ir_node *node);
221
222 void set_ia32_is_spill(ir_node *node);
223 int is_ia32_is_spill(const ir_node *node);
224
225 void set_ia32_is_remat(ir_node *node);
226 int is_ia32_is_remat(const ir_node *node);
227
228 /**
229  * Gets the mode of the stored/loaded value (only set for Store/Load)
230  */
231 ir_mode *get_ia32_ls_mode(const ir_node *node);
232
233 /**
234  * Sets the mode of the stored/loaded value (only set for Store/Load)
235  */
236 void set_ia32_ls_mode(ir_node *node, ir_mode *mode);
237
238 /**
239  * Gets the frame entity assigned to this node;
240  */
241 ir_entity *get_ia32_frame_ent(const ir_node *node);
242
243 /**
244  * Sets the frame entity for this node;
245  */
246 void set_ia32_frame_ent(ir_node *node, ir_entity *ent);
247
248 /**
249  * Returns the condition code of a node.
250  */
251 ia32_condition_code_t get_ia32_condcode(const ir_node *node);
252
253 /**
254  * Sets the condition code of a node
255  */
256 void set_ia32_condcode(ir_node *node, ia32_condition_code_t code);
257
258 const ir_switch_table *get_ia32_switch_table(const ir_node *node);
259
260 unsigned get_ia32_copyb_size(const ir_node *node);
261
262 /**
263  * Gets the instruction latency.
264  */
265 unsigned get_ia32_latency(const ir_node *node);
266
267 /**
268  * Get the exception label attribute.
269  */
270 unsigned get_ia32_exc_label(const ir_node *node);
271
272 /**
273  * Set the exception label attribute.
274  */
275 void set_ia32_exc_label(ir_node *node, unsigned flag);
276
277 /**
278  * Return the exception label id.
279  */
280 ir_label_t get_ia32_exc_label_id(const ir_node *node);
281
282 /**
283  * Assign the exception label id.
284  */
285 void set_ia32_exc_label_id(ir_node *node, ir_label_t id);
286
287 #ifndef NDEBUG
288
289 /**
290  * Returns the name of the original ir node.
291  */
292 const char *get_ia32_orig_node(const ir_node *node);
293
294 /**
295  * Sets the name of the original ir node.
296  */
297 void set_ia32_orig_node(ir_node *node, const ir_node *old);
298
299 #endif /* NDEBUG */
300
301
302 /**
303  * Returns the ident of an entity
304  * @param ent The entity
305  * @return The ident of the entity
306  */
307 ident *ia32_get_ent_ident(ir_entity *ent);
308
309 /**
310  * Copy the attributes from a Const to an ia32_Const
311  */
312 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);
313
314 void set_ia32_Const_tarval(ir_node *node, ir_tarval *tv);
315
316 /**
317  * Returns whether or not the node is an AddrModeS node.
318  */
319 int is_ia32_AddrModeS(const ir_node *node);
320
321 /**
322  * Returns whether or not the node is an AddrModeD node.
323  */
324 int is_ia32_AddrModeD(const ir_node *node);
325
326 /**
327  * Swaps left/right input of a node (and sets ins_permuted accordingly)
328  */
329 void ia32_swap_left_right(ir_node *node);
330
331 /* Include the generated headers */
332 #include "gen_ia32_new_nodes.h"
333
334 #endif