X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fmips%2Fmips_emitter.c;h=dd4bf043b367ce25bef09e1f8874a075915879ce;hb=de3a2dd34bde1c1128f6afb0643b8fac13d38d76;hp=bcd7a20d63e75751a23104d70106bde6ca27cca7;hpb=18dfdacb6faf2f93d4f6f9a6362584f8c7eb30a1;p=libfirm diff --git a/ir/be/mips/mips_emitter.c b/ir/be/mips/mips_emitter.c index bcd7a20d6..dd4bf043b 100644 --- a/ir/be/mips/mips_emitter.c +++ b/ir/be/mips/mips_emitter.c @@ -97,10 +97,10 @@ static const char *node_const_to_str(ir_node *n) assert(attr->tv != NULL); if(get_mode_sign(get_tarval_mode(attr->tv))) { long val = get_tarval_long(attr->tv); - snprintf(buf, sizeof(buf), "0x%04X", val & 0xffff); + snprintf(buf, sizeof(buf), "0x%04lX", val & 0xffff); } else { unsigned long val = get_tarval_long(attr->tv); - snprintf(buf, sizeof(buf), "0x%04X", val & 0xffff); + snprintf(buf, sizeof(buf), "0x%04lX", val & 0xffff); } return buf; @@ -109,11 +109,11 @@ static const char *node_const_to_str(ir_node *n) if(get_mode_sign(get_tarval_mode(attr->tv))) { long val = get_tarval_long(attr->tv); val = (val & 0xffff0000) >> 16; - snprintf(buf, sizeof(buf), "0x%04X", val & 0xffff); + snprintf(buf, sizeof(buf), "0x%04lX", val & 0xffff); } else { unsigned long val = get_tarval_long(attr->tv); val = (val & 0xffff0000) >> 16; - snprintf(buf, sizeof(buf), "0x%04X", val & 0xffff); + snprintf(buf, sizeof(buf), "0x%04lX", val & 0xffff); } return buf; @@ -332,26 +332,15 @@ static char *get_unique_label(char *buf, size_t buflen, const char *prefix) return buf; } - -/** - * Returns the target label for a control flow node. - */ -static char *get_cfop_target(const ir_node *irn, char *buf) -{ - ir_node *bl = get_irn_link(irn); - - snprintf(buf, SNPRINTF_BUF_LEN, "BLOCK_%ld", get_irn_node_nr(bl)); - return buf; -} - /************************************************************************/ -/* ABI Handling +/* ABI Handling */ /************************************************************************/ static void mips_emit_IncSP(const ir_node *node, mips_emit_env_t *env) { - FILE *F = env->out; - int offset = be_get_IncSP_offset(node); + FILE *F = env->out; + int offset = be_get_IncSP_offset(node); + if(offset == 0) return; @@ -385,9 +374,9 @@ static void mips_emit_nops(FILE* F, int n) static void mips_emit_Perm(const ir_node *node, mips_emit_env_t *env) { - FILE* F = env->out; + FILE *F = env->out; - assert(/*get_irn_n_outs(node) == 2 &&*/ get_irn_arity(node) == 2); + assert(get_irn_arity(node) == 2); lc_efprintf(mips_get_arg_env(), F, "\txor %1S, %1S, %2S\t\t\t# perm\n", node, node, node); mips_emit_nops(F, 3); @@ -399,23 +388,22 @@ static void mips_emit_Perm(const ir_node *node, mips_emit_env_t *env) static void mips_emit_Spill(const ir_node* node, mips_emit_env_t *env) { - FILE* F = env->out; + FILE *F = env->out; + entity *ent = be_get_frame_entity(node); - ir_node* context = be_get_Spill_context(node); - entity* ent = be_get_spill_entity(node); lc_efprintf(mips_get_arg_env(), F, "\tsw %1S, %d($fp)\n", node, get_entity_offset_bytes(ent)); } static void mips_emit_Reload(const ir_node* node, mips_emit_env_t *env) { - FILE* F = env->out; + FILE *F = env->out; + entity *ent = be_get_frame_entity(node); - entity* ent = be_get_spill_entity(node); lc_efprintf(mips_get_arg_env(), F, "\tlw %1D, %d($fp)\n", node, get_entity_offset_bytes(ent)); } /************************************************************************/ -/* Calls +/* Calls */ /************************************************************************/ static void mips_emit_Call(ir_node *node, mips_emit_env_t *env) @@ -533,15 +521,11 @@ const char* mips_get_jumptbl_label(const ir_node* switchjmp) * possible otherwise a cmp-jmp cascade). Stolen from ia32 */ void emit_mips_jump_table(const ir_node *irn, FILE* F) { - int lastval, i, pn, do_jmp_tbl = 1; - jmp_tbl_t tbl; - ir_node *proj; - const ir_edge_t *edge; - const lc_arg_env_t *env = mips_get_arg_env(); - mips_attr_t *attr; - int i2; - - attr = get_mips_attr(irn); + int lastval, i, i2, pn; + jmp_tbl_t tbl; + ir_node *proj; + const ir_edge_t *edge; + mips_attr_t *attr = get_mips_attr(irn); /* fill the table structure */ tbl.label = xmalloc(SNPRINTF_BUF_LEN); @@ -646,6 +630,7 @@ void mips_register_emitters(void) op_be_RegParams->ops.generic = (op_func) mips_emit_nothing; op_be_Spill->ops.generic = (op_func) mips_emit_Spill; op_be_Reload->ops.generic = (op_func) mips_emit_Reload; + op_be_Perm->ops.generic = (op_func) mips_emit_Perm; op_Start->ops.generic = (op_func) mips_emit_nothing; op_Proj->ops.generic = (op_func) mips_emit_nothing; @@ -662,10 +647,10 @@ typedef void (*emit_func) (const ir_node *, mips_emit_env_t *); */ static void mips_emit_node(ir_node *irn, mips_emit_env_t* env) { - mips_emit_env_t *emit_env = env; - firm_dbg_module_t *mod = emit_env->mod; + mips_emit_env_t *emit_env = env; FILE *F = emit_env->out; ir_op *op = get_irn_op(irn); + DEBUG_ONLY(firm_dbg_module_t *mod = emit_env->mod;) DBG((mod, LEVEL_1, "emitting code for %+F\n", irn)); @@ -750,10 +735,10 @@ void mips_gen_routine(FILE *F, ir_graph *irg, const mips_code_gen_t *cg) mips_emit_env_t emit_env; int i, n; - emit_env.mod = firm_dbg_register("firm.be.mips.emit"); emit_env.out = F; emit_env.arch_env = cg->arch_env; emit_env.cg = cg; + FIRM_DBG_REGISTER(emit_env.mod, "firm.be.mips.emit"); /* set the global arch_env (needed by print hooks) */ arch_env = cg->arch_env;