2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Handling of ia32 specific firm opcodes.
23 * @author Christian Wuerdig
26 * This file implements the creation of the achitecture specific firm opcodes
27 * and the coresponding node constructors for the ia32 assembler irg.
29 #ifndef FIRM_BE_IA32_IA32_NEW_NODES_H
30 #define FIRM_BE_IA32_IA32_NEW_NODES_H
32 #include "firm_config.h"
33 #include "ia32_nodes_attr.h"
35 /** indices for AM inputs */
41 n_ia32_binary_left = 3,
42 n_ia32_binary_right = 4
45 /** proj numbers for "normal" one-result nodes (for the complicated cases where we not only
55 /***************************************************************************************************
57 * | | | | | | / / | | | | | | | |
58 * __ _| |_| |_ _ __ ___ ___| |_ / /_ _ ___| |_ _ __ ___ ___| |_| |__ ___ __| |___
59 * / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
60 * | (_| | |_| |_| | \__ \ __/ |_ / / (_| | __/ |_ | | | | | | __/ |_| | | | (_) | (_| \__ \
61 * \__,_|\__|\__|_| |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
64 ***************************************************************************************************/
67 * returns true if a node has x87 registers
69 int ia32_has_x87_register(const ir_node *n);
72 * Returns the attributes of an ia32 node.
74 ia32_attr_t *get_ia32_attr(ir_node *node);
75 const ia32_attr_t *get_ia32_attr_const(const ir_node *node);
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);
80 const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node);
83 * Gets the condcode attributes of a node.
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);
89 * Gets the CopyB node attributes.
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);
95 * Gets the type of an ia32 node.
97 ia32_op_type_t get_ia32_op_type(const ir_node *node);
100 * Sets the type of an ia32 node.
102 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
105 * Gets the supported addrmode of an ia32 node
107 ia32_am_type_t get_ia32_am_support(const ir_node *node);
109 ia32_am_arity_t get_ia32_am_arity(const ir_node *node);
112 * Sets the supported addrmode of an ia32 node
114 void set_ia32_am_support(ir_node *node, ia32_am_type_t am_tp,
115 ia32_am_arity_t am_arity);
118 * Gets the addressmode offset as long.
120 int get_ia32_am_offs_int(const ir_node *node);
123 * Sets the addressmode offset
125 void set_ia32_am_offs_int(ir_node *node, int offset);
127 void add_ia32_am_offs_int(ir_node *node, int offset);
130 * Returns the symconst entity associated to addrmode.
132 ir_entity *get_ia32_am_sc(const ir_node *node);
135 * Sets the symconst entity associated to addrmode.
137 void set_ia32_am_sc(ir_node *node, ir_entity *sc);
140 * Sets the sign bit for address mode symconst.
142 void set_ia32_am_sc_sign(ir_node *node);
145 * Clears the sign bit for address mode symconst.
147 void clear_ia32_am_sc_sign(ir_node *node);
150 * Returns the sign bit for address mode symconst.
152 int is_ia32_am_sc_sign(const ir_node *node);
155 * Gets the addr mode const.
157 int get_ia32_am_scale(const ir_node *node);
160 * Sets the const for addr mode.
162 void set_ia32_am_scale(ir_node *node, int scale);
165 * Sets the uses_frame flag.
167 void set_ia32_use_frame(ir_node *node);
170 * Clears the uses_frame flag.
172 void clear_ia32_use_frame(ir_node *node);
175 * Gets the uses_frame flag.
177 int is_ia32_use_frame(const ir_node *node);
180 * copies all address-mode attributes from one node to the other
182 void ia32_copy_am_attrs(ir_node *to, const ir_node *from);
185 * Sets node to commutative.
187 void set_ia32_commutative(ir_node *node);
190 * Sets node to non-commutative.
192 void clear_ia32_commutative(ir_node *node);
195 * Checks if node is commutative.
197 int is_ia32_commutative(const ir_node *node);
200 * Sets node needs_stackent
202 void set_ia32_need_stackent(ir_node *node);
205 * Clears node needs_stackent
207 void clear_ia32_need_stackent(ir_node *node);
210 * Checks if node needs a stack entity assigned
212 int is_ia32_need_stackent(const ir_node *node);
215 * Gets the mode of the stored/loaded value (only set for Store/Load)
217 ir_mode *get_ia32_ls_mode(const ir_node *node);
220 * Sets the mode of the stored/loaded value (only set for Store/Load)
222 void set_ia32_ls_mode(ir_node *node, ir_mode *mode);
225 * Gets the frame entity assigned to this node;
227 ir_entity *get_ia32_frame_ent(const ir_node *node);
230 * Sets the frame entity for this node;
232 void set_ia32_frame_ent(ir_node *node, ir_entity *ent);
235 * Returns the argument register requirements of an ia32 node.
237 const arch_register_req_t **get_ia32_in_req_all(const ir_node *node);
240 * Sets the argument register requirements of an ia32 node.
242 void set_ia32_in_req_all(ir_node *node, const arch_register_req_t **reqs);
245 * Returns the result register requirements of an ia32 node.
247 const arch_register_req_t **get_ia32_out_req_all(const ir_node *node);
250 * Sets the result register requirements of an ia32 node.
252 void set_ia32_out_req_all(ir_node *node, const arch_register_req_t **reqs);
255 * Returns the argument register requirements of an ia32 node.
257 const arch_register_req_t *get_ia32_in_req(const ir_node *node, int pos);
260 * Returns the result register requirements of an ia32 node.
262 const arch_register_req_t *get_ia32_out_req(const ir_node *node, int pos);
265 * Sets the OUT register requirements at position pos.
267 void set_ia32_req_out(ir_node *node, const arch_register_req_t *req, int pos);
270 * Sets the IN register requirements at position pos.
272 void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos);
275 * Returns the register flag of an ia32 node.
277 arch_irn_flags_t get_ia32_flags(const ir_node *node);
280 * Sets the register flag of an ia32 node.
282 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags);
284 void add_ia32_flags(ir_node *node, arch_irn_flags_t flags);
287 * Returns the result register slots of an ia32 node.
289 const arch_register_t **get_ia32_slots(const ir_node *node);
292 * Returns the name of the OUT register at position pos.
294 const char *get_ia32_out_reg_name(const ir_node *node, int pos);
297 * Returns the index of the OUT register at position pos within its register class.
299 int get_ia32_out_regnr(const ir_node *node, int pos);
302 * Returns the OUT register at position pos.
304 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos);
307 * Returns the number of results.
309 int get_ia32_n_res(const ir_node *node);
312 * Returns the condition code of a node.
314 long get_ia32_condcode(const ir_node *node);
317 * Sets the condition code of a node
319 void set_ia32_condcode(ir_node *node, long code);
322 * Returns the condition code of a node.
324 unsigned get_ia32_copyb_size(const ir_node *node);
327 * Gets the instruction latency.
329 unsigned get_ia32_latency(const ir_node *node);
333 * Sets the flags for the n'th out.
335 void set_ia32_out_flags(ir_node *node, arch_irn_flags_t flags, int pos);
338 * Gets the flags for the n'th out.
340 arch_irn_flags_t get_ia32_out_flags(const ir_node *node, int pos);
343 * Get the list of available execution units.
345 const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node);
348 * Get the exception label attribute.
350 unsigned get_ia32_exc_label(const ir_node *node);
353 * Set the exception label attribute.
355 void set_ia32_exc_label(ir_node *node, unsigned flag);
360 * Returns the name of the original ir node.
362 const char *get_ia32_orig_node(const ir_node *node);
365 * Sets the name of the original ir node.
367 void set_ia32_orig_node(ir_node *node, const char *name);
371 /******************************************************************************************************
373 * (_) | | | | | | / _| | | (_)
374 * ___ _ __ ___ ___ _ __ _| | __ _| |_| |_ _ __ | |_ _ _ _ __ ___| |_ _ ___ _ __ ___
375 * / __| '_ \ / _ \/ __| |/ _` | | / _` | __| __| '__| | _| | | | '_ \ / __| __| |/ _ \| '_ \ / __|
376 * \__ \ |_) | __/ (__| | (_| | | | (_| | |_| |_| | | | | |_| | | | | (__| |_| | (_) | | | | \__ \
377 * |___/ .__/ \___|\___|_|\__,_|_| \__,_|\__|\__|_| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
380 ******************************************************************************************************/
383 * Returns the ident of an entity
384 * @param ent The entity
385 * @return The ident of the entity
387 ident *ia32_get_ent_ident(ir_entity *ent);
390 * Returns the proj of the result value for nodes that have the usual
391 * (res, Mem) result tuple
393 ir_node *get_ia32_result_proj(const ir_node *node);
396 * Copy the attributes from a Const to an ia32_Const
398 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);
400 void set_ia32_Const_tarval(ir_node *node, tarval *tv);
403 * Returns whether or not the node is an AddrModeS node.
405 int is_ia32_AddrModeS(const ir_node *node);
408 * Returns whether or not the node is an AddrModeD node.
410 int is_ia32_AddrModeD(const ir_node *node);
413 * Checks if node is a Load or fLoad.
415 int is_ia32_Ld(const ir_node *node);
418 * Checks if node is a Store or fStore.
420 int is_ia32_St(const ir_node *node);
423 * Swaps left/right input of a node (and adjusts pnc if needed)
425 void ia32_swap_left_right(ir_node *node);
428 * Initializes the nodes attributes.
430 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
431 const arch_register_req_t **in_reqs,
432 const arch_register_req_t **out_reqs,
433 const be_execution_unit_t ***execution_units,
436 void init_ia32_x87_attributes(ir_node *node);
437 void init_ia32_asm_attributes(ir_node *node);
438 void init_ia32_immediate_attributes(ir_node *node, ir_entity *symconst,
439 int symconst_sign, long offset);
440 void init_ia32_copyb_attributes(ir_node *res, unsigned size);
441 void init_ia32_condcode_attributes(ir_node *res, long pnc);
443 /* Include the generated headers */
444 #include "gen_ia32_new_nodes.h"
446 #endif /* FIRM_BE_IA32_IA32_NEW_NODES_H */