becopyilp: Do not advertise the switch to dump the solution, because this is not...
[libfirm] / ir / be / TEMPLATE / TEMPLATE_emitter.c
index 836ff64..cd9a013 100644 (file)
@@ -1,20 +1,6 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
- *
  * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
  */
 
 /**
@@ -25,6 +11,7 @@
 
 #include <limits.h>
 
+#include "error.h"
 #include "xmalloc.h"
 #include "tv.h"
 #include "iredges.h"
@@ -54,7 +41,7 @@ static void TEMPLATE_emit_immediate(const ir_node *node)
 
 static void emit_register(const arch_register_t *reg)
 {
-       be_emit_string(arch_register_get_name(reg));
+       be_emit_string(reg->name);
 }
 
 static void TEMPLATE_emit_source_register(const ir_node *node, int pos)
@@ -218,21 +205,6 @@ static void emit_be_Return(const ir_node *node)
        TEMPLATE_emitf(node, "ret");
 }
 
-static void emit_nothing(const ir_node *node)
-{
-       (void) node;
-}
-
-/**
- * The type of a emitter function.
- */
-typedef void (emit_func)(const ir_node *node);
-
-static inline void set_emitter(ir_op *op, emit_func func)
-{
-       op->ops.generic = (op_func)func;
-}
-
 /**
  * Enters the emitter functions for handled nodes into the generic
  * pointer of an opcode.
@@ -246,31 +218,14 @@ static void TEMPLATE_register_emitters(void)
        TEMPLATE_register_spec_emitters();
 
        /* custom emitters not provided by the spec */
-       set_emitter(op_TEMPLATE_Jmp,   emit_TEMPLATE_Jmp);
-       set_emitter(op_be_IncSP,       emit_be_IncSP);
-       set_emitter(op_be_Return,      emit_be_Return);
-       set_emitter(op_be_Start,       emit_be_Start);
+       be_set_emitter(op_TEMPLATE_Jmp, emit_TEMPLATE_Jmp);
+       be_set_emitter(op_be_IncSP,     emit_be_IncSP);
+       be_set_emitter(op_be_Return,    emit_be_Return);
+       be_set_emitter(op_be_Start,     emit_be_Start);
 
        /* no need to emit anything for the following nodes */
-       set_emitter(op_Phi,            emit_nothing);
-       set_emitter(op_be_Keep,        emit_nothing);
-}
-
-typedef void (*emit_func_ptr) (const ir_node *);
-
-/**
- * Emits code for a node.
- */
-static void TEMPLATE_emit_node(const ir_node *node)
-{
-       ir_op               *op       = get_irn_op(node);
-
-       if (op->ops.generic) {
-               emit_func_ptr func = (emit_func_ptr) op->ops.generic;
-               (*func) (node);
-       } else {
-               ir_fprintf(stderr, "No emitter for node %+F\n", node);
-       }
+       be_set_emitter(op_Phi,     be_emit_nothing);
+       be_set_emitter(op_be_Keep, be_emit_nothing);
 }
 
 /**
@@ -282,7 +237,7 @@ static void TEMPLATE_emit_block(ir_node *block)
        be_gas_begin_block(block, true);
 
        sched_foreach(block, node) {
-               TEMPLATE_emit_node(node);
+               be_emit_node(node);
        }
 }