#include "execfreq.h"
#include "irprofile.h"
#include "irpass_t.h"
+#include "ircons.h"
#include "bearch.h"
#include "be_t.h"
LC_OPT_LAST
};
-static be_module_list_entry_t *isa_ifs = NULL;
-
+static be_module_list_entry_t *isa_ifs = NULL;
+static bool isa_initialized = false;
asm_constraint_flags_t asm_constraint_flags[256];
+static void initialize_isa(void)
+{
+ if (isa_initialized)
+ return;
+ isa_if->init();
+ isa_initialized = true;
+}
+
+static void finish_isa(void)
+{
+ if (isa_initialized) {
+ isa_if->finish();
+ isa_initialized = false;
+ }
+}
+
void be_init_default_asm_constraint_flags(void)
{
asm_constraint_flags['?'] = ASM_CONSTRAINT_FLAG_NO_SUPPORT;
const char *c;
asm_constraint_flags_t tflags;
+ initialize_isa();
+
for (c = constraint; *c != '\0'; ++c) {
switch (*c) {
case '#':
int be_is_valid_clobber(const char *clobber)
{
+ initialize_isa();
+
/* memory is a valid clobber. (the frontend has to detect this case too,
* because it has to add memory edges to the asm) */
if (strcmp(clobber, "memory") == 0)
/* Finalize the Firm backend. */
void firm_be_finish(void)
{
+ finish_isa();
be_quit_modules();
}
/* Returns the backend parameter */
const backend_params *be_get_backend_param(void)
{
+ initialize_isa();
return isa_if->get_params();
}
env->pic_symbols_type = new_type_struct(NEW_ID("$PIC_SYMBOLS_TYPE"));
env->cup_name = compilation_unit_name;
- remove_irp_type(env->pic_trampolines_type);
- remove_irp_type(env->pic_symbols_type);
set_class_final(env->pic_trampolines_type, 1);
memset(asm_constraint_flags, 0, sizeof(asm_constraint_flags));
- env->arch_env = arch_env_init(isa_if, env);
+ env->arch_env = arch_env_begin_codegeneration(isa_if, env);
return env;
}
birg->irg = irg;
birg->main_env = env;
obstack_init(&birg->obst);
+ birg->lv = be_liveness_new(irg);
edges_deactivate_kind(irg, EDGE_KIND_DEP);
edges_activate_kind(irg, EDGE_KIND_DEP);
{
size_t i;
+ initialize_isa();
+
+ /* shouldn't lower program twice */
+ assert(get_irp_phase_state() != phase_low);
+
isa_if->lower_for_target();
/* set the phase to low */
for (i = get_irp_n_irgs(); i > 0;) {
be_timing = (be_options.timing == BE_TIME_ON);
+ /* perform target lowering if it didn't happen yet */
+ if (get_irp_phase_state() != phase_low)
+ be_lower_for_target();
+
if (be_timing) {
for (i = 0; i < T_LAST+1; ++i) {
be_timers[i] = ir_timer_new();
prof_filename);
}
}
- if (be_options.opt_profile_generate) {
+ if (num_birgs > 0 && be_options.opt_profile_generate) {
ir_graph *prof_init_irg
= ir_profile_instrument(prof_filename);
initialize_birg(&birgs[num_birgs], prof_init_irg, &env);
dump(DUMP_RA, irg, "ra");
be_timer_push(T_FINISH);
- if (arch_env->impl->finish != NULL)
- arch_env->impl->finish(irg);
+ if (arch_env->impl->finish_graph != NULL)
+ arch_env->impl->finish_graph(irg);
be_timer_pop(T_FINISH);
dump(DUMP_FINAL, irg, "finish");
stat_ev_ctx_pop("bemain_irg");
}
- arch_env_done(arch_env);
+ arch_env_end_codegeneration(arch_env);
ir_profile_free();
be_done_env(&env);