X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fbe%2FTEMPLATE%2Fbearch_TEMPLATE.c;h=60b3a2755d358b268655122a01bc933d3158d8a2;hb=dd277bbb2a94fbf96cb4c5b5df92470242dc697b;hp=2cb771d04e3a5124e85387e063f719b8e667e5eb;hpb=87965f5c94d561cb15233b80711123f6edc80b30;p=libfirm diff --git a/ir/be/TEMPLATE/bearch_TEMPLATE.c b/ir/be/TEMPLATE/bearch_TEMPLATE.c index 2cb771d04..60b3a2755 100644 --- a/ir/be/TEMPLATE/bearch_TEMPLATE.c +++ b/ir/be/TEMPLATE/bearch_TEMPLATE.c @@ -1,7 +1,29 @@ -/* The main TEMPLATE backend driver file. */ -/* $Id$ */ +/* + * Copyright (C) 1995-2007 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. + */ + +/** + * @file + * @brief The main TEMPLATE backend driver file. + * @version $Id$ + */ #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #include "pseudo_irg.h" @@ -14,7 +36,7 @@ #include "bitset.h" #include "debug.h" -#include "../bearch.h" /* the general register allocator interface */ +#include "../bearch_t.h" #include "../benode_t.h" #include "../belower.h" #include "../besched_t.h" @@ -25,8 +47,8 @@ #include "bearch_TEMPLATE_t.h" -#include "TEMPLATE_new_nodes.h" /* TEMPLATE nodes interface */ -#include "gen_TEMPLATE_regalloc_if.h" /* the generated interface (register type and class defenitions) */ +#include "TEMPLATE_new_nodes.h" +#include "gen_TEMPLATE_regalloc_if.h" #include "TEMPLATE_transform.h" #include "TEMPLATE_emitter.h" #include "TEMPLATE_map_regs.h" @@ -112,7 +134,9 @@ static void TEMPLATE_set_irn_reg(const void *self, ir_node *irn, const arch_regi } } -static const arch_register_t *TEMPLATE_get_irn_reg(const void *self, const ir_node *irn) { +static +const arch_register_t *TEMPLATE_get_irn_reg(const void *self, + const ir_node *irn) { int pos = 0; const arch_register_t *reg = NULL; @@ -122,8 +146,8 @@ static const arch_register_t *TEMPLATE_get_irn_reg(const void *self, const ir_no } if (is_TEMPLATE_irn(irn)) { - const arch_register_t **slots; - slots = get_TEMPLATE_slots(irn); + const arch_register_t * const *slots; + slots = get_TEMPLATE_slots_const(irn); reg = slots[pos]; } else { @@ -270,7 +294,7 @@ static void TEMPLATE_emit_and_done(void *self) { /* de-allocate code generator */ del_set(cg->reg_set); - free(self); + free(cg); } static void *TEMPLATE_cg_init(be_irg_t *birg); @@ -291,13 +315,14 @@ static const arch_code_generator_if_t TEMPLATE_code_gen_if = { * Initializes the code generator. */ static void *TEMPLATE_cg_init(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)); + const arch_env_t *arch_env = be_get_birg_arch_env(birg); + TEMPLATE_isa_t *isa = (TEMPLATE_isa_t *) arch_env->isa; + TEMPLATE_code_gen_t *cg = xmalloc(sizeof(*cg)); cg->impl = &TEMPLATE_code_gen_if; - cg->irg = birg->irg; + cg->irg = be_get_birg_irg(birg); cg->reg_set = new_set(TEMPLATE_cmp_irn_reg_assoc, 1024); - cg->arch_env = birg->main_env->arch_env; + cg->arch_env = arch_env; cg->isa = isa; cg->birg = birg; FIRM_DBG_REGISTER(cg->mod, "firm.be.TEMPLATE.cg"); @@ -328,8 +353,10 @@ static TEMPLATE_isa_t TEMPLATE_isa_template = { &TEMPLATE_general_purpose_regs[REG_BP], /* base pointer register */ -1, /* stack direction */ NULL, /* main environment */ + 7, /* costs for a spill instruction */ + 5, /* costs for a reload instruction */ }, - {}, /* emitter environment */ + { NULL, }, /* emitter environment */ }; /** @@ -363,7 +390,7 @@ static void TEMPLATE_done(void *self) { TEMPLATE_isa_t *isa = self; /* emit now all global declarations */ - be_gas_emit_decls(&isa->emit, isa->arch_isa.main_env); + be_gas_emit_decls(&isa->emit, isa->arch_isa.main_env, 0); be_emit_destroy_env(&isa->emit); free(self);