Commit bdf50dd0 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

beemit: Provide be_emit_node(), which merges the (almost) identical node emit...

beemit: Provide be_emit_node(), which merges the (almost) identical node emit functions of the backends.
parent 0f422870
......@@ -242,23 +242,6 @@ static void TEMPLATE_register_emitters(void)
be_set_emitter(op_be_Keep, be_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);
}
}
/**
* Walks over the nodes in a block connected by scheduling edges
* and emits code for each node.
......@@ -268,7 +251,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);
}
}
......
......@@ -483,23 +483,6 @@ static void amd64_register_emitters(void)
be_set_emitter(op_be_Start, be_emit_nothing);
}
typedef void (*emit_func_ptr) (const ir_node *);
/**
* Emits code for a node.
*/
static void amd64_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);
}
}
/**
* Walks over the nodes in a block connected by scheduling edges
* and emits code for each node.
......@@ -514,7 +497,7 @@ static void amd64_gen_block(ir_node *block, void *data)
be_gas_begin_block(block, true);
sched_foreach(block, node) {
amd64_emit_node(node);
be_emit_node(node);
}
}
......
......@@ -752,23 +752,6 @@ static void arm_register_emitters(void)
be_set_emitter(op_be_Keep, be_emit_nothing);
}
/**
* Emits code for a node.
*/
static void arm_emit_node(const ir_node *irn)
{
ir_op *op = get_irn_op(irn);
if (op->ops.generic) {
emit_func *emit = (emit_func *)op->ops.generic;
be_dwarf_location(get_irn_dbg_info(irn));
(*emit)(irn);
} else {
panic("Error: No emit handler for node %+F (graph %+F)\n",
irn, get_irn_irg(irn));
}
}
/**
* emit the block label if needed.
*/
......@@ -803,7 +786,7 @@ static void arm_gen_block(ir_node *block, ir_node *prev_block)
arm_emit_block_header(block, prev_block);
be_dwarf_location(get_irn_dbg_info(block));
sched_foreach(block, irn) {
arm_emit_node(irn);
be_emit_node(irn);
}
}
......
......@@ -25,8 +25,10 @@
*/
#include "config.h"
#include "bedwarf.h"
#include "beemitter.h"
#include "be_t.h"
#include "error.h"
#include "irnode_t.h"
#include "irprintf.h"
#include "ident.h"
......@@ -113,3 +115,12 @@ void be_emit_nothing(ir_node const *const node)
{
(void)node;
}
void be_emit_node(ir_node const *const node)
{
be_dwarf_location(get_irn_dbg_info(node));
ir_op *const op = get_irn_op(node);
emit_func *const emit = get_generic_function_ptr(emit_func, op);
DEBUG_ONLY(if (!emit) panic("no emit handler for node %+F (%+G, graph %+F)\n", node, node, get_irn_irg(node));)
emit(node);
}
......@@ -133,4 +133,9 @@ static inline void be_set_emitter(ir_op *const op, emit_func *const func)
void be_emit_nothing(ir_node const *node);
/**
* Emit code for a node.
*/
void be_emit_node(ir_node const *node);
#endif
......@@ -1431,8 +1431,6 @@ static void ia32_register_emitters(void)
#undef IA32_EMIT
}
typedef void (*emit_func_ptr) (const ir_node *);
/**
* Assign and emit an exception label if the current instruction can fail.
*/
......@@ -1455,8 +1453,6 @@ static void ia32_assign_exc_label(ir_node *node)
*/
static void ia32_emit_node(ir_node *node)
{
ir_op *op = get_irn_op(node);
DBG((dbg, LEVEL_1, "emitting code for %+F\n", node));
if (is_ia32_irn(node)) {
......@@ -1476,15 +1472,8 @@ static void ia32_emit_node(ir_node *node)
}
}
}
if (op->ops.generic) {
emit_func_ptr func = (emit_func_ptr) op->ops.generic;
be_dwarf_location(get_irn_dbg_info(node));
(*func) (node);
} else {
panic("no emit handler for node %+F (%+G, graph %+F)\n", node, node, get_irn_irg(node));
}
be_emit_node(node);
if (sp_relative) {
int sp_change = arch_get_sp_bias(node);
......
......@@ -65,7 +65,6 @@ static ir_heights_t *heights;
static unsigned *delay_slot_fillers;
static pmap *delay_slots;
static void sparc_emit_node(const ir_node *node);
static bool emitting_delay_slot;
/**
......@@ -741,7 +740,7 @@ static void fill_delay_slot(const ir_node *node)
if (filler != NULL) {
assert(!is_no_instruction(filler));
assert(!emits_multiple_instructions(filler));
sparc_emit_node(filler);
be_emit_node(filler);
} else {
sparc_emitf(NULL, "nop");
}
......@@ -1301,23 +1300,6 @@ static void sparc_register_emitters(void)
be_set_emitter(op_sparc_Start, be_emit_nothing);
}
/**
* Emits code for a node.
*/
static void sparc_emit_node(const ir_node *node)
{
ir_op *op = get_irn_op(node);
if (op->ops.generic) {
emit_func *func = (emit_func*)op->ops.generic;
be_dwarf_location(get_irn_dbg_info(node));
(*func) (node);
} else {
panic("No emit handler for node %+F (graph %+F)\n", node,
get_irn_irg(node));
}
}
static bool block_needs_label(const ir_node *block, const ir_node *sched_prev)
{
if (get_Block_entity(block) != NULL)
......@@ -1349,7 +1331,7 @@ static void sparc_emit_block(ir_node *block, ir_node *prev)
sched_foreach(block, node) {
if (rbitset_is_set(delay_slot_fillers, get_irn_idx(node)))
continue;
sparc_emit_node(node);
be_emit_node(node);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment