From d96cf3cbdb3d7a08f9492aa70f97c02bb0c85e39 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Fri, 30 Nov 2012 08:42:56 +0100 Subject: [PATCH] bemain: Centrally call be_gas_end_compilation_unit() and be_emit_exit() instead of doing it per backend. Also remove the now write-only attribute main_env from struct arch_env_t. --- ir/be/TEMPLATE/bearch_TEMPLATE.c | 7 ------- ir/be/amd64/bearch_amd64.c | 7 ------- ir/be/arm/bearch_arm.c | 6 ------ ir/be/bearch.c | 4 +--- ir/be/bearch.h | 4 +--- ir/be/bemain.c | 5 ++++- ir/be/ia32/bearch_ia32.c | 7 ------- ir/be/sparc/bearch_sparc.c | 6 ------ 8 files changed, 6 insertions(+), 40 deletions(-) diff --git a/ir/be/TEMPLATE/bearch_TEMPLATE.c b/ir/be/TEMPLATE/bearch_TEMPLATE.c index 9fc08cb0c..c6f6b9cd5 100644 --- a/ir/be/TEMPLATE/bearch_TEMPLATE.c +++ b/ir/be/TEMPLATE/bearch_TEMPLATE.c @@ -139,7 +139,6 @@ static TEMPLATE_isa_t TEMPLATE_isa_template = { &TEMPLATE_registers[REG_SP], /* stack pointer register */ &TEMPLATE_registers[REG_BP], /* base pointer register */ 2, /* power of two stack alignment for calls, 2^2 == 4 */ - NULL, /* main environment */ 7, /* costs for a spill instruction */ 5, /* costs for a reload instruction */ true, /* no custom abi handling */ @@ -170,12 +169,6 @@ static arch_env_t *TEMPLATE_begin_codegeneration(void) */ static void TEMPLATE_end_codegeneration(void *self) { - TEMPLATE_isa_t *isa = (TEMPLATE_isa_t*)self; - - /* emit now all global declarations */ - be_gas_end_compilation_unit(isa->base.main_env); - - be_emit_exit(); free(self); } diff --git a/ir/be/amd64/bearch_amd64.c b/ir/be/amd64/bearch_amd64.c index c2764d839..3e9332ea4 100644 --- a/ir/be/amd64/bearch_amd64.c +++ b/ir/be/amd64/bearch_amd64.c @@ -252,7 +252,6 @@ static amd64_isa_t amd64_isa_template = { &amd64_registers[REG_RSP], /* stack pointer register */ &amd64_registers[REG_RBP], /* base pointer register */ 3, /* power of two stack alignment for calls, 2^2 == 4 */ - NULL, /* main environment */ 7, /* costs for a spill instruction */ 5, /* costs for a reload instruction */ false, /* no custom abi handling */ @@ -283,12 +282,6 @@ static arch_env_t *amd64_begin_codegeneration(void) */ static void amd64_end_codegeneration(void *self) { - amd64_isa_t *isa = (amd64_isa_t*)self; - - /* emit now all global declarations */ - be_gas_end_compilation_unit(isa->base.main_env); - - be_emit_exit(); free(self); } diff --git a/ir/be/arm/bearch_arm.c b/ir/be/arm/bearch_arm.c index f365e20cd..03a6d20da 100644 --- a/ir/be/arm/bearch_arm.c +++ b/ir/be/arm/bearch_arm.c @@ -407,7 +407,6 @@ static arm_isa_t arm_isa_template = { &arm_registers[REG_SP], /* stack pointer */ &arm_registers[REG_R11], /* base pointer */ 2, /* power of two stack alignment for calls, 2^2 == 4 */ - NULL, /* main environment */ 7, /* spill costs */ 5, /* reload costs */ true, /* we do have custom abi handling */ @@ -442,11 +441,6 @@ static arch_env_t *arm_begin_codegeneration(void) */ static void arm_end_codegeneration(void *self) { - arm_isa_t *isa = (arm_isa_t*)self; - - be_gas_end_compilation_unit(isa->base.main_env); - - be_emit_exit(); free(self); } diff --git a/ir/be/bearch.c b/ir/be/bearch.c index 9fc2c5604..17b529640 100644 --- a/ir/be/bearch.c +++ b/ir/be/bearch.c @@ -49,11 +49,9 @@ arch_register_req_t const arch_no_requirement = { }; /* Initialize the architecture environment struct. */ -arch_env_t *arch_env_begin_codegeneration(const arch_isa_if_t *isa_if, - be_main_env_t *main_env) +arch_env_t *arch_env_begin_codegeneration(const arch_isa_if_t *isa_if) { arch_env_t *arch_env = isa_if->begin_codegeneration(); - arch_env->main_env = main_env; return arch_env; } diff --git a/ir/be/bearch.h b/ir/be/bearch.h index d9a875a22..b6212ca02 100644 --- a/ir/be/bearch.h +++ b/ir/be/bearch.h @@ -215,8 +215,7 @@ static inline unsigned arch_get_irn_n_outs(const ir_node *node) /** * Start codegeneration */ -arch_env_t *arch_env_begin_codegeneration(const arch_isa_if_t *isa, - be_main_env_t *main_env); +arch_env_t *arch_env_begin_codegeneration(const arch_isa_if_t *isa); /** * Register an instruction set architecture @@ -547,7 +546,6 @@ struct arch_env_t { const arch_register_t *sp; /**< The stack pointer register. */ const arch_register_t *bp; /**< The base pointer register. */ int stack_alignment; /**< power of 2 stack alignment */ - const be_main_env_t *main_env; /**< the be main environment */ int spill_cost; /**< cost for a be_Spill node */ int reload_cost; /**< cost for a be_Reload node */ bool custom_abi : 1; /**< backend does all abi handling diff --git a/ir/be/bemain.c b/ir/be/bemain.c index 494e26872..b3aa7d994 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -411,7 +411,7 @@ static be_main_env_t *be_init_env(be_main_env_t *const env, char const *const co set_class_final(env->pic_trampolines_type, 1); memset(asm_constraint_flags, 0, sizeof(asm_constraint_flags)); - env->arch_env = arch_env_begin_codegeneration(isa_if, env); + env->arch_env = arch_env_begin_codegeneration(isa_if); return env; } @@ -820,6 +820,9 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) stat_ev_ctx_pop("bemain_irg"); } + be_gas_end_compilation_unit(&env); + be_emit_exit(); + arch_env_end_codegeneration(arch_env); be_done_env(&env); diff --git a/ir/be/ia32/bearch_ia32.c b/ir/be/ia32/bearch_ia32.c index f93ba3c7a..8b5a8ff2d 100644 --- a/ir/be/ia32/bearch_ia32.c +++ b/ir/be/ia32/bearch_ia32.c @@ -1640,7 +1640,6 @@ static ia32_isa_t ia32_isa_template = { &ia32_registers[REG_ESP], /* stack pointer register */ &ia32_registers[REG_EBP], /* base pointer register */ 2, /* power of two stack alignment, 2^2 == 4 */ - NULL, /* main environment */ 7, /* costs for a spill instruction */ 5, /* costs for a reload instruction */ false, /* no custom abi handling */ @@ -1667,12 +1666,6 @@ static arch_env_t *ia32_begin_codegeneration(void) static void ia32_end_codegeneration(void *self) { ia32_isa_t *isa = (ia32_isa_t*)self; - - /* emit now all global declarations */ - be_gas_end_compilation_unit(isa->base.main_env); - - be_emit_exit(); - pmap_destroy(isa->tv_ent); free(self); } diff --git a/ir/be/sparc/bearch_sparc.c b/ir/be/sparc/bearch_sparc.c index 5dd3cb4cb..30ae039ab 100644 --- a/ir/be/sparc/bearch_sparc.c +++ b/ir/be/sparc/bearch_sparc.c @@ -178,7 +178,6 @@ static sparc_isa_t sparc_isa_template = { &sparc_registers[REG_FRAME_POINTER], /* base pointer register */ 3, /* power of two stack alignment for calls */ - NULL, /* main environment */ 7, /* costs for a spill instruction */ 5, /* costs for a reload instruction */ true, /* custom abi handling */ @@ -442,12 +441,7 @@ static arch_env_t *sparc_begin_codegeneration(void) static void sparc_end_codegeneration(void *self) { sparc_isa_t *isa = (sparc_isa_t*)self; - - /* emit now all global declarations */ - be_gas_end_compilation_unit(isa->base.main_env); - pmap_destroy(isa->constants); - be_emit_exit(); free(isa); } -- 2.20.1