avoid unnecessary passing around of arch_env_t* in backend APIs
authorMatthias Braun <matze@braunis.de>
Thu, 15 Jul 2010 18:11:14 +0000 (18:11 +0000)
committerMatthias Braun <matze@braunis.de>
Thu, 15 Jul 2010 18:11:14 +0000 (18:11 +0000)
[r27749]

16 files changed:
ir/be/TEMPLATE/bearch_TEMPLATE.c
ir/be/TEMPLATE/bearch_TEMPLATE_t.h
ir/be/amd64/bearch_amd64.c
ir/be/amd64/bearch_amd64_t.h
ir/be/arm/bearch_arm.c
ir/be/arm/bearch_arm_t.h
ir/be/beabi.c
ir/be/beabi.h
ir/be/beintlive_t.h
ir/be/benode.c
ir/be/benode.h
ir/be/bespillslots.c
ir/be/ia32/bearch_ia32.c
ir/be/ia32/bearch_ia32_t.h
ir/be/sparc/bearch_sparc.c
ir/be/sparc/bearch_sparc_t.h

index 34d200a..1a2dbae 100644 (file)
@@ -218,7 +218,7 @@ static arch_env_t *TEMPLATE_init(FILE *outfile)
        TEMPLATE_register_init();
        TEMPLATE_create_opcodes(&TEMPLATE_irn_ops);
 
-       return &isa->arch_env;
+       return &isa->base;
 }
 
 
@@ -231,7 +231,7 @@ static void TEMPLATE_done(void *self)
        TEMPLATE_isa_t *isa = self;
 
        /* emit now all global declarations */
-       be_gas_emit_decls(isa->arch_env.main_env);
+       be_gas_emit_decls(isa->base.main_env);
 
        be_emit_exit();
        free(self);
@@ -269,17 +269,15 @@ static const arch_register_class_t *TEMPLATE_get_reg_class_for_mode(const ir_mod
 
 typedef struct {
        be_abi_call_flags_bits_t flags;
-       const arch_env_t *arch_env;
-       ir_graph *irg;
+       ir_graph                *irg;
 } TEMPLATE_abi_env_t;
 
-static void *TEMPLATE_abi_init(const be_abi_call_t *call, const arch_env_t *arch_env, ir_graph *irg)
+static void *TEMPLATE_abi_init(const be_abi_call_t *call, ir_graph *irg)
 {
        TEMPLATE_abi_env_t *env = XMALLOC(TEMPLATE_abi_env_t);
        be_abi_call_flags_t fl = be_abi_call_get_flags(call);
        env->flags    = fl.bits;
        env->irg      = irg;
-       env->arch_env = arch_env;
        return env;
 }
 
@@ -317,14 +315,15 @@ static ir_type *TEMPLATE_get_between_type(void *self)
 static const arch_register_t *TEMPLATE_abi_prologue(void *self, ir_node **mem,
                                                     pmap *reg_map, int *stack_bias)
 {
-       TEMPLATE_abi_env_t *env = self;
+       TEMPLATE_abi_env_t *env      = self;
+       const arch_env_t   *arch_env = be_get_irg_arch_env(env->irg);
        (void) reg_map;
        (void) mem;
        (void) stack_bias;
 
        if (env->flags.try_omit_fp)
-               return env->arch_env->sp;
-       return env->arch_env->bp;
+               return arch_env->sp;
+       return arch_env->bp;
 }
 
 /* Build the epilog */
index 59d8428..739e96e 100644 (file)
@@ -42,7 +42,7 @@ struct TEMPLATE_code_gen_t {
 };
 
 struct TEMPLATE_isa_t {
-       arch_env_t  arch_env;      /**< must be derived from arch_isa */
+       arch_env_t  base;      /**< must be derived from arch_isa */
 };
 
 /**
index 974a145..73dd0cd 100644 (file)
@@ -337,7 +337,7 @@ static arch_env_t *amd64_init(FILE *outfile)
        amd64_register_init();
        amd64_create_opcodes(&amd64_irn_ops);
 
-       return &isa->arch_env;
+       return &isa->base;
 }
 
 
@@ -350,7 +350,7 @@ static void amd64_done(void *self)
        amd64_isa_t *isa = self;
 
        /* emit now all global declarations */
-       be_gas_emit_decls(isa->arch_env.main_env);
+       be_gas_emit_decls(isa->base.main_env);
 
        be_emit_exit();
        free(self);
@@ -386,17 +386,15 @@ static const arch_register_class_t *amd64_get_reg_class_for_mode(const ir_mode *
 
 typedef struct {
        be_abi_call_flags_bits_t flags;
-       const arch_env_t *arch_env;
        ir_graph *irg;
 } amd64_abi_env_t;
 
-static void *amd64_abi_init(const be_abi_call_t *call, const arch_env_t *arch_env, ir_graph *irg)
+static void *amd64_abi_init(const be_abi_call_t *call, ir_graph *irg)
 {
        amd64_abi_env_t *env = XMALLOC(amd64_abi_env_t);
        be_abi_call_flags_t fl = be_abi_call_get_flags(call);
        env->flags    = fl.bits;
        env->irg      = irg;
-       env->arch_env = arch_env;
        return env;
 }
 
@@ -435,7 +433,7 @@ static const arch_register_t *amd64_abi_prologue(void *self, ir_node **mem,
                                                     pmap *reg_map, int *stack_bias)
 {
        amd64_abi_env_t  *env  = self;
-       const arch_env_t *aenv = env->arch_env;
+       const arch_env_t *aenv = be_get_irg_arch_env(env->irg);
        (void) mem;
        (void) stack_bias;
        (void) aenv;
@@ -444,10 +442,10 @@ static const arch_register_t *amd64_abi_prologue(void *self, ir_node **mem,
        if (!env->flags.try_omit_fp) {
                /* FIXME: maybe later here should be some code to generate
                 * the usual abi prologue */
-               return env->arch_env->bp;
+               return aenv->bp;
        }
 
-       return env->arch_env->sp;
+       return aenv->sp;
 }
 
 /* Build the epilog */
@@ -455,7 +453,7 @@ static void amd64_abi_epilogue(void *self, ir_node *bl, ir_node **mem,
                                pmap *reg_map)
 {
        amd64_abi_env_t  *env  = self;
-       const arch_env_t *aenv = env->arch_env;
+       const arch_env_t *aenv = be_get_irg_arch_env(env->irg);
        ir_node          *curr_sp  = be_abi_reg_map_get(reg_map, aenv->sp);
        ir_node          *curr_bp  = be_abi_reg_map_get(reg_map, aenv->bp);
        (void) bl;
index 8d4716c..ff0fe9a 100644 (file)
@@ -40,11 +40,11 @@ struct amd64_code_gen_t {
        ir_graph                       *irg;            /**< current irg */
        amd64_isa_t                    *isa;            /**< the isa instance */
        char                            dump;           /**< set to 1 if graphs should be dumped */
-       ir_node  *noreg_gp;                             /**< unique NoReg_GP node */
+       ir_node                        *noreg_gp;       /**< unique NoReg_GP node */
 };
 
 struct amd64_isa_t {
-       arch_env_t  arch_env;      /**< must be derived from arch_isa */
+       arch_env_t  base;      /**< must be derived from arch_isa */
 };
 
 /**
index f58b90e..a4b25fa 100644 (file)
@@ -550,7 +550,7 @@ static arch_env_t *arm_init(FILE *file_handle)
        be_emit_write_line();
 
        inited = 1;
-       return &isa->arch_env;
+       return &isa->base;
 }
 
 
@@ -562,7 +562,7 @@ static void arm_done(void *self)
 {
        arm_isa_t *isa = self;
 
-       be_gas_emit_decls(isa->arch_env.main_env);
+       be_gas_emit_decls(isa->base.main_env);
 
        be_emit_exit();
        free(self);
index 8baa276..96fd189 100644 (file)
@@ -148,7 +148,7 @@ typedef struct _arm_code_gen_t {
 
 
 struct _arm_isa_t {
-       arch_env_t     arch_env;      /**< must be derived from arch_env_t */
+       arch_env_t     base;      /**< must be derived from arch_env_t */
        int            gen_reg_names; /**< use generic register names instead of SP, LR, PC */
        int            fpu_arch;      /**< FPU architecture */
        arm_code_gen_t *cg;           /**< current code generator */
index fc8fdab..9bc4ca4 100644 (file)
@@ -2301,7 +2301,7 @@ be_abi_irg_t *be_abi_introduce(ir_graph *irg)
                Beware: init backend abi call object after processing calls,
                otherwise some information might be not yet available.
        */
-       env->cb = env->call->cb->init(env->call, arch_env, irg);
+       env->cb = env->call->cb->init(env->call, irg);
 
        /* Process the IRG */
        modify_irg(irg);
index ddc727e..7d801ac 100644 (file)
@@ -56,11 +56,10 @@ struct _be_abi_callbacks_t {
        /**
         * Initialize the callback object.
         * @param call The call object.
-        * @param aenv The architecture environment.
         * @param irg  The graph with the method.
         * @return     Some pointer. This pointer is passed to all other callback functions as self object.
         */
-       void *(*init)(const be_abi_call_t *call, const arch_env_t *aenv, ir_graph *irg);
+       void *(*init)(const be_abi_call_t *call, ir_graph *irg);
 
        /**
         * Destroy the callback object.
index 3115087..9961b6e 100644 (file)
@@ -131,8 +131,6 @@ static inline int be_values_interfere(const be_lv_t *lv, const ir_node *a, const
                const ir_edge_t *edge;
                ir_node *bb = get_nodes_block(b);
 
-               //stat_ev_dbl("beintlive_ignore", arch_irn_is(be_get_irg_arch_env(lv->irg), a, ignore));
-
                /*
                 * If a is live end in b's block it is
                 * live at b's definition (a dominates b)
@@ -160,7 +158,7 @@ static inline int be_values_interfere(const be_lv_t *lv, const ir_node *a, const
                                goto end;
                        }
                }
-       }
+       }
 
 end:
        return res;
index 2d6dff7..3383f38 100644 (file)
@@ -441,9 +441,10 @@ void be_Perm_reduce(ir_node *perm, int new_size, int *map)
        set_irn_in(perm, new_size, new_in);
 }
 
-ir_node *be_new_MemPerm(const arch_env_t *arch_env, ir_node *bl, int n, ir_node *in[])
+ir_node *be_new_MemPerm(ir_node *block, int n, ir_node *in[])
 {
-       ir_graph                     *irg       = get_Block_irg(bl);
+       ir_graph                     *irg       = get_Block_irg(block);
+       const arch_env_t             *arch_env  = be_get_irg_arch_env(irg);
        ir_node                      *frame     = get_irg_frame(irg);
        const arch_register_t        *sp        = arch_env->sp;
        ir_node                      *irn;
@@ -454,7 +455,7 @@ ir_node *be_new_MemPerm(const arch_env_t *arch_env, ir_node *bl, int n, ir_node
        real_in[0] = frame;
        memcpy(&real_in[1], in, n * sizeof(real_in[0]));
 
-       irn = new_ir_node(NULL, irg, bl, op_be_MemPerm, mode_T, n+1, real_in);
+       irn = new_ir_node(NULL, irg, block, op_be_MemPerm, mode_T, n+1, real_in);
 
        init_node_attr(irn, n + 1, n);
        be_node_set_reg_class_in(irn, 0, sp->reg_class);
index 880981a..d9f8a01 100644 (file)
@@ -147,8 +147,7 @@ void be_Perm_reduce(ir_node *perm, int new_size, int *map);
  * used as spillslots). MemPerm nodes perform this operation without modifying
  * any register values.
  */
-ir_node *be_new_MemPerm(const arch_env_t *arch_env, ir_node *block, int n,
-                        ir_node *in[]);
+ir_node *be_new_MemPerm(ir_node *block, int n, ir_node *in[]);
 ir_node *be_new_Keep(ir_node *block, int arity, ir_node *in[]);
 
 void be_Keep_add_node(ir_node *keep, const arch_register_class_t *cls,
index 684720a..c0502a5 100644 (file)
@@ -68,7 +68,6 @@ typedef struct affinity_edge_t {
 
 struct be_fec_env_t {
        struct obstack         obst;
-       const arch_env_t      *arch_env;
        ir_graph              *irg;
        set                   *spills;
        ir_node              **reloads;
@@ -702,7 +701,6 @@ static ir_node *get_end_of_block_insertion_point(ir_node* block)
 
 static void create_memperms(be_fec_env_t *env)
 {
-       const arch_env_t *arch_env = env->arch_env;
        ir_graph         *irg      = env->irg;
        memperm_t        *memperm;
 
@@ -720,8 +718,8 @@ static void create_memperms(be_fec_env_t *env)
                        nodes[i] = arg;
                }
 
-               mempermnode = be_new_MemPerm(arch_env, memperm->block,
-                                            memperm->entrycount, nodes);
+               mempermnode = be_new_MemPerm(memperm->block, memperm->entrycount,
+                                            nodes);
 
                /* insert node into schedule */
                blockend = get_end_of_block_insertion_point(memperm->block);
@@ -765,13 +763,11 @@ static int count_spillslots(const be_fec_env_t *env)
 
 be_fec_env_t *be_new_frame_entity_coalescer(ir_graph *irg)
 {
-       const arch_env_t *arch_env = be_get_irg_arch_env(irg);
-       be_fec_env_t     *env      = XMALLOC(be_fec_env_t);
+       be_fec_env_t *env = XMALLOCZ(be_fec_env_t);
 
        be_liveness_assure_chk(be_assure_liveness(irg));
 
        obstack_init(&env->obst);
-       env->arch_env       = arch_env;
        env->irg            = irg;
        env->spills         = new_set(cmp_spill, 10);
        env->reloads        = NEW_ARR_F(ir_node*, 0);
@@ -816,17 +812,21 @@ void be_assign_entities(be_fec_env_t *env,
  */
 static void collect_spills_walker(ir_node *node, void *data)
 {
-       be_fec_env_t *env = data;
-       const ir_mode *mode;
+       be_fec_env_t                *env = data;
+       const ir_mode               *mode;
        const arch_register_class_t *cls;
-       int align;
+       int                          align;
+       ir_graph                    *irg;
+       const arch_env_t            *arch_env;
 
        if (! (arch_irn_classify(node) & arch_irn_class_reload))
                return;
 
-       mode  = get_irn_mode(node);
-       cls   = arch_get_irn_reg_class_out(node);
-       align = arch_env_get_reg_class_alignment(env->arch_env, cls);
+       mode     = get_irn_mode(node);
+       cls      = arch_get_irn_reg_class_out(node);
+       irg      = get_irn_irg(node);
+       arch_env = be_get_irg_arch_env(irg);
+       align    = arch_env_get_reg_class_alignment(arch_env, cls);
 
        be_node_needs_frame_entity(env, node, mode, align);
 }
index 401c2cf..3be7fe6 100644 (file)
@@ -219,7 +219,6 @@ static arch_irn_class_t ia32_classify(const ir_node *irn)
  */
 typedef struct {
        be_abi_call_flags_bits_t flags;  /**< The call flags. */
-       const arch_env_t *aenv;          /**< The architecture environment. */
        ir_graph *irg;                   /**< The associated graph. */
 } ia32_abi_env_t;
 
@@ -284,7 +283,7 @@ static const arch_register_t *ia32_abi_prologue(void *self, ir_node **mem, pmap
 {
        ia32_abi_env_t   *env      = self;
        ia32_code_gen_t  *cg       = ia32_current_cg;
-       const arch_env_t *arch_env = env->aenv;
+       const arch_env_t *arch_env = be_get_irg_arch_env(env->irg);
 
        ia32_curr_fp_ommitted = env->flags.try_omit_fp;
        if (! env->flags.try_omit_fp) {
@@ -341,7 +340,7 @@ static const arch_register_t *ia32_abi_prologue(void *self, ir_node **mem, pmap
 static void ia32_abi_epilogue(void *self, ir_node *bl, ir_node **mem, pmap *reg_map)
 {
        ia32_abi_env_t   *env      = self;
-       const arch_env_t *arch_env = env->aenv;
+       const arch_env_t *arch_env = be_get_irg_arch_env(env->irg);
        ir_node          *curr_sp  = be_abi_reg_map_get(reg_map, arch_env->sp);
        ir_node          *curr_bp  = be_abi_reg_map_get(reg_map, arch_env->bp);
 
@@ -389,17 +388,15 @@ static void ia32_abi_epilogue(void *self, ir_node *bl, ir_node **mem, pmap *reg_
 /**
  * Initialize the callback object.
  * @param call The call object.
- * @param aenv The architecture environment.
  * @param irg  The graph with the method.
  * @return     Some pointer. This pointer is passed to all other callback functions as self object.
  */
-static void *ia32_abi_init(const be_abi_call_t *call, const arch_env_t *aenv, ir_graph *irg)
+static void *ia32_abi_init(const be_abi_call_t *call, ir_graph *irg)
 {
        ia32_abi_env_t      *env = XMALLOC(ia32_abi_env_t);
        be_abi_call_flags_t  fl  = be_abi_call_get_flags(call);
        env->flags = fl.bits;
        env->irg   = irg;
-       env->aenv  = aenv;
        return env;
 }
 
@@ -1662,7 +1659,7 @@ static arch_env_t *ia32_init(FILE *file_handle)
        be_emit_irprintf("%stext0:\n", be_gas_get_private_prefix());
        be_emit_write_line();
 
-       return &isa->arch_env;
+       return &isa->base;
 }
 
 
@@ -1675,7 +1672,7 @@ static void ia32_done(void *self)
        ia32_isa_t *isa = self;
 
        /* emit now all global declarations */
-       be_gas_emit_decls(isa->arch_env.main_env);
+       be_gas_emit_decls(isa->base.main_env);
 
        pmap_destroy(isa->regs_16bit);
        pmap_destroy(isa->regs_8bit);
@@ -2428,7 +2425,7 @@ static const lc_opt_table_entry_t ia32_options[] = {
        LC_OPT_ENT_ENUM_INT("transformer", "the transformer used for code selection", &transformer_var),
 #endif
        LC_OPT_ENT_INT("stackalign", "set power of two stack alignment for calls",
-                      &ia32_isa_template.arch_env.stack_alignment),
+                      &ia32_isa_template.base.stack_alignment),
        LC_OPT_LAST
 };
 
index 0ce6262..a42dcb0 100644 (file)
@@ -79,7 +79,7 @@ struct ia32_code_gen_t {
  * IA32 ISA object
  */
 struct ia32_isa_t {
-       arch_env_t            arch_env;       /**< must be derived from arch_env_t */
+       arch_env_t             base;          /**< must be derived from arch_env_t */
        pmap                  *regs_16bit;    /**< Contains the 16bits names of the gp registers */
        pmap                  *regs_8bit;     /**< Contains the 8bits names of the gp registers */
        pmap                  *regs_8bit_high; /**< contains the high part of the 8 bit names of the gp registers */
index 3f81ba4..d73ab3a 100644 (file)
@@ -430,7 +430,7 @@ static arch_env_t *sparc_init(FILE *outfile)
        sparc_create_opcodes(&sparc_irn_ops);
        sparc_handle_intrinsics();
 
-       return &isa->arch_env;
+       return &isa->base;
 }
 
 
@@ -443,7 +443,7 @@ static void sparc_done(void *self)
        sparc_isa_t *isa = self;
 
        /* emit now all global declarations */
-       be_gas_emit_decls(isa->arch_env.main_env);
+       be_gas_emit_decls(isa->base.main_env);
 
        be_emit_exit();
        free(self);
@@ -481,17 +481,15 @@ static const arch_register_class_t *sparc_get_reg_class_for_mode(const ir_mode *
 
 typedef struct {
        be_abi_call_flags_bits_t flags;
-       const arch_env_t *arch_env;
-       ir_graph *irg;
+       ir_graph                *irg;
 } sparc_abi_env_t;
 
-static void *sparc_abi_init(const be_abi_call_t *call, const arch_env_t *arch_env, ir_graph *irg)
+static void *sparc_abi_init(const be_abi_call_t *call, ir_graph *irg)
 {
        sparc_abi_env_t *env = XMALLOC(sparc_abi_env_t);
        be_abi_call_flags_t fl = be_abi_call_get_flags(call);
        env->flags    = fl.bits;
        env->irg      = irg;
-       env->arch_env = arch_env;
        return env;
 }
 
index aae05e8..2bf7482 100644 (file)
@@ -49,8 +49,8 @@ typedef struct _sparc_code_gen_t {
 
 
 struct _sparc_isa_t {
-    arch_env_t     arch_env;      /**< must be derived from arch_env_t */
-    sparc_code_gen_t *cg;           /**< current code generator */
+    arch_env_t        base;      /**< must be derived from arch_env_t */
+    sparc_code_gen_t *cg;        /**< current code generator */
 };