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