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