Commit b2b916ba authored by Michael Beck's avatar Michael Beck
Browse files

updated for new i/f and latest backend praktikum changes

parent 5f8cf26f
......@@ -15,6 +15,7 @@
#include "irprintf.h"
#include "irop_t.h"
#include "irargs_t.h"
#include "irprog.h"
#include "../besched.h"
......@@ -296,10 +297,10 @@ static void TEMPLATE_register_emitters(void) {
* Emits code for a node.
*/
void TEMPLATE_emit_node(ir_node *irn, void *env) {
emit_env_t *emit_env = env;
FILE *F = emit_env->out;
ir_op *op = get_irn_op(irn);
DEBUG_ONLY(firm_dbg_module_t *mod = emit_env->mod;)
TEMPLATE_emit_env_t *emit_env = env;
FILE *F = emit_env->out;
ir_op *op = get_irn_op(irn);
DEBUG_ONLY(firm_dbg_module_t *mod = emit_env->mod;)
DBG((mod, LEVEL_1, "emitting code for %+F\n", irn));
......@@ -317,12 +318,13 @@ void TEMPLATE_emit_node(ir_node *irn, void *env) {
* and emits code for each node.
*/
void TEMPLATE_gen_block(ir_node *block, void *env) {
TEMPLATE_emit_env_t *emit_env = env;
ir_node *irn;
if (! is_Block(block))
return;
fprintf(((emit_env_t *)env)->out, "BLOCK_%ld:\n", get_irn_node_nr(block));
fprintf(emit_env->out, "BLOCK_%ld:\n", get_irn_node_nr(block));
sched_foreach(block, irn) {
TEMPLATE_emit_node(irn, env);
}
......@@ -365,7 +367,7 @@ void TEMPLATE_gen_labels(ir_node *block, void *env) {
* Main driver
*/
void TEMPLATE_gen_routine(FILE *F, ir_graph *irg, const TEMPLATE_code_gen_t *cg) {
emit_env_t emit_env;
TEMPLATE_emit_env_t emit_env;
emit_env.out = F;
emit_env.arch_env = cg->arch_env;
......
......@@ -9,12 +9,12 @@
#include "bearch_TEMPLATE_t.h"
typedef struct _emit_env_t {
typedef struct _TEMPLATE_emit_env_t {
FILE *out;
const arch_env_t *arch_env;
const TEMPLATE_code_gen_t *cg;
DEBUG_ONLY(firm_dbg_module_t *mod;)
} emit_env_t;
} TEMPLATE_emit_env_t;
const lc_arg_env_t *TEMPLATE_get_arg_env(void);
......
......@@ -294,10 +294,10 @@ static void TEMPLATE_after_ra(void *self) {
static void TEMPLATE_emit_and_done(void *self) {
TEMPLATE_code_gen_t *cg = self;
ir_graph *irg = cg->irg;
FILE *out = cg->out;
FILE *out = cg->isa->out;
if (cg->emit_decls) {
TEMPLATE_gen_decls(cg->out);
TEMPLATE_gen_decls(out);
cg->emit_decls = 0;
}
......@@ -312,7 +312,7 @@ static void TEMPLATE_emit_and_done(void *self) {
free(self);
}
static void *TEMPLATE_cg_init(FILE *F, const be_irg_t *birg);
static void *TEMPLATE_cg_init(const be_irg_t *birg);
static const arch_code_generator_if_t TEMPLATE_code_gen_if = {
TEMPLATE_cg_init,
......@@ -326,15 +326,15 @@ static const arch_code_generator_if_t TEMPLATE_code_gen_if = {
/**
* Initializes the code generator.
*/
static void *TEMPLATE_cg_init(FILE *F, const be_irg_t *birg) {
static void *TEMPLATE_cg_init(const be_irg_t *birg) {
TEMPLATE_isa_t *isa = (TEMPLATE_isa_t *)birg->main_env->arch_env->isa;
TEMPLATE_code_gen_t *cg = xmalloc(sizeof(*cg));
cg->impl = &TEMPLATE_code_gen_if;
cg->irg = birg->irg;
cg->reg_set = new_set(TEMPLATE_cmp_irn_reg_assoc, 1024);
cg->out = F;
cg->arch_env = birg->main_env->arch_env;
cg->isa = isa;
cg->birg = birg;
FIRM_DBG_REGISTER(cg->mod, "firm.be.TEMPLATE.cg");
......@@ -375,7 +375,7 @@ static TEMPLATE_isa_t TEMPLATE_isa_template = {
/**
* Initializes the backend ISA and opens the output file.
*/
static void *TEMPLATE_init(void) {
static void *TEMPLATE_init(FILE *outfile) {
static int inited = 0;
TEMPLATE_isa_t *isa;
......@@ -385,6 +385,8 @@ static void *TEMPLATE_init(void) {
isa = xcalloc(1, sizeof(*isa));
memcpy(isa, &TEMPLATE_isa_template, sizeof(*isa));
isa->out = outfile;
TEMPLATE_register_init(isa);
TEMPLATE_create_opcodes();
......@@ -489,7 +491,7 @@ void TEMPLATE_get_call_abi(const void *self, ir_type *method_type, be_abi_call_t
/* be_abi_call_param_reg(abi, i, reg); */
/* default: all parameters on stack */
be_abi_call_param_stack(abi, i);
be_abi_call_param_stack(abi, i, 4, 0, 0);
}
/* TODO: set correct return register */
......@@ -537,6 +539,14 @@ static const list_sched_selector_t *TEMPLATE_get_list_sched_selector(const void
return &TEMPLATE_sched_selector;
}
/**
* Returns the necessary byte alignment for storing a register of given class.
*/
static int TEMPLATE_get_reg_class_alignment(const void *self, const arch_register_class_t *cls) {
ir_mode *mode = arch_register_class_mode(cls);
return get_mode_size_bytes(mode);
}
#ifdef WITH_LIBCORE
static void TEMPLATE_register_options(lc_opt_entry_t *ent)
{
......@@ -544,9 +554,6 @@ static void TEMPLATE_register_options(lc_opt_entry_t *ent)
#endif /* WITH_LIBCORE */
const arch_isa_if_t TEMPLATE_isa_if = {
#ifdef WITH_LIBCORE
TEMPLATE_register_options,
#endif
TEMPLATE_init,
TEMPLATE_done,
TEMPLATE_get_n_reg_class,
......@@ -556,4 +563,8 @@ const arch_isa_if_t TEMPLATE_isa_if = {
TEMPLATE_get_irn_handler,
TEMPLATE_get_code_generator_if,
TEMPLATE_get_list_sched_selector,
TEMPLATE_get_reg_class_alignment,
#ifdef WITH_LIBCORE
TEMPLATE_register_options
#endif
};
......@@ -5,26 +5,29 @@
#include "bearch_TEMPLATE.h"
#include "TEMPLATE_nodes_attr.h"
#include "../be.h"
#include "set.h"
typedef struct _TEMPLATE_isa_t TEMPLATE_isa_t;
typedef struct _TEMPLATE_code_gen_t {
const arch_code_generator_if_t *impl; /* implementation */
ir_graph *irg; /* current irg */
FILE *out; /* output file */
const arch_env_t *arch_env; /* the arch env */
set *reg_set; /* set to memorize registers for FIRM nodes (e.g. phi) */
int emit_decls; /* flag indicating if decls were already emitted */
const be_irg_t *birg; /* The be-irg (contains additional information about the irg) */
DEBUG_ONLY(firm_dbg_module_t *mod;) /* debugging module */
const arch_code_generator_if_t *impl; /**< implementation */
ir_graph *irg; /**< current irg */
const arch_env_t *arch_env; /**< the arch env */
set *reg_set; /**< set to memorize registers for FIRM nodes (e.g. phi) */
int emit_decls; /**< flag indicating if decls were already emitted */
TEMPLATE_isa_t *isa; /**< the isa instance */
const be_irg_t *birg; /**< The be-irg (contains additional information about the irg) */
DEBUG_ONLY(firm_dbg_module_t *mod;) /**< debugging module */
} TEMPLATE_code_gen_t;
typedef struct _TEMPLATE_isa_t {
struct _TEMPLATE_isa_t {
const arch_isa_if_t *impl;
const arch_register_t *sp; /** The stack pointer register. */
const arch_register_t *bp; /** The base pointer register. */
const int stack_dir; /** -1 for decreasing, 1 for increasing. */
int num_codegens;
} TEMPLATE_isa_t;
const arch_register_t *sp; /**< The stack pointer register. */
const arch_register_t *bp; /**< The base pointer register. */
const int stack_dir; /**< -1 for decreasing, 1 for increasing. */
int num_codegens;
FILE *out; /**< output file */
};
typedef struct _TEMPLATE_irn_ops_t {
......
Supports Markdown
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