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