-#ifndef _IA32_NEW_NODES_H_
-#define _IA32_NEW_NODES_H_
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Handling of ia32 specific firm opcodes.
+ * @author Christian Wuerdig
+ * @version $Id$
+ *
+ * This file implements the creation of the achitecture specific firm opcodes
+ * and the coresponding node constructors for the ia32 assembler irg.
+ */
+#ifndef FIRM_BE_IA32_IA32_NEW_NODES_H
+#define FIRM_BE_IA32_IA32_NEW_NODES_H
-/**
- * Function prototypes for the assembler ir node constructors.
- * @author Christian Wuerdig
- * $Id$
- */
-
-#include "firm_config.h"
#include "ia32_nodes_attr.h"
-/***************************************************************************************************
- * _ _ _ __ _ _ _ _
- * | | | | | | / / | | | | | | | |
- * __ _| |_| |_ _ __ ___ ___| |_ / /_ _ ___| |_ _ __ ___ ___| |_| |__ ___ __| |___
- * / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
- * | (_| | |_| |_| | \__ \ __/ |_ / / (_| | __/ |_ | | | | | | __/ |_| | | | (_) | (_| \__ \
- * \__,_|\__|\__|_| |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
- * __/ |
- * |___/
- ***************************************************************************************************/
+/** indices for AM inputs */
+enum {
+ n_ia32_base = 0,
+ n_ia32_index = 1,
+ n_ia32_mem = 2,
+ n_ia32_unary_op = 3,
+ n_ia32_binary_left = 3,
+ n_ia32_binary_right = 4
+};
-/**
- * Returns the attributes of an ia32 node.
- */
-ia32_attr_t *get_ia32_attr(const ir_node *node);
+/** proj numbers for "normal" one-result nodes (for the complicated cases where we not only
+ * need the result) */
+enum {
+ pn_ia32_res = 0,
+ pn_ia32_flags = 1,
+ pn_ia32_mem = 2,
+ pn_ia32_add1 = 3,
+ pn_ia32_add2 = 4
+};
-/**
- * Gets the type of an ia32 node.
- */
-ia32_op_type_t get_ia32_op_type(const ir_node *node);
/**
- * Sets the type of an ia32 node.
+ * returns true if a node has x87 registers
*/
-void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
+int ia32_has_x87_register(const ir_node *n);
/**
- * Gets the immediate op type of an ia32 node.
+ * Returns the attributes of an ia32 node.
*/
-ia32_immop_type_t get_ia32_immop_type(const ir_node *node);
+ia32_attr_t *get_ia32_attr(ir_node *node);
+const ia32_attr_t *get_ia32_attr_const(const ir_node *node);
-/**
- * Sets the immediate op type of an ia32 node.
- */
-void set_ia32_immop_type(ir_node *node, ia32_immop_type_t tp);
+ia32_x87_attr_t *get_ia32_x87_attr(ir_node *node);
+const ia32_x87_attr_t *get_ia32_x87_attr_const(const ir_node *node);
+
+ia32_immediate_attr_t *get_ia32_immediate_attr(ir_node *node);
+const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node);
+
+const ia32_asm_attr_t *get_ia32_asm_attr_const(const ir_node *node);
/**
- * Gets the supported addrmode of an ia32 node
+ * Gets the condcode attributes of a node.
*/
-ia32_am_type_t get_ia32_am_support(const ir_node *node);
+ia32_condcode_attr_t *get_ia32_condcode_attr(ir_node *node);
+const ia32_condcode_attr_t *get_ia32_condcode_attr_const(const ir_node *node);
/**
- * Sets the supported addrmode of an ia32 node
+ * Gets the Call node attributes.
*/
-void set_ia32_am_support(ir_node *node, ia32_am_type_t am_tp);
+ia32_call_attr_t *get_ia32_call_attr(ir_node *node);
+const ia32_call_attr_t *get_ia32_call_attr_const(const ir_node *node);
/**
- * Gets the addrmode flavour of an ia32 node
+ * Gets the CopyB node attributes.
*/
-ia32_am_flavour_t get_ia32_am_flavour(const ir_node *node);
+ia32_copyb_attr_t *get_ia32_copyb_attr(ir_node *node);
+const ia32_copyb_attr_t *get_ia32_copyb_attr_const(const ir_node *node);
/**
- * Sets the addrmode flavour of an ia32 node
+ * Gets the ClimbFrame node attributes.
*/
-void set_ia32_am_flavour(ir_node *node, ia32_am_flavour_t am_flavour);
+ia32_climbframe_attr_t *get_ia32_climbframe_attr(ir_node *node);
+const ia32_climbframe_attr_t *get_ia32_climbframe_attr_const(const ir_node *node);
+
+ia32_switch_attr_t *get_ia32_switch_attr(ir_node *node);
+const ia32_switch_attr_t *get_ia32_switch_attr_const(const ir_node *node);
/**
- * Gets the joined addrmode offset.
+ * Gets the type of an ia32 node.
*/
-char *get_ia32_am_offs(const ir_node *node);
+ia32_op_type_t get_ia32_op_type(const ir_node *node);
/**
- * Adds an offset for addrmode.
+ * Sets the type of an ia32 node.
*/
-void add_ia32_am_offs(ir_node *node, const char *offset);
+void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
/**
- * Subs an offset for addrmode.
+ * Gets the supported address mode of an ia32 node
*/
-void sub_ia32_am_offs(ir_node *node, const char *offset);
+ia32_am_type_t get_ia32_am_support(const ir_node *node);
/**
- * Gets the addr mode const.
+ * Sets the supported addrmode of an ia32 node
*/
-int get_ia32_am_scale(const ir_node *node);
+void set_ia32_am_support(ir_node *node, ia32_am_type_t am_arity);
/**
- * Sets the const for addr mode.
+ * Gets the addressmode offset as long.
*/
-void set_ia32_am_scale(ir_node *node, int scale);
+int get_ia32_am_offs_int(const ir_node *node);
/**
- * Return the tarval of an immediate operation or NULL in case of SymConst
+ * Sets the addressmode offset
*/
-tarval *get_ia32_Immop_tarval(const ir_node *node);
+void set_ia32_am_offs_int(ir_node *node, int offset);
+
+void add_ia32_am_offs_int(ir_node *node, int offset);
/**
- * Sets the attributes of an immediate operation to the specified tarval
+ * Returns the symconst entity associated to addrmode.
*/
-void set_ia32_Immop_tarval(ir_node *node, tarval *tv);
+ir_entity *get_ia32_am_sc(const ir_node *node);
/**
- * Return the sc attribute.
+ * Sets the symconst entity associated to addrmode.
*/
-ident *get_ia32_sc(const ir_node *node);
+void set_ia32_am_sc(ir_node *node, ir_entity *sc);
/**
- * Sets the sc attribute.
+ * Sets the sign bit for address mode symconst.
*/
-void set_ia32_sc(ir_node *node, ident *sc);
+void set_ia32_am_sc_sign(ir_node *node);
/**
- * Gets the string representation of the internal const (tv or symconst)
+ * Clears the sign bit for address mode symconst.
*/
-const char *get_ia32_cnst(const ir_node *node);
+void clear_ia32_am_sc_sign(ir_node *node);
/**
- * Sets the string representation of the internal const.
+ * Returns the sign bit for address mode symconst.
*/
-void set_ia32_cnst(ir_node *node, char *cnst);
+int is_ia32_am_sc_sign(const ir_node *node);
/**
- * Gets the ident representation of the internal const (tv or symconst)
+ * Gets the addr mode const.
*/
-ident *get_ia32_id_cnst(const ir_node *node);
+unsigned get_ia32_am_scale(const ir_node *node);
/**
- * Sets the ident representation of the internal const.
+ * Sets the const for addr mode.
*/
-void set_ia32_id_cnst(ir_node *node, ident *cnst);
+void set_ia32_am_scale(ir_node *node, unsigned scale);
/**
* Sets the uses_frame flag.
*/
int is_ia32_use_frame(const ir_node *node);
+/**
+ * copies all address-mode attributes from one node to the other
+ */
+void ia32_copy_am_attrs(ir_node *to, const ir_node *from);
+
/**
* Sets node to commutative.
*/
int is_ia32_commutative(const ir_node *node);
/**
- * Sets node emit_cl.
+ * Sets node needs_stackent
*/
-void set_ia32_emit_cl(ir_node *node);
+void set_ia32_need_stackent(ir_node *node);
/**
- * Clears node emit_cl.
+ * Clears node needs_stackent
*/
-void clear_ia32_emit_cl(ir_node *node);
+void clear_ia32_need_stackent(ir_node *node);
/**
- * Checks if node is commutative.
+ * Checks if node needs a stack entity assigned
*/
-int is_ia32_emit_cl(const ir_node *node);
+int is_ia32_need_stackent(const ir_node *node);
+
+void set_ia32_is_reload(ir_node *node);
+int is_ia32_is_reload(const ir_node *node);
+
+void set_ia32_is_spill(ir_node *node);
+int is_ia32_is_spill(const ir_node *node);
+
+void set_ia32_is_remat(ir_node *node);
+int is_ia32_is_remat(const ir_node *node);
/**
* Gets the mode of the stored/loaded value (only set for Store/Load)
*/
void set_ia32_ls_mode(ir_node *node, ir_mode *mode);
-/**
- * Gets the mode of the result.
- */
-ir_mode *get_ia32_res_mode(const ir_node *node);
-
-/**
- * Sets the mode of the result.
- */
-void set_ia32_res_mode(ir_node *node, ir_mode *mode);
-
/**
* Gets the frame entity assigned to this node;
*/
-entity *get_ia32_frame_ent(const ir_node *node);
+ir_entity *get_ia32_frame_ent(const ir_node *node);
/**
* Sets the frame entity for this node;
*/
-void set_ia32_frame_ent(ir_node *node, entity *ent);
+void set_ia32_frame_ent(ir_node *node, ir_entity *ent);
/**
- * Returns the argument register requirements of an ia32 node.
+ * Returns the condition code of a node.
*/
-const ia32_register_req_t **get_ia32_in_req_all(const ir_node *node);
+ia32_condition_code_t get_ia32_condcode(const ir_node *node);
/**
- * Sets the argument register requirements of an ia32 node.
+ * Sets the condition code of a node
*/
-void set_ia32_in_req_all(ir_node *node, const ia32_register_req_t **reqs);
+void set_ia32_condcode(ir_node *node, ia32_condition_code_t code);
-/**
- * Returns the result register requirements of an ia32 node.
- */
-const ia32_register_req_t **get_ia32_out_req_all(const ir_node *node);
+long get_ia32_default_pn(const ir_node *node);
-/**
- * Sets the result register requirements of an ia32 node.
- */
-void set_ia32_out_req_all(ir_node *node, const ia32_register_req_t **reqs);
+unsigned get_ia32_copyb_size(const ir_node *node);
/**
- * Returns the argument register requirements of an ia32 node.
+ * Gets the instruction latency.
*/
-const ia32_register_req_t *get_ia32_in_req(const ir_node *node, int pos);
+unsigned get_ia32_latency(const ir_node *node);
-/**
- * Returns the result register requirements of an ia32 node.
- */
-const ia32_register_req_t *get_ia32_out_req(const ir_node *node, int pos);
-
-/**
- * Sets the OUT register requirements at position pos.
- */
-void set_ia32_req_out(ir_node *node, const ia32_register_req_t *req, int pos);
/**
- * Sets the IN register requirements at position pos.
+ * Get the list of available execution units.
*/
-void set_ia32_req_in(ir_node *node, const ia32_register_req_t *req, int pos);
+const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node);
/**
- * Returns the register flag of an ia32 node.
+ * Get the exception label attribute.
*/
-arch_irn_flags_t get_ia32_flags(const ir_node *node);
+unsigned get_ia32_exc_label(const ir_node *node);
/**
- * Sets the register flag of an ia32 node.
+ * Set the exception label attribute.
*/
-void set_ia32_flags(ir_node *node, arch_irn_flags_t flags);
+void set_ia32_exc_label(ir_node *node, unsigned flag);
/**
- * Returns the result register slots of an ia32 node.
+ * Return the exception label id.
*/
-const arch_register_t **get_ia32_slots(const ir_node *node);
+ir_label_t get_ia32_exc_label_id(const ir_node *node);
/**
- * Returns the name of the OUT register at position pos.
+ * Assign the exception label id.
*/
-const char *get_ia32_out_reg_name(const ir_node *node, int pos);
-
-/**
- * Returns the index of the OUT register at position pos within its register class.
- */
-int get_ia32_out_regnr(const ir_node *node, int pos);
-
-/**
- * Returns the OUT register at position pos.
- */
-const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos);
-
-/**
- * Sets the number of results.
- */
-void set_ia32_n_res(ir_node *node, int n_res);
-
-/**
- * Returns the number of results.
- */
-int get_ia32_n_res(const ir_node *node);
-
-/**
- * Returns the flavour of an ia32 node,
- */
-ia32_op_flavour_t get_ia32_flavour(const ir_node *node);
-
-/**
- * Sets the flavour of an ia32 node to flavour_Div/Mod/DivMod/Mul/Mulh.
- */
-void set_ia32_flavour(ir_node *node, ia32_op_flavour_t op_flav);
-
-/**
- * Returns the projnum code.
- */
-long get_ia32_pncode(const ir_node *node);
-
-/**
- * Sets the projnum code
- */
-void set_ia32_pncode(ir_node *node, long code);
+void set_ia32_exc_label_id(ir_node *node, ir_label_t id);
#ifndef NDEBUG
/**
* Sets the name of the original ir node.
*/
-void set_ia32_orig_node(ir_node *node, const char *name);
+void set_ia32_orig_node(ir_node *node, const ir_node *old);
#endif /* NDEBUG */
-/******************************************************************************************************
- * _ _ _ _ __ _ _
- * (_) | | | | | | / _| | | (_)
- * ___ _ __ ___ ___ _ __ _| | __ _| |_| |_ _ __ | |_ _ _ _ __ ___| |_ _ ___ _ __ ___
- * / __| '_ \ / _ \/ __| |/ _` | | / _` | __| __| '__| | _| | | | '_ \ / __| __| |/ _ \| '_ \ / __|
- * \__ \ |_) | __/ (__| | (_| | | | (_| | |_| |_| | | | | |_| | | | | (__| |_| | (_) | | | | \__ \
- * |___/ .__/ \___|\___|_|\__,_|_| \__,_|\__|\__|_| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
- * | |
- * |_|
- ******************************************************************************************************/
-
-/**
- * Gets the type of an ia32_Const.
- */
-unsigned get_ia32_Const_type(const ir_node *node);
-
-/**
- * Sets the type of an ia32_Const.
- */
-void set_ia32_Const_type(ir_node *node, int type);
-
-/**
- * Copy the attributes from an ia32_Const to an Immop (Add_i, Sub_i, ...) node
- */
-void set_ia32_Immop_attr(ir_node *node, ir_node *cnst);
/**
- * Copy the attributes from Immop to an Immop
+ * Returns the ident of an entity
+ * @param ent The entity
+ * @return The ident of the entity
*/
-void copy_ia32_Immop_attr(ir_node *node, ir_node *src);
+ident *ia32_get_ent_ident(ir_entity *ent);
/**
* Copy the attributes from a Const to an ia32_Const
*/
void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);
-/**
- * Sets the AddrMode attribute
- * @param direction The "direction" of AM ('S' source or 'D' destination)
- */
-void set_ia32_AddrMode(ir_node *node, char direction);
-
-/**
- * Returns whether or not the node is an immediate operation with Const.
- */
-int is_ia32_ImmConst(const ir_node *node);
-
-/**
- * Returns whether or not the node is an immediate operation with SymConst.
- */
-int is_ia32_ImmSymConst(const ir_node *node);
+void set_ia32_Const_tarval(ir_node *node, ir_tarval *tv);
/**
* Returns whether or not the node is an AddrModeS node.
int is_ia32_AddrModeD(const ir_node *node);
/**
- * Checks if node is a Load or fLoad.
- */
-int is_ia32_Ld(const ir_node *node);
-
-/**
- * Checks if node is a Store or fStore.
- */
-int is_ia32_St(const ir_node *node);
-
-/**
- * Checks if node is a Const or fConst.
- */
-int is_ia32_Cnst(const ir_node *node);
-
-/**
- * Allocates num register slots for node.
- */
-void alloc_ia32_reg_slots(ir_node *node, int num);
-
-/**
- * Initializes the nodes attributes.
- */
-void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags, const ia32_register_req_t **in_reqs, \
- const ia32_register_req_t **out_reqs, int n_res);
-
-/**
- * Registers the ia32_copy_attr function for all ia32 opcodes.
+ * Swaps left/right input of a node (and sets ins_permuted accordingly)
*/
-void ia32_register_copy_attr_func(void);
+void ia32_swap_left_right(ir_node *node);
/* Include the generated headers */
#include "gen_ia32_new_nodes.h"
-#endif /* _IA32_NEW_NODES_H_ */
+#endif