be_req_t in_req;
} be_reg_data_t;
+/** The generic be nodes attribute type. */
typedef struct {
- int max_reg_data;
- be_reg_data_t *reg_data;
+ int max_reg_data;
+ be_reg_data_t *reg_data;
} be_node_attr_t;
+/** The be_Stack attribute type. */
typedef struct {
be_node_attr_t node_attr;
int offset; /**< The offset by which the stack shall be increased/decreased. */
be_stack_dir_t dir; /**< The direction in which the stack shall be modified (expand or shrink). */
} be_stack_attr_t;
+/** The be_Frame attribute type. */
typedef struct {
be_node_attr_t node_attr;
entity *ent;
int offset;
} be_frame_attr_t;
+/** The be_Call attribute type. */
typedef struct {
be_node_attr_t node_attr;
- entity *ent;
+ entity *ent; /**< The called entity if this is a static call. */
+ ir_type *call_tp; /**< The call type, copied from the original Call node. */
} be_call_attr_t;
+/** The be_Spill attribute type. */
typedef struct {
be_frame_attr_t frame_attr;
ir_node *spill_ctx; /**< The node in whose context this spill was introduced. */
#define H irop_flag_highlevel
#define c irop_flag_constlike
#define K irop_flag_keep
+#define M irop_flag_machine
+
void be_node_init(void) {
static int inited = 0;
set_op_tag(op_be_FrameLoad, &be_node_tag);
set_op_tag(op_be_FrameStore, &be_node_tag);
set_op_tag(op_be_FrameAddr, &be_node_tag);
- set_op_tag(op_be_Barrier, &be_node_tag);
+ set_op_tag(op_be_Barrier, &be_node_tag);
}
+/**
+ * Initializes the generic attribute of all be nodes and return ir.
+ */
static void *init_node_attr(ir_node* irn, int max_reg_data)
{
ir_graph *irg = get_irn_irg(irn);
return irn;
}
-ir_node *be_new_Call(ir_graph *irg, ir_node *bl, ir_node *mem, ir_node *sp, ir_node *ptr, int n_outs, int n, ir_node *in[])
+ir_node *be_new_Call(dbg_info *dbg, ir_graph *irg, ir_node *bl, ir_node *mem, ir_node *sp, ir_node *ptr,
+ int n_outs, int n, ir_node *in[], ir_type *call_tp)
{
- int real_n = 3 + n;
+ be_call_attr_t *a;
+ int real_n = be_pos_Call_first_arg + n;
ir_node *irn;
ir_node **real_in;
- real_in = xmalloc(sizeof(real_in[0]) * (real_n));
-
- real_in[0] = mem;
- real_in[1] = sp;
- real_in[2] = ptr;
- memcpy(&real_in[3], in, n * sizeof(in[0]));
+ NEW_ARR_A(ir_node *, real_in, real_n);
+ real_in[be_pos_Call_mem] = mem;
+ real_in[be_pos_Call_sp] = sp;
+ real_in[be_pos_Call_ptr] = ptr;
+ memcpy(&real_in[be_pos_Call_first_arg], in, n * sizeof(in[0]));
irn = new_ir_node(NULL, irg, bl, op_be_Call, mode_T, real_n, real_in);
- init_node_attr(irn, (n_outs > real_n ? n_outs : real_n));
+ a = init_node_attr(irn, (n_outs > real_n ? n_outs : real_n));
+ a->ent = NULL;
+ a->call_tp = call_tp;
return irn;
}
-entity *be_Call_get_entity(const ir_node *call)
-{
+/* Gets the call entity or NULL if this is no static call. */
+entity *be_Call_get_entity(const ir_node *call) {
be_call_attr_t *a = get_irn_attr(call);
assert(be_is_Call(call));
return a->ent;
}
-void be_Call_set_entity(ir_node *call, entity *ent)
-{
+/* Sets the call entity. */
+void be_Call_set_entity(ir_node *call, entity *ent) {
be_call_attr_t *a = get_irn_attr(call);
assert(be_is_Call(call));
a->ent = ent;
}
+/* Gets the call type. */
+ir_type *be_Call_get_type(ir_node *call) {
+ be_call_attr_t *a = get_irn_attr(call);
+ assert(be_is_Call(call));
+ return a->call_tp;
+}
+
+/* Sets the call type. */
+void be_Call_set_type(ir_node *call, ir_type *call_tp) {
+ be_call_attr_t *a = get_irn_attr(call);
+ assert(be_is_Call(call));
+ a->call_tp = call_tp;
+}
+
+
ir_node *be_new_Return(dbg_info *dbg, ir_graph *irg, ir_node *bl, int n, ir_node *in[])
{
ir_node *irn = new_ir_node(dbg, irg, bl, op_be_Return, mode_X, n, in);
case beo_FrameLoad:
case beo_FrameAddr:
return 1;
+ default:
+ return 0;
}
-
- return 0;
}
entity *be_get_frame_entity(const ir_node *irn)
r->req.type = type;
}
+ir_node *be_get_IncSP_pred(ir_node *irn) {
+ assert(be_is_IncSP(irn));
+ return get_irn_n(irn, 0);
+}
+
void be_set_IncSP_offset(ir_node *irn, unsigned offset)
{
be_stack_attr_t *a = get_irn_attr(irn);
entity *be_get_spill_entity(const ir_node *irn)
{
- int opc = get_irn_opcode(irn);
-
switch(be_get_irn_opcode(irn)) {
case beo_Reload:
{
*/
insert = sched_next(irn);
- if(bl == get_irg_start_block(irg) && insert != bl && sched_get_time_step(frame) >= sched_get_time_step(insert))
+ if(insert != bl && bl == get_irg_start_block(irg) && sched_get_time_step(frame) >= sched_get_time_step(insert))
insert = sched_next(frame);
while((is_Phi(insert) || is_Proj(insert)) && !sched_is_end(insert))
static void *put_in_reg_req(arch_register_req_t *req, const ir_node *irn, int pos)
{
const be_node_attr_t *a = get_irn_attr(irn);
- int n = get_irn_arity(irn);
if(pos < get_irn_arity(irn) && pos < a->max_reg_data)
memcpy(req, &a->reg_data[pos].in_req, sizeof(req[0]));
redir_proj((const ir_node **) &irn, -1);
switch(be_get_irn_opcode(irn)) {
-#define XXX(a,b) case beo_ ## a: return arch_irn_class_ ## b;
- XXX(Spill, spill)
- XXX(Reload, reload)
- XXX(Perm, perm)
- XXX(Copy, copy)
+#define XXX(a,b) case beo_ ## a: return arch_irn_class_ ## b
+ XXX(Spill, spill);
+ XXX(Reload, reload);
+ XXX(Perm, perm);
+ XXX(Copy, copy);
+ XXX(Return, branch);
#undef XXX
default:
return 0;
{
int n = get_irn_arity(phi);
ir_node *op;
- int done = 0;
int i;
if(*visited && pset_find_ptr(*visited, phi))
|_| |___/
*/
+/**
+ * Dumps a register requirement to a file.
+ */
static void dump_node_req(FILE *f, int idx, be_req_t *req)
{
unsigned i;
fprintf(f, "\n");
}
+/**
+ * Dumps node register requirements to a file.
+ */
static void dump_node_reqs(FILE *f, ir_node *irn)
{
int i;
}
}
+/**
+ * ir_op-Operation: dump a be node to file
+ */
static int dump_node(ir_node *irn, FILE *f, dump_reason_t reason)
{
be_node_attr_t *at = get_irn_attr(irn);
if(be_has_frame_entity(irn)) {
be_frame_attr_t *a = (be_frame_attr_t *) at;
- if (a->ent)
- ir_fprintf(f, "frame entity: %+F offset %x (%d)\n", a->ent, a->offset, a->offset);
+ if (a->ent) {
+ int bits = get_type_size_bits(get_entity_type(a->ent));
+ ir_fprintf(f, "frame entity: %+F offset 0x%x (%d) size 0x%x %d\n",
+ a->ent, a->offset, a->offset, bits, bits);
+ }
}
fprintf(f, "direction: %s\n", a->dir == be_stack_dir_expand ? "expand" : "shrink");
}
break;
+ default:
+ break;
}
-
}
return 0;
}
/**
+ * ir_op-Operation:
* Copies the backend specific attributes from old node to new node.
*/
static void copy_attr(const ir_node *old_node, ir_node *new_node)