static heights_t *ir_heights;
/* Flag: if set, try to omit the frame pointer if called by the backend */
-int be_omit_fp = 1;
+static int be_omit_fp = 1;
/*
_ ____ ___ ____ _ _ _ _
return frame;
}
+#if 0
/** Dumps the stack layout to file. */
static void stack_layout_dump(FILE *file, be_stack_layout_t *frame)
{
}
}
}
+#endif
/**
* Returns non-zero if the call argument at given position
const arch_register_t *sp = arch_isa_sp(isa);
ir_mode *mach_mode = sp->reg_class->mode;
struct obstack *obst = &env->obst;
- ir_node *no_mem = get_irg_no_mem(irg);
int no_alloc = call->flags.bits.frame_is_setup_on_call;
ir_node *res_proj = NULL;
}
}
+ if(!do_seq) {
+ obstack_ptr_grow(obst, get_Call_mem(irn));
+ curr_mem = new_NoMem();
+ } else {
+ curr_mem = get_Call_mem(irn);
+ }
+
assert(mode_is_reference(mach_mode) && "machine mode must be pointer");
for(i = 0; i < n_pos; ++i) {
int p = pos[i];
/* Insert a store for primitive arguments. */
if (is_atomic_type(param_type)) {
- mem = new_r_Store(irg, bl, curr_mem, addr, param);
- mem = new_r_Proj(irg, bl, mem, mode_M, pn_Store_M);
+ ir_node *store;
+ store = new_r_Store(irg, bl, curr_mem, addr, param);
+ mem = new_r_Proj(irg, bl, store, mode_M, pn_Store_M);
}
/* Make a mem copy for compound arguments. */
else {
+ ir_node *copy;
+
assert(mode_is_reference(get_irn_mode(param)));
- mem = new_r_CopyB(irg, bl, curr_mem, addr, param, param_type);
- mem = new_r_Proj(irg, bl, mem, mode_M, pn_CopyB_M_regular);
+ copy = new_r_CopyB(irg, bl, curr_mem, addr, param, param_type);
+ mem = new_r_Proj(irg, bl, copy, mode_M, pn_CopyB_M_regular);
}
curr_ofs += param_size;
in = (ir_node **) obstack_finish(obst);
/* We need the sync only, if we didn't build the stores sequentially. */
- if(!do_seq)
- curr_mem = new_r_Sync(irg, bl, n_pos, in);
+ if(!do_seq) {
+ if(n_pos >= 1) {
+ curr_mem = new_r_Sync(irg, bl, n_pos + 1, in);
+ } else {
+ curr_mem = get_Call_mem(irn);
+ }
+ }
obstack_free(obst, in);
}
}
}
- if(!mem_proj)
+ if(!mem_proj) {
mem_proj = new_r_Proj(irg, bl, low_call, mode_M, pn_Call_M);
+ keep_alive(mem_proj);
+ }
/* Clean up the stack frame if we allocated it */
if(!no_alloc) {
ir_node *new_alloc;
ir_node *addr;
ir_node *copy;
+ ir_node *ins[2];
foreach_out_edge(alloc, edge) {
ir_node *irn = get_edge_src_irn(edge);
env->call->flags.bits.try_omit_fp = 0;
new_alloc = be_new_AddSP(env->isa->sp, irg, bl, curr_sp, get_Alloc_size(alloc));
- exchange(alloc, new_alloc);
+ if(alloc_mem != NULL) {
+ ir_node *addsp_mem;
+ ir_node *sync;
+
+ addsp_mem = new_r_Proj(irg, bl, new_alloc, mode_M, pn_be_AddSP_M);
+
+ // We need to sync the output mem of the AddSP with the input mem
+ // edge into the alloc node
+ ins[0] = get_Alloc_mem(alloc);
+ ins[1] = addsp_mem;
+ sync = new_r_Sync(irg, bl, 2, ins);
- if(alloc_mem != NULL)
- set_Proj_proj(alloc_mem, pn_be_AddSP_M);
+ exchange(alloc_mem, sync);
+ }
+
+ exchange(alloc, new_alloc);
/* fix projnum of alloca res */
set_Proj_proj(alloc_res, pn_be_AddSP_res);
heights_free(ir_heights);
}
-static void collect_return_walker(ir_node *irn, void *data)
-{
- if(get_irn_opcode(irn) == iro_Return) {
- struct obstack *obst = data;
- obstack_ptr_grow(obst, irn);
- }
-}
-
#if 0 /*
static ir_node *setup_frame(be_abi_irg_t *env)
{
return res;
}
+#if 0
static void create_register_perms(const arch_isa_t *isa, ir_graph *irg, ir_node *bl, pmap *regs)
{
int i, j, n;
obstack_free(&obst, NULL);
}
+#endif
typedef struct {
const arch_register_t *reg;
ir_graph *irg = env->birg->irg;
ir_node *bl = get_irg_start_block(irg);
ir_node *end = get_irg_end_block(irg);
- ir_node *no_mem = get_irg_no_mem(irg);
ir_node *mem = get_irg_initial_mem(irg);
ir_type *method_type = get_entity_type(get_irg_entity(irg));
pset *dont_save = pset_new_ptr(8);
obstack_free(&env->obst, args);
}
-/**
- * Walker: puts all Alloc(stack_alloc) on a obstack
- */
-static void collect_alloca_walker(ir_node *irn, void *data)
-{
- be_abi_irg_t *env = data;
- if(get_irn_opcode(irn) == iro_Alloc && get_Alloc_where(irn) == stack_alloc)
- obstack_ptr_grow(&env->obst, irn);
-}
-
be_abi_irg_t *be_abi_introduce(be_irg_t *birg)
{
be_abi_irg_t *env = xmalloc(sizeof(env[0]));
ir_node *dummy;
optimization_state_t state;
+ be_omit_fp = birg->main_env->options->omit_fp;
+
obstack_init(&env->obst);
env->isa = birg->main_env->arch_env->isa;