/*
- * 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.
+ * Copyright (C) 2012 University of Karlsruhe.
*/
/**
* @brief Backend node support for generic backend nodes.
* @author Sebastian Hack
* @date 17.05.2005
- * @version $Id$
*
* Backend node support for generic backend nodes.
* This file provides Perm, Copy, Spill and Reload nodes.
extern ir_op *op_be_SubSP;
extern ir_op *op_be_Start;
extern ir_op *op_be_FrameAddr;
-extern ir_op *op_be_Barrier;
-
-/**
- * A "symbolic constant" for the size of the stack frame to use with IncSP nodes.
- * It gets back-patched to the real size as soon it is known.
- */
-#define BE_STACK_FRAME_SIZE_EXPAND INT_MAX
-#define BE_STACK_FRAME_SIZE_SHRINK INT_MIN
/**
* Determines if irn is a be_node.
*/
void be_init_op(void);
+void be_finish_op(void);
+
/**
* Position numbers for the be_Spill inputs.
*/
enum {
- be_pos_Spill_frame = 0,
- be_pos_Spill_val = 1
+ n_be_Spill_frame = 0,
+ n_be_Spill_val = 1
};
/**
* Position numbers for the be_Reload inputs.
*/
enum {
- be_pos_Reload_frame = 0,
- be_pos_Reload_mem = 1
+ n_be_Reload_frame = 0,
+ n_be_Reload_mem = 1
};
/**
* Position numbers for the be_Copy inputs.
*/
enum {
- be_pos_Copy_op = 0
+ n_be_Copy_op = 0
};
/**
* Make a new Copy node.
*/
-ir_node *be_new_Copy(const arch_register_class_t *cls, ir_node *block,
- ir_node *in);
+ir_node *be_new_Copy(ir_node *block, ir_node *in);
/** Returns the Copy Argument. */
ir_node *be_get_Copy_op(const ir_node *cpy);
-/** Sets the Copy Argument. */
-void be_set_Copy_op(ir_node *cpy, ir_node *op);
/**
* Make a new Perm node.
* used as spillslots). MemPerm nodes perform this operation without modifying
* any register values.
*/
-ir_node *be_new_MemPerm(const arch_env_t *arch_env, ir_node *block, int n,
- ir_node *in[]);
+ir_node *be_new_MemPerm(ir_node *block, int n, ir_node *in[]);
ir_node *be_new_Keep(ir_node *block, int arity, ir_node *in[]);
void be_Keep_add_node(ir_node *keep, const arch_register_class_t *cls,
* Position numbers for the be_FrameAddr inputs
*/
enum {
- be_pos_FrameAddr_ptr = 0
+ n_be_FrameAddr_ptr = 0
};
/** Create a new FrameAddr node. */
* Position numbers for the be_AddSP inputs
*/
enum {
- be_pos_AddSP_old_sp = 0,
- be_pos_AddSP_size = 1,
- be_pos_AddSP_last = 2
+ n_be_AddSP_old_sp = 0,
+ n_be_AddSP_size = 1,
+ n_be_AddSP_last = 2
};
enum {
* Position numbers for the be_SubSP inputs
*/
enum {
- be_pos_SubSP_old_sp = 0,
- be_pos_SubSP_size = 1,
- be_pos_SubSP_last = 2
+ n_be_SubSP_old_sp = 0,
+ n_be_SubSP_size = 1,
+ n_be_SubSP_last = 2
};
enum {
* (negative offset). Note that the offset is independent of the
* natural stack direction of the architecture but just specifies
* abstract expanding/shrinking of the stack area.
- * @param align force stack alignment to this power of 2. (ie. specifying 3
+ * @param align force stack alignment to this power of 2. (i.e. specifying 3
* results in a 2^3 = 8byte stack alignment)
* @return A new stack pointer increment/decrement node.
* @note This node sets a register constraint to the @p sp register on
* Position numbers for the be_Call inputs.
*/
enum {
- be_pos_Call_mem = 0, /**< memory input of a be_Call node */
- be_pos_Call_sp = 1, /**< stack pointer input of a be_Call node */
- be_pos_Call_ptr = 2, /**< call pointer input of a be_Call node */
- be_pos_Call_first_arg = 3 /**< first argument input of a be_Call node */
+ n_be_Call_mem = 0, /**< memory input of a be_Call node */
+ n_be_Call_sp = 1, /**< stack pointer input of a be_Call node */
+ n_be_Call_ptr = 2, /**< call pointer input of a be_Call node */
+ n_be_Call_first_arg = 3 /**< first argument input of a be_Call node */
};
/**
* Projection numbers for result of be_Call node: use for Proj nodes!
*/
typedef enum {
- pn_be_Call_M_regular = pn_Call_M, /**< The memory result of a be_Call. */
- pn_be_Call_sp = pn_Call_max,
- pn_be_Call_first_res /**< The first result proj number of a
- be_Call. */
+ pn_be_Call_M = pn_Call_M, /**< The memory result of a be_Call. */
+ pn_be_Call_X_regular = pn_Call_X_regular,
+ pn_be_Call_X_except = pn_Call_X_except,
+ pn_be_Call_sp = pn_Call_max+1,
+ pn_be_Call_first_res /**< The first result proj number of a be_Call. */
} pn_be_Call;
/**
* Construct a new be_Call.
*
* @param dbg debug info
- * @param irg the graph where the call is placed
* @param block the block where the call is placed
* @param mem the memory input of the call
* @param sp the stack pointer input of the call
* @param in the (register) inputs of this call
* @param call_tp the call type of this call
*/
-ir_node *be_new_Call(dbg_info *dbg, ir_graph *irg, ir_node *block, ir_node *mem,
- ir_node *sp, ir_node *ptr, int n_outs,
- int n, ir_node *in[], ir_type *call_tp);
+ir_node *be_new_Call(dbg_info *dbg, ir_node *block, ir_node *mem,
+ const arch_register_req_t *sp_req, ir_node *sp,
+ const arch_register_req_t *ptr_req, ir_node *ptr,
+ int n_outs, int n, ir_node *in[], ir_type *call_tp);
/**
* Position numbers for the be_Return inputs.
*/
enum {
- be_pos_Return_mem = 0, /**< memory input of a be_Return node */
- be_pos_Return_sp = 1, /**< stack pointer input of a be_Return node */
- be_pos_Return_val = 2, /**< first "real" return value if any */
+ n_be_Return_mem = 0, /**< memory input of a be_Return node */
+ n_be_Return_sp = 1, /**< stack pointer input of a be_Return node */
+ n_be_Return_val = 2, /**< first "real" return value if any */
};
/**
* Construct a new be_Return.
*
* @param dbg debug info
- * @param irg the graph where the new node will be placed
* @param block the block where the new node will be placed
* @param n_res number of "real" results
* @param pop pop number of bytes on return
* @param n number of inputs
* @param in input array
*/
-ir_node *be_new_Return(dbg_info *dbg, ir_graph *irg, ir_node *block, int n_res,
- unsigned pop, int n, ir_node *in[]);
+ir_node *be_new_Return(dbg_info *dbg, ir_node *block, int n_res, unsigned pop, int n, ir_node *in[]);
/** Returns the number of real returns values */
int be_Return_get_n_rets(const ir_node *ret);
*/
void be_Return_set_emit_pop(ir_node *ret, int emit_pop);
-/** appends a node to the return node, returns the position of the node */
-int be_Return_append_node(ir_node *ret, ir_node *node);
-
ir_node *be_new_Start(dbg_info *dbgi, ir_node *block, int n_out);
-ir_node *be_new_Barrier(ir_node *block, int n, ir_node *in[]);
-
-/**
- * Appends a node to a barrier, returns the result proj of the node
- */
-ir_node *be_Barrier_append_node(ir_node *barrier, ir_node *node);
-
-/**
- * Make a spill node.
- *
- * @param irn The node to be spilled.
- * @param block the block where the spill should be placed
- * @return The new spill node.
- */
-ir_node *be_spill(ir_node *block, ir_node *irn);
-
-/**
- * Make a reload and insert it into the schedule.
- *
- * @param cls The register class of the reloaded value.
- * @param insert The node in the schedule in front of which the reload is
- * inserted.
- * @param mode The mode of the original (spilled) value.
- * @param spill The spill node corresponding to this reload.
- * @return A freshly made reload.
- */
-ir_node *be_reload(const arch_register_class_t *cls, ir_node *insert,
- ir_mode *mode, ir_node *spill);
-
enum {
- be_pos_CopyKeep_op = 0
+ n_be_CopyKeep_op = 0
};
-ir_node *be_new_CopyKeep(const arch_register_class_t *cls, ir_node *block,
- ir_node *src, int n, ir_node *in_keep[],
- ir_mode *mode);
+ir_node *be_new_CopyKeep(ir_node *block, ir_node *src,
+ int n, ir_node *in_keep[]);
-ir_node *be_new_CopyKeep_single(const arch_register_class_t *cls,
- ir_node *block, ir_node *src, ir_node *keep,
- ir_mode *mode);
+ir_node *be_new_CopyKeep_single(ir_node *block, ir_node *src, ir_node *keep);
ir_node *be_get_CopyKeep_op(const ir_node *cpy);
*/
ir_entity *be_get_frame_entity(const ir_node *irn);
+void be_node_set_frame_entity(ir_node *node, ir_entity *entity);
+
/**
* Returns the frame offset of this node.
*/
void be_set_constr_single_reg_out(ir_node *irn, int pos,
const arch_register_t *reg, arch_register_req_type_t additional_flags);
+const arch_register_req_t *be_create_reg_req(struct obstack *obst,
+ const arch_register_t *reg, arch_register_req_type_t additional_types);
+
/**
* Impose register constraints on a backend node.
* The register subsets given by the limited function in @p req are copied to
*/
void be_set_phi_reg_req(ir_node *phi, const arch_register_req_t *req);
-void be_dump_phi_reg_reqs(FILE *out, ir_node *node, dump_reason_t reason);
+void be_dump_phi_reg_reqs(FILE *out, const ir_node *node, dump_reason_t reason);
/**
* Creates a new phi with associated backend informations
*/
ir_node *be_new_Phi(ir_node *block, int n_ins, ir_node **ins, ir_mode *mode,
- const arch_register_class_t *cls);
+ const arch_register_req_t *req);
/**
- * irn handler for common be nodes and Phi's.
+ * Search for output of start node with a specific register
*/
-const void *be_node_get_irn_ops(const ir_node *irn);
+ir_node *be_get_initial_reg_value(ir_graph *irg, const arch_register_t *reg);
static inline int be_is_Spill (const ir_node *irn) { return get_irn_opcode(irn) == beo_Spill ; }
static inline int be_is_Reload (const ir_node *irn) { return get_irn_opcode(irn) == beo_Reload ; }
static inline int be_is_IncSP (const ir_node *irn) { return get_irn_opcode(irn) == beo_IncSP ; }
static inline int be_is_AddSP (const ir_node *irn) { return get_irn_opcode(irn) == beo_AddSP ; }
static inline int be_is_SubSP (const ir_node *irn) { return get_irn_opcode(irn) == beo_SubSP ; }
-static inline int be_is_Start (const ir_node *irn) { return get_irn_opcode(irn) == beo_Start; }
+static inline int be_is_Start (const ir_node *irn) { return get_irn_opcode(irn) == beo_Start ; }
static inline int be_is_FrameAddr(const ir_node *irn) { return get_irn_opcode(irn) == beo_FrameAddr; }
-static inline int be_is_Barrier (const ir_node *irn) { return get_irn_opcode(irn) == beo_Barrier ; }
#endif