Commit 880f870d authored by Christoph Mallon's avatar Christoph Mallon
Browse files

bemain: Centrally call be_emit_init() and be_gas_begin_compilation_unit()...

bemain: Centrally call be_emit_init() and be_gas_begin_compilation_unit() instead of doing it per backend.
parent c57decb6
......@@ -157,14 +157,11 @@ static void TEMPLATE_finish(void)
TEMPLATE_free_opcodes();
}
static arch_env_t *TEMPLATE_begin_codegeneration(const be_main_env_t *env)
static arch_env_t *TEMPLATE_begin_codegeneration(void)
{
TEMPLATE_isa_t *isa = XMALLOC(TEMPLATE_isa_t);
*isa = TEMPLATE_isa_template;
be_emit_init(env->file_handle);
be_gas_begin_compilation_unit(env);
return &isa->base;
}
......
......@@ -270,14 +270,11 @@ static void amd64_finish(void)
amd64_free_opcodes();
}
static arch_env_t *amd64_begin_codegeneration(const be_main_env_t *env)
static arch_env_t *amd64_begin_codegeneration(void)
{
amd64_isa_t *isa = XMALLOC(amd64_isa_t);
*isa = amd64_isa_template;
be_emit_init(env->file_handle);
be_gas_begin_compilation_unit(env);
return &isa->base;
}
......
......@@ -427,16 +427,13 @@ static void arm_finish(void)
arm_free_opcodes();
}
static arch_env_t *arm_begin_codegeneration(const be_main_env_t *env)
static arch_env_t *arm_begin_codegeneration(void)
{
arm_isa_t *isa = XMALLOC(arm_isa_t);
*isa = arm_isa_template;
be_gas_emit_types = false;
be_emit_init(env->file_handle);
be_gas_begin_compilation_unit(env);
return &isa->base;
}
......
......@@ -73,7 +73,6 @@ extern be_options_t be_options;
struct be_main_env_t {
arch_env_t *arch_env;
FILE *file_handle;
const char *cup_name; /**< name of the compilation unit */
pmap *ent_trampoline_map; /**< A map containing PIC trampolines for methods. */
ir_type *pic_trampolines_type; /**< Class type containing all trampolines */
......
......@@ -52,7 +52,7 @@ arch_register_req_t const arch_no_requirement = {
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 = isa_if->begin_codegeneration(main_env);
arch_env_t *arch_env = isa_if->begin_codegeneration();
arch_env->main_env = main_env;
return arch_env;
}
......
......@@ -431,7 +431,7 @@ struct arch_isa_if_t {
* Start codegeneration
* @return a new isa instance
*/
arch_env_t *(*begin_codegeneration)(const be_main_env_t *env);
arch_env_t *(*begin_codegeneration)(void);
/**
* Free the isa instance.
......
......@@ -53,6 +53,7 @@
#include "bearch.h"
#include "be_t.h"
#include "begnuas.h"
#include "bemodule.h"
#include "beutil.h"
#include "benode.h"
......@@ -398,11 +399,9 @@ ir_type *be_get_type_long_double(void)
* @param env an empty environment
* @param file_handle the file handle where the output will be written to
*/
static be_main_env_t *be_init_env(be_main_env_t *env, FILE *file_handle,
const char *compilation_unit_name)
static be_main_env_t *be_init_env(be_main_env_t *const env, char const *const compilation_unit_name)
{
memset(env, 0, sizeof(*env));
env->file_handle = file_handle;
env->ent_trampoline_map = pmap_create();
env->pic_trampolines_type = new_type_class(NEW_ID("$PIC_TRAMPOLINE_TYPE"));
env->ent_pic_symbol_map = pmap_create();
......@@ -564,7 +563,10 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
}
}
be_init_env(&env, file_handle, cup_name);
be_init_env(&env, cup_name);
be_emit_init(file_handle);
be_gas_begin_compilation_unit(&env);
arch_env = env.arch_env;
......
......@@ -1649,7 +1649,7 @@ static ia32_isa_t ia32_isa_template = {
IA32_FPU_ARCH_X87, /* FPU architecture */
};
static arch_env_t *ia32_begin_codegeneration(const be_main_env_t *env)
static arch_env_t *ia32_begin_codegeneration(void)
{
ia32_isa_t *isa = XMALLOC(ia32_isa_t);
......@@ -1658,9 +1658,6 @@ static arch_env_t *ia32_begin_codegeneration(const be_main_env_t *env)
*isa = ia32_isa_template;
isa->tv_ent = pmap_create();
be_emit_init(env->file_handle);
be_gas_begin_compilation_unit(env);
return &isa->base;
}
......
......@@ -424,7 +424,7 @@ static void sparc_finish(void)
sparc_free_opcodes();
}
static arch_env_t *sparc_begin_codegeneration(const be_main_env_t *env)
static arch_env_t *sparc_begin_codegeneration(void)
{
sparc_isa_t *isa = XMALLOC(sparc_isa_t);
*isa = sparc_isa_template;
......@@ -433,9 +433,6 @@ static arch_env_t *sparc_begin_codegeneration(const be_main_env_t *env)
be_gas_elf_type_char = '#';
be_gas_elf_variant = ELF_VARIANT_SPARC;
be_emit_init(env->file_handle);
be_gas_begin_compilation_unit(env);
return &isa->base;
}
......
Markdown is supported
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