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