Commit 13c55699 authored by Matthias Braun's avatar Matthias Braun
Browse files

fix some warnings by removing the strange abi_get_ignore_irn API

parent bba15007
......@@ -2103,7 +2103,7 @@ static void fix_pic_symconsts(ir_node *node, void *data)
}
}
be_abi_irg_t *be_abi_introduce(ir_graph *irg)
void be_abi_introduce(ir_graph *irg)
{
be_abi_irg_t *env = XMALLOCZ(be_abi_irg_t);
ir_node *old_frame = get_irg_frame(irg);
......@@ -2167,7 +2167,8 @@ be_abi_irg_t *be_abi_introduce(ir_graph *irg)
exchange(dummy, env->init_sp);
exchange(old_frame, get_irg_frame(irg));
return env;
pmap_destroy(env->regs);
env->regs = NULL;
}
void be_abi_free(ir_graph *irg)
......@@ -2176,35 +2177,12 @@ void be_abi_free(ir_graph *irg)
if (env->call != NULL)
be_abi_call_free(env->call);
if (env->regs != NULL)
pmap_destroy(env->regs);
free(env);
assert(env->regs == NULL);
be_set_irg_abi(irg, NULL);
}
/**
* called after nodes have been transformed so some node references can be
* replaced with new nodes
*/
void be_abi_transform_fixup(ir_graph *irg)
{
be_abi_irg_t *abi = be_get_irg_abi(irg);
pmap *new_regs;
pmap_entry *entry;
if (abi == NULL || abi->regs == NULL)
return;
new_regs = pmap_create();
foreach_pmap(abi->regs, entry) {
ir_node *value = (ir_node*)entry->value;
ir_node *transformed = be_transform_node(value);
pmap_insert(new_regs, entry->key, transformed);
}
pmap_destroy(abi->regs);
abi->regs = new_regs;
}
void be_put_allocatable_regs(const ir_graph *irg,
const arch_register_class_t *cls, bitset_t *bs)
{
......@@ -2245,21 +2223,6 @@ void be_set_allocatable_regs(const ir_graph *irg,
}
}
ir_node *be_abi_get_callee_save_irn(ir_graph *irg, const arch_register_t *reg)
{
const be_abi_irg_t *abi = be_get_irg_abi(irg);
assert(reg->type & arch_register_type_callee_save);
assert(pmap_contains(abi->regs, (void *) reg));
return (ir_node*)pmap_get(abi->regs, (void *) reg);
}
ir_node *be_abi_get_ignore_irn(ir_graph *irg, const arch_register_t *reg)
{
const be_abi_irg_t *abi = be_get_irg_abi(irg);
assert(pmap_contains(abi->regs, (void *) reg));
return (ir_node*)pmap_get(abi->regs, (void *) reg);
}
BE_REGISTER_MODULE_CONSTRUCTOR(be_init_abi);
void be_init_abi(void)
{
......
......@@ -144,16 +144,8 @@ be_abi_call_flags_t be_abi_call_get_flags(const be_abi_call_t *call);
*/
ir_type *be_abi_call_get_method_type(const be_abi_call_t *call);
be_abi_irg_t *be_abi_introduce(ir_graph *irg);
/**
* should be called by betranshlp.c while the graph is transformed
*/
void be_abi_transform_fixup(ir_graph *irg);
void be_abi_introduce(ir_graph *irg);
void be_abi_free(ir_graph *irg);
ir_node *be_abi_get_callee_save_irn(ir_graph *irg, const arch_register_t *reg);
ir_node *be_abi_get_ignore_irn(ir_graph *irg, const arch_register_t *reg);
#endif
......@@ -367,10 +367,6 @@ static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform)
be_transform_node(node);
}
/* let beabi grab new nodes */
be_abi_transform_fixup(irg);
assert(waitq_empty(env.worklist)); // let's hope this didn't trigger new transforms
/* fix loops and set new anchors*/
inc_irg_visited(irg);
for (i = get_irg_n_anchors(irg) - 1; i >= 0; --i) {
......
......@@ -263,6 +263,43 @@ static int ia32_get_sp_bias(const ir_node *node)
return 0;
}
static int get_start_reg_index(ir_graph *irg, const arch_register_t *reg)
{
ir_node *start = get_irg_start(irg);
unsigned n_outs = arch_irn_get_n_outs(start);
int i;
/* do a naive linear search... */
for (i = 0; i < (int)n_outs; ++i) {
const arch_register_req_t *out_req
= arch_get_out_register_req(start, i);
if (! (out_req->type & arch_register_req_type_limited))
continue;
if (rbitset_is_set(out_req->limited, reg->index))
return i;
}
panic("Tried querying undefined register '%s' at Start", reg->name);
}
ir_node *ia32_get_initial_reg_value(ir_graph *irg, const arch_register_t *reg)
{
int i = get_start_reg_index(irg, reg);
ir_node *start = get_irg_start(irg);
ir_mode *mode = arch_register_class_mode(arch_register_get_class(reg));
const ir_edge_t *edge;
foreach_out_edge(start, edge) {
ir_node *proj = get_edge_src_irn(edge);
if (!is_Proj(proj)) // maybe End/Anchor
continue;
if (get_Proj_proj(proj) == i) {
return proj;
}
}
ir_node *res = new_r_Proj(start, mode, i);
return res;
}
/**
* Build the between type and entities if not already build.
*/
......@@ -988,7 +1025,7 @@ static void transform_MemPerm(ir_node *node)
{
ir_node *block = get_nodes_block(node);
ir_graph *irg = get_irn_irg(node);
ir_node *sp = be_abi_get_ignore_irn(irg, &ia32_registers[REG_ESP]);
ir_node *sp = ia32_get_initial_reg_value(irg, &ia32_registers[REG_ESP]);
int arity = be_get_MemPerm_entity_arity(node);
ir_node **pops = ALLOCAN(ir_node*, arity);
ir_node *in[1];
......@@ -1252,7 +1289,7 @@ static void introduce_prolog_epilog(ir_graph *irg)
ir_type *frame_type = get_irg_frame_type(irg);
unsigned frame_size = get_type_size_bytes(frame_type);
be_stack_layout_t *layout = be_get_irg_stack_layout(irg);
ir_node *initial_sp = be_abi_get_ignore_irn(irg, sp);
ir_node *initial_sp = ia32_get_initial_reg_value(irg, sp);
ir_node *curr_sp = initial_sp;
ir_mode *mode_gp = mode_Iu;
......@@ -1260,7 +1297,7 @@ static void introduce_prolog_epilog(ir_graph *irg)
/* push ebp */
ir_node *mem = get_irg_initial_mem(irg);
ir_node *noreg = ia32_new_NoReg_gp(irg);
ir_node *initial_bp = be_abi_get_ignore_irn(irg, bp);
ir_node *initial_bp = ia32_get_initial_reg_value(irg, bp);
ir_node *curr_bp = initial_bp;
ir_node *push = new_bd_ia32_Push(NULL, block, noreg, noreg, mem, curr_bp, curr_sp);
ir_node *incsp;
......
......@@ -154,4 +154,9 @@ ir_entity *ia32_get_return_address_entity(ir_graph *irg);
*/
ir_entity *ia32_get_frame_address_entity(ir_graph *irg);
/**
* Get node representing the initial value of a register
*/
ir_node *ia32_get_initial_reg_value(ir_graph *irg, const arch_register_t *reg);
#endif
......@@ -251,8 +251,6 @@ static void rewire_fpu_mode_nodes(ir_graph *irg)
env.state_nodes = NEW_ARR_F(ir_node*, 0);
irg_walk_graph(irg, collect_fpu_mode_nodes_walker, NULL, &env);
initial_value = be_abi_get_ignore_irn(irg, reg);
/* nothing needs to be done, in fact we must not continue as for endless
* loops noone is using the initial_value and it will point to a bad node
* now
......@@ -262,6 +260,7 @@ static void rewire_fpu_mode_nodes(ir_graph *irg)
return;
}
initial_value = ia32_get_initial_reg_value(irg, reg);
be_ssa_construction_init(&senv, irg);
be_ssa_construction_add_copies(&senv, env.state_nodes,
ARR_LEN(env.state_nodes));
......
......@@ -89,6 +89,7 @@
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
static ir_node *old_initial_fpcw = NULL;
static ir_node *initial_fpcw = NULL;
int ia32_no_pic_adjust;
......@@ -1037,14 +1038,10 @@ static ir_node *gen_binop_flags(ir_node *node, construct_binop_flags_func *func,
static ir_node *get_fpcw(void)
{
ir_node *fpcw;
if (initial_fpcw != NULL)
return initial_fpcw;
fpcw = be_abi_get_ignore_irn(current_ir_graph,
&ia32_registers[REG_FPCW]);
initial_fpcw = be_transform_node(fpcw);
initial_fpcw = be_transform_node(old_initial_fpcw);
return initial_fpcw;
}
......@@ -5720,8 +5717,6 @@ static void ia32_pretransform_node(void)
nomem = get_irg_no_mem(irg);
noreg_GP = ia32_new_NoReg_gp(irg);
get_fpcw();
}
/**
......@@ -5827,6 +5822,9 @@ void ia32_transform_graph(ir_graph *irg)
initial_fpcw = NULL;
ia32_no_pic_adjust = 0;
old_initial_fpcw
= ia32_get_initial_reg_value(irg, &ia32_registers[REG_FPCW]);
be_timer_push(T_HEIGHTS);
ia32_heights = heights_new(irg);
be_timer_pop(T_HEIGHTS);
......
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