ac935e56147da5f88f3144335a91845296986d9e
[libfirm] / ir / be / ia32 / ia32_new_nodes.h
1 /*
2  * Copyright (C) 1995-2007 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 "firm_config.h"
33 #include "ia32_nodes_attr.h"
34
35 /***************************************************************************************************
36  *        _   _                   _       __        _                    _   _               _
37  *       | | | |                 | |     / /       | |                  | | | |             | |
38  *   __ _| |_| |_ _ __   ___  ___| |_   / /_ _  ___| |_   _ __ ___   ___| |_| |__   ___   __| |___
39  *  / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
40  * | (_| | |_| |_| |    \__ \  __/ |_ / / (_| |  __/ |_  | | | | | |  __/ |_| | | | (_) | (_| \__ \
41  *  \__,_|\__|\__|_|    |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
42  *                                        __/ |
43  *                                       |___/
44  ***************************************************************************************************/
45
46 /**
47  * returns true if a node has x87 registers
48  */
49 int ia32_has_x87_register(const ir_node *n);
50
51 /**
52  * Returns the attributes of an ia32 node.
53  */
54 ia32_attr_t *get_ia32_attr(ir_node *node);
55 const ia32_attr_t *get_ia32_attr_const(const ir_node *node);
56
57 ia32_x87_attr_t *get_ia32_x87_attr(ir_node *node);
58 const ia32_x87_attr_t *get_ia32_x87_attr_const(const ir_node *node);
59
60 const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node);
61
62 /**
63  * Gets the type of an ia32 node.
64  */
65 ia32_op_type_t get_ia32_op_type(const ir_node *node);
66
67 /**
68  * Sets the type of an ia32 node.
69  */
70 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
71
72 /**
73  * Gets the immediate op type of an ia32 node.
74  */
75 ia32_immop_type_t get_ia32_immop_type(const ir_node *node);
76
77 /**
78  * Sets the immediate op type of an ia32 node.
79  */
80 void set_ia32_immop_type(ir_node *node, ia32_immop_type_t tp);
81
82 /**
83  * Gets the supported addrmode of an ia32 node
84  */
85 ia32_am_type_t get_ia32_am_support(const ir_node *node);
86
87 /**
88  * Sets the supported addrmode of an ia32 node
89  */
90 void set_ia32_am_support(ir_node *node, ia32_am_type_t am_tp);
91
92 /**
93  * Gets the addrmode flavour of an ia32 node
94  */
95 ia32_am_flavour_t get_ia32_am_flavour(const ir_node *node);
96
97 /**
98  * Sets the addrmode flavour of an ia32 node
99  */
100 void set_ia32_am_flavour(ir_node *node, ia32_am_flavour_t am_flavour);
101
102 /**
103  * Gets the addressmode offset as long.
104  */
105 int get_ia32_am_offs_int(const ir_node *node);
106
107 /**
108  * Sets the addressmode offset
109  */
110 void set_ia32_am_offs_int(ir_node *node, int offset);
111
112 void add_ia32_am_offs_int(ir_node *node, int offset);
113
114 /**
115  * Returns the symconst entity associated to addrmode.
116  */
117 ir_entity *get_ia32_am_sc(const ir_node *node);
118
119 /**
120  * Sets the symconst entity associated to addrmode.
121  */
122 void set_ia32_am_sc(ir_node *node, ir_entity *sc);
123
124 /**
125  * Sets the sign bit for address mode symconst.
126  */
127 void set_ia32_am_sc_sign(ir_node *node);
128
129 /**
130  * Clears the sign bit for address mode symconst.
131  */
132 void clear_ia32_am_sc_sign(ir_node *node);
133
134 /**
135  * Returns the sign bit for address mode symconst.
136  */
137 int is_ia32_am_sc_sign(const ir_node *node);
138
139 /**
140  * Gets the addr mode const.
141  */
142 int get_ia32_am_scale(const ir_node *node);
143
144 /**
145  * Sets the const for addr mode.
146  */
147 void set_ia32_am_scale(ir_node *node, int scale);
148
149 /**
150  * Return the tarval of an immediate operation or NULL if none set
151  */
152 tarval *get_ia32_Immop_tarval(const ir_node *node);
153
154 /**
155  * Return the symconst entity of an immediate operation or NULL if none set
156  */
157 ir_entity* get_ia32_Immop_symconst(const ir_node *node);
158
159 /**
160  * Sets the attributes of an immediate operation to the specified tarval
161  */
162 void set_ia32_Immop_tarval(ir_node *node, tarval *tv);
163
164 /**
165  * Sets the attributes of an immediate operation to the specified SymConst
166  */
167 void set_ia32_Immop_symconst(ir_node *node, ir_entity *entity);
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  * Sets node to commutative.
186  */
187 void set_ia32_commutative(ir_node *node);
188
189 /**
190  * Sets node to non-commutative.
191  */
192 void clear_ia32_commutative(ir_node *node);
193
194 /**
195  * Checks if node is commutative.
196  */
197 int is_ia32_commutative(const ir_node *node);
198
199 /**
200  * Sets node emit_cl.
201  */
202 void set_ia32_emit_cl(ir_node *node);
203
204 /**
205  * Clears node emit_cl.
206  */
207 void clear_ia32_emit_cl(ir_node *node);
208
209 /**
210  * Checks if node is commutative.
211  */
212 int is_ia32_emit_cl(const ir_node *node);
213
214 /**
215  * Sets node got_lea.
216  */
217 void set_ia32_got_lea(ir_node *node);
218
219 /**
220  * Clears node got_lea.
221  */
222 void clear_ia32_got_lea(ir_node *node);
223
224 /**
225  * Checks if node got lea.
226  */
227 int is_ia32_got_lea(const ir_node *node);
228
229 /**
230  * Sets node needs_stackent
231  */
232 void set_ia32_need_stackent(ir_node *node);
233
234 /**
235  * Clears node needs_stackent
236  */
237 void clear_ia32_need_stackent(ir_node *node);
238
239 /**
240  * Checks if node needs a stackentity assigned
241  */
242 int is_ia32_need_stackent(const ir_node *node);
243
244 /**
245  * Gets the mode of the stored/loaded value (only set for Store/Load)
246  */
247 ir_mode *get_ia32_ls_mode(const ir_node *node);
248
249 /**
250  * Sets the mode of the stored/loaded value (only set for Store/Load)
251  */
252 void set_ia32_ls_mode(ir_node *node, ir_mode *mode);
253
254 /**
255  * Gets the frame entity assigned to this node;
256  */
257 ir_entity *get_ia32_frame_ent(const ir_node *node);
258
259 /**
260  * Sets the frame entity for this node;
261  */
262 void set_ia32_frame_ent(ir_node *node, ir_entity *ent);
263
264 /**
265  * Returns the argument register requirements of an ia32 node.
266  */
267 const arch_register_req_t **get_ia32_in_req_all(const ir_node *node);
268
269 /**
270  * Sets the argument register requirements of an ia32 node.
271  */
272 void set_ia32_in_req_all(ir_node *node, const arch_register_req_t **reqs);
273
274 /**
275  * Returns the result register requirements of an ia32 node.
276  */
277 const arch_register_req_t **get_ia32_out_req_all(const ir_node *node);
278
279 /**
280  * Sets the result register requirements of an ia32 node.
281  */
282 void set_ia32_out_req_all(ir_node *node, const arch_register_req_t **reqs);
283
284 /**
285  * Returns the argument register requirements of an ia32 node.
286  */
287 const arch_register_req_t *get_ia32_in_req(const ir_node *node, int pos);
288
289 /**
290  * Returns the result register requirements of an ia32 node.
291  */
292 const arch_register_req_t *get_ia32_out_req(const ir_node *node, int pos);
293
294 /**
295  * Sets the OUT register requirements at position pos.
296  */
297 void set_ia32_req_out(ir_node *node, const arch_register_req_t *req, int pos);
298
299 /**
300  * Sets the IN register requirements at position pos.
301  */
302 void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos);
303
304 /**
305  * Returns the register flag of an ia32 node.
306  */
307 arch_irn_flags_t get_ia32_flags(const ir_node *node);
308
309 /**
310  * Sets the register flag of an ia32 node.
311  */
312 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags);
313
314 /**
315  * Returns the result register slots of an ia32 node.
316  */
317 const arch_register_t **get_ia32_slots(const ir_node *node);
318
319 /**
320  * Returns the name of the OUT register at position pos.
321  */
322 const char *get_ia32_out_reg_name(const ir_node *node, int pos);
323
324 /**
325  * Returns the index of the OUT register at position pos within its register class.
326  */
327 int get_ia32_out_regnr(const ir_node *node, int pos);
328
329 /**
330  * Returns the OUT register at position pos.
331  */
332 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos);
333
334 /**
335  * Returns the number of results.
336  */
337 int get_ia32_n_res(const ir_node *node);
338
339 /**
340  * Returns the flavour of an ia32 node,
341  */
342 ia32_op_flavour_t get_ia32_flavour(const ir_node *node);
343
344 /**
345  * Sets the flavour of an ia32 node to flavour_Div/Mod/DivMod/Mul/Mulh.
346  */
347 void set_ia32_flavour(ir_node *node, ia32_op_flavour_t op_flav);
348
349 /**
350  * Returns the projnum code.
351  */
352 long get_ia32_pncode(const ir_node *node);
353
354 /**
355  * Sets the projnum code
356  */
357 void set_ia32_pncode(ir_node *node, long code);
358
359 /**
360  * Gets the instruction latency.
361  */
362 unsigned get_ia32_latency(const ir_node *node);
363
364 /**
365  * Sets the instruction latency.
366  */
367 void set_ia32_latency(ir_node *node, unsigned latency);
368
369
370 /**
371  * Sets the flags for the n'th out.
372  */
373 void set_ia32_out_flags(ir_node *node, arch_irn_flags_t flags, int pos);
374
375 /**
376  * Gets the flags for the n'th out.
377  */
378 arch_irn_flags_t get_ia32_out_flags(const ir_node *node, int pos);
379
380 /**
381  * Get the list of available execution units.
382  */
383 const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node);
384
385 /**
386  * Get the exception label attribute.
387  */
388 unsigned get_ia32_exc_label(const ir_node *node);
389
390 /**
391  * Set the exception label attribute.
392  */
393 void set_ia32_exc_label(ir_node *node, unsigned flag);
394
395 #ifndef NDEBUG
396
397 /**
398  * Returns the name of the original ir node.
399  */
400 const char *get_ia32_orig_node(const ir_node *node);
401
402 /**
403  * Sets the name of the original ir node.
404  */
405 void set_ia32_orig_node(ir_node *node, const char *name);
406
407 #endif /* NDEBUG */
408
409 /******************************************************************************************************
410  *                      _       _         _   _           __                  _   _
411  *                     (_)     | |       | | | |         / _|                | | (_)
412  *  ___ _ __   ___  ___ _  __ _| |   __ _| |_| |_ _ __  | |_ _   _ _ __   ___| |_ _  ___  _ __    ___
413  * / __| '_ \ / _ \/ __| |/ _` | |  / _` | __| __| '__| |  _| | | | '_ \ / __| __| |/ _ \| '_ \  / __|
414  * \__ \ |_) |  __/ (__| | (_| | | | (_| | |_| |_| |    | | | |_| | | | | (__| |_| | (_) | | | | \__ \
415  * |___/ .__/ \___|\___|_|\__,_|_|  \__,_|\__|\__|_|    |_|  \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
416  *     | |
417  *     |_|
418  ******************************************************************************************************/
419
420 /**
421  * Returns the ident of an entity
422  * @param ent The entity
423  * @return The ident of the entity
424  */
425 ident *ia32_get_ent_ident(ir_entity *ent);
426
427 /**
428  * Copy the attributes from Immop to an Immop
429  */
430 void copy_ia32_Immop_attr(ir_node *node, ir_node *src);
431
432 /**
433  * Returns the proj of the result value for nodes that have the usual
434  * (res, Mem) result tuple
435  */
436 ir_node *get_ia32_result_proj(const ir_node *node);
437
438 /**
439  * Copy the attributes from a Const to an ia32_Const
440  */
441 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);
442
443 void set_ia32_Const_tarval(ir_node *node, tarval *tv);
444
445 /**
446  * Sets the AddrMode attribute
447  * @param direction The "direction" of AM ('S' source or 'D' destination)
448  */
449 void set_ia32_AddrMode(ir_node *node, char direction);
450
451 /**
452  * Returns whether or not the node is an immediate operation with Const.
453  */
454 int is_ia32_ImmConst(const ir_node *node);
455
456 /**
457  * Returns whether or not the node is an immediate operation with SymConst.
458  */
459 int is_ia32_ImmSymConst(const ir_node *node);
460
461 /**
462  * Returns whether or not the node is an AddrModeS node.
463  */
464 int is_ia32_AddrModeS(const ir_node *node);
465
466 /**
467  * Returns whether or not the node is an AddrModeD node.
468  */
469 int is_ia32_AddrModeD(const ir_node *node);
470
471 /**
472  * Checks if node is a Load or fLoad.
473  */
474 int is_ia32_Ld(const ir_node *node);
475
476 /**
477  * Checks if node is a Store or fStore.
478  */
479 int is_ia32_St(const ir_node *node);
480
481 /**
482  * Checks if node is a Const or fConst.
483  */
484 int is_ia32_Cnst(const ir_node *node);
485
486 /**
487  * Initializes the nodes attributes.
488  */
489 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
490                           const arch_register_req_t **in_reqs,
491                           const arch_register_req_t **out_reqs,
492                           const be_execution_unit_t ***execution_units,
493                           int n_res, unsigned latency);
494
495 void init_ia32_x87_attributes(ir_node *node);
496 void init_ia32_asm_attributes(ir_node *node);
497 void init_ia32_immediate_attributes(ir_node *node, ir_entity *symconst,
498                                     int symconst_sign, tarval *offset);
499
500 /**
501  * Registers the ia32_copy_attr function for all ia32 opcodes.
502  */
503 void ia32_register_copy_attr_func(void);
504
505 /* Include the generated headers */
506 #include "gen_ia32_new_nodes.h"
507
508 #endif /* FIRM_BE_IA32_IA32_NEW_NODES_H */