we don't need no stinking selfs
[libfirm] / ir / be / arm / arm_emitter.c
index bc673e2..7a3affe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
 #include "irargs_t.h"
 #include "error.h"
 #include "raw_bitset.h"
+#include "dbginfo.h"
 
 #include "../besched.h"
 #include "../beblocksched.h"
 #include "../beirg_t.h"
 #include "../begnuas.h"
+#include "../be_dbgout.h"
 
 #include "arm_emitter.h"
 #include "gen_arm_emitter.h"
@@ -221,9 +223,9 @@ void arm_emit_immediate(const ir_node *node) {
        const arm_attr_t *attr = get_arm_attr_const(node);
 
        if (ARM_GET_SHF_MOD(attr) == ARM_SHF_IMM) {
-               be_emit_irprintf("#0x%X", arm_decode_imm_w_shift(get_arm_value(node)));
+               be_emit_irprintf("#0x%X", arm_decode_imm_w_shift(get_arm_imm_value(node)));
        } else if (ARM_GET_FPA_IMM(attr)) {
-               be_emit_irprintf("#0x%F", get_arm_value(node));
+               be_emit_irprintf("#%s", arm_get_fpa_imm_name(get_arm_imm_value(node)));
        } else if (is_arm_SymConst(node))
                be_emit_ident(get_arm_symconst_id(node));
        else {
@@ -239,7 +241,7 @@ void arm_emit_shift(const ir_node *node) {
 
        mod = get_arm_shift_modifier(node);
        if (ARM_HAS_SHIFT(mod)) {
-               long v = get_tarval_long(get_arm_value(node));
+               long v = get_arm_imm_value(node);
 
                be_emit_irprintf(", %s #%l", arm_shf_mod_name(mod), v);
        }
@@ -296,7 +298,7 @@ static void emit_arm_fpaConst(const ir_node *irn) {
        unsigned label;
        ir_mode *mode;
 
-       key.u.tv     = get_arm_value(irn);
+       key.u.tv     = get_fpaConst_value(irn);
        key.is_ident = 0;
        key.label    = 0;
        entry = (sym_or_tv_t *)set_insert(sym_or_tv, &key, sizeof(key), HASH_PTR(key.u.generic));
@@ -477,7 +479,7 @@ static int reg_cmp(const void *a, const void *b) {
  * Create the CopyB instruction sequence.
  */
 static void emit_arm_CopyB(const ir_node *irn) {
-       unsigned int size = get_tarval_long(get_arm_value(irn));
+       unsigned size = (unsigned)get_arm_imm_value(irn);
 
        const char *tgt = arch_register_get_name(get_in_reg(irn, 0));
        const char *src = arch_register_get_name(get_in_reg(irn, 1));
@@ -504,7 +506,7 @@ static void emit_arm_CopyB(const ir_node *irn) {
        be_emit_string(src);
        be_emit_cstring(")->(");
        arm_emit_source_register(irn, 0);
-       be_emit_irprintf(" [%d bytes], Uses ", size);
+       be_emit_irprintf(" [%u bytes], Uses ", size);
        be_emit_string(t0);
        be_emit_cstring(", ");
        be_emit_string(t1);
@@ -984,40 +986,6 @@ static void arm_register_emitters(void) {
 #undef SILENCE
 }
 
-static const char *last_name = NULL;
-static unsigned last_line = -1;
-static unsigned num = -1;
-
-/**
- * Emit the debug support for node node.
- */
-static void arm_emit_dbg(const ir_node *irn) {
-       dbg_info *db = get_irn_dbg_info(irn);
-       unsigned lineno;
-       const char *fname = be_retrieve_dbg_info(db, &lineno);
-
-       if (! cg->birg->main_env->options->stabs_debug_support)
-               return;
-
-       if (fname) {
-               if (last_name != fname) {
-                       last_line = -1;
-                       be_dbg_include_begin(cg->birg->main_env->db_handle, fname);
-                       last_name = fname;
-               }
-               if (last_line != lineno) {
-                       char name[64];
-
-                       snprintf(name, sizeof(name), ".LM%u", ++num);
-                       last_line = lineno;
-                       be_dbg_line(cg->birg->main_env->db_handle, lineno, name);
-                       be_emit_string(name);
-                       be_emit_cstring(":\n");
-                       be_emit_write_line();
-               }
-       }
-}
-
 /**
  * Emits code for a node.
  */
@@ -1026,7 +994,7 @@ static void arm_emit_node(const ir_node *irn) {
 
        if (op->ops.generic) {
                emit_func *emit = (emit_func *)op->ops.generic;
-               arm_emit_dbg(irn);
+               be_dbg_set_dbg_info(get_irn_dbg_info(irn));
                (*emit)(irn);
        } else {
                be_emit_cstring("\t/* TODO */");
@@ -1096,7 +1064,7 @@ static void arm_gen_block(ir_node *block, ir_node *prev_block) {
        ir_node *irn;
 
        arm_emit_block_header(block, prev_block);
-       arm_emit_dbg(block);
+       be_dbg_set_dbg_info(get_irn_dbg_info(block));
        sched_foreach(block, irn) {
                arm_emit_node(irn);
        }
@@ -1163,10 +1131,10 @@ void arm_gen_routine(const arm_code_gen_t *arm_cg, ir_graph *irg) {
        ir_node *last_block = NULL;
 
        cg        = arm_cg;
+       isa       = (const arm_isa_t *)cg->arch_env->isa;
        arch_env  = cg->arch_env;
        sym_or_tv = new_set(cmp_sym_or_tv, 8);
 
-
        arm_register_emitters();
 
        /* create the block schedule. For now, we don't need it earlier. */