X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2FTEMPLATE%2FTEMPLATE_emitter.c;h=cd9a013a525e99e43a29c75e43cc01fcca12c677;hb=0ac0b440ce2d239c5e7e7db56b8273559d9a7741;hp=836ff6406e1b585765d6e5e96c513bf5b1ff39fc;hpb=2b31fff481c9cb3a16ca4a0dc3b15bad3e19e5ec;p=libfirm diff --git a/ir/be/TEMPLATE/TEMPLATE_emitter.c b/ir/be/TEMPLATE/TEMPLATE_emitter.c index 836ff6406..cd9a013a5 100644 --- a/ir/be/TEMPLATE/TEMPLATE_emitter.c +++ b/ir/be/TEMPLATE/TEMPLATE_emitter.c @@ -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 +#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); } }