Removed the arch_irn_handler_t. This was just an additional redirection without
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 23 May 2008 14:25:50 +0000 (14:25 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 23 May 2008 14:25:50 +0000 (14:25 +0000)
greater function...

[r19732]

13 files changed:
ir/be/TEMPLATE/bearch_TEMPLATE.c
ir/be/TEMPLATE/bearch_TEMPLATE_t.h
ir/be/arm/bearch_arm.c
ir/be/be_t.h
ir/be/bearch.c
ir/be/bearch.h
ir/be/bearch_t.h
ir/be/bemain.c
ir/be/benode.c
ir/be/benode_t.h
ir/be/ia32/bearch_ia32.c
ir/be/mips/bearch_mips.c
ir/be/ppc32/bearch_ppc32.c

index 7aa0ace..267ea40 100644 (file)
@@ -589,22 +589,16 @@ void TEMPLATE_get_call_abi(const void *self, ir_type *method_type,
        }
 }
 
-static const void *TEMPLATE_get_irn_ops(const arch_irn_handler_t *self,
-                                        const ir_node *irn)
+static const void *TEMPLATE_get_irn_ops(const ir_node *irn)
 {
-       (void) self;
        (void) irn;
        return &TEMPLATE_irn_ops;
 }
 
-const arch_irn_handler_t TEMPLATE_irn_handler = {
-       TEMPLATE_get_irn_ops
-};
-
-const arch_irn_handler_t *TEMPLATE_get_irn_handler(const void *self)
+arch_get_irn_ops_t *TEMPLATE_get_irn_handler(const void *self)
 {
        (void) self;
-       return &TEMPLATE_irn_handler;
+       return &TEMPLATE_get_irn_ops;
 }
 
 int TEMPLATE_to_appear_in_schedule(void *block_env, const ir_node *irn)
index 05fa07f..b5650fc 100644 (file)
@@ -22,8 +22,8 @@
  * @brief   declarations for TEMPALTE backend -- private header
  * @version $Id$
  */
-#ifndef FIRM_BE_IA32_BEARCH_TEMPLATE_T_H
-#define FIRM_BE_IA32_BEARCH_TEMPLATE_T_H
+#ifndef FIRM_BE_TEMPLATE_BEARCH_TEMPLATE_T_H
+#define FIRM_BE_TEMPLATE_BEARCH_TEMPLATE_T_H
 
 #include "debug.h"
 #include "bearch_TEMPLATE.h"
index 2b18576..d9db5ee 100644 (file)
@@ -1088,19 +1088,14 @@ void arm_get_call_abi(const void *self, ir_type *method_type, be_abi_call_t *abi
        }
 }
 
-static const void *arm_get_irn_ops(const arch_irn_handler_t *self, const ir_node *irn) {
-       (void) self;
+static const void *arm_get_irn_ops(const ir_node *irn) {
        (void) irn;
        return &arm_irn_ops;
 }
 
-const arch_irn_handler_t arm_irn_handler = {
-       arm_get_irn_ops
-};
-
-const arch_irn_handler_t *arm_get_irn_handler(const void *self) {
+arch_get_irn_ops_t *arm_get_irn_handler(const void *self) {
        (void) self;
-       return &arm_irn_handler;
+       return &arm_get_irn_ops;
 }
 
 int arm_to_appear_in_schedule(void *block_env, const ir_node *irn) {
index 1caeb61..4a3ed46 100644 (file)
@@ -80,7 +80,7 @@ struct be_options_t {
 };
 
 typedef struct {
-       arch_irn_handler_t irn_handler;
+       arch_get_irn_ops_t *get_irn_ops;
        arch_irn_ops_t     irn_ops;
        const arch_env_t   *arch_env;
        pmap               *phi_attrs;
index f262c35..a71faf4 100644 (file)
@@ -50,14 +50,14 @@ arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa_if, FILE *fi
 }
 
 arch_env_t *arch_env_push_irn_handler(arch_env_t *env,
-                                      const arch_irn_handler_t *handler)
+                                      arch_get_irn_ops_t *handler)
 {
        assert(env->handlers_tos < ARCH_MAX_HANDLERS);
        env->handlers[env->handlers_tos++] = handler;
        return env;
 }
 
-const arch_irn_handler_t *arch_env_pop_irn_handler(arch_env_t *env)
+arch_get_irn_ops_t *arch_env_pop_irn_handler(arch_env_t *env)
 {
        assert(env->handlers_tos > 0 && env->handlers_tos <= ARCH_MAX_HANDLERS);
        return env->handlers[--env->handlers_tos];
@@ -85,16 +85,32 @@ int arch_register_class_put(const arch_register_class_t *cls, bitset_t *bs)
 static INLINE const arch_irn_ops_t *
 get_irn_ops(const arch_env_t *env, const ir_node *irn)
 {
+#if 1
        int i;
 
        for(i = env->handlers_tos - 1; i >= 0; --i) {
-               const arch_irn_handler_t *handler = env->handlers[i];
-               const arch_irn_ops_t *ops = handler->get_irn_ops(handler, irn);
+               arch_get_irn_ops_t *get_irn_ops = env->handlers[i];
+               const arch_irn_ops_t *ops = get_irn_ops(irn);
 
                if(ops)
                        return ops;
        }
+#else
+       if (is_Phi(irn) && !mode_is_datab(get_irn_mode(irn))) {
+               const phi_handler_t *h;
+               return &h->irn_ops;
+       }
+       if (is_Proj(irn)) {
+               irn = get_Proj_pred(irn);
+               if (is_Proj(irn)) {
+                       assert(get_irn_mode(irn) == mode_T);
+                       irn = get_Proj_pred(irn);
+               }
+       }
+       if (is_be_node(irn))
+               return &be_node_irn_ops;
 
+#endif
        return fallback_irn_ops;
 }
 
index edbf7cf..21b4584 100644 (file)
@@ -41,7 +41,6 @@ typedef struct arch_isa_t                arch_isa_t;
 typedef struct arch_env_t                arch_env_t;
 typedef struct arch_irn_ops_if_t         arch_irn_ops_if_t;
 typedef struct arch_irn_ops_t            arch_irn_ops_t;
-typedef struct arch_irn_handler_t        arch_irn_handler_t;
 typedef struct arch_code_generator_t     arch_code_generator_t;
 typedef struct arch_code_generator_if_t  arch_code_generator_if_t;
 
@@ -273,6 +272,14 @@ extern arch_irn_flags_t arch_irn_get_flags(const arch_env_t *env, const ir_node
 #define arch_irn_consider_in_reg_alloc(env, cls, irn) \
        (arch_irn_has_reg_class(env, irn, -1, cls) && !arch_irn_is(env, irn, ignore))
 
+/**
+ * Get the operations of an irn.
+ * @param self The handler from which the method is invoked.
+ * @param irn Some node.
+ * @return Operations for that irn.
+ */
+typedef const void *(arch_get_irn_ops_t)(const ir_node *irn);
+
 /**
  * Initialize the architecture environment struct.
  * @param isa           The isa which shall be put into the environment.
@@ -288,14 +295,14 @@ extern arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa,
  * @param handler A node handler.
  * @return The environment itself.
  */
-extern arch_env_t *arch_env_push_irn_handler(arch_env_t *env, const arch_irn_handler_t *handler);
+extern arch_env_t *arch_env_push_irn_handler(arch_env_t *env, arch_get_irn_ops_t *handler);
 
 /**
  * Remove a node handler from the handler stack.
  * @param env The architecture environment.
  * @return The popped handler.
  */
-extern const arch_irn_handler_t *arch_env_pop_irn_handler(arch_env_t *env);
+extern arch_get_irn_ops_t *arch_env_pop_irn_handler(arch_env_t *env);
 
 /**
  * Register an instruction set architecture
index 0e7590b..c29cc25 100644 (file)
@@ -318,21 +318,6 @@ struct arch_irn_ops_t {
        const arch_irn_ops_if_t *impl;
 };
 
-/**
- * Somebody who can be asked about IR nodes.
- */
-struct arch_irn_handler_t {
-
-  /**
-    * Get the operations of an irn.
-    * @param self The handler from which the method is invoked.
-    * @param irn Some node.
-    * @return Operations for that irn.
-    */
-  const void *(*get_irn_ops)(const arch_irn_handler_t *handler,
-      const ir_node *irn);
-};
-
 /**
  * The code generator interface.
  */
@@ -497,9 +482,8 @@ struct arch_isa_if_t {
         * The irn handler for this architecture.
         * The irn handler is registered by the Firm back end
         * when the architecture is initialized.
-        * (May be NULL).
         */
-       const arch_irn_handler_t *(*get_irn_handler)(const void *self);
+       arch_get_irn_ops_t *(*get_irn_handler)(const void *self);
 
        /**
         * Get the code generator interface.
@@ -593,7 +577,7 @@ struct arch_isa_if_t {
 struct arch_env_t {
        arch_isa_t *isa;                                /**< The isa about which everything is. */
 
-       arch_irn_handler_t const *handlers[ARCH_MAX_HANDLERS]; /**< The handlers are organized as
+       arch_get_irn_ops_t *handlers[ARCH_MAX_HANDLERS]; /**< The handlers are organized as
                                                            a stack. */
 
        int handlers_tos;                                   /**< The stack pointer of the handler
index 46c6296..f34dacb 100644 (file)
@@ -250,7 +250,7 @@ const backend_params *be_init(void)
  */
 static be_main_env_t *be_init_env(be_main_env_t *env, FILE *file_handle)
 {
-       const arch_irn_handler_t *handler;
+       arch_get_irn_ops_t *handler;
 
        memset(env, 0, sizeof(*env));
        env->options              = &be_options;
@@ -275,9 +275,9 @@ static be_main_env_t *be_init_env(be_main_env_t *env, FILE *file_handle)
         * This irn handler takes care of the platform independent
         * spill, reload and perm nodes.
         */
-       arch_env_push_irn_handler(&env->arch_env, &be_node_irn_handler);
+       arch_env_push_irn_handler(&env->arch_env, be_node_get_irn_ops);
        be_phi_handler_new(env);
-       arch_env_push_irn_handler(&env->arch_env, &env->phi_handler.irn_handler);
+       arch_env_push_irn_handler(&env->arch_env, env->phi_handler.get_irn_ops);
 
        be_dbg_open();
        return env;
index 0ba1c1a..9475b29 100644 (file)
@@ -66,6 +66,9 @@
 
 static unsigned be_node_tag = FOURCC('B', 'E', 'N', 'O');
 
+/** The current phi handler */
+static const phi_handler_t *curr_phi_handler;
+
 typedef struct {
        arch_register_req_t req;
        arch_irn_flags_t    flags;
@@ -1337,7 +1340,7 @@ static const arch_irn_ops_t be_node_irn_ops = {
        &be_node_irn_ops_if
 };
 
-const void *be_node_get_irn_ops(const arch_irn_handler_t *self, const ir_node *irn)
+const void *be_node_get_irn_ops(const ir_node *irn)
 {
        if (is_Proj(irn)) {
                irn = get_Proj_pred(irn);
@@ -1346,14 +1349,9 @@ const void *be_node_get_irn_ops(const arch_irn_handler_t *self, const ir_node *i
                        irn = get_Proj_pred(irn);
                }
        }
-       (void) self;
        return is_be_node(irn) ? &be_node_irn_ops : NULL;
 }
 
-const arch_irn_handler_t be_node_irn_handler = {
-       be_node_get_irn_ops
-};
-
 /*
   ____  _     _   ___ ____  _   _   _   _                 _ _
  |  _ \| |__ (_) |_ _|  _ \| \ | | | | | | __ _ _ __   __| | | ___ _ __
@@ -1373,15 +1371,12 @@ typedef struct {
 #define get_phi_handler_from_ops(h)      container_of(h, phi_handler_t, irn_ops)
 
 static
-const void *phi_get_irn_ops(const arch_irn_handler_t *handler,
-                            const ir_node *irn)
+const void *phi_get_irn_ops(const ir_node *irn)
 {
-       const phi_handler_t *h;
-       if(!is_Phi(irn) || !mode_is_datab(get_irn_mode(irn)))
+       if (!is_Phi(irn) || !mode_is_datab(get_irn_mode(irn)))
                return NULL;
 
-       h = get_phi_handler_from_handler(handler);
-       return &h->irn_ops;
+       return &curr_phi_handler->irn_ops;
 }
 
 static INLINE
@@ -1584,18 +1579,20 @@ const arch_irn_ops_if_t phi_irn_ops = {
 
 void be_phi_handler_new(be_main_env_t *env)
 {
-       phi_handler_t *h           = &env->phi_handler;
-       h->irn_handler.get_irn_ops = phi_get_irn_ops;
-       h->irn_ops.impl            = &phi_irn_ops;
-       h->arch_env                = &env->arch_env;
-       h->phi_attrs               = pmap_create();
+       phi_handler_t *h = &env->phi_handler;
+       h->get_irn_ops   = phi_get_irn_ops;
+       h->irn_ops.impl  = &phi_irn_ops;
+       h->arch_env      = &env->arch_env;
+       h->phi_attrs     = pmap_create();
+       curr_phi_handler = h;
 }
 
 void be_phi_handler_free(be_main_env_t *env)
 {
        phi_handler_t *h = &env->phi_handler;
        pmap_destroy(h->phi_attrs);
-       h->phi_attrs = NULL;
+       h->phi_attrs     = NULL;
+       curr_phi_handler = NULL;
 }
 
 void be_phi_handler_reset(be_main_env_t *env)
index 45e4dc3..3999fb6 100644 (file)
@@ -537,7 +537,7 @@ void be_set_phi_flags(const arch_env_t *arch_env, ir_node *phi,
 /**
  * irn handler for common be nodes.
  */
-extern const arch_irn_handler_t be_node_irn_handler;
+const void *be_node_get_irn_ops(const ir_node *irn);
 
 static INLINE int be_is_Spill    (const ir_node *irn) { return get_irn_opcode(irn) == beo_Spill    ; }
 static INLINE int be_is_Reload   (const ir_node *irn) { return get_irn_opcode(irn) == beo_Reload   ; }
index 2f39e9f..7d9cf66 100644 (file)
@@ -1896,22 +1896,16 @@ static void ia32_get_call_abi(const void *self, ir_type *method_type,
 }
 
 
-static const void *ia32_get_irn_ops(const arch_irn_handler_t *self,
-                                    const ir_node *irn)
+static const void *ia32_get_irn_ops(const ir_node *irn)
 {
-       (void) self;
        (void) irn;
        return &ia32_irn_ops;
 }
 
-const arch_irn_handler_t ia32_irn_handler = {
-       ia32_get_irn_ops
-};
-
-const arch_irn_handler_t *ia32_get_irn_handler(const void *self)
+arch_get_irn_ops_t *ia32_get_irn_handler(const void *self)
 {
        (void) self;
-       return &ia32_irn_handler;
+       return &ia32_get_irn_ops;
 }
 
 int ia32_to_appear_in_schedule(void *block_env, const ir_node *irn)
index 8ef88ef..2a7b8b9 100644 (file)
@@ -947,22 +947,16 @@ static void mips_get_call_abi(const void *self, ir_type *method_type,
        }
 }
 
-static const void *mips_get_irn_ops(const arch_irn_handler_t *self,
-                                    const ir_node *irn)
+static const void *mips_get_irn_ops(const ir_node *irn)
 {
-       (void) self;
        (void) irn;
        return &mips_irn_ops;
 }
 
-const arch_irn_handler_t mips_irn_handler = {
-       mips_get_irn_ops
-};
-
-const arch_irn_handler_t *mips_get_irn_handler(const void *self)
+arch_get_irn_ops_t *mips_get_irn_handler(const void *self)
 {
        (void) self;
-       return &mips_irn_handler;
+       return &mips_get_irn_ops;
 }
 
 /**
index 9e10a8b..62d6a42 100644 (file)
@@ -848,19 +848,14 @@ static void ppc32_get_call_abi(const void *self, ir_type *method_type, be_abi_ca
        }
 }
 
-static const void *ppc32_get_irn_ops(const arch_irn_handler_t *self, const ir_node *irn) {
-       (void) self;
+static const void *ppc32_get_irn_ops(const ir_node *irn) {
        (void) irn;
        return &ppc32_irn_ops;
 }
 
-const arch_irn_handler_t ppc32_irn_handler = {
-       ppc32_get_irn_ops
-};
-
-const arch_irn_handler_t *ppc32_get_irn_handler(const void *self) {
+arch_get_irn_ops_t *ppc32_get_irn_handler(const void *self) {
        (void) self;
-       return &ppc32_irn_handler;
+       return &ppc32_get_irn_ops;
 }
 
 int ppc32_to_appear_in_schedule(void *block_env, const ir_node *irn) {