}
static void remove_unused_nodes(ir_node *irn, bitset_t *already_visited) {
- int i;
+ int i, arity;
ir_mode *mode;
- ir_node *mem_proj;
+ ir_node *mem_proj = NULL;
if (is_Block(irn))
return;
/* tuple node has one user which is not the mem proj-> ok */
if (mode == mode_T && get_irn_n_edges(irn) == 1) {
mem_proj = ia32_get_proj_for_mode(irn, mode_M);
- if (! mem_proj)
+ if (mem_proj == NULL)
return;
}
- for (i = get_irn_arity(irn) - 1; i >= 0; i--) {
+ arity = get_irn_arity(irn);
+ for (i = 0; i < arity; ++i) {
ir_node *pred = get_irn_n(irn, i);
/* do not follow memory edges or we will accidentally remove stores */
- if (is_Proj(pred) && get_irn_mode(pred) == mode_M)
+ if (get_irn_mode(pred) == mode_M) {
+ if(mem_proj != NULL) {
+ edges_reroute(mem_proj, pred, get_irn_irg(mem_proj));
+ mem_proj = NULL;
+ }
continue;
+ }
set_irn_n(irn, i, new_Bad());
remove_unused_nodes(pred, already_visited);
}
+ // we need to set the presd to Bad again to also get the memory edges
+ arity = get_irn_arity(irn);
+ for (i = 0; i < arity; ++i) {
+ set_irn_n(irn, i, new_Bad());
+ }
+
if (sched_is_scheduled(irn)) {
- set_irn_n(irn, 0, new_Bad());
- set_irn_n(irn, 1, new_Bad());
- set_irn_n(irn, 2, new_Bad());
sched_remove(irn);
}
}
*/
static void ia32_before_ra(void *self) {
ia32_code_gen_t *cg = self;
- bitset_t *already_visited = bitset_irg_malloc(cg->irg);
+ bitset_t *already_visited = bitset_irg_alloca(cg->irg);
/*
Handle special case:
after removing the Load from schedule.
*/
irg_walk_graph(cg->irg, remove_unused_loads_walker, NULL, already_visited);
- bitset_free(already_visited);
}
int imm = 0;
ir_node *res = NULL;
ir_node *nomem, *noreg, *base, *index, *op1, *op2;
- char *offs;
+ const char *offs;
ia32_transform_env_t tenv;
const arch_register_t *out_reg, *base_reg, *index_reg;
+ int imm_tp = ia32_ImmConst;
/* must be a LEA */
if (! is_ia32_Lea(irn))
base = get_irn_n(irn, 0);
index = get_irn_n(irn,1);
- offs = get_ia32_am_offs(irn);
+ if (am_flav & ia32_O) {
+ offs = get_ia32_am_offs(irn);
- /* offset has a explicit sign -> we need to skip + */
- if (offs && offs[0] == '+')
- offs++;
+ if (! offs) {
+ ident *id = get_ia32_am_sc(irn);
+
+ assert(id != NULL);
+ offs = get_id_str(id);
+ imm_tp = ia32_ImmSymConst;
+ }
+ /* offset has a explicit sign -> we need to skip + */
+ else if (offs[0] == '+')
+ offs++;
+ }
out_reg = arch_get_irn_register(cg->arch_env, irn);
base_reg = arch_get_irn_register(cg->arch_env, base);
if (imm) {
set_ia32_cnst(res, offs);
- set_ia32_immop_type(res, ia32_ImmConst);
+ set_ia32_immop_type(res, imm_tp);
}
SET_IA32_ORIG_NODE(res, ia32_get_old_node_name(cg, irn));