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