fixed spill lowering
[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  * Gets the addr mode const.
86  */
87 int get_ia32_am_scale(const ir_node *node);
88
89 /**
90  * Sets the const for addr mode.
91  */
92 void set_ia32_am_scale(ir_node *node, int scale);
93
94 /**
95  * Return the tarval of an immediate operation or NULL in case of SymConst
96  */
97 tarval *get_ia32_Immop_tarval(const ir_node *node);
98
99 /**
100  * Sets the attributes of an immediate operation to the specified tarval
101  */
102 void set_ia32_Immop_tarval(ir_node *node, tarval *tv);
103
104 /**
105  * Return the sc attribute.
106  */
107 ident *get_ia32_sc(const ir_node *node);
108
109 /**
110  * Sets the sc attribute.
111  */
112 void set_ia32_sc(ir_node *node, ident *sc);
113
114 /**
115  * Gets the string representation of the internal const (tv or symconst)
116  */
117 const char *get_ia32_cnst(const ir_node *node);
118
119 /**
120  * Sets the string representation of the internal const.
121  */
122 void set_ia32_cnst(ir_node *node, char *cnst);
123
124 /**
125  * Gets the ident representation of the internal const (tv or symconst)
126  */
127 ident *get_ia32_id_cnst(const ir_node *node);
128
129 /**
130  * Sets the ident representation of the internal const.
131  */
132 void set_ia32_id_cnst(ir_node *node, ident *cnst);
133
134 /**
135  * Sets the uses_frame flag.
136  */
137 void set_ia32_use_frame(ir_node *node);
138
139 /**
140  * Clears the uses_frame flag.
141  */
142 void clear_ia32_use_frame(ir_node *node);
143
144 /**
145  * Gets the uses_frame flag.
146  */
147 int is_ia32_use_frame(const ir_node *node);
148
149 /**
150  * Sets node to commutative.
151  */
152 void set_ia32_commutative(ir_node *node);
153
154 /**
155  * Sets node to non-commutative.
156  */
157 void clear_ia32_commutative(ir_node *node);
158
159 /**
160  * Checks if node is commutative.
161  */
162 int is_ia32_commutative(const ir_node *node);
163
164 /**
165  * Sets node emit_cl.
166  */
167 void set_ia32_emit_cl(ir_node *node);
168
169 /**
170  * Clears node emit_cl.
171  */
172 void clear_ia32_emit_cl(ir_node *node);
173
174 /**
175  * Checks if node is commutative.
176  */
177 int is_ia32_emit_cl(const ir_node *node);
178
179 /**
180  * Gets the mode of the stored/loaded value (only set for Store/Load)
181  */
182 ir_mode *get_ia32_ls_mode(const ir_node *node);
183
184 /**
185  * Sets the mode of the stored/loaded value (only set for Store/Load)
186  */
187 void set_ia32_ls_mode(ir_node *node, ir_mode *mode);
188
189 /**
190  * Gets the mode of the result.
191  */
192 ir_mode *get_ia32_res_mode(const ir_node *node);
193
194 /**
195  * Sets the mode of the result.
196  */
197 void set_ia32_res_mode(ir_node *node, ir_mode *mode);
198
199 /**
200  * Gets the frame entity assigned to this node;
201  */
202 entity *get_ia32_frame_ent(const ir_node *node);
203
204 /**
205  * Sets the frame entity for this node;
206  */
207 void set_ia32_frame_ent(ir_node *node, entity *ent);
208
209 /**
210  * Returns the argument register requirements of an ia32 node.
211  */
212 const ia32_register_req_t **get_ia32_in_req_all(const ir_node *node);
213
214 /**
215  * Sets the argument register requirements of an ia32 node.
216  */
217 void set_ia32_in_req_all(ir_node *node, const ia32_register_req_t **reqs);
218
219 /**
220  * Returns the result register requirements of an ia32 node.
221  */
222 const ia32_register_req_t **get_ia32_out_req_all(const ir_node *node);
223
224 /**
225  * Sets the result register requirements of an ia32 node.
226  */
227 void set_ia32_out_req_all(ir_node *node, const ia32_register_req_t **reqs);
228
229 /**
230  * Returns the argument register requirements of an ia32 node.
231  */
232 const ia32_register_req_t *get_ia32_in_req(const ir_node *node, int pos);
233
234 /**
235  * Returns the result register requirements of an ia32 node.
236  */
237 const ia32_register_req_t *get_ia32_out_req(const ir_node *node, int pos);
238
239 /**
240  * Sets the OUT register requirements at position pos.
241  */
242 void set_ia32_req_out(ir_node *node, const ia32_register_req_t *req, int pos);
243
244 /**
245  * Sets the IN register requirements at position pos.
246  */
247 void set_ia32_req_in(ir_node *node, const ia32_register_req_t *req, int pos);
248
249 /**
250  * Returns the register flag of an ia32 node.
251  */
252 arch_irn_flags_t get_ia32_flags(const ir_node *node);
253
254 /**
255  * Sets the register flag of an ia32 node.
256  */
257 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags);
258
259 /**
260  * Returns the result register slots of an ia32 node.
261  */
262 const arch_register_t **get_ia32_slots(const ir_node *node);
263
264 /**
265  * Returns the name of the OUT register at position pos.
266  */
267 const char *get_ia32_out_reg_name(const ir_node *node, int pos);
268
269 /**
270  * Returns the index of the OUT register at position pos within its register class.
271  */
272 int get_ia32_out_regnr(const ir_node *node, int pos);
273
274 /**
275  * Returns the OUT register at position pos.
276  */
277 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos);
278
279 /**
280  * Sets the number of results.
281  */
282 void set_ia32_n_res(ir_node *node, int n_res);
283
284 /**
285  * Returns the number of results.
286  */
287 int get_ia32_n_res(const ir_node *node);
288
289 /**
290  * Returns the flavour of an ia32 node,
291  */
292 ia32_op_flavour_t get_ia32_flavour(const ir_node *node);
293
294 /**
295  * Sets the flavour of an ia32 node to flavour_Div/Mod/DivMod/Mul/Mulh.
296  */
297 void set_ia32_flavour(ir_node *node, ia32_op_flavour_t op_flav);
298
299 /**
300  * Returns the projnum code.
301  */
302 long get_ia32_pncode(const ir_node *node);
303
304 /**
305  * Sets the projnum code
306  */
307 void set_ia32_pncode(ir_node *node, long code);
308
309 #ifndef NDEBUG
310
311 /**
312  * Returns the name of the original ir node.
313  */
314 const char *get_ia32_orig_node(const ir_node *node);
315
316 /**
317  * Sets the name of the original ir node.
318  */
319 void set_ia32_orig_node(ir_node *node, const char *name);
320
321 #endif /* NDEBUG */
322
323 /******************************************************************************************************
324  *                      _       _         _   _           __                  _   _
325  *                     (_)     | |       | | | |         / _|                | | (_)
326  *  ___ _ __   ___  ___ _  __ _| |   __ _| |_| |_ _ __  | |_ _   _ _ __   ___| |_ _  ___  _ __    ___
327  * / __| '_ \ / _ \/ __| |/ _` | |  / _` | __| __| '__| |  _| | | | '_ \ / __| __| |/ _ \| '_ \  / __|
328  * \__ \ |_) |  __/ (__| | (_| | | | (_| | |_| |_| |    | | | |_| | | | | (__| |_| | (_) | | | | \__ \
329  * |___/ .__/ \___|\___|_|\__,_|_|  \__,_|\__|\__|_|    |_|  \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
330  *     | |
331  *     |_|
332  ******************************************************************************************************/
333
334 /**
335  * Gets the type of an ia32_Const.
336  */
337 unsigned get_ia32_Const_type(const ir_node *node);
338
339 /**
340  * Sets the type of an ia32_Const.
341  */
342 void set_ia32_Const_type(ir_node *node, int type);
343
344 /**
345  * Copy the attributes from an ia32_Const to an Immop (Add_i, Sub_i, ...) node
346  */
347 void set_ia32_Immop_attr(ir_node *node, ir_node *cnst);
348
349 /**
350  * Copy the attributes from Immop to an Immop
351  */
352 void copy_ia32_Immop_attr(ir_node *node, ir_node *src);
353
354 /**
355  * Copy the attributes from a Const to an ia32_Const
356  */
357 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);
358
359 /**
360  * Sets the AddrMode attribute
361  * @param direction The "direction" of AM ('S' source or 'D' destination)
362  */
363 void set_ia32_AddrMode(ir_node *node, char direction);
364
365 /**
366  * Returns whether or not the node is an immediate operation with Const.
367  */
368 int is_ia32_ImmConst(const ir_node *node);
369
370 /**
371  * Returns whether or not the node is an immediate operation with SymConst.
372  */
373 int is_ia32_ImmSymConst(const ir_node *node);
374
375 /**
376  * Returns whether or not the node is an AddrModeS node.
377  */
378 int is_ia32_AddrModeS(const ir_node *node);
379
380 /**
381  * Returns whether or not the node is an AddrModeD node.
382  */
383 int is_ia32_AddrModeD(const ir_node *node);
384
385 /**
386  * Checks if node is a Load or fLoad.
387  */
388 int is_ia32_Ld(const ir_node *node);
389
390 /**
391  * Checks if node is a Store or fStore.
392  */
393 int is_ia32_St(const ir_node *node);
394
395 /**
396  * Checks if node is a Const or fConst.
397  */
398 int is_ia32_Cnst(const ir_node *node);
399
400 /**
401  * Allocates num register slots for node.
402  */
403 void alloc_ia32_reg_slots(ir_node *node, int num);
404
405 /**
406  * Initializes the nodes attributes.
407  */
408 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags, const ia32_register_req_t **in_reqs, \
409         const ia32_register_req_t **out_reqs, int n_res);
410
411 /**
412  * Registers the ia32_copy_attr function for all ia32 opcodes.
413  */
414 void ia32_register_copy_attr_func(void);
415
416 /* Include the generated headers */
417 #include "gen_ia32_new_nodes.h"
418
419 #endif /* _IA32_NEW_NODES_H_ */