Commit 85646be4 authored by Matthias Braun's avatar Matthias Braun
Browse files

remove pointless be_FrameAddr node, Member on irg_frame does the same

parent 445d6c9b
......@@ -1159,32 +1159,6 @@ static ir_node *create_be_return(be_abi_irg_t *const env, ir_node *const irn)
return ret;
}
typedef struct lower_frame_members_env_t {
ir_node *frame; /**< the current frame */
const arch_register_class_t *sp_class; /**< register class of the stack pointer */
} lower_frame_members_env_t;
/**
* Walker: Replaces Member nodes of frame type and
* value param type entities by FrameAddress.
* Links all used entities.
*/
static void lower_frame_members_walker(ir_node *irn, void *data)
{
lower_frame_members_env_t *ctx = (lower_frame_members_env_t*)data;
if (!is_Member(irn))
return;
ir_node *ptr = get_Member_ptr(irn);
if (ptr == ctx->frame) {
ir_entity *ent = get_Member_entity(irn);
ir_node *bl = get_nodes_block(irn);
ir_node *nw
= be_new_FrameAddr(ctx->sp_class, bl, ctx->frame, ent);
exchange(irn, nw);
}
}
/**
* The start block has no jump, instead it has an initial exec Proj.
* The backend wants to handle all blocks the same way, so we replace
......@@ -1234,11 +1208,6 @@ static void modify_irg(ir_graph *const irg, be_abi_irg_t *const env)
ir_type *const arg_type = compute_arg_type(irg, call, method_type);
/* Convert the Sel nodes in the irg to frame addr nodes: */
lower_frame_members_env_t ctx;
ctx.frame = get_irg_frame(irg);
ctx.sp_class = arch_env->sp->reg_class;
ir_type *const frame_tp = get_irg_frame_type(irg);
/* layout the stackframe now */
if (get_type_state(frame_tp) == layout_undefined) {
......@@ -1258,8 +1227,6 @@ static void modify_irg(ir_graph *const irg, be_abi_irg_t *const env)
be_add_parameter_entity_stores(irg);
irg_walk_graph(irg, lower_frame_members_walker, NULL, &ctx);
irp_free_resources(irp, IRP_RESOURCE_ENTITY_LINK);
/* Fill the argument vector */
......@@ -1381,8 +1348,16 @@ static void modify_irg(ir_graph *const irg, be_abi_irg_t *const env)
ir_node *repl;
if (arg->in_reg) {
repl = pmap_get(ir_node, env->regs, arg->reg);
/* Beware: the mode of the register parameters is always the mode of
* the register class which may be wrong. Add Conv's then. */
ir_mode *mode = get_irn_mode(args[i]);
if (mode != get_irn_mode(repl)) {
repl = new_r_Conv(get_nodes_block(repl), repl, mode);
}
} else {
ir_node *addr = be_new_FrameAddr(sp->reg_class, start_bl, frame_pointer, arg->stack_ent);
ir_node *addr = new_r_Member(start_bl, frame_pointer,
arg->stack_ent);
/* For atomic parameters which are actually used, we create a Load
* node. */
......@@ -1407,12 +1382,6 @@ static void modify_irg(ir_graph *const irg, be_abi_irg_t *const env)
assert(repl != NULL);
/* Beware: the mode of the register parameters is always the mode of
* the register class which may be wrong. Add Conv's then. */
ir_mode *mode = get_irn_mode(args[i]);
if (mode != get_irn_mode(repl)) {
repl = new_r_Conv(get_nodes_block(repl), repl, mode);
}
exchange(args[i], repl);
}
......
......@@ -66,13 +66,6 @@ typedef struct {
IncSP */
} be_incsp_attr_t;
/** The be_Frame attribute type. */
typedef struct {
be_node_attr_t base;
ir_entity *ent;
int offset;
} be_frame_attr_t;
/** The be_Call attribute type. */
typedef struct {
be_node_attr_t base;
......@@ -100,26 +93,9 @@ ir_op *op_be_IncSP;
ir_op *op_be_AddSP;
ir_op *op_be_SubSP;
ir_op *op_be_Start;
ir_op *op_be_FrameAddr;
#define be_op_tag FOURCC('B', 'E', '\0', '\0')
/**
* Compare the attributes of two be_FrameAddr nodes.
*
* @return zero if both nodes have identically attributes
*/
static int FrameAddr_cmp_attr(const ir_node *a, const ir_node *b)
{
const be_frame_attr_t *a_attr = (const be_frame_attr_t*)get_irn_generic_attr_const(a);
const be_frame_attr_t *b_attr = (const be_frame_attr_t*)get_irn_generic_attr_const(b);
if (a_attr->ent != b_attr->ent || a_attr->offset != b_attr->offset)
return 1;
return be_nodes_equal(a, b);
}
/**
* Compare the attributes of two be_Return nodes.
*
......@@ -574,38 +550,6 @@ ir_node *be_new_Start(dbg_info *dbgi, ir_node *bl, int n_outs)
return res;
}
ir_node *be_new_FrameAddr(const arch_register_class_t *cls_frame, ir_node *bl, ir_node *frame, ir_entity *ent)
{
be_frame_attr_t *a;
ir_node *irn;
ir_node *in[1];
ir_graph *irg = get_Block_irg(bl);
in[0] = frame;
irn = new_ir_node(NULL, irg, bl, op_be_FrameAddr, get_irn_mode(frame), 1, in);
init_node_attr(irn, 1, 1);
a = (be_frame_attr_t*)get_irn_generic_attr(irn);
a->ent = ent;
a->offset = 0;
a->base.exc.pin_state = op_pin_state_floats;
be_node_set_reg_class_in(irn, 0, cls_frame);
be_node_set_reg_class_out(irn, 0, cls_frame);
return optimize_node(irn);
}
ir_node *be_get_FrameAddr_frame(const ir_node *node)
{
assert(be_is_FrameAddr(node));
return get_irn_n(node, n_be_FrameAddr_ptr);
}
ir_entity *be_get_FrameAddr_entity(const ir_node *node)
{
const be_frame_attr_t *attr = (const be_frame_attr_t*)get_irn_generic_attr_const(node);
return attr->ent;
}
ir_node *be_new_CopyKeep(ir_node *bl, ir_node *src, int n, ir_node *in_keep[])
{
ir_node *irn;
......@@ -649,11 +593,6 @@ void be_set_CopyKeep_op(ir_node *cpy, ir_node *op)
set_irn_n(cpy, n_be_CopyKeep_op, op);
}
static bool be_has_frame_entity(const ir_node *irn)
{
return be_is_FrameAddr(irn);
}
void be_set_MemPerm_in_entity(const ir_node *irn, int n, ir_entity *ent)
{
const be_memperm_attr_t *attr = (const be_memperm_attr_t*)get_irn_generic_attr_const(irn);
......@@ -817,10 +756,7 @@ int be_get_IncSP_align(const ir_node *irn)
static ir_entity *be_node_get_frame_entity(const ir_node *irn)
{
if (be_has_frame_entity(irn)) {
const be_frame_attr_t *a = (const be_frame_attr_t*)get_irn_generic_attr_const(irn);
return a->ent;
} else if (be_is_MemPerm(irn)) {
if (be_is_MemPerm(irn)) {
return be_get_MemPerm_in_entity(irn, 0);
}
return NULL;
......@@ -830,13 +766,7 @@ static void be_node_set_frame_offset(ir_node *irn, int offset)
{
if (be_is_MemPerm(irn)) {
be_set_MemPerm_offset(irn, offset);
return;
}
if (!be_has_frame_entity(irn))
return;
be_frame_attr_t *a = (be_frame_attr_t*)get_irn_generic_attr(irn);
a->offset = offset;
}
static int be_node_get_sp_bias(const ir_node *irn)
......@@ -1022,16 +952,6 @@ static void dump_node(FILE *f, const ir_node *irn, dump_reason_t reason)
case dump_node_info_txt:
arch_dump_reqs_and_registers(f, irn);
if (be_has_frame_entity(irn)) {
const be_frame_attr_t *a = (const be_frame_attr_t*)get_irn_generic_attr_const(irn);
if (a->ent) {
unsigned size = get_type_size_bytes(get_entity_type(a->ent));
ir_fprintf(f, "frame entity: %+F, offset 0x%x (%d), size 0x%x (%d) bytes\n",
a->ent, a->offset, a->offset, size, size);
}
}
switch (get_be_irn_opcode(irn)) {
case beo_IncSP: {
const be_incsp_attr_t *a = (const be_incsp_attr_t*)get_irn_generic_attr_const(irn);
......@@ -1145,8 +1065,6 @@ void be_init_op(void)
op_be_SubSP = new_be_op(o+beo_SubSP, "be_SubSP", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_node_attr_t));
op_be_IncSP = new_be_op(o+beo_IncSP, "be_IncSP", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_incsp_attr_t));
op_be_Start = new_be_op(o+beo_Start, "be_Start", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_node_attr_t));
op_be_FrameAddr = new_be_op(o+beo_FrameAddr, "be_FrameAddr", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_frame_attr_t));
ir_op_set_memory_index(op_be_Call, n_be_Call_mem);
ir_op_set_fragile_indices(op_be_Call, pn_be_Call_X_regular, pn_be_Call_X_except);
......@@ -1161,7 +1079,6 @@ void be_init_op(void)
op_be_SubSP->ops.node_cmp_attr = be_nodes_equal;
op_be_IncSP->ops.node_cmp_attr = IncSP_cmp_attr;
op_be_Start->ops.node_cmp_attr = be_nodes_equal;
op_be_FrameAddr->ops.node_cmp_attr = FrameAddr_cmp_attr;
/* attach out dummy_ops to middle end nodes */
for (unsigned opc = iro_first; opc <= iro_last; ++opc) {
......@@ -1186,5 +1103,4 @@ void be_finish_op(void)
free_ir_op(op_be_AddSP); op_be_AddSP = NULL;
free_ir_op(op_be_SubSP); op_be_SubSP = NULL;
free_ir_op(op_be_Start); op_be_Start = NULL;
free_ir_op(op_be_FrameAddr); op_be_FrameAddr = NULL;
}
......@@ -34,8 +34,7 @@ typedef enum be_opcode {
beo_AddSP,
beo_SubSP,
beo_Start,
beo_FrameAddr,
beo_last = beo_FrameAddr
beo_last = beo_Start
} be_opcode;
/**
......@@ -52,7 +51,6 @@ extern ir_op *op_be_IncSP;
extern ir_op *op_be_AddSP;
extern ir_op *op_be_SubSP;
extern ir_op *op_be_Start;
extern ir_op *op_be_FrameAddr;
/**
* Determines if irn is a be_node.
......@@ -116,22 +114,6 @@ ir_node *be_new_Keep(ir_node *block, int arity, ir_node *const *in);
void be_Keep_add_node(ir_node *keep, const arch_register_class_t *cls,
ir_node *node);
/**
* Position numbers for the be_FrameAddr inputs
*/
enum {
n_be_FrameAddr_ptr = 0
};
/** Create a new FrameAddr node. */
ir_node *be_new_FrameAddr(const arch_register_class_t *cls_frame,
ir_node *block, ir_node *frame, ir_entity *ent);
/** Return the frame input of a FrameAddr node. */
ir_node *be_get_FrameAddr_frame(const ir_node *node);
ir_entity *be_get_FrameAddr_entity(const ir_node *node);
/**
* Position numbers for the be_AddSP inputs
*/
......@@ -417,6 +399,5 @@ static inline bool be_is_IncSP (const ir_node *irn) { return get_irn_op(irn)
static inline bool be_is_AddSP (const ir_node *irn) { return get_irn_op(irn) == op_be_AddSP ; }
static inline bool be_is_SubSP (const ir_node *irn) { return get_irn_op(irn) == op_be_SubSP ; }
static inline bool be_is_Start (const ir_node *irn) { return get_irn_op(irn) == op_be_Start ; }
static inline bool be_is_FrameAddr(const ir_node *irn) { return get_irn_op(irn) == op_be_FrameAddr; }
#endif
......@@ -4123,14 +4123,20 @@ static ir_node *create_immediate_or_transform(ir_node *const node)
/**
* Transforms a FrameAddr into an ia32 Add.
*/
static ir_node *gen_be_FrameAddr(ir_node *node)
static ir_node *gen_Member(ir_node *node)
{
ir_node *block = be_transform_node(get_nodes_block(node));
ir_node *op = be_get_FrameAddr_frame(node);
ir_node *new_op = be_transform_node(op);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *new_node = new_bd_ia32_Lea(dbgi, block, new_op, noreg_GP);
set_ia32_frame_ent(new_node, arch_get_frame_entity(node));
ir_node *block = be_transform_node(get_nodes_block(node));
ir_node *ptr = get_Member_ptr(node);
/* the only non-lowered member nodes should select entities from the
* stackframe */
if (!is_Proj(ptr) || !be_is_Start(get_Proj_pred(ptr)))
panic("%+F not lowered", node);
ir_node *new_ptr = be_transform_node(ptr);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *new_node = new_bd_ia32_Lea(dbgi, block, new_ptr, noreg_GP);
ir_entity *entity = get_Member_entity(node);
set_ia32_frame_ent(new_node, entity);
set_ia32_use_frame(new_node);
SET_IA32_ORIG_NODE(new_node, node);
......@@ -5663,7 +5669,6 @@ static void register_transformers(void)
be_set_transform_function(op_ASM, ia32_gen_ASM);
be_set_transform_function(op_be_AddSP, gen_be_AddSP);
be_set_transform_function(op_be_Call, gen_be_Call);
be_set_transform_function(op_be_FrameAddr, gen_be_FrameAddr);
be_set_transform_function(op_be_IncSP, gen_be_IncSP);
be_set_transform_function(op_be_Return, gen_be_Return);
be_set_transform_function(op_be_SubSP, gen_be_SubSP);
......@@ -5695,6 +5700,7 @@ static void register_transformers(void)
be_set_transform_function(op_IJmp, gen_IJmp);
be_set_transform_function(op_Jmp, gen_Jmp);
be_set_transform_function(op_Load, gen_Load);
be_set_transform_function(op_Member, gen_Member);
be_set_transform_function(op_Minus, gen_Minus);
be_set_transform_function(op_Mod, gen_Mod);
be_set_transform_function(op_Mul, gen_Mul);
......
......@@ -262,12 +262,20 @@ static bool eat_shl(x86_address_t *addr, ir_node *node)
return true;
}
static bool is_frame_addr(const ir_node *const node)
{
if (!is_Member(node))
return false;
ir_node *base = get_Member_ptr(node);
return base == get_irg_frame(get_irn_irg(node));
}
static void set_frame_addr(x86_address_t *const addr, ir_node *const frame)
{
assert(!addr->base);
assert(!addr->frame_entity);
addr->base = be_get_FrameAddr_frame(frame);
addr->frame_entity = be_get_FrameAddr_entity(frame);
addr->base = get_Member_ptr(frame);
addr->frame_entity = get_Member_entity(frame);
addr->use_frame = true;
}
......@@ -346,7 +354,7 @@ void x86_create_address_mode(x86_address_t *addr, ir_node *node,
/* we can hit this case in x86_create_am_force mode */
eat_immediate(addr, node, false);
return;
} else if (be_is_FrameAddr(node)) {
} else if (is_frame_addr(node)) {
set_frame_addr(addr, node);
return;
} else if (is_Add(node)) {
......@@ -363,11 +371,11 @@ void x86_create_address_mode(x86_address_t *addr, ir_node *node,
} else if (eat_shl(addr, right)) {
right = NULL;
}
if (left != NULL && be_is_FrameAddr(left)
if (left != NULL && is_frame_addr(left)
&& !x86_is_non_address_mode_node(left)) {
set_frame_addr(addr, left);
left = NULL;
} else if (right != NULL && be_is_FrameAddr(right)
} else if (right != NULL && is_frame_addr(right)
&& !x86_is_non_address_mode_node(right)) {
set_frame_addr(addr, right);
right = NULL;
......
......@@ -596,7 +596,11 @@ static int verify_node_Sel(const ir_node *n)
static int verify_node_Member(const ir_node *n)
{
bool fine = check_mode_func(n, mode_is_reference, "reference");
fine &= check_input_func(n, n_Member_ptr, "ptr", mode_is_reference, "reference");
/* do not check in backend until beabi.c is gone */
if (!irg_is_constrained(get_irn_irg(n), IR_GRAPH_CONSTRAINT_BACKEND)) {
fine &= check_input_func(n, n_Member_ptr, "ptr", mode_is_reference,
"reference");
}
ir_entity *entity = get_Member_entity(n);
if (entity == NULL) {
warn(n, "entity is NULL");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment