no need for firm_config.h includes anymore
[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  *       | | | |                 | |     / /       | |                  | | | |             | |
57  *   __ _| |_| |_ _ __   ___  ___| |_   / /_ _  ___| |_   _ __ ___   ___| |_| |__   ___   __| |___
58  *  / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
59  * | (_| | |_| |_| |    \__ \  __/ |_ / / (_| |  __/ |_  | | | | | |  __/ |_| | | | (_) | (_| \__ \
60  *  \__,_|\__|\__|_|    |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
61  *                                        __/ |
62  *                                       |___/
63  ***************************************************************************************************/
64
65 /**
66  * returns true if a node has x87 registers
67  */
68 int ia32_has_x87_register(const ir_node *n);
69
70 /**
71  * Returns the attributes of an ia32 node.
72  */
73 ia32_attr_t *get_ia32_attr(ir_node *node);
74 const ia32_attr_t *get_ia32_attr_const(const ir_node *node);
75
76 ia32_x87_attr_t *get_ia32_x87_attr(ir_node *node);
77 const ia32_x87_attr_t *get_ia32_x87_attr_const(const ir_node *node);
78
79 ia32_immediate_attr_t *get_ia32_immediate_attr(ir_node *node);
80 const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node);
81
82 /**
83  * Gets the condcode attributes of a node.
84  */
85 ia32_condcode_attr_t *get_ia32_condcode_attr(ir_node *node);
86 const ia32_condcode_attr_t *get_ia32_condcode_attr_const(const ir_node *node);
87
88 /**
89  * Gets the Call node attributes.
90  */
91 ia32_call_attr_t *get_ia32_call_attr(ir_node *node);
92 const ia32_call_attr_t *get_ia32_call_attr_const(const ir_node *node);
93
94 /**
95  * Gets the CopyB node attributes.
96  */
97 ia32_copyb_attr_t *get_ia32_copyb_attr(ir_node *node);
98 const ia32_copyb_attr_t *get_ia32_copyb_attr_const(const ir_node *node);
99
100 /**
101  * Gets the type of an ia32 node.
102  */
103 ia32_op_type_t get_ia32_op_type(const ir_node *node);
104
105 /**
106  * Sets the type of an ia32 node.
107  */
108 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
109
110 /**
111  * Gets the supported address mode of an ia32 node
112  */
113 ia32_am_type_t get_ia32_am_support(const ir_node *node);
114
115 /**
116  * Sets the supported addrmode of an ia32 node
117  */
118 void set_ia32_am_support(ir_node *node, ia32_am_type_t am_arity);
119
120 /**
121  * Gets the addressmode offset as long.
122  */
123 int get_ia32_am_offs_int(const ir_node *node);
124
125 /**
126  * Sets the addressmode offset
127  */
128 void set_ia32_am_offs_int(ir_node *node, int offset);
129
130 void add_ia32_am_offs_int(ir_node *node, int offset);
131
132 /**
133  * Returns the symconst entity associated to addrmode.
134  */
135 ir_entity *get_ia32_am_sc(const ir_node *node);
136
137 /**
138  * Sets the symconst entity associated to addrmode.
139  */
140 void set_ia32_am_sc(ir_node *node, ir_entity *sc);
141
142 /**
143  * Sets the sign bit for address mode symconst.
144  */
145 void set_ia32_am_sc_sign(ir_node *node);
146
147 /**
148  * Clears the sign bit for address mode symconst.
149  */
150 void clear_ia32_am_sc_sign(ir_node *node);
151
152 /**
153  * Returns the sign bit for address mode symconst.
154  */
155 int is_ia32_am_sc_sign(const ir_node *node);
156
157 /**
158  * Gets the addr mode const.
159  */
160 int get_ia32_am_scale(const ir_node *node);
161
162 /**
163  * Sets the const for addr mode.
164  */
165 void set_ia32_am_scale(ir_node *node, int scale);
166
167 /**
168  * Sets the uses_frame flag.
169  */
170 void set_ia32_use_frame(ir_node *node);
171
172 /**
173  * Clears the uses_frame flag.
174  */
175 void clear_ia32_use_frame(ir_node *node);
176
177 /**
178  * Gets the uses_frame flag.
179  */
180 int is_ia32_use_frame(const ir_node *node);
181
182 /**
183  * copies all address-mode attributes from one node to the other
184  */
185 void ia32_copy_am_attrs(ir_node *to, const ir_node *from);
186
187 /**
188  * Sets node to commutative.
189  */
190 void set_ia32_commutative(ir_node *node);
191
192 /**
193  * Sets node to non-commutative.
194  */
195 void clear_ia32_commutative(ir_node *node);
196
197 /**
198  * Checks if node is commutative.
199  */
200 int is_ia32_commutative(const ir_node *node);
201
202 /**
203  * Sets node needs_stackent
204  */
205 void set_ia32_need_stackent(ir_node *node);
206
207 /**
208  * Clears node needs_stackent
209  */
210 void clear_ia32_need_stackent(ir_node *node);
211
212 /**
213  * Checks if node needs a stack entity assigned
214  */
215 int is_ia32_need_stackent(const ir_node *node);
216
217 void set_ia32_is_reload(ir_node *node);
218 int is_ia32_is_reload(const ir_node *node);
219
220 void set_ia32_is_spill(ir_node *node);
221 int is_ia32_is_spill(const ir_node *node);
222
223 void set_ia32_is_remat(ir_node *node);
224 int is_ia32_is_remat(const ir_node *node);
225
226 /**
227  * Gets the mode of the stored/loaded value (only set for Store/Load)
228  */
229 ir_mode *get_ia32_ls_mode(const ir_node *node);
230
231 /**
232  * Sets the mode of the stored/loaded value (only set for Store/Load)
233  */
234 void set_ia32_ls_mode(ir_node *node, ir_mode *mode);
235
236 /**
237  * Gets the frame entity assigned to this node;
238  */
239 ir_entity *get_ia32_frame_ent(const ir_node *node);
240
241 /**
242  * Sets the frame entity for this node;
243  */
244 void set_ia32_frame_ent(ir_node *node, ir_entity *ent);
245
246 /**
247  * Returns the argument register requirements of an ia32 node.
248  */
249 const arch_register_req_t **get_ia32_in_req_all(const ir_node *node);
250
251 /**
252  * Sets the argument register requirements of an ia32 node.
253  */
254 void set_ia32_in_req_all(ir_node *node, const arch_register_req_t **reqs);
255
256 /**
257  * Returns the result register requirements of an ia32 node.
258  */
259 const arch_register_req_t **get_ia32_out_req_all(const ir_node *node);
260
261 /**
262  * Sets the result register requirements of an ia32 node.
263  */
264 void set_ia32_out_req_all(ir_node *node, const arch_register_req_t **reqs);
265
266 /**
267  * Returns the argument register requirements of an ia32 node.
268  */
269 const arch_register_req_t *get_ia32_in_req(const ir_node *node, int pos);
270
271 /**
272  * Returns the result register requirements of an ia32 node.
273  */
274 const arch_register_req_t *get_ia32_out_req(const ir_node *node, int pos);
275
276 /**
277  * Sets the OUT register requirements at position pos.
278  */
279 void set_ia32_req_out(ir_node *node, const arch_register_req_t *req, int pos);
280
281 /**
282  * Sets the IN register requirements at position pos.
283  */
284 void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos);
285
286 /**
287  * Returns the register flag of an ia32 node.
288  */
289 arch_irn_flags_t get_ia32_flags(const ir_node *node);
290
291 /**
292  * Sets the register flag of an ia32 node.
293  */
294 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags);
295
296 void add_ia32_flags(ir_node *node, arch_irn_flags_t flags);
297
298 /**
299  * Returns the result register slots of an ia32 node.
300  */
301 const arch_register_t **get_ia32_slots(const ir_node *node);
302
303 /**
304  * Returns the name of the OUT register at position pos.
305  */
306 const char *get_ia32_out_reg_name(const ir_node *node, int pos);
307
308 /**
309  * Returns the index of the OUT register at position pos within its register class.
310  */
311 int get_ia32_out_regnr(const ir_node *node, int pos);
312
313 /**
314  * Returns the OUT register at position pos.
315  */
316 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos);
317
318 /**
319  * Returns the number of results.
320  */
321 int get_ia32_n_res(const ir_node *node);
322
323 /**
324  * Returns the condition code of a node.
325  */
326 long get_ia32_condcode(const ir_node *node);
327
328 /**
329  * Sets the condition code of a node
330  */
331 void set_ia32_condcode(ir_node *node, long code);
332
333 /**
334  * Returns the condition code of a node.
335  */
336 unsigned get_ia32_copyb_size(const ir_node *node);
337
338 /**
339  * Gets the instruction latency.
340  */
341 unsigned get_ia32_latency(const ir_node *node);
342
343
344 /**
345  * Sets the flags for the n'th out.
346  */
347 void set_ia32_out_flags(ir_node *node, arch_irn_flags_t flags, int pos);
348
349 /**
350  * Gets the flags for the n'th out.
351  */
352 arch_irn_flags_t get_ia32_out_flags(const ir_node *node, int pos);
353
354 /**
355  * Get the list of available execution units.
356  */
357 const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node);
358
359 /**
360  * Get the exception label attribute.
361  */
362 unsigned get_ia32_exc_label(const ir_node *node);
363
364 /**
365  * Set the exception label attribute.
366  */
367 void set_ia32_exc_label(ir_node *node, unsigned flag);
368
369 /**
370  * Return the exception label id.
371  */
372 ir_label_t get_ia32_exc_label_id(const ir_node *node);
373
374 /**
375  * Assign the exception label id.
376  */
377 void set_ia32_exc_label_id(ir_node *node, ir_label_t id);
378
379 #ifndef NDEBUG
380
381 /**
382  * Returns the name of the original ir node.
383  */
384 const char *get_ia32_orig_node(const ir_node *node);
385
386 /**
387  * Sets the name of the original ir node.
388  */
389 void set_ia32_orig_node(ir_node *node, const char *name);
390
391 #endif /* NDEBUG */
392
393 /******************************************************************************************************
394  *                      _       _         _   _           __                  _   _
395  *                     (_)     | |       | | | |         / _|                | | (_)
396  *  ___ _ __   ___  ___ _  __ _| |   __ _| |_| |_ _ __  | |_ _   _ _ __   ___| |_ _  ___  _ __    ___
397  * / __| '_ \ / _ \/ __| |/ _` | |  / _` | __| __| '__| |  _| | | | '_ \ / __| __| |/ _ \| '_ \  / __|
398  * \__ \ |_) |  __/ (__| | (_| | | | (_| | |_| |_| |    | | | |_| | | | | (__| |_| | (_) | | | | \__ \
399  * |___/ .__/ \___|\___|_|\__,_|_|  \__,_|\__|\__|_|    |_|  \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
400  *     | |
401  *     |_|
402  ******************************************************************************************************/
403
404 /**
405  * Returns the ident of an entity
406  * @param ent The entity
407  * @return The ident of the entity
408  */
409 ident *ia32_get_ent_ident(ir_entity *ent);
410
411 /**
412  * Returns the proj of the result value for nodes that have the usual
413  * (res, Mem) result tuple
414  */
415 ir_node *get_ia32_result_proj(const ir_node *node);
416
417 /**
418  * Copy the attributes from a Const to an ia32_Const
419  */
420 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);
421
422 void set_ia32_Const_tarval(ir_node *node, tarval *tv);
423
424 /**
425  * Returns whether or not the node is an AddrModeS node.
426  */
427 int is_ia32_AddrModeS(const ir_node *node);
428
429 /**
430  * Returns whether or not the node is an AddrModeD node.
431  */
432 int is_ia32_AddrModeD(const ir_node *node);
433
434 /**
435  * Checks if node is a Load or fLoad.
436  */
437 int is_ia32_Ld(const ir_node *node);
438
439 /**
440  * Checks if node is a Store or fStore.
441  */
442 int is_ia32_St(const ir_node *node);
443
444 /**
445  * Swaps left/right input of a node (and adjusts pnc if needed)
446  */
447 void ia32_swap_left_right(ir_node *node);
448
449 /**
450  * Initializes the nodes attributes.
451  */
452 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
453                           const arch_register_req_t **in_reqs,
454                           const arch_register_req_t **out_reqs,
455                           const be_execution_unit_t ***execution_units,
456                           int n_res);
457
458 void init_ia32_x87_attributes(ir_node *node);
459 void init_ia32_asm_attributes(ir_node *node);
460 void init_ia32_immediate_attributes(ir_node *node, ir_entity *symconst,
461                                     int symconst_sign, long offset);
462 void init_ia32_call_attributes(ir_node *res, unsigned pop, ir_type *call_tp);
463 void init_ia32_copyb_attributes(ir_node *res, unsigned size);
464 void init_ia32_condcode_attributes(ir_node *res, long pnc);
465
466 /* Include the generated headers */
467 #include "gen_ia32_new_nodes.h"
468
469 #endif /* FIRM_BE_IA32_IA32_NEW_NODES_H */