be_irg_t *birg; /**< The back end IRG. */
const arch_env_t *arch_env;
survive_dce_t *dce_survivor;
be_irg_t *birg; /**< The back end IRG. */
const arch_env_t *arch_env;
survive_dce_t *dce_survivor;
pmap *keep_map; /**< mapping blocks to keep nodes. */
pset *ignore_regs; /**< Additional registers which shall be ignored. */
pmap *keep_map; /**< mapping blocks to keep nodes. */
pset *ignore_regs; /**< Additional registers which shall be ignored. */
- arch_register_req_t sp_req;
- arch_register_req_t sp_cls_req;
+ arch_register_req_t sp_req;
+ arch_register_req_t sp_cls_req;
+
+ be_stack_layout_t frame; /**< The stack frame model. */
curr_sp = new_r_Proj(irg, bl, low_call, get_irn_mode(curr_sp),
pn_be_Call_sp);
be_set_constr_single_reg(low_call, BE_OUT_POS(pn_be_Call_sp), sp);
curr_sp = new_r_Proj(irg, bl, low_call, get_irn_mode(curr_sp),
pn_be_Call_sp);
be_set_constr_single_reg(low_call, BE_OUT_POS(pn_be_Call_sp), sp);
be_node_set_flags(low_call, BE_OUT_POS(pn_be_Call_sp),
arch_irn_flags_ignore | arch_irn_flags_modify_sp);
be_node_set_flags(low_call, BE_OUT_POS(pn_be_Call_sp),
arch_irn_flags_ignore | arch_irn_flags_modify_sp);
/* memorize the register in the link field. we need afterwards to set the register class of the keep correctly. */
be_set_constr_single_reg(low_call, BE_OUT_POS(curr_res_proj), reg);
/* memorize the register in the link field. we need afterwards to set the register class of the keep correctly. */
be_set_constr_single_reg(low_call, BE_OUT_POS(curr_res_proj), reg);
/* a call can produce ignore registers, in this case set the flag and register for the Proj */
if (arch_register_type_is(reg, ignore)) {
/* a call can produce ignore registers, in this case set the flag and register for the Proj */
if (arch_register_type_is(reg, ignore)) {
set_irn_link(proj, (void*) reg);
obstack_ptr_grow(obst, proj);
}
set_irn_link(proj, (void*) reg);
obstack_ptr_grow(obst, proj);
}
const arch_register_t *reg = &cls->regs[j];
ir_node *irn = pmap_get(regs, (void *) reg);
const arch_register_t *reg = &cls->regs[j];
ir_node *irn = pmap_get(regs, (void *) reg);
obstack_ptr_grow(&obst, NULL);
in = obstack_finish(&obst);
obstack_ptr_grow(&obst, NULL);
in = obstack_finish(&obst);
perm = be_new_Perm(cls, irg, bl, n_regs, in);
perm = be_new_Perm(cls, irg, bl, n_regs, in);
ir_node *arg = in[j];
arch_register_t *reg = get_irn_link(arg);
pmap_insert(regs, reg, arg);
ir_node *arg = in[j];
arch_register_t *reg = get_irn_link(arg);
pmap_insert(regs, reg, arg);
proj = new_r_Proj(irg, bl, irn, get_irn_mode(rm[n].irn), n);
be_node_set_reg_class(irn, n, reg->reg_class);
proj = new_r_Proj(irg, bl, irn, get_irn_mode(rm[n].irn), n);
be_node_set_reg_class(irn, n, reg->reg_class);
be_set_constr_single_reg(irn, n, reg);
be_set_constr_single_reg(irn, pos, reg);
be_node_set_reg_class(irn, pos, reg->reg_class);
be_set_constr_single_reg(irn, n, reg);
be_set_constr_single_reg(irn, pos, reg);
be_node_set_reg_class(irn, pos, reg->reg_class);
- if(arch_register_type_is(reg, ignore) || arch_irn_is(env->birg->main_env->arch_env, in[n], ignore))
+ if (arch_register_type_is(reg, ignore) || arch_irn_is(env->birg->main_env->arch_env, in[n], ignore))
flags |= arch_irn_flags_modify_sp;
be_node_set_flags(irn, pos, flags);
flags |= arch_irn_flags_modify_sp;
be_node_set_flags(irn, pos, flags);
*mem = new_r_Proj(irg, bl, irn, mode_M, n);
}
*mem = new_r_Proj(irg, bl, irn, mode_M, n);
}
ir_node *res = get_Return_res(irn, i);
be_abi_call_arg_t *arg = get_call_arg(call, 1, i);
assert(arg->in_reg && "return value must be passed in register");
ir_node *res = get_Return_res(irn, i);
be_abi_call_arg_t *arg = get_call_arg(call, 1, i);
assert(arg->in_reg && "return value must be passed in register");
/* clear SP entry, since it has already been grown. */
pmap_insert(reg_map, (void *) arch_env->sp, NULL);
/* clear SP entry, since it has already been grown. */
pmap_insert(reg_map, (void *) arch_env->sp, NULL);
be_abi_call_arg_t *arg = get_call_arg(call, 1, i);
in[n] = be_abi_reg_map_get(reg_map, arg->reg);
be_abi_call_arg_t *arg = get_call_arg(call, 1, i);
in[n] = be_abi_reg_map_get(reg_map, arg->reg);
/* grow the rest of the stuff. */
foreach_pmap(reg_map, ent) {
/* grow the rest of the stuff. */
foreach_pmap(reg_map, ent) {
ret = be_new_Return(dbgi, env->birg->irg, bl, n_res, pop, n, in);
/* Set the register classes of the return's parameter accordingly. */
ret = be_new_Return(dbgi, env->birg->irg, bl, n_res, pop, n, in);
/* Set the register classes of the return's parameter accordingly. */
be_node_set_reg_class(ret, i, regs[i]->reg_class);
/* Free the space of the Epilog's in array and the register <-> proj map. */
be_node_set_reg_class(ret, i, regs[i]->reg_class);
/* Free the space of the Epilog's in array and the register <-> proj map. */
const arch_env_t *arch_env= env->birg->main_env->arch_env;
const arch_register_t *sp = arch_env_sp(arch_env);
ir_graph *irg = env->birg->irg;
const arch_env_t *arch_env= env->birg->main_env->arch_env;
const arch_register_t *sp = arch_env_sp(arch_env);
ir_graph *irg = env->birg->irg;
DBG((dbg, LEVEL_1, "introducing abi on %+F\n", irg));
DBG((dbg, LEVEL_1, "introducing abi on %+F\n", irg));
/* set the links of all frame entities to NULL, we use it
to detect if an entity is already linked in the value_param_list */
tp = get_method_value_param_type(method_type);
/* set the links of all frame entities to NULL, we use it
to detect if an entity is already linked in the value_param_list */
tp = get_method_value_param_type(method_type);
kill_node(value_param_base);
set_irg_value_param_base(irg, new_r_Bad(irg));
kill_node(value_param_base);
set_irg_value_param_base(irg, new_r_Bad(irg));
arg_type = compute_arg_type(env, call, method_type, ¶m_map);
bet_type = call->cb->get_between_type(env->cb);
arg_type = compute_arg_type(env, call, method_type, ¶m_map);
bet_type = call->cb->get_between_type(env->cb);
- stack_frame_init(env->frame, arg_type, bet_type, get_irg_frame_type(irg), arch_env->stack_dir, param_map);
+ stack_frame_init(&env->frame, arg_type, bet_type, get_irg_frame_type(irg), arch_env->stack_dir, param_map);
assert(arg->reg != sp && "cannot use stack pointer as parameter register");
assert(i == get_Proj_proj(args[i]));
assert(arg->reg != sp && "cannot use stack pointer as parameter register");
assert(i == get_Proj_proj(args[i]));
arch_register_type_is(reg, state)) {
pmap_insert(env->regs, (void *) reg, NULL);
}
arch_register_type_is(reg, state)) {
pmap_insert(env->regs, (void *) reg, NULL);
}
proj = new_r_Proj(irg, reg_params_bl, env->reg_params, mode, nr);
pmap_insert(env->regs, (void *) reg, proj);
be_set_constr_single_reg(env->reg_params, pos, reg);
proj = new_r_Proj(irg, reg_params_bl, env->reg_params, mode, nr);
pmap_insert(env->regs, (void *) reg, proj);
be_set_constr_single_reg(env->reg_params, pos, reg);
/*
* If the register is an ignore register,
* The Proj for that register shall also be ignored during register allocation.
*/
/*
* If the register is an ignore register,
* The Proj for that register shall also be ignored during register allocation.
*/
flags |= arch_irn_flags_modify_sp;
be_node_set_flags(env->reg_params, pos, flags);
flags |= arch_irn_flags_modify_sp;
be_node_set_flags(env->reg_params, pos, flags);
- fp_reg = call->cb->prologue(env->cb, &mem, env->regs, &env->frame->initial_bias);
+ fp_reg = call->cb->prologue(env->cb, &mem, env->regs, &env->frame.initial_bias);
/* do the stack allocation BEFORE the barrier, or spill code
might be added before it */
env->init_sp = be_abi_reg_map_get(env->regs, sp);
/* do the stack allocation BEFORE the barrier, or spill code
might be added before it */
env->init_sp = be_abi_reg_map_get(env->regs, sp);
- env->init_sp = be_new_IncSP(sp, irg, bl, env->init_sp, BE_STACK_FRAME_SIZE_EXPAND, 0);
+ start_bl = get_irg_start_block(irg);
+ env->init_sp = be_new_IncSP(sp, irg, start_bl, env->init_sp, BE_STACK_FRAME_SIZE_EXPAND, 0);
- create_barrier(env, bl, &mem, env->regs, 0);
+ create_barrier(env, start_bl, &mem, env->regs, 0);
frame_pointer = be_abi_reg_map_get(env->regs, fp_reg);
set_irg_frame(irg, frame_pointer);
frame_pointer = be_abi_reg_map_get(env->regs, fp_reg);
set_irg_frame(irg, frame_pointer);
set_irg_initial_mem(irg, mem);
/* Now, introduce stack param nodes for all parameters passed on the stack */
set_irg_initial_mem(irg, mem);
/* Now, introduce stack param nodes for all parameters passed on the stack */
ir_node *addr = be_new_FrameAddr(sp->reg_class, irg, reg_params_bl, frame_pointer, arg->stack_ent);
/* For atomic parameters which are actually used, we create a Load node. */
ir_node *addr = be_new_FrameAddr(sp->reg_class, irg, reg_params_bl, frame_pointer, arg->stack_ent);
/* For atomic parameters which are actually used, we create a Load node. */
set_irg_args(irg, new_rd_Bad(irg));
/* All Return nodes hang on the End node, so look for them there. */
set_irg_args(irg, new_rd_Bad(irg));
/* All Return nodes hang on the End node, so look for them there. */
for (i = 0, n = get_Block_n_cfgpreds(end); i < n; ++i) {
ir_node *irn = get_Block_cfgpred(end, i);
for (i = 0, n = get_Block_n_cfgpreds(end); i < n; ++i) {
ir_node *irn = get_Block_cfgpred(end, i);
/* if we have endless loops here, n might be <= 0. Do NOT create a be_Return then,
the code is dead and will never be executed. */
/* if we have endless loops here, n might be <= 0. Do NOT create a be_Return then,
the code is dead and will never be executed. */
obstack_free(&env->obst, args);
/* handle start block here (place a jump in the block) */
obstack_free(&env->obst, args);
/* handle start block here (place a jump in the block) */
int s, arity;
ir_node *call = env->calls[i];
arity = get_irn_arity(call);
/* the state reg inputs are the last n inputs of the calls */
int s, arity;
ir_node *call = env->calls[i];
arity = get_irn_arity(call);
/* the state reg inputs are the last n inputs of the calls */
int inp = arity - n_states + s;
const arch_register_t *reg = stateregs[s];
ir_node *regnode = be_abi_reg_map_get(env->regs, reg);
int inp = arity - n_states + s;
const arch_register_t *reg = stateregs[s];
ir_node *regnode = be_abi_reg_map_get(env->regs, reg);
mode = get_irn_mode(pred);
unknown = new_r_Unknown(irg, mode);
pic_base = arch_code_generator_get_pic_base(env->birg->cg);
mode = get_irn_mode(pred);
unknown = new_r_Unknown(irg, mode);
pic_base = arch_code_generator_get_pic_base(env->birg->cg);
pic_symbol = get_pic_symbol(be, entity);
pic_symconst = new_rd_SymConst_addr_ent(dbgi, irg, mode_P_code,
pic_symbol, NULL);
pic_symbol = get_pic_symbol(be, entity);
pic_symconst = new_rd_SymConst_addr_ent(dbgi, irg, mode_P_code,
pic_symbol, NULL);
/* we need an extra indirection for global data outside our current
module. The loads are always safe and can therefore float
/* we need an extra indirection for global data outside our current
module. The loads are always safe and can therefore float
/* Returns the stack layout from a abi environment. */
const be_stack_layout_t *be_abi_get_stack_layout(const be_abi_irg_t *abi) {
/* Returns the stack layout from a abi environment. */
const be_stack_layout_t *be_abi_get_stack_layout(const be_abi_irg_t *abi) {
ir_node *phi = phis[i];
be_set_phi_reg_req(walker_env.arch_env, phi, &env->sp_req);
be_set_phi_flags(walker_env.arch_env, phi, arch_irn_flags_ignore | arch_irn_flags_modify_sp);
ir_node *phi = phis[i];
be_set_phi_reg_req(walker_env.arch_env, phi, &env->sp_req);
be_set_phi_flags(walker_env.arch_env, phi, arch_irn_flags_ignore | arch_irn_flags_modify_sp);
- int offset = get_stack_entity_offset(env->frame, ent, bias);
- arch_set_frame_offset(arch_env, irn, offset);
+ int offset = get_stack_entity_offset(&env->frame, ent, bias);
+ arch_set_frame_offset(irn, offset);
DBG((env->dbg, LEVEL_2, "%F has offset %d (including bias %d)\n",
ent, offset, bias));
}
DBG((env->dbg, LEVEL_2, "%F has offset %d (including bias %d)\n",
ent, offset, bias));
}
* If the node modifies the stack pointer by a constant offset,
* record that in the bias.
*/
* If the node modifies the stack pointer by a constant offset,
* record that in the bias.
*/
int between_size = get_type_size_bytes(between_type);
int alignment = 1 << env->arch_env->stack_alignment;
int delta = (real_bias + ofs + between_size) & (alignment - 1);
int between_size = get_type_size_bytes(between_type);
int alignment = 1 << env->arch_env->stack_alignment;
int delta = (real_bias + ofs + between_size) & (alignment - 1);
// stack_layout_dump(stdout, frame);
/* Determine the stack bias at the end of the start block. */
// stack_layout_dump(stdout, frame);
/* Determine the stack bias at the end of the start block. */
- bw.start_block_bias = process_stack_bias(env, get_irg_start_block(irg), frame->initial_bias);
- bw.between_size = get_type_size_bytes(frame->between_type);
+ bw.start_block_bias = process_stack_bias(env, get_irg_start_block(irg), env->frame.initial_bias);
+ bw.between_size = get_type_size_bytes(env->frame.between_type);