summaryrefslogtreecommitdiffhomepage
path: root/ir/be/TEMPLATE
diff options
context:
space:
mode:
authorChristoph Mallon <mallon@cs.uni-saarland.de>2015-08-07 22:58:20 +0200
committerChristoph Mallon <mallon@cs.uni-saarland.de>2015-08-07 22:58:20 +0200
commit4f7811db7b0ad2348da3689d6f43ed07aa48d2f5 (patch)
treeb384ad86639c532872c559efbe8b82e839cfbc79 /ir/be/TEMPLATE
parent154081effd225af540cbf398e00fc314d8f66f07 (diff)
template: Add a function prologue like all other backends do.
Diffstat (limited to 'ir/be/TEMPLATE')
-rw-r--r--ir/be/TEMPLATE/TEMPLATE_emitter.c15
-rw-r--r--ir/be/TEMPLATE/TEMPLATE_spec.pl1
-rw-r--r--ir/be/TEMPLATE/bearch_TEMPLATE.c16
3 files changed, 17 insertions, 15 deletions
diff --git a/ir/be/TEMPLATE/TEMPLATE_emitter.c b/ir/be/TEMPLATE/TEMPLATE_emitter.c
index 69b57f8..d7500d7 100644
--- a/ir/be/TEMPLATE/TEMPLATE_emitter.c
+++ b/ir/be/TEMPLATE/TEMPLATE_emitter.c
@@ -167,20 +167,6 @@ static void emit_be_IncSP(const ir_node *node)
TEMPLATE_emitf(node, "%s %S0, %d, %D0", op, offset);
}
-static void emit_Start(const ir_node *node)
-{
- ir_graph *irg = get_irn_irg(node);
- ir_type *frame_type = get_irg_frame_type(irg);
- unsigned size = get_type_size_bytes(frame_type);
-
- /* emit function prolog */
-
- /* allocate stackframe */
- if (size > 0) {
- TEMPLATE_emitf(node, "sub %%sp, %u, %%sp", size);
- }
-}
-
static void emit_Return(const ir_node *node)
{
ir_graph *irg = get_irn_irg(node);
@@ -217,7 +203,6 @@ static void TEMPLATE_register_emitters(void)
/* custom emitters not provided by the spec */
be_set_emitter(op_TEMPLATE_Jmp, emit_TEMPLATE_Jmp);
be_set_emitter(op_TEMPLATE_Return, emit_Return);
- be_set_emitter(op_TEMPLATE_Start, emit_Start);
be_set_emitter(op_be_IncSP, emit_be_IncSP);
}
diff --git a/ir/be/TEMPLATE/TEMPLATE_spec.pl b/ir/be/TEMPLATE/TEMPLATE_spec.pl
index ee88bf7..8af0c0e 100644
--- a/ir/be/TEMPLATE/TEMPLATE_spec.pl
+++ b/ir/be/TEMPLATE/TEMPLATE_spec.pl
@@ -172,6 +172,7 @@ Start => {
out_reqs => [ "sp:I", "r0", "r1", "r2", "r3", "mem" ],
outs => [ "stack", "arg0", "arg1", "arg2", "arg3", "M" ],
ins => [],
+ emit => "",
},
Return => {
diff --git a/ir/be/TEMPLATE/bearch_TEMPLATE.c b/ir/be/TEMPLATE/bearch_TEMPLATE.c
index 1fd1e61..a1c3f18 100644
--- a/ir/be/TEMPLATE/bearch_TEMPLATE.c
+++ b/ir/be/TEMPLATE/bearch_TEMPLATE.c
@@ -15,6 +15,7 @@
#include "bemodule.h"
#include "benode.h"
#include "bera.h"
+#include "besched.h"
#include "bestack.h"
#include "debug.h"
#include "gen_TEMPLATE_regalloc_if.h"
@@ -58,6 +59,19 @@ static const regalloc_if_t TEMPLATE_regalloc_if = {
.new_reload = TEMPLATE_new_reload,
};
+static void introduce_prologue(ir_graph *const irg)
+{
+ arch_register_t const *const sp = &TEMPLATE_registers[REG_SP];
+ ir_node *const start = get_irg_start(irg);
+ ir_node *const block = get_nodes_block(start);
+ ir_node *const initial_sp = be_get_initial_reg_value(irg, sp);
+ ir_type *const frame_type = get_irg_frame_type(irg);
+ unsigned const frame_size = get_type_size_bytes(frame_type);
+ ir_node *const incsp = be_new_IncSP(sp, block, initial_sp, frame_size, 0);
+ edges_reroute_except(initial_sp, incsp, incsp);
+ sched_add_after(start, incsp);
+}
+
static void TEMPLATE_generate_code(FILE *output, const char *cup_name)
{
be_begin(output, cup_name);
@@ -75,6 +89,8 @@ static void TEMPLATE_generate_code(FILE *output, const char *cup_name)
be_step_regalloc(irg, &TEMPLATE_regalloc_if);
+ introduce_prologue(irg);
+
be_fix_stack_nodes(irg, &TEMPLATE_registers[REG_SP]);
be_birg_from_irg(irg)->non_ssa_regs = NULL;