Commit 62405326 authored by Matthias Braun's avatar Matthias Braun
Browse files

be: remove be_Start,be_Return,be_Call,be_AddSP,be_SubSP nodes

parent 11ab1db9
......@@ -170,7 +170,7 @@ static void emit_be_IncSP(const ir_node *node)
TEMPLATE_emitf(node, "%s %S0, %d, %D0", op, offset);
}
static void emit_be_Start(const ir_node *node)
static void emit_Start(const ir_node *node)
{
ir_graph *irg = get_irn_irg(node);
ir_type *frame_type = get_irg_frame_type(irg);
......@@ -184,7 +184,7 @@ static void emit_be_Start(const ir_node *node)
}
}
static void emit_be_Return(const ir_node *node)
static void emit_Return(const ir_node *node)
{
ir_graph *irg = get_irn_irg(node);
ir_type *frame_type = get_irg_frame_type(irg);
......@@ -216,8 +216,8 @@ static void TEMPLATE_register_emitters(void)
/* custom emitters not provided by the spec */
be_set_emitter(op_TEMPLATE_Jmp, emit_TEMPLATE_Jmp);
be_set_emitter(op_be_IncSP, emit_be_IncSP);
be_set_emitter(op_be_Return, emit_be_Return);
be_set_emitter(op_be_Start, emit_be_Start);
be_set_emitter(op_Return, emit_Return);
be_set_emitter(op_Start, emit_Start);
/* no need to emit anything for the following nodes */
be_set_emitter(op_Phi, be_emit_nothing);
......
......@@ -63,14 +63,6 @@ typedef struct {
int align; /**< alignment after the IncSP (0=no alignment) */
} be_incsp_attr_t;
/** The be_Call attribute type. */
typedef struct {
be_node_attr_t base;
ir_entity *ent; /**< called entity if this is a static call. */
ir_type *call_tp; /**< call type, copied from the original Call */
unsigned pop;
} be_call_attr_t;
typedef struct {
be_node_attr_t base;
ir_entity **in_entities;
......@@ -84,27 +76,10 @@ ir_op *op_be_MemPerm;
ir_op *op_be_Copy;
ir_op *op_be_Keep;
ir_op *op_be_CopyKeep;
ir_op *op_be_Call;
ir_op *op_be_Return;
ir_op *op_be_IncSP;
ir_op *op_be_AddSP;
ir_op *op_be_SubSP;
ir_op *op_be_Start;
#define be_op_tag FOURCC('B', 'E', '\0', '\0')
/**
* Compare the attributes of two be_Return nodes.
*/
static int be_return_attrs_equal(const ir_node *a, const ir_node *b)
{
const be_return_attr_t *attr_a = (const be_return_attr_t*)get_irn_generic_attr_const(a);
const be_return_attr_t *attr_b = (const be_return_attr_t*)get_irn_generic_attr_const(b);
return attr_a->num_ret_vals == attr_b->num_ret_vals
&& attr_a->pop == attr_b->pop && attr_a->emit_pop == attr_b->emit_pop
&& attrs_equal_be_node(a, b);
}
/**
* Compare the attributes of two be_IncSP nodes.
*/
......@@ -115,17 +90,6 @@ static int be_incsp_attrs_equal(const ir_node *a, const ir_node *b)
return attr_a->offset == attr_b->offset && attrs_equal_be_node(a, b);
}
/**
* Compare the attributes of two be_Call nodes.
*/
static int be_call_attrs_equal(const ir_node *a, const ir_node *b)
{
const be_call_attr_t *attr_a = (const be_call_attr_t*)get_irn_generic_attr_const(a);
const be_call_attr_t *attr_b = (const be_call_attr_t*)get_irn_generic_attr_const(b);
return attr_a->ent == attr_b->ent && attr_a->call_tp == attr_b->call_tp
&& attrs_equal_be_node(a, b);
}
static arch_register_req_t *allocate_reg_req(ir_graph *const irg)
{
struct obstack *obst = be_get_be_obst(irg);
......@@ -314,114 +278,6 @@ void be_Keep_add_node(ir_node *keep, const arch_register_class_t *cls, ir_node *
add_register_req_in(keep, cls->class_req);
}
ir_node *be_new_Call(dbg_info *const dbg, ir_node *const bl, ir_node *const mem,
arch_register_req_t const *const sp_req, ir_node *const sp,
arch_register_req_t const *const ptr_req,
ir_node *const ptr, int const n_outs, int const n,
ir_node *const *const in, ir_type *const call_tp)
{
int real_n = n_be_Call_first_arg + n;
ir_node **real_in = ALLOCAN(ir_node*, real_n);
real_in[n_be_Call_mem] = mem;
real_in[n_be_Call_sp] = sp;
real_in[n_be_Call_ptr] = ptr;
memcpy(&real_in[n_be_Call_first_arg], in, n * sizeof(in[0]));
ir_graph *const irg = get_irn_irg(bl);
ir_node *const irn = new_ir_node(dbg, irg, bl, op_be_Call, mode_T, real_n, real_in);
init_node_attr(irn, real_n, n_outs, arch_irn_flags_none);
be_call_attr_t *a = (be_call_attr_t*)get_irn_generic_attr(irn);
a->ent = NULL;
a->call_tp = call_tp;
a->pop = 0;
a->base.exc.pin_state = op_pin_state_pinned;
be_set_constr_in(irn, n_be_Call_sp, sp_req);
be_set_constr_in(irn, n_be_Call_ptr, ptr_req);
return irn;
}
ir_entity *be_Call_get_entity(const ir_node *call)
{
const be_call_attr_t *a = (const be_call_attr_t*)get_irn_generic_attr_const(call);
assert(be_is_Call(call));
return a->ent;
}
void be_Call_set_entity(ir_node *call, ir_entity *ent)
{
be_call_attr_t *a = (be_call_attr_t*)get_irn_generic_attr(call);
assert(be_is_Call(call));
a->ent = ent;
}
ir_type *be_Call_get_type(ir_node *call)
{
const be_call_attr_t *a = (const be_call_attr_t*)get_irn_generic_attr_const(call);
assert(be_is_Call(call));
return a->call_tp;
}
void be_Call_set_type(ir_node *call, ir_type *call_tp)
{
be_call_attr_t *a = (be_call_attr_t*)get_irn_generic_attr(call);
assert(be_is_Call(call));
a->call_tp = call_tp;
}
void be_Call_set_pop(ir_node *call, unsigned pop)
{
be_call_attr_t *a = (be_call_attr_t*)get_irn_generic_attr(call);
a->pop = pop;
}
unsigned be_Call_get_pop(const ir_node *call)
{
const be_call_attr_t *a = (const be_call_attr_t*)get_irn_generic_attr_const(call);
return a->pop;
}
ir_node *be_new_Return(dbg_info *const dbg, ir_node *const block,
int const n_res, unsigned const pop, int const n,
ir_node *const *const in)
{
ir_graph *const irg = get_irn_irg(block);
ir_node *const res = new_ir_node(dbg, irg, block, op_be_Return, mode_X, n, in);
init_node_attr(res, n, 1, arch_irn_flags_none);
be_set_constr_out(res, 0, arch_no_register_req);
be_return_attr_t *const a = (be_return_attr_t*)get_irn_generic_attr(res);
a->num_ret_vals = n_res;
a->pop = pop;
a->emit_pop = 0;
a->base.exc.pin_state = op_pin_state_pinned;
return res;
}
int be_Return_get_n_rets(const ir_node *ret)
{
const be_return_attr_t *a = (const be_return_attr_t*)get_irn_generic_attr_const(ret);
return a->num_ret_vals;
}
unsigned be_Return_get_pop(const ir_node *ret)
{
const be_return_attr_t *a = (const be_return_attr_t*)get_irn_generic_attr_const(ret);
return a->pop;
}
int be_Return_get_emit_pop(const ir_node *ret)
{
const be_return_attr_t *a = (const be_return_attr_t*)get_irn_generic_attr_const(ret);
return a->emit_pop;
}
void be_Return_set_emit_pop(ir_node *ret, int emit_pop)
{
be_return_attr_t *a = (be_return_attr_t*)get_irn_generic_attr(ret);
a->emit_pop = emit_pop;
}
ir_node *be_new_IncSP(const arch_register_t *sp, ir_node *bl,
ir_node *old_sp, int offset, int align)
{
......@@ -441,56 +297,6 @@ ir_node *be_new_IncSP(const arch_register_t *sp, ir_node *bl,
return irn;
}
ir_node *be_new_AddSP(const arch_register_t *sp, ir_node *bl, ir_node *old_sp,
ir_node *sz)
{
ir_graph *irg = get_irn_irg(bl);
ir_node *in[] = { old_sp, sz };
assert(ARRAY_SIZE(in) == n_be_AddSP_max+1);
ir_node *irn = new_ir_node(NULL, irg, bl, op_be_AddSP, mode_T,
ARRAY_SIZE(in), in);
init_node_attr(irn, ARRAY_SIZE(in), pn_be_AddSP_max+1, arch_irn_flags_none);
be_node_attr_t *attr = (be_node_attr_t*)get_irn_generic_attr(irn);
attr->exc.pin_state = op_pin_state_pinned;
/* Set output constraint to stack register. */
be_set_constr_single_reg_in(irn, n_be_AddSP_old_sp, sp,
arch_register_req_type_none);
be_node_set_reg_class_in(irn, n_be_AddSP_size, sp->reg_class);
be_set_constr_single_reg_out(irn, pn_be_AddSP_sp, sp,
arch_register_req_type_produces_sp);
return irn;
}
ir_node *be_new_SubSP(const arch_register_t *sp, ir_node *bl, ir_node *old_sp, ir_node *sz)
{
ir_graph *irg = get_irn_irg(bl);
ir_node *in[] = { old_sp, sz };
assert(ARRAY_SIZE(in) == n_be_SubSP_max+1);
ir_node *irn = new_ir_node(NULL, irg, bl, op_be_SubSP, mode_T,
ARRAY_SIZE(in), in);
init_node_attr(irn, ARRAY_SIZE(in), pn_be_SubSP_max+1, arch_irn_flags_none);
be_node_attr_t *attr = (be_node_attr_t*)get_irn_generic_attr(irn);
attr->exc.pin_state = op_pin_state_pinned;
/* Set output constraint to stack register. */
be_set_constr_single_reg_in(irn, n_be_SubSP_old_sp, sp,
arch_register_req_type_none);
be_node_set_reg_class_in(irn, n_be_SubSP_size, sp->reg_class);
be_set_constr_single_reg_out(irn, pn_be_SubSP_sp, sp, arch_register_req_type_produces_sp);
return irn;
}
ir_node *be_new_Start(dbg_info *dbgi, ir_node *bl, int n_outs)
{
ir_graph *irg = get_irn_irg(bl);
ir_node *res = new_ir_node(dbgi, irg, bl, op_be_Start, mode_T, 0, NULL);
init_node_attr(res, 0, n_outs, arch_irn_flag_schedule_first);
be_node_attr_t *attr = (be_node_attr_t*) get_irn_generic_attr(res);
attr->exc.pin_state = op_pin_state_pinned;
return res;
}
ir_node *be_new_CopyKeep(ir_node *bl, ir_node *src, int n, ir_node *in_keep[])
{
ir_mode *mode = get_irn_mode(src);
......@@ -838,11 +644,7 @@ static void dump_node(FILE *f, const ir_node *irn, dump_reason_t reason)
fprintf(f, "%s", get_mode_name(get_irn_mode(irn)));
break;
case dump_node_nodeattr_txt:
if (be_is_Call(irn)) {
const be_call_attr_t *a = (const be_call_attr_t*)get_irn_generic_attr_const(irn);
if (a->ent)
fprintf(f, " [%s] ", get_entity_name(a->ent));
} else if (be_is_IncSP(irn)) {
if (be_is_IncSP(irn)) {
const be_incsp_attr_t *attr = (const be_incsp_attr_t*)get_irn_generic_attr_const(irn);
fprintf(f, " [%d] ", attr->offset);
}
......@@ -857,12 +659,6 @@ static void dump_node(FILE *f, const ir_node *irn, dump_reason_t reason)
fprintf(f, "offset: %d\n", a->offset);
break;
}
case beo_Call: {
const be_call_attr_t *a = (const be_call_attr_t*)get_irn_generic_attr_const(irn);
if (a->ent != NULL)
fprintf(f, "\nentity: %s\n", get_entity_name(a->ent));
break;
}
case beo_MemPerm: {
for (unsigned i = 0; i < be_get_MemPerm_entity_arity(irn); ++i) {
ir_entity *in = be_get_MemPerm_in_entity(irn, i);
......@@ -950,26 +746,14 @@ void be_init_op(void)
op_be_Copy = new_be_op(o+beo_Copy, "be_Copy", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_node_attr_t));
op_be_Keep = new_be_op(o+beo_Keep, "be_Keep", op_pin_state_exc_pinned, irop_flag_keep, oparity_dynamic, sizeof(be_node_attr_t));
op_be_CopyKeep = new_be_op(o+beo_CopyKeep, "be_CopyKeep", op_pin_state_exc_pinned, irop_flag_keep, oparity_variable, sizeof(be_node_attr_t));
op_be_Call = new_be_op(o+beo_Call, "be_Call", op_pin_state_exc_pinned, irop_flag_fragile|irop_flag_uses_memory, oparity_variable, sizeof(be_call_attr_t));
op_be_Return = new_be_op(o+beo_Return, "be_Return", op_pin_state_exc_pinned, irop_flag_cfopcode, oparity_variable, sizeof(be_return_attr_t));
op_be_AddSP = new_be_op(o+beo_AddSP, "be_AddSP", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_node_attr_t));
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));
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);
set_op_attrs_equal(op_be_Perm, attrs_equal_be_node);
set_op_attrs_equal(op_be_MemPerm, attrs_equal_be_node);
set_op_attrs_equal(op_be_Copy, attrs_equal_be_node);
set_op_attrs_equal(op_be_Keep, attrs_equal_be_node);
set_op_attrs_equal(op_be_CopyKeep, attrs_equal_be_node);
set_op_attrs_equal(op_be_Call, be_call_attrs_equal);
set_op_attrs_equal(op_be_Return, be_return_attrs_equal);
set_op_attrs_equal(op_be_AddSP, attrs_equal_be_node);
set_op_attrs_equal(op_be_SubSP, attrs_equal_be_node);
set_op_attrs_equal(op_be_IncSP, be_incsp_attrs_equal);
set_op_attrs_equal(op_be_Start, attrs_equal_be_node);
/* attach out dummy_ops to middle end nodes */
for (unsigned opc = iro_first; opc <= iro_last; ++opc) {
......@@ -987,10 +771,5 @@ void be_finish_op(void)
free_ir_op(op_be_Copy); op_be_Copy = NULL;
free_ir_op(op_be_Keep); op_be_Keep = NULL;
free_ir_op(op_be_CopyKeep); op_be_CopyKeep = NULL;
free_ir_op(op_be_Call); op_be_Call = NULL;
free_ir_op(op_be_Return); op_be_Return = NULL;
free_ir_op(op_be_IncSP); op_be_IncSP = NULL;
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;
}
......@@ -28,13 +28,8 @@ typedef enum be_opcode {
beo_Copy,
beo_Keep,
beo_CopyKeep,
beo_Call,
beo_Return,
beo_IncSP,
beo_AddSP,
beo_SubSP,
beo_Start,
beo_last = beo_Start
beo_last = beo_IncSP
} be_opcode;
/**
......@@ -45,12 +40,7 @@ extern ir_op *op_be_MemPerm;
extern ir_op *op_be_Copy;
extern ir_op *op_be_Keep;
extern ir_op *op_be_CopyKeep;
extern ir_op *op_be_Call;
extern ir_op *op_be_Return;
extern ir_op *op_be_IncSP;
extern ir_op *op_be_AddSP;
extern ir_op *op_be_SubSP;
extern ir_op *op_be_Start;
/**
* Determines if irn is a be_node.
......@@ -114,67 +104,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_AddSP inputs
*/
enum {
n_be_AddSP_old_sp,
n_be_AddSP_size,
n_be_AddSP_max = n_be_AddSP_size
};
enum {
pn_be_AddSP_sp,
pn_be_AddSP_res,
pn_be_AddSP_M,
pn_be_AddSP_max = pn_be_AddSP_M
};
/**
* Make a new AddSP node.
* An AddSP node expresses an increase of the stack pointer in the direction
* the stack grows. In contrast to IncSP, the amount of bytes the stack pointer
* is grown, is not given by a constant but an ordinary Firm node.
* @param sp The stack pointer register.
* @param block The block.
* @param old_sp The node representing the old stack pointer value.
* @param size The node expressing the size by which the stack pointer shall
* be grown.
* @return A new AddSP node.
*/
ir_node *be_new_AddSP(const arch_register_t *sp, ir_node *block,
ir_node *old_sp, ir_node *size);
/**
* Position numbers for the be_SubSP inputs
*/
enum {
n_be_SubSP_old_sp,
n_be_SubSP_size,
n_be_SubSP_max = n_be_SubSP_size
};
enum {
pn_be_SubSP_sp,
pn_be_SubSP_M,
pn_be_SubSP_max = pn_be_SubSP_M
};
/**
* Make a new SubSP node.
* A SubSP node expresses a decrease of the stack pointer in the direction the
* stack grows. In contrast to IncSP, the amount of bytes the stack pointer is
* grown, is not given by a constant but an ordinary Firm node.
* @param sp The stack pointer register.
* @param block The block.
* @param old_sp The node representing the old stack pointer value.
* @param size The node expressing the size by which the stack pointer shall
* be grown.
* @return A new DecSP node.
*/
ir_node *be_new_SubSP(const arch_register_t *sp, ir_node *block,
ir_node *old_sp, ir_node *size);
/**
* Make a stack pointer increase/decrease node.
* @param sp The stack pointer register.
......@@ -211,105 +140,6 @@ void be_set_IncSP_offset(ir_node *irn, int offset);
int be_get_IncSP_offset(const ir_node *irn);
int be_get_IncSP_align(const ir_node *irn);
/** Gets the call entity or NULL if this is no static call. */
ir_entity *be_Call_get_entity(const ir_node *call);
/** Sets the call entity. */
void be_Call_set_entity(ir_node *call, ir_entity *ent);
/** Gets the call type. */
ir_type *be_Call_get_type(ir_node *call);
/** Sets the call type. */
void be_Call_set_type(ir_node *call, ir_type *call_tp);
void be_Call_set_pop(ir_node *call, unsigned pop);
unsigned be_Call_get_pop(const ir_node *call);
/**
* Position numbers for the be_Call inputs.
*/
enum {
n_be_Call_mem, /**< memory input of a be_Call node */
n_be_Call_sp, /**< stack pointer input of a be_Call node */
n_be_Call_ptr, /**< call pointer input of a be_Call node */
n_be_Call_first_arg /**< 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 = 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 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 ptr the address of the called function, if immediate call set
* to sp
* @param n_outs the number of outcoming values from this call
* @param n the number of (register) inputs of this 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_node *block, ir_node *mem, arch_register_req_t const *sp_req, ir_node *sp, arch_register_req_t const *ptr_req, ir_node *ptr, int n_outs, int n, ir_node *const *in, ir_type *call_tp);
/**
* Position numbers for the be_Return inputs.
*/
enum {
n_be_Return_mem, /**< memory input of a be_Return node */
n_be_Return_sp, /**< stack pointer input of a be_Return node */
n_be_Return_val, /**< first "real" return value if any */
n_be_Return_max = n_be_Return_val
};
/**
* Construct a new be_Return.
*
* @param dbg debug info
* @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_node *block, int n_res, unsigned pop, int n, ir_node *const *in);
/** Returns the number of real returns values */
int be_Return_get_n_rets(const ir_node *ret);
/**
* Return the number of bytes that should be popped from stack when executing
* the Return.
*
* @param ret the be_Return node
*/
unsigned be_Return_get_pop(const ir_node *ret);
/**
* Return non-zero, if number of popped bytes must be always emitted.
*
* @param ret the be_Return node
*/
int be_Return_get_emit_pop(const ir_node *ret);
/**
* Set the emit_pop flag.
*
* @param ret the be_Return node
*/
void be_Return_set_emit_pop(ir_node *ret, int emit_pop);
ir_node *be_new_Start(dbg_info *dbgi, ir_node *block, int n_out);
enum {
n_be_CopyKeep_op,
n_be_CopyKeep_max = n_be_CopyKeep_op
......@@ -395,11 +225,6 @@ static inline bool be_is_CopyKeep (const ir_node *irn) { return get_irn_op(irn)
static inline bool be_is_Perm (const ir_node *irn) { return get_irn_op(irn) == op_be_Perm ; }
static inline bool be_is_MemPerm (const ir_node *irn) { return get_irn_op(irn) == op_be_MemPerm ; }
static inline bool be_is_Keep (const ir_node *irn) { return get_irn_op(irn) == op_be_Keep ; }
static inline bool be_is_Call (const ir_node *irn) { return get_irn_op(irn) == op_be_Call ; }
static inline bool be_is_Return (const ir_node *irn) { return get_irn_op(irn) == op_be_Return ; }
static inline bool be_is_IncSP (const ir_node *irn) { return get_irn_op(irn) == op_be_IncSP ; }
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 ; }
#endif
......@@ -180,7 +180,6 @@ static void insn_count_walker(ir_node *irn, void *data)
switch (get_irn_opcode(irn)) {
case iro_Proj:
case iro_Phi:
case beo_Start:
case iro_End:
break;
default:
......
......@@ -509,8 +509,6 @@ void be_start_transform_setup(void)
be_set_transform_function(op_be_CopyKeep, be_duplicate_node);
be_set_transform_function(op_be_IncSP, be_duplicate_node);
be_set_transform_function(op_be_Keep, be_duplicate_node);
be_set_transform_function(op_be_Return, be_duplicate_node);
be_set_transform_function(op_be_Start, be_duplicate_node);
be_set_transform_function(op_Block, transform_block);
be_set_transform_function(op_End, transform_end);
be_set_transform_function(op_NoMem, be_duplicate_node);
......
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