added copy attr function
[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
12 #include "ia32_nodes_attr.h"
13
14 /**
15  * Returns the name of a firm symconst.
16  */
17 const char *get_sc_name(ir_node *symc);
18
19
20
21 /***************************************************************************************************
22  *        _   _                   _       __        _                    _   _               _
23  *       | | | |                 | |     / /       | |                  | | | |             | |
24  *   __ _| |_| |_ _ __   ___  ___| |_   / /_ _  ___| |_   _ __ ___   ___| |_| |__   ___   __| |___
25  *  / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
26  * | (_| | |_| |_| |    \__ \  __/ |_ / / (_| |  __/ |_  | | | | | |  __/ |_| | | | (_) | (_| \__ \
27  *  \__,_|\__|\__|_|    |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
28  *                                        __/ |
29  *                                       |___/
30  ***************************************************************************************************/
31
32 /**
33  * Returns the attributes of an ia32 node.
34  */
35 ia32_attr_t *get_ia32_attr(const ir_node *node);
36
37 /**
38  * Gets the type of an ia32 node.
39  */
40 ia32_op_type_t get_ia32_op_type(const ir_node *node);
41
42 /**
43  * Sets the type of an ia32 node.
44  */
45 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
46
47 /**
48  * Gets the supported addrmode of an ia32 node
49  */
50 ia32_am_type_t get_ia32_am_support(const ir_node *node);
51
52 /**
53  * Sets the supported addrmode of an ia32 node
54  */
55 void set_ia32_am_support(ir_node *node, ia32_am_type_t am_tp);
56
57 /**
58  * Gets the addrmode flavour of an ia32 node
59  */
60 ia32_am_flavour_t get_ia32_am_flavour(const ir_node *node);
61
62 /**
63  * Sets the addrmode flavour of an ia32 node
64  */
65 void set_ia32_am_flavour(ir_node *node, ia32_am_flavour_t am_flavour);
66
67 /**
68  * Gets the joined addrmode offset.
69  */
70 char *get_ia32_am_offs(const ir_node *node);
71
72 /**
73  * Adds an offset for addrmode.
74  */
75 void add_ia32_am_offs(ir_node *node, char *offset);
76
77 /**
78  * Subs an offset for addrmode.
79  */
80 void sub_ia32_am_offs(ir_node *node, char *offset);
81
82 /**
83  * Gets the addr mode const.
84  */
85 int get_ia32_am_scale(const ir_node *node);
86
87 /**
88  * Sets the const for addr mode.
89  */
90 void set_ia32_am_scale(ir_node *node, int scale);
91
92 /**
93  * Return the tarval of an immediate operation or NULL in case of SymConst
94  */
95 tarval *get_ia32_Immop_tarval(const ir_node *node);
96
97 /**
98  * Sets the attributes of an immediate operation to the specified tarval
99  */
100 void set_ia32_Immop_tarval(ir_node *node, tarval *tv);
101
102 /**
103  * Return the sc attribute.
104  */
105 const char *get_ia32_sc(const ir_node *node);
106
107 /**
108  * Sets the sc attribute.
109  */
110 void set_ia32_sc(ir_node *node, const char *sc);
111
112 /**
113  * Gets the string representation of the internal const (tv or symconst)
114  */
115 char *get_ia32_cnst(const ir_node *node);
116
117 /**
118  * Sets the string representation of the internal const.
119  */
120 void set_ia32_cnst(ir_node *node, char *cnst);
121
122 /**
123  * Sets the uses_frame flag.
124  */
125 void set_ia32_use_frame(ir_node *node);
126
127 /**
128  * Clears the uses_frame flag.
129  */
130 void clear_ia32_use_frame(ir_node *node);
131
132 /**
133  * Gets the uses_frame flag.
134  */
135 int is_ia32_use_frame(const ir_node *node);
136
137 /**
138  * Sets node to commutative.
139  */
140 void set_ia32_commutative(ir_node *node);
141
142 /**
143  * Sets node to non-commutative.
144  */
145 void clear_ia32_commutative(ir_node *node);
146
147 /**
148  * Checks if node is commutative.
149  */
150 int is_ia32_commutative(const ir_node *node);
151
152 /**
153  * Gets the mode of the stored/loaded value (only set for Store/Load)
154  */
155 ir_mode *get_ia32_ls_mode(const ir_node *node);
156
157 /**
158  * Sets the mode of the stored/loaded value (only set for Store/Load)
159  */
160 void set_ia32_ls_mode(ir_node *node, ir_mode *mode);
161
162 /**
163  * Gets the mode of the result.
164  */
165 ir_mode *get_ia32_res_mode(const ir_node *node);
166
167 /**
168  * Sets the mode of the result.
169  */
170 void set_ia32_res_mode(ir_node *node, ir_mode *mode);
171
172 /**
173  * Gets the frame entity assigned to this node;
174  */
175 entity *get_ia32_frame_ent(const ir_node *node);
176
177 /**
178  * Sets the frame entity for this node;
179  */
180 void set_ia32_frame_ent(ir_node *node, entity *ent);
181
182 /**
183  * Returns the argument register requirements of an ia32 node.
184  */
185 const ia32_register_req_t **get_ia32_in_req_all(const ir_node *node);
186
187 /**
188  * Sets the argument register requirements of an ia32 node.
189  */
190 void set_ia32_in_req_all(ir_node *node, const ia32_register_req_t **reqs);
191
192 /**
193  * Returns the result register requirements of an ia32 node.
194  */
195 const ia32_register_req_t **get_ia32_out_req_all(const ir_node *node);
196
197 /**
198  * Sets the result register requirements of an ia32 node.
199  */
200 void set_ia32_out_req_all(ir_node *node, const ia32_register_req_t **reqs);
201
202 /**
203  * Returns the argument register requirements of an ia32 node.
204  */
205 const ia32_register_req_t *get_ia32_in_req(const ir_node *node, int pos);
206
207 /**
208  * Returns the result register requirements of an ia32 node.
209  */
210 const ia32_register_req_t *get_ia32_out_req(const ir_node *node, int pos);
211
212 /**
213  * Sets the OUT register requirements at position pos.
214  */
215 void set_ia32_req_out(ir_node *node, const ia32_register_req_t *req, int pos);
216
217 /**
218  * Sets the IN register requirements at position pos.
219  */
220 void set_ia32_req_in(ir_node *node, const ia32_register_req_t *req, int pos);
221
222 /**
223  * Returns the register flag of an ia32 node.
224  */
225 arch_irn_flags_t get_ia32_flags(const ir_node *node);
226
227 /**
228  * Sets the register flag of an ia32 node.
229  */
230 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags);
231
232 /**
233  * Returns the result register slots of an ia32 node.
234  */
235 const arch_register_t **get_ia32_slots(const ir_node *node);
236
237 /**
238  * Returns the name of the OUT register at position pos.
239  */
240 const char *get_ia32_out_reg_name(const ir_node *node, int pos);
241
242 /**
243  * Returns the index of the OUT register at position pos within its register class.
244  */
245 int get_ia32_out_regnr(const ir_node *node, int pos);
246
247 /**
248  * Returns the OUT register at position pos.
249  */
250 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos);
251
252 /**
253  * Sets the number of results.
254  */
255 void set_ia32_n_res(ir_node *node, int n_res);
256
257 /**
258  * Returns the number of results.
259  */
260 int get_ia32_n_res(const ir_node *node);
261
262 /**
263  * Returns the flavour of an ia32 node,
264  */
265 ia32_op_flavour_t get_ia32_flavour(const ir_node *node);
266
267 /**
268  * Sets the flavour of an ia32 node to flavour_Div/Mod/DivMod/Mul/Mulh.
269  */
270 void set_ia32_flavour(ir_node *node, ia32_op_flavour_t op_flav);
271
272 /**
273  * Returns the projnum code.
274  */
275 long get_ia32_pncode(const ir_node *node);
276
277 /**
278  * Sets the projnum code
279  */
280 void set_ia32_pncode(ir_node *node, long code);
281
282 #ifndef NDEBUG
283
284 /**
285  * Returns the name of the original ir node.
286  */
287 const char *get_ia32_orig_node(const ir_node *node);
288
289 /**
290  * Sets the name of the original ir node.
291  */
292 void set_ia32_orig_node(ir_node *node, const char *name);
293
294 #endif /* NDEBUG */
295
296 /******************************************************************************************************
297  *                      _       _         _   _           __                  _   _
298  *                     (_)     | |       | | | |         / _|                | | (_)
299  *  ___ _ __   ___  ___ _  __ _| |   __ _| |_| |_ _ __  | |_ _   _ _ __   ___| |_ _  ___  _ __    ___
300  * / __| '_ \ / _ \/ __| |/ _` | |  / _` | __| __| '__| |  _| | | | '_ \ / __| __| |/ _ \| '_ \  / __|
301  * \__ \ |_) |  __/ (__| | (_| | | | (_| | |_| |_| |    | | | |_| | | | | (__| |_| | (_) | | | | \__ \
302  * |___/ .__/ \___|\___|_|\__,_|_|  \__,_|\__|\__|_|    |_|  \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
303  *     | |
304  *     |_|
305  ******************************************************************************************************/
306
307 /**
308  * Gets the type of an ia32_Const.
309  */
310 unsigned get_ia32_Const_type(const ir_node *node);
311
312 /**
313  * Sets the type of an ia32_Const.
314  */
315 void set_ia32_Const_type(ir_node *node, int type);
316
317 /**
318  * Copy the attributes from an ia32_Const to an Immop (Add_i, Sub_i, ...) node
319  */
320 void set_ia32_Immop_attr(ir_node *node, ir_node *cnst);
321
322 /**
323  * Copy the attributes from Immop to an Immop
324  */
325 void copy_ia32_Immop_attr(ir_node *node, ir_node *src);
326
327 /**
328  * Copy the attributes from a Const to an ia32_Const
329  */
330 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);
331
332 /**
333  * Sets the AddrMode attribute
334  * @param direction The "direction" of AM ('S' source or 'D' destination)
335  */
336 void set_ia32_AddrMode(ir_node *node, char direction);
337
338 /**
339  * Returns whether or not the node is an AddrModeS node.
340  */
341 int is_ia32_AddrModeS(const ir_node *node);
342
343 /**
344  * Returns whether or not the node is an AddrModeD node.
345  */
346 int is_ia32_AddrModeD(const ir_node *node);
347
348 /**
349  * Checks if node is a Load or fLoad.
350  */
351 int is_ia32_Ld(const ir_node *node);
352
353 /**
354  * Checks if node is a Store or fStore.
355  */
356 int is_ia32_St(const ir_node *node);
357
358 /**
359  * Checks if node is a Const or fConst.
360  */
361 int is_ia32_Cnst(const ir_node *node);
362
363 /**
364  * Allocates num register slots for node.
365  */
366 void alloc_ia32_reg_slots(ir_node *node, int num);
367
368 /**
369  * Initializes the nodes attributes.
370  */
371 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags, const ia32_register_req_t **in_reqs, \
372         const ia32_register_req_t **out_reqs, int n_res);
373
374 /* Include the generated headers */
375 #include "gen_ia32_new_nodes.h"
376
377 #endif /* _IA32_NEW_NODES_H_ */