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