- Add a generic_attribute field to irops
[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 /** indices for AM inputs */
36 enum {
37         n_ia32_base         = 0,
38         n_ia32_index        = 1,
39         n_ia32_mem          = 2,
40         n_ia32_unary_op     = 3,
41         n_ia32_binary_left  = 3,
42         n_ia32_binary_right = 4
43 };
44
45 /** proj numbers for "normal" one-result nodes (for the complicated cases where we not only
46  * need the result) */
47 enum {
48         pn_ia32_res   = 0,
49         pn_ia32_mem   = 1,
50         pn_ia32_flags = 2,
51         pn_ia32_add1  = 3,
52         pn_ia32_add2  = 4
53 };
54
55 /***************************************************************************************************
56  *        _   _                   _       __        _                    _   _               _
57  *       | | | |                 | |     / /       | |                  | | | |             | |
58  *   __ _| |_| |_ _ __   ___  ___| |_   / /_ _  ___| |_   _ __ ___   ___| |_| |__   ___   __| |___
59  *  / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
60  * | (_| | |_| |_| |    \__ \  __/ |_ / / (_| |  __/ |_  | | | | | |  __/ |_| | | | (_) | (_| \__ \
61  *  \__,_|\__|\__|_|    |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
62  *                                        __/ |
63  *                                       |___/
64  ***************************************************************************************************/
65
66 /**
67  * returns true if a node has x87 registers
68  */
69 int ia32_has_x87_register(const ir_node *n);
70
71 /**
72  * Returns the attributes of an ia32 node.
73  */
74 ia32_attr_t *get_ia32_attr(ir_node *node);
75 const ia32_attr_t *get_ia32_attr_const(const ir_node *node);
76
77 ia32_x87_attr_t *get_ia32_x87_attr(ir_node *node);
78 const ia32_x87_attr_t *get_ia32_x87_attr_const(const ir_node *node);
79
80 const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node);
81
82 /**
83  * Gets the condcode attributes of a node.
84  */
85 ia32_condcode_attr_t *get_ia32_condcode_attr(ir_node *node);
86 const ia32_condcode_attr_t *get_ia32_condcode_attr_const(const ir_node *node);
87
88 /**
89  * Gets the CopyB node attributes.
90  */
91 ia32_copyb_attr_t *get_ia32_copyb_attr(ir_node *node);
92 const ia32_copyb_attr_t *get_ia32_copyb_attr_const(const ir_node *node);
93
94 /**
95  * Gets the type of an ia32 node.
96  */
97 ia32_op_type_t get_ia32_op_type(const ir_node *node);
98
99 /**
100  * Sets the type of an ia32 node.
101  */
102 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
103
104 /**
105  * Gets the supported addrmode of an ia32 node
106  */
107 ia32_am_type_t get_ia32_am_support(const ir_node *node);
108
109 ia32_am_arity_t get_ia32_am_arity(const ir_node *node);
110
111 /**
112  * Sets the supported addrmode of an ia32 node
113  */
114 void set_ia32_am_support(ir_node *node, ia32_am_type_t am_tp,
115                          ia32_am_arity_t am_arity);
116
117 /**
118  * Gets the addressmode offset as long.
119  */
120 int get_ia32_am_offs_int(const ir_node *node);
121
122 /**
123  * Sets the addressmode offset
124  */
125 void set_ia32_am_offs_int(ir_node *node, int offset);
126
127 void add_ia32_am_offs_int(ir_node *node, int offset);
128
129 /**
130  * Returns the symconst entity associated to addrmode.
131  */
132 ir_entity *get_ia32_am_sc(const ir_node *node);
133
134 /**
135  * Sets the symconst entity associated to addrmode.
136  */
137 void set_ia32_am_sc(ir_node *node, ir_entity *sc);
138
139 /**
140  * Sets the sign bit for address mode symconst.
141  */
142 void set_ia32_am_sc_sign(ir_node *node);
143
144 /**
145  * Clears the sign bit for address mode symconst.
146  */
147 void clear_ia32_am_sc_sign(ir_node *node);
148
149 /**
150  * Returns the sign bit for address mode symconst.
151  */
152 int is_ia32_am_sc_sign(const ir_node *node);
153
154 /**
155  * Gets the addr mode const.
156  */
157 int get_ia32_am_scale(const ir_node *node);
158
159 /**
160  * Sets the const for addr mode.
161  */
162 void set_ia32_am_scale(ir_node *node, int scale);
163
164 /**
165  * Sets the uses_frame flag.
166  */
167 void set_ia32_use_frame(ir_node *node);
168
169 /**
170  * Clears the uses_frame flag.
171  */
172 void clear_ia32_use_frame(ir_node *node);
173
174 /**
175  * Gets the uses_frame flag.
176  */
177 int is_ia32_use_frame(const ir_node *node);
178
179 /**
180  * copies all address-mode attributes from one node to the other
181  */
182 void ia32_copy_am_attrs(ir_node *to, const ir_node *from);
183
184 /**
185  * Sets node to commutative.
186  */
187 void set_ia32_commutative(ir_node *node);
188
189 /**
190  * Sets node to non-commutative.
191  */
192 void clear_ia32_commutative(ir_node *node);
193
194 /**
195  * Checks if node is commutative.
196  */
197 int is_ia32_commutative(const ir_node *node);
198
199 /**
200  * Sets node needs_stackent
201  */
202 void set_ia32_need_stackent(ir_node *node);
203
204 /**
205  * Clears node needs_stackent
206  */
207 void clear_ia32_need_stackent(ir_node *node);
208
209 /**
210  * Checks if node needs a stack entity assigned
211  */
212 int is_ia32_need_stackent(const ir_node *node);
213
214 /**
215  * Gets the mode of the stored/loaded value (only set for Store/Load)
216  */
217 ir_mode *get_ia32_ls_mode(const ir_node *node);
218
219 /**
220  * Sets the mode of the stored/loaded value (only set for Store/Load)
221  */
222 void set_ia32_ls_mode(ir_node *node, ir_mode *mode);
223
224 /**
225  * Gets the frame entity assigned to this node;
226  */
227 ir_entity *get_ia32_frame_ent(const ir_node *node);
228
229 /**
230  * Sets the frame entity for this node;
231  */
232 void set_ia32_frame_ent(ir_node *node, ir_entity *ent);
233
234 /**
235  * Returns the argument register requirements of an ia32 node.
236  */
237 const arch_register_req_t **get_ia32_in_req_all(const ir_node *node);
238
239 /**
240  * Sets the argument register requirements of an ia32 node.
241  */
242 void set_ia32_in_req_all(ir_node *node, const arch_register_req_t **reqs);
243
244 /**
245  * Returns the result register requirements of an ia32 node.
246  */
247 const arch_register_req_t **get_ia32_out_req_all(const ir_node *node);
248
249 /**
250  * Sets the result register requirements of an ia32 node.
251  */
252 void set_ia32_out_req_all(ir_node *node, const arch_register_req_t **reqs);
253
254 /**
255  * Returns the argument register requirements of an ia32 node.
256  */
257 const arch_register_req_t *get_ia32_in_req(const ir_node *node, int pos);
258
259 /**
260  * Returns the result register requirements of an ia32 node.
261  */
262 const arch_register_req_t *get_ia32_out_req(const ir_node *node, int pos);
263
264 /**
265  * Sets the OUT register requirements at position pos.
266  */
267 void set_ia32_req_out(ir_node *node, const arch_register_req_t *req, int pos);
268
269 /**
270  * Sets the IN register requirements at position pos.
271  */
272 void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos);
273
274 /**
275  * Returns the register flag of an ia32 node.
276  */
277 arch_irn_flags_t get_ia32_flags(const ir_node *node);
278
279 /**
280  * Sets the register flag of an ia32 node.
281  */
282 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags);
283
284 /**
285  * Returns the result register slots of an ia32 node.
286  */
287 const arch_register_t **get_ia32_slots(const ir_node *node);
288
289 /**
290  * Returns the name of the OUT register at position pos.
291  */
292 const char *get_ia32_out_reg_name(const ir_node *node, int pos);
293
294 /**
295  * Returns the index of the OUT register at position pos within its register class.
296  */
297 int get_ia32_out_regnr(const ir_node *node, int pos);
298
299 /**
300  * Returns the OUT register at position pos.
301  */
302 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos);
303
304 /**
305  * Returns the number of results.
306  */
307 int get_ia32_n_res(const ir_node *node);
308
309 /**
310  * Returns the condition code of a node.
311  */
312 long get_ia32_condcode(const ir_node *node);
313
314 /**
315  * Sets the condition code of a node
316  */
317 void set_ia32_condcode(ir_node *node, long code);
318
319 /**
320  * Returns the condition code of a node.
321  */
322 unsigned get_ia32_copyb_size(const ir_node *node);
323
324 /**
325  * Gets the instruction latency.
326  */
327 unsigned get_ia32_latency(const ir_node *node);
328
329
330 /**
331  * Sets the flags for the n'th out.
332  */
333 void set_ia32_out_flags(ir_node *node, arch_irn_flags_t flags, int pos);
334
335 /**
336  * Gets the flags for the n'th out.
337  */
338 arch_irn_flags_t get_ia32_out_flags(const ir_node *node, int pos);
339
340 /**
341  * Get the list of available execution units.
342  */
343 const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node);
344
345 /**
346  * Get the exception label attribute.
347  */
348 unsigned get_ia32_exc_label(const ir_node *node);
349
350 /**
351  * Set the exception label attribute.
352  */
353 void set_ia32_exc_label(ir_node *node, unsigned flag);
354
355 #ifndef NDEBUG
356
357 /**
358  * Returns the name of the original ir node.
359  */
360 const char *get_ia32_orig_node(const ir_node *node);
361
362 /**
363  * Sets the name of the original ir node.
364  */
365 void set_ia32_orig_node(ir_node *node, const char *name);
366
367 #endif /* NDEBUG */
368
369 /******************************************************************************************************
370  *                      _       _         _   _           __                  _   _
371  *                     (_)     | |       | | | |         / _|                | | (_)
372  *  ___ _ __   ___  ___ _  __ _| |   __ _| |_| |_ _ __  | |_ _   _ _ __   ___| |_ _  ___  _ __    ___
373  * / __| '_ \ / _ \/ __| |/ _` | |  / _` | __| __| '__| |  _| | | | '_ \ / __| __| |/ _ \| '_ \  / __|
374  * \__ \ |_) |  __/ (__| | (_| | | | (_| | |_| |_| |    | | | |_| | | | | (__| |_| | (_) | | | | \__ \
375  * |___/ .__/ \___|\___|_|\__,_|_|  \__,_|\__|\__|_|    |_|  \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
376  *     | |
377  *     |_|
378  ******************************************************************************************************/
379
380 /**
381  * Returns the ident of an entity
382  * @param ent The entity
383  * @return The ident of the entity
384  */
385 ident *ia32_get_ent_ident(ir_entity *ent);
386
387 /**
388  * Returns the proj of the result value for nodes that have the usual
389  * (res, Mem) result tuple
390  */
391 ir_node *get_ia32_result_proj(const ir_node *node);
392
393 /**
394  * Copy the attributes from a Const to an ia32_Const
395  */
396 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);
397
398 void set_ia32_Const_tarval(ir_node *node, tarval *tv);
399
400 /**
401  * Returns whether or not the node is an AddrModeS node.
402  */
403 int is_ia32_AddrModeS(const ir_node *node);
404
405 /**
406  * Returns whether or not the node is an AddrModeD node.
407  */
408 int is_ia32_AddrModeD(const ir_node *node);
409
410 /**
411  * Checks if node is a Load or fLoad.
412  */
413 int is_ia32_Ld(const ir_node *node);
414
415 /**
416  * Checks if node is a Store or fStore.
417  */
418 int is_ia32_St(const ir_node *node);
419
420 /**
421  * Swaps left/right input of a node (and adjusts pnc if needed)
422  */
423 void ia32_swap_left_right(ir_node *node);
424
425 /**
426  * Initializes the nodes attributes.
427  */
428 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
429                           const arch_register_req_t **in_reqs,
430                           const arch_register_req_t **out_reqs,
431                           const be_execution_unit_t ***execution_units,
432                           int n_res);
433
434 void init_ia32_x87_attributes(ir_node *node);
435 void init_ia32_asm_attributes(ir_node *node);
436 void init_ia32_immediate_attributes(ir_node *node, ir_entity *symconst,
437                                     int symconst_sign, long offset);
438 void init_ia32_copyb_attributes(ir_node *res, unsigned size);
439 void init_ia32_condcode_attributes(ir_node *res, long pnc);
440
441 /* Include the generated headers */
442 #include "gen_ia32_new_nodes.h"
443
444 #endif /* FIRM_BE_IA32_IA32_NEW_NODES_H */