Fixed name mangling for private entities
[libfirm] / ir / be / mips / mips_emitter.c
index a10de95..4578924 100644 (file)
@@ -23,9 +23,7 @@
  * @author  Matthias Braun, Mehdi
  * @version $Id$
  */
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include <limits.h>
 
@@ -42,7 +40,7 @@
 #include "error.h"
 
 #include "../besched.h"
-#include "../benode_t.h"
+#include "../benode.h"
 #include "../beutil.h"
 #include "../begnuas.h"
 
@@ -58,10 +56,6 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
 
 #define SNPRINTF_BUF_LEN 128
 
-static const mips_isa_t      *isa;
-static const arch_env_t      *arch_env;
-static const mips_code_gen_t *cg;
-
 /**
  * Returns the register at in position pos.
  */
@@ -76,7 +70,7 @@ static const arch_register_t *get_in_reg(const ir_node *node, int pos)
           in register we need. */
        op = get_irn_n(node, pos);
 
-       reg = arch_get_irn_register(arch_env, op);
+       reg = arch_get_irn_register(op);
 
        assert(reg && "no in register found");
        return reg;
@@ -96,9 +90,9 @@ static const arch_register_t *get_out_reg(const ir_node *node, int pos)
        /*           Proj with the corresponding projnum for the register */
 
        if (get_irn_mode(node) != mode_T) {
-               reg = arch_get_irn_register(arch_env, node);
+               reg = arch_get_irn_register(node);
        } else if (is_mips_irn(node)) {
-               reg = get_mips_out_reg(node, pos);
+               reg = arch_irn_get_register(node, pos);
        } else {
                const ir_edge_t *edge;
 
@@ -106,7 +100,7 @@ static const arch_register_t *get_out_reg(const ir_node *node, int pos)
                        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(arch_env, proj);
+                               reg = arch_get_irn_register(proj);
                                break;
                        }
                }
@@ -160,7 +154,7 @@ static const char *get_symconst_str(ir_node *node)
                id = get_entity_ident(get_SymConst_entity(node));
                return get_id_str(id);
        default:
-               assert(0);
+               panic("Unsupported SymConst kind");
        }
 
        return NULL;
@@ -311,13 +305,11 @@ void mips_emit_IncSP(const ir_node *node)
        int   offset = be_get_IncSP_offset(node);
 
        if(offset == 0) {
-               be_emit_cstring("\t/* omitted IncSP with 0 */");
-               be_emit_finish_line_gas(node);
                return;
        }
 
        if(offset > 0xffff || offset < -0xffff) {
-               panic("stackframe > 2^16 bytes not supported yet\n");
+               panic("stackframe > 2^16 bytes not supported yet");
        }
 
        if(offset > 0) {
@@ -431,9 +423,9 @@ const char* mips_get_block_label(const ir_node* block)
  */
 static void mips_emit_block_label(const ir_node *block)
 {
-       if (has_Block_label(block)) {
-               be_emit_string(be_gas_block_label_prefix());
-               be_emit_irprintf("%lu", get_Block_label(block));
+       if (has_Block_entity(block)) {
+               ir_entity *entity = get_Block_entity(block);
+               be_gas_emit_entity(entity);
        } else {
                be_emit_cstring(BLOCK_PREFIX);
                be_emit_irprintf("%ld", get_irn_node_nr(block));
@@ -556,11 +548,11 @@ void emit_mips_jump_table(const ir_node *irn)
        const mips_attr_t *attr = get_mips_attr_const(irn);
 
        /* fill the table structure */
-       tbl.label        = xmalloc(SNPRINTF_BUF_LEN);
+       tbl.label        = XMALLOCN(char, SNPRINTF_BUF_LEN);
        tbl.label        = get_unique_label(tbl.label, SNPRINTF_BUF_LEN, "JMPTBL_");
        tbl.defBlock     = NULL;
        tbl.num_branches = get_irn_n_edges(irn);
-       tbl.branches     = xcalloc(tbl.num_branches, sizeof(tbl.branches[0]));
+       tbl.branches     = XMALLOCNZ(branch_t, tbl.num_branches);
        tbl.min_value    = INT_MAX;
        tbl.max_value    = INT_MIN;
 
@@ -683,12 +675,11 @@ void mips_register_emitters(void)
        register_emitter(op_be_Keep, mips_emit_nothing);
        register_emitter(op_be_Barrier, mips_emit_nothing);
        register_emitter(op_be_Return, mips_emit_Return);
-       register_emitter(op_be_RegParams, mips_emit_nothing);
+       register_emitter(op_be_Start, mips_emit_nothing);
        register_emitter(op_be_Spill, mips_emit_this_shouldnt_happen);
        register_emitter(op_be_Reload, mips_emit_this_shouldnt_happen);
        register_emitter(op_be_Perm, mips_emit_Perm);
 
-       register_emitter(op_Start, mips_emit_nothing);
        register_emitter(op_Proj, mips_emit_nothing);
        register_emitter(op_SymConst, mips_emit_this_shouldnt_happen);
        register_emitter(op_Const, mips_emit_this_shouldnt_happen);
@@ -806,20 +797,15 @@ void mips_gen_routine(mips_code_gen_t *mips_cg, ir_graph *irg)
 {
        int i, n;
 
-       cg       = mips_cg;
-       isa      = (const mips_isa_t*) cg->arch_env;
-       arch_env = cg->arch_env;
-
        mips_register_emitters();
 
        irg_block_walk_graph(irg, mips_gen_labels, NULL, NULL);
 
        mips_emit_func_prolog(irg);
 
-       dump_ir_block_graph_sched(irg, "-kaputtelist");
-
-       for (i = 0, n = mips_get_sched_n_blocks(cg); i < n; ++i) {
-               ir_node *block = mips_get_sched_block(cg, i);
+       n = ARR_LEN(mips_cg->block_schedule);
+       for (i = 0; i < n; ++i) {
+               ir_node *block = mips_cg->block_schedule[i];
                mips_gen_block(block);
        }