avoid unnecessary passing around of arch_env_t* in backend APIs
[libfirm] / ir / be / TEMPLATE / bearch_TEMPLATE.c
index dae8636..1a2dbae 100644 (file)
@@ -24,7 +24,6 @@
  */
 #include "config.h"
 
-#include "pseudo_irg.h"
 #include "irgwalk.h"
 #include "irprog.h"
 #include "irprintf.h"
@@ -66,13 +65,6 @@ static ir_entity *TEMPLATE_get_frame_entity(const ir_node *node)
        return NULL;
 }
 
-static void TEMPLATE_set_frame_entity(ir_node *node, ir_entity *ent)
-{
-       (void) node;
-       (void) ent;
-       /* TODO: set the ir_entity assigned to the frame */
-}
-
 /**
  * This function is called by the generic backend to correct offsets for
  * nodes accessing the stack.
@@ -96,7 +88,6 @@ static const arch_irn_ops_t TEMPLATE_irn_ops = {
        get_TEMPLATE_in_req,
        TEMPLATE_classify,
        TEMPLATE_get_frame_entity,
-       TEMPLATE_set_frame_entity,
        TEMPLATE_set_frame_offset,
        TEMPLATE_get_sp_bias,
        NULL,    /* get_inverse             */
@@ -227,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;
 }
 
 
@@ -240,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);
@@ -278,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;
 }
 
@@ -326,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 */