-static ir_node *make_jmp_or_fallthrough(mips_transform_env_t *env)
-{
- const ir_edge_t *edge;
- ir_node *node = env->irn;
- ir_node *next_block;
- int our_block_sched_nr = mips_get_block_sched_nr(get_nodes_block(node));
-
- edge = get_irn_out_edge_first(node);
- next_block = get_edge_src_irn(edge);
-
- if(mips_get_sched_block(env->cg, our_block_sched_nr + 1) == next_block) {
- return new_rd_mips_fallthrough(env->dbg, env->irg, env->block, mode_X);
- }
-
- return new_rd_mips_b(env->dbg, env->irg, env->block, mode_X);
-}
-
-static ir_node *gen_node_for_Cond_Proj(mips_transform_env_t *env, ir_node* node, int true_false)
-{
- // we can't use get_Cond_selector here because the selector is already
- // replaced by a mips_ compare node
- ir_node *proj = get_Cond_selector(node);
- ir_node *original_cmp = get_irn_n(proj, 0);
- ir_node *result = NULL;
- ir_node *cmp;
- ir_node *condjmp;
- ir_node *op1, *op2;
- dbg_info *dbg = env->dbg;
- ir_graph *irg = env->irg;
- ir_node *block = env->block;
- long n;
-
- n = get_Proj_proj(proj);
- assert(n < 8 && "Only ordered comps supported");
-
- assert(get_irn_opcode(original_cmp) == iro_Cmp);
- op1 = get_Cmp_left(original_cmp);
- op2 = get_Cmp_right(original_cmp);
-
- switch(n) {
- case pn_Cmp_False:
- if(true_false)
- return NULL;
-
- return make_jmp_or_fallthrough(env);
-
- case pn_Cmp_Eq:
- if(!true_false)
- return make_jmp_or_fallthrough(env);
-
- condjmp = new_rd_mips_beq(dbg, irg, block, op1, op2, mode_T);
- return new_rd_Proj(dbg, irg, block, condjmp, mode_X, 1);
-
- case pn_Cmp_Lt:
- if(!true_false)
- return make_jmp_or_fallthrough(env);
-
- cmp = new_rd_mips_slt(dbg, irg, block, op1, op2, get_irn_mode(op1));
- condjmp = new_rd_mips_bgtz(dbg, irg, block, cmp, mode_T);
- return new_rd_Proj(dbg, irg, block, condjmp, mode_X, 1);
-
- case pn_Cmp_Le:
- if(!true_false)
- return make_jmp_or_fallthrough(env);
-
- cmp = new_rd_mips_slt(dbg, irg, block, op2, op1, get_irn_mode(op1));
- condjmp = new_rd_mips_blez(dbg, irg, block, cmp, mode_T);
- return new_rd_Proj(dbg, irg, block, condjmp, mode_X, 1);
-
- case pn_Cmp_Gt:
- if(!true_false)
- return make_jmp_or_fallthrough(env);
-
- cmp = new_rd_mips_slt(dbg, irg, block, op2, op1, get_irn_mode(op1));
- condjmp = new_rd_mips_bgtz(dbg, irg, block, cmp, mode_T);
- return new_rd_Proj(dbg, irg, block, condjmp, mode_X, 1);
-
- case pn_Cmp_Ge:
- if(!true_false)
- return make_jmp_or_fallthrough(env);
-
- cmp = new_rd_mips_slt(dbg, irg, block, op1, op2, get_irn_mode(op1));
- condjmp = new_rd_mips_blez(dbg, irg, block, cmp, mode_T);
- return new_rd_Proj(dbg, irg, block, condjmp, mode_X, 1);
-
- case pn_Cmp_Lg:
- if(!true_false)
- return make_jmp_or_fallthrough(env);
-
- condjmp = new_rd_mips_bne(dbg, irg, block, op1, op2, mode_T);
- return new_rd_Proj(dbg, irg, block, condjmp, mode_X, 1);
-
- case pn_Cmp_Leg:
- if(!true_false)
- return NULL;
-
- return make_jmp_or_fallthrough(env);
-
- default:
- assert(0);
- }
-
- return NULL;
-}
-
-static ir_node *gen_node_for_Proj(mips_transform_env_t *env)