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