- add new finish call to architecture calls. This call is meant to be the last place...
authorMatthias Braun <matze@braunis.de>
Wed, 9 Aug 2006 12:43:11 +0000 (12:43 +0000)
committerMatthias Braun <matze@braunis.de>
Wed, 9 Aug 2006 12:43:11 +0000 (12:43 +0000)
ir/be/TEMPLATE/bearch_TEMPLATE.c
ir/be/arm/bearch_arm.c
ir/be/bearch.h
ir/be/bechordal_main.c
ir/be/bemain.c
ir/be/ia32/bearch_ia32.c
ir/be/mips/bearch_mips.c
ir/be/ppc32/bearch_ppc32.c

index 1cd6a88..d7fa82c 100644 (file)
@@ -263,10 +263,11 @@ static void TEMPLATE_prepare_graph(void *self) {
 /**
  * Called immediatly before emit phase.
  */
-static void TEMPLATE_finish_irg(ir_graph *irg, TEMPLATE_code_gen_t *cg) {
-       /* TODO: - fix offsets for nodes accessing stack
-                        - ...
-       */
+static void TEMPLATE_finish_irg(void *self) {
+       TEMPLATE_code_gen_t *cg = self;
+       ir_graph            *irg = cg->irg;
+
+       dump_ir_block_graph_sched(irg, "-TEMPLATE-finished");
 }
 
 
@@ -301,8 +302,6 @@ static void TEMPLATE_emit_and_done(void *self) {
                cg->emit_decls = 0;
        }
 
-       TEMPLATE_finish_irg(irg, cg);
-       dump_ir_block_graph_sched(irg, "-TEMPLATE-finished");
        TEMPLATE_gen_routine(out, irg, cg);
 
        cur_reg_set = NULL;
@@ -320,6 +319,7 @@ static const arch_code_generator_if_t TEMPLATE_code_gen_if = {
        TEMPLATE_before_sched,   /* before scheduling hook */
        TEMPLATE_before_ra,      /* before register allocation hook */
        TEMPLATE_after_ra,       /* after register allocation hook */
+       TEMPLATE_finish_irg,
        TEMPLATE_emit_and_done
 };
 
index 3914f4a..e2c1889 100644 (file)
@@ -286,7 +286,7 @@ static void arm_prepare_graph(void *self) {
 /**
  * Called immediately before emit phase.
  */
-static void arm_finish_irg(ir_graph *irg, arm_code_gen_t *cg) {
+static void arm_finish_irg(void *self) {
        /* TODO: - fix offsets for nodes accessing stack
                         - ...
        */
@@ -319,7 +319,6 @@ static void arm_emit_and_done(void *self) {
                cg->emit_decls = 0;
        }
 
-       arm_finish_irg(irg, cg);
        dump_ir_block_graph_sched(irg, "-arm-finished");
        arm_gen_routine(out, irg, cg);
 
@@ -532,6 +531,7 @@ static const arch_code_generator_if_t arm_code_gen_if = {
        arm_before_sched,   /* before scheduling hook */
        arm_before_ra,      /* before register allocation hook */
        NULL,               /* after register allocation */
+       arm_finish_irg,
        arm_emit_and_done,
 };
 
index 6da6382..70f9a9a 100644 (file)
@@ -524,7 +524,14 @@ struct _arch_code_generator_if_t {
        void (*after_ra)(void *self);
 
        /**
-        * Called after everything happened.
+        * Called directly before done is called. This should be the last place
+        * where the irg is modified.
+        */
+       void (*finish)(void *self);
+
+       /**
+        * Called after everything happened. This call should emit the final
+        * assembly code but avoid changing the irg.
         * The code generator must also be de-allocated here.
         */
        void (*done)(void *self);
@@ -545,6 +552,7 @@ do { \
 #define arch_code_generator_before_sched(cg)    _arch_cg_call(cg, before_sched)
 #define arch_code_generator_before_ra(cg)       _arch_cg_call(cg, before_ra)
 #define arch_code_generator_after_ra(cg)        _arch_cg_call(cg, after_ra)
+#define arch_code_generator_finish(cg)          _arch_cg_call(cg, finish)
 #define arch_code_generator_done(cg)            _arch_cg_call(cg, done)
 
 /**
index 4afa70c..19feace 100644 (file)
@@ -609,18 +609,6 @@ static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi)
        free_execfreq(chordal_env.exec_freq);
 
        BE_TIMER_POP(ra_timer.t_epilog);
-
-       BE_TIMER_PUSH(ra_timer.t_verify);
-
-       /* verify spillslots */
-       if (options.vrfy_option == BE_CH_VRFY_WARN) {
-               be_verify_schedule(irg);
-       }
-       else if (options.vrfy_option == BE_CH_VRFY_ASSERT) {
-               assert(be_verify_schedule(irg) && "Schedule verification failed");
-       }
-       BE_TIMER_POP(ra_timer.t_verify);
-
        BE_TIMER_POP(ra_timer.t_other);
 
 #undef BE_TIMER_PUSH
index d3ec2a7..4ee7aa4 100644 (file)
@@ -539,6 +539,10 @@ static void be_main_loop(FILE *file_handle)
                be_abi_fix_stack_bias(birg.abi);
                BE_TIMER_POP(t_abi);
 
+               BE_TIMER_PUSH(t_finish);
+               arch_code_generator_finish(birg.cg);
+               BE_TIMER_POP(t_finish);
+
                /* check schedule */
                BE_TIMER_PUSH(t_verify);
                be_sched_vrfy(birg.irg, vrfy_option);
index 269901c..c65aa13 100644 (file)
@@ -1039,6 +1039,17 @@ static void ia32_after_ra(void *self) {
        }
 }
 
+/**
+ * Last touchups for the graph before emit
+ */
+static void ia32_finish(void *self) {
+       ia32_code_gen_t *cg = self;
+       ir_graph        *irg = cg->irg;
+
+       ia32_finish_irg(irg, cg);
+       if (cg->dump)
+               be_dump(irg, "-finished", dump_ir_block_graph_sched);
+}
 
 /**
  * Emits the code, closes the output file and frees
@@ -1048,9 +1059,6 @@ static void ia32_codegen(void *self) {
        ia32_code_gen_t *cg = self;
        ir_graph        *irg = cg->irg;
 
-       ia32_finish_irg(irg, cg);
-       if (cg->dump)
-               be_dump(irg, "-finished", dump_ir_block_graph_sched);
        ia32_gen_routine(cg->isa->out, irg, cg);
 
        cur_reg_set = NULL;
@@ -1061,7 +1069,6 @@ static void ia32_codegen(void *self) {
        /* de-allocate code generator */
        del_set(cg->reg_set);
        free(self);
-
 }
 
 static void *ia32_cg_init(const be_irg_t *birg);
@@ -1073,6 +1080,7 @@ static const arch_code_generator_if_t ia32_code_gen_if = {
        ia32_before_sched,   /* before scheduling hook */
        ia32_before_ra,      /* before register allocation hook */
        ia32_after_ra,       /* after register allocation hook */
+       ia32_finish,         /* called before codegen */
        ia32_codegen         /* emit && done */
 };
 
index b41aa31..7819624 100644 (file)
@@ -448,10 +448,11 @@ static void mips_prepare_graph(void *self) {
 /**
  * Called immediately before emit phase.
  */
-static void mips_finish_irg(ir_graph *irg, mips_code_gen_t *cg) {
-       /* TODO: - fix offsets for nodes accessing stack
-                        - ...
-       */
+static void mips_finish_irg(void *self) {
+       mips_code_gen_t *cg = self;
+       ir_graph        *irg = cg->irg;
+
+       dump_ir_block_graph_sched(irg, "-mips-finished");
 }
 
 
@@ -487,8 +488,6 @@ static void mips_emit_and_done(void *self) {
                cg->emit_decls = 0;
        }
 
-       mips_finish_irg(irg, cg);
-       dump_ir_block_graph_sched(irg, "-mips-finished");
        mips_gen_routine(out, irg, cg);
 
        cur_reg_set = NULL;
@@ -511,6 +510,7 @@ static const arch_code_generator_if_t mips_code_gen_if = {
        mips_before_sched,   /* before scheduling hook */
        mips_before_ra,      /* before register allocation hook */
        mips_after_ra,
+       mips_finish_irg,
        mips_emit_and_done
 };
 
index 09b5276..c1222d6 100644 (file)
@@ -434,7 +434,7 @@ static void ppc32_prepare_graph(void *self) {
 /**
  * Called immediatly before emit phase.
  */
-static void ppc32_finish_irg(ir_graph *irg, ppc32_code_gen_t *cg) {
+static void ppc32_finish_irg(void *self) {
        /* TODO: - fix offsets for nodes accessing stack
                         - ...
        */
@@ -557,7 +557,6 @@ static void ppc32_emit_and_done(void *self) {
                cg->emit_decls = 0;
        }
 
-       ppc32_finish_irg(irg, cg);
        dump_ir_block_graph_sched(irg, "-ppc-finished");
        ppc32_gen_routine(out, irg, cg);
 
@@ -600,6 +599,7 @@ static const arch_code_generator_if_t ppc32_code_gen_if = {
        ppc32_before_sched,   /* before scheduling hook */
        ppc32_before_ra,      /* before register allocation hook */
        ppc32_after_ra,
+       ppc32_finish_irg,
        ppc32_emit_and_done
 };