X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Famd64%2Famd64_emitter.c;h=3754cdc7898ad4a7877b0a98ad99d6b160ce2201;hb=c32482bc042c9f0591bec432ccb6dfcadbad4cb7;hp=1a7a417bc517bbc5597a166a21263c10f2b9b57a;hpb=ea6e9be0bea5ad0079ab09d5e494cf7b5c889552;p=libfirm diff --git a/ir/be/amd64/amd64_emitter.c b/ir/be/amd64/amd64_emitter.c index 1a7a417bc..3754cdc78 100644 --- a/ir/be/amd64/amd64_emitter.c +++ b/ir/be/amd64/amd64_emitter.c @@ -20,7 +20,6 @@ /** * @file * @brief emit assembler for a backend graph - * @version $Id: amd64_emitter.c 26746 2009-11-27 08:53:15Z matze $ */ #include "config.h" @@ -36,10 +35,9 @@ #include "irargs_t.h" #include "irprog.h" -#include "../besched.h" -#include "../begnuas.h" -#include "../beblocksched.h" -#include "../be_dbgout.h" +#include "besched.h" +#include "begnuas.h" +#include "beblocksched.h" #include "amd64_emitter.h" #include "gen_amd64_emitter.h" @@ -47,63 +45,7 @@ #include "amd64_nodes_attr.h" #include "amd64_new_nodes.h" -#define SNPRINTF_BUF_LEN 128 - -#include "../benode.h" - -/** - * Returns the register at in position pos. - */ -static const arch_register_t *get_in_reg(const ir_node *node, int pos) -{ - ir_node *op; - const arch_register_t *reg = NULL; - - assert(get_irn_arity(node) > pos && "Invalid IN position"); - - /* The out register of the operator at position pos is the - in register we need. */ - op = get_irn_n(node, pos); - - reg = arch_get_irn_register(op); - - assert(reg && "no in register found"); - return reg; -} - -/** - * Returns the register at out position pos. - */ -static const arch_register_t *get_out_reg(const ir_node *node, int pos) -{ - ir_node *proj; - const arch_register_t *reg = NULL; - - /* 1st case: irn is not of mode_T, so it has only */ - /* one OUT register -> good */ - /* 2nd case: irn is of mode_T -> collect all Projs and ask the */ - /* Proj with the corresponding projnum for the register */ - - if (get_irn_mode(node) != mode_T) { - reg = arch_get_irn_register(node); - } else if (is_amd64_irn(node)) { - reg = arch_irn_get_register(node, pos); - } else { - const ir_edge_t *edge; - - foreach_out_edge(node, edge) { - proj = get_edge_src_irn(edge); - assert(is_Proj(proj) && "non-Proj from mode_T node"); - if (get_Proj_proj(proj) == pos) { - reg = arch_get_irn_register(proj); - break; - } - } - } - - assert(reg && "no out register found"); - return reg; -} +#include "benode.h" /************************************************************* * _ _ __ _ _ @@ -138,12 +80,12 @@ void amd64_emit_fp_offset(const ir_node *node) void amd64_emit_source_register(const ir_node *node, int pos) { - amd64_emit_register(get_in_reg(node, pos)); + amd64_emit_register(arch_get_irn_register_in(node, pos)); } void amd64_emit_dest_register(const ir_node *node, int pos) { - amd64_emit_register(get_out_reg(node, pos)); + amd64_emit_register(arch_get_irn_register_out(node, pos)); } /** @@ -189,7 +131,7 @@ static void emit_amd64_SymConst(const ir_node *irn) key.u.id = get_entity_ld_ident(attr->entity); key.is_ident = 1; key.label = 0; - entry = (sym_or_tv_t *)set_insert(sym_or_tv, &key, sizeof(key), HASH_PTR(key.u.generic)); + entry = set_insert(sym_or_tv_t, sym_or_tv, &key, sizeof(key), hash_ptr(key.u.generic)); if (entry->label == 0) { /* allocate a label */ entry->label = get_unique_label(); @@ -259,9 +201,11 @@ static void emit_amd64_Jmp(const ir_node *node) be_emit_cstring("\tjmp "); amd64_emit_cfop_target(node); } else { - be_emit_cstring("\t/* fallthrough to "); - amd64_emit_cfop_target(node); - be_emit_cstring(" */"); + if (be_options.verbose_asm) { + be_emit_cstring("\t/* fallthrough to "); + amd64_emit_cfop_target(node); + be_emit_cstring(" */"); + } } be_emit_finish_line_gas(node); } @@ -271,17 +215,16 @@ static void emit_amd64_Jmp(const ir_node *node) */ static void emit_amd64_Jcc(const ir_node *irn) { - const ir_edge_t *edge; - const ir_node *proj_true = NULL; - const ir_node *proj_false = NULL; - const ir_node *block; - const ir_node *next_block; - const char *suffix; - const amd64_attr_t *attr = get_amd64_attr_const(irn); - ir_relation relation = attr->ext.relation; - ir_node *op1 = get_irn_n(irn, 0); - const amd64_attr_t *cmp_attr = get_amd64_attr_const(op1); - bool is_signed = !cmp_attr->data.cmp_unsigned; + const ir_node *proj_true = NULL; + const ir_node *proj_false = NULL; + const ir_node *block; + const ir_node *next_block; + const char *suffix; + const amd64_attr_t *attr = get_amd64_attr_const(irn); + ir_relation relation = attr->ext.relation; + ir_node *op1 = get_irn_n(irn, 0); + const amd64_attr_t *cmp_attr = get_amd64_attr_const(op1); + bool is_signed = !cmp_attr->data.cmp_unsigned; assert(is_amd64_Cmp(op1)); @@ -334,10 +277,12 @@ static void emit_amd64_Jcc(const ir_node *irn) be_emit_finish_line_gas(proj_true); if (get_cfop_target_block(proj_false) == next_block) { - be_emit_cstring("\t/* fallthrough to "); - amd64_emit_cfop_target(proj_false); - be_emit_cstring(" */"); - be_emit_finish_line_gas(proj_false); + if (be_options.verbose_asm) { + be_emit_cstring("\t/* fallthrough to "); + amd64_emit_cfop_target(proj_false); + be_emit_cstring(" */"); + be_emit_finish_line_gas(proj_false); + } } else { be_emit_cstring("\tjmp "); amd64_emit_cfop_target(proj_false); @@ -377,13 +322,13 @@ static void emit_be_Copy(const ir_node *irn) { ir_mode *mode = get_irn_mode(irn); - if (get_in_reg(irn, 0) == get_out_reg(irn, 0)) { + if (arch_get_irn_register_in(irn, 0) == arch_get_irn_register_out(irn, 0)) { /* omitted Copy */ return; } if (mode_is_float(mode)) { - panic("emit_be_Copy: move not supported for FP"); + panic("move not supported for FP"); } else if (mode_is_data(mode)) { be_emit_cstring("\tmov "); amd64_emit_source_register(irn, 0); @@ -391,7 +336,7 @@ static void emit_be_Copy(const ir_node *irn) amd64_emit_dest_register(irn, 0); be_emit_finish_line_gas(irn); } else { - panic("emit_be_Copy: move not supported for this mode"); + panic("move not supported for this mode"); } } @@ -499,9 +444,9 @@ static void emit_amd64_binop_op(const ir_node *irn, int second_op) */ static void emit_amd64_binop(const ir_node *irn) { - const arch_register_t *reg_s1 = get_in_reg(irn, 0); - const arch_register_t *reg_s2 = get_in_reg(irn, 1); - const arch_register_t *reg_d1 = get_out_reg(irn, 0); + const arch_register_t *reg_s1 = arch_get_irn_register_in(irn, 0); + const arch_register_t *reg_s2 = arch_get_irn_register_in(irn, 1); + const arch_register_t *reg_d1 = arch_get_irn_register_out(irn, 0); int second_op = 0; @@ -541,7 +486,7 @@ static inline void set_emitter(ir_op *op, emit_func arm_emit_node) static void amd64_register_emitters(void) { /* first clear the generic function pointer for all ops */ - clear_irp_opcodes_generic_func(); + ir_clear_opcodes_generic_func(); /* register all emitter functions defined in spec */ amd64_register_spec_emitters(); @@ -588,16 +533,12 @@ static void amd64_emit_node(const ir_node *node) */ static void amd64_gen_block(ir_node *block, void *data) { - ir_node *node; (void) data; if (! is_Block(block)) return; - be_gas_emit_block_name(block); - be_emit_char(':'); - - be_emit_write_line(); + be_gas_begin_block(block, true); sched_foreach(block, node) { amd64_emit_node(node); @@ -635,8 +576,7 @@ void amd64_gen_routine(ir_graph *irg) blk_sched = be_create_block_schedule(irg); - be_dbg_method_begin(entity); - be_gas_emit_function_prolog(entity, 4); + be_gas_emit_function_prolog(entity, 4, NULL); irg_block_walk_graph(irg, amd64_gen_labels, NULL, NULL); @@ -655,7 +595,4 @@ void amd64_gen_routine(ir_graph *irg) } be_gas_emit_function_epilog(entity); - be_dbg_method_end(); - be_emit_char('\n'); - be_emit_write_line(); }