X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fia32%2Fia32_emitter.c;h=d8481b7e40e8fd76da7f4fa9041227029f48255d;hb=18814151f8c0ea17b2a7bf84c82ee3c2e66d6a6b;hp=ba007bfcfb745e22690481075e888fb926ca7425;hpb=4a00c4a202c77e20fcb4ebb80f6f4152b46aff21;p=libfirm diff --git a/ir/be/ia32/ia32_emitter.c b/ir/be/ia32/ia32_emitter.c index ba007bfcf..d8481b7e4 100644 --- a/ir/be/ia32/ia32_emitter.c +++ b/ir/be/ia32/ia32_emitter.c @@ -70,6 +70,7 @@ #include "../be_dbgout.h" #include "ia32_emitter.h" +#include "ia32_common_transform.h" #include "gen_ia32_emitter.h" #include "gen_ia32_regalloc_if.h" #include "ia32_nodes_attr.h" @@ -157,20 +158,6 @@ static const arch_register_t *get_in_reg(const ir_node *irn, int pos) if (reg == &ia32_gp_regs[REG_GP_NOREG]) panic("trying to emit noreg for %+F input %d", irn, pos); - /* in case of unknown register: just return a valid register */ - if (reg == &ia32_gp_regs[REG_GP_UKNWN]) { - const arch_register_req_t *req = arch_get_register_req(irn, pos); - - if (arch_register_req_is(req, limited)) { - /* in case of limited requirements: get the first allowed register */ - unsigned idx = rbitset_next(req->limited, 0, 1); - reg = arch_register_for_index(req->cls, idx); - } else { - /* otherwise get first register in class */ - reg = arch_register_for_index(req->cls, 0); - } - } - return reg; } @@ -215,7 +202,7 @@ static const arch_register_t *get_out_reg(const ir_node *irn, int pos) static char *get_unique_label(char *buf, size_t buflen, const char *prefix) { static unsigned long id = 0; - snprintf(buf, buflen, "%s%lu", prefix, ++id); + snprintf(buf, buflen, "%s%s%lu", be_gas_get_private_prefix(), prefix, ++id); return buf; } @@ -443,7 +430,7 @@ void ia32_emit_x87_mode_suffix(const ir_node *node) case 128: be_emit_char('t'); return; } } else { - assert(mode_is_int(mode)); + assert(mode_is_int(mode) || mode_is_reference(mode)); switch (get_mode_size_bits(mode)) { case 16: be_emit_char('s'); return; case 32: be_emit_char('l'); return; @@ -458,7 +445,7 @@ void ia32_emit_x87_mode_suffix(const ir_node *node) static char get_xmm_mode_suffix(ir_mode *mode) { assert(mode_is_float(mode)); - switch(get_mode_size_bits(mode)) { + switch (get_mode_size_bits(mode)) { case 32: return 's'; case 64: return 'd'; default: panic("Invalid XMM mode"); @@ -685,8 +672,8 @@ static void ia32_emitf(const ir_node *node, const char *fmt, ...) break; ++fmt; - while (1) { - switch(*fmt) { + for (;;) { + switch (*fmt) { case '*': mod |= EMIT_ALTERNATE_AM; break; case '#': mod |= EMIT_RESPECT_LS; break; case 'l': mod |= EMIT_LONG; break; @@ -863,7 +850,7 @@ void ia32_emit_binop(const ir_node *node) */ void ia32_emit_x87_binop(const ir_node *node) { - switch(get_ia32_op_type(node)) { + switch (get_ia32_op_type(node)) { case ia32_Normal: { const ia32_x87_attr_t *x87_attr = get_ia32_x87_attr_const(node); @@ -1060,7 +1047,6 @@ static void emit_ia32_Jcc(const ir_node *node) int need_parity_label = 0; const ir_node *proj_true; const ir_node *proj_false; - const ir_node *block; pn_Cmp pnc = get_ia32_condcode(node); pnc = determine_final_pnc(node, 0, pnc); @@ -1072,8 +1058,6 @@ static void emit_ia32_Jcc(const ir_node *node) proj_false = get_proj(node, pn_ia32_Jcc_false); assert(proj_false && "Jcc without false Proj"); - block = get_nodes_block(node); - if (can_be_fallthrough(proj_true)) { /* exchange both proj's so the second one can be omitted */ const ir_node *t = proj_true; @@ -1283,7 +1267,7 @@ static void generate_jump_table(jmp_tbl_t *tbl, const ir_node *node) const ir_edge_t *edge; /* fill the table structure */ - get_unique_label(tbl->label, SNPRINTF_BUF_LEN, ".TBL_"); + get_unique_label(tbl->label, SNPRINTF_BUF_LEN, "TBL_"); tbl->defProj = NULL; tbl->num_branches = get_irn_n_edges(node) - 1; tbl->branches = XMALLOCNZ(branch_t, tbl->num_branches); @@ -1411,7 +1395,7 @@ static const char* emit_asm_operand(const ir_node *node, const char *s) c = *(++s); /* parse modifiers */ - switch(c) { + switch (c) { case 0: ir_fprintf(stderr, "Warning: asm text (%+F) ends with %%\n", node); be_emit_char('%'); @@ -1490,7 +1474,7 @@ static const char* emit_asm_operand(const ir_node *node, const char *s) /* emit it */ if (modifier != 0) { be_emit_char('%'); - switch(modifier) { + switch (modifier) { case 'b': reg_name = ia32_get_mapped_reg_name(isa->regs_8bit, reg); break; @@ -1531,7 +1515,7 @@ static void emit_ia32_Asm(const ir_node *node) if (s[0] != '\t') be_emit_char('\t'); - while(*s != 0) { + while (*s != 0) { if (*s == '%') { s = emit_asm_operand(node, s); } else { @@ -1683,16 +1667,6 @@ static void emit_be_IncSP(const ir_node *node) } } -static inline bool is_unknown_reg(const arch_register_t *reg) -{ - if(reg == &ia32_gp_regs[REG_GP_UKNWN] - || reg == &ia32_xmm_regs[REG_XMM_UKNWN] - || reg == &ia32_vfp_regs[REG_VFP_UKNWN]) - return true; - - return false; -} - /** * Emits code for Copy/CopyKeep. */ @@ -1704,8 +1678,6 @@ static void Copy_emitter(const ir_node *node, const ir_node *op) if (in == out) { return; } - if (is_unknown_reg(in)) - return; /* copies of vf nodes aren't real... */ if (arch_register_get_class(in) == &ia32_reg_classes[CLASS_ia32_vfp]) return; @@ -2078,7 +2050,7 @@ static int should_align_block(const ir_node *block) return 0; n_cfgpreds = get_Block_n_cfgpreds(block); - for(i = 0; i < n_cfgpreds; ++i) { + for (i = 0; i < n_cfgpreds; ++i) { const ir_node *pred = get_Block_cfgpred_block(block, i); double pred_freq = get_block_execfreq(exec_freq, pred); @@ -2250,7 +2222,7 @@ void ia32_gen_routine(ia32_code_gen_t *ia32_cg, ir_graph *irg) ia32_register_emitters(); - get_unique_label(pic_base_label, sizeof(pic_base_label), ".PIC_BASE"); + get_unique_label(pic_base_label, sizeof(pic_base_label), "PIC_BASE"); be_dbg_method_begin(entity, be_abi_get_stack_layout(cg->birg->abi)); be_gas_emit_function_prolog(entity, ia32_cg_config.function_alignment); @@ -2726,7 +2698,7 @@ static void bemit_copy(const ir_node *copy) const arch_register_t *in = get_in_reg(copy, 0); const arch_register_t *out = get_out_reg(copy, 0); - if (in == out || is_unknown_reg(in)) + if (in == out) return; /* copies of vf nodes aren't real... */ if (arch_register_get_class(in) == &ia32_reg_classes[CLASS_ia32_vfp])