Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
4f7811db
Commit
4f7811db
authored
Aug 07, 2015
by
Christoph Mallon
Browse files
template: Add a function prologue like all other backends do.
parent
154081ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
ir/be/TEMPLATE/TEMPLATE_emitter.c
View file @
4f7811db
...
...
@@ -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
);
}
...
...
ir/be/TEMPLATE/TEMPLATE_spec.pl
View file @
4f7811db
...
...
@@ -172,6 +172,7 @@ Start => {
out_reqs
=>
[
"
sp:I
",
"
r0
",
"
r1
",
"
r2
",
"
r3
",
"
mem
"
],
outs
=>
[
"
stack
",
"
arg0
",
"
arg1
",
"
arg2
",
"
arg3
",
"
M
"
],
ins
=>
[]
,
emit
=>
"",
},
Return
=>
{
...
...
ir/be/TEMPLATE/bearch_TEMPLATE.c
View file @
4f7811db
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment