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