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