From 38efd2ac16aa827ae9f07acc9ebfc7d74422290e Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Fri, 23 May 2008 14:48:27 +0000 Subject: [PATCH] Removed the irn_handler stack. [r19733] --- ir/be/be_t.h | 1 - ir/be/bearch.c | 44 ++++++++------------------------------------ ir/be/bearch.h | 13 +++---------- ir/be/bearch_t.h | 10 ++-------- ir/be/bemain.c | 10 +--------- ir/be/benode.c | 18 +++++++----------- ir/be/benode_t.h | 2 +- 7 files changed, 22 insertions(+), 76 deletions(-) diff --git a/ir/be/be_t.h b/ir/be/be_t.h index 4a3ed4623..af6a0b5ac 100644 --- a/ir/be/be_t.h +++ b/ir/be/be_t.h @@ -80,7 +80,6 @@ struct be_options_t { }; typedef struct { - arch_get_irn_ops_t *get_irn_ops; arch_irn_ops_t irn_ops; const arch_env_t *arch_env; pmap *phi_attrs; diff --git a/ir/be/bearch.c b/ir/be/bearch.c index a71faf4d1..4ecb2c119 100644 --- a/ir/be/bearch.c +++ b/ir/be/bearch.c @@ -30,6 +30,7 @@ #include #include "bearch_t.h" +#include "benode_t.h" #include "ircons_t.h" #include "irnode_t.h" #include "xmalloc.h" @@ -49,18 +50,9 @@ arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa_if, FILE *fi return env; } -arch_env_t *arch_env_push_irn_handler(arch_env_t *env, - arch_get_irn_ops_t *handler) +void arch_env_set_irn_handler(arch_env_t *env, arch_get_irn_ops_t *handler) { - assert(env->handlers_tos < ARCH_MAX_HANDLERS); - env->handlers[env->handlers_tos++] = handler; - return 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]; + env->arch_handler = handler; } static const arch_irn_ops_t *fallback_irn_ops = NULL; @@ -85,33 +77,13 @@ 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) { - arch_get_irn_ops_t *get_irn_ops = env->handlers[i]; - const arch_irn_ops_t *ops = get_irn_ops(irn); + const arch_irn_ops_t *ops = be_node_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; + if (ops) + return ops; + ops = env->arch_handler(irn); -#endif - return fallback_irn_ops; + return ops != NULL ? ops : fallback_irn_ops; } const arch_irn_ops_t *arch_get_irn_ops(const arch_env_t *env, const ir_node *irn) { diff --git a/ir/be/bearch.h b/ir/be/bearch.h index 21b458453..ddb9c3276 100644 --- a/ir/be/bearch.h +++ b/ir/be/bearch.h @@ -290,19 +290,12 @@ extern arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa, FILE *file_handle, be_main_env_t *main_env); /** - * Add a node handler to the environment. + * Set the architectural node handler to the environment. * @param env The environment. - * @param handler A node handler. + * @param handler The node handler for the selected architecture. * @return The environment itself. */ -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 arch_get_irn_ops_t *arch_env_pop_irn_handler(arch_env_t *env); +extern void arch_env_set_irn_handler(arch_env_t *env, arch_get_irn_ops_t *handler); /** * Register an instruction set architecture diff --git a/ir/be/bearch_t.h b/ir/be/bearch_t.h index c29cc25b3..e85c872fa 100644 --- a/ir/be/bearch_t.h +++ b/ir/be/bearch_t.h @@ -568,20 +568,14 @@ struct arch_isa_if_t { #define arch_isa_get_machine(isa) ((isa)->impl->get_machine((isa))) #define arch_isa_get_backend_irg_list(isa, irgs) ((isa)->impl->get_backend_irg_list((isa), (irgs))) -#define ARCH_MAX_HANDLERS 8 - /** * Environment for the architecture infrastructure. * Keep this everywhere you're going. */ struct arch_env_t { - arch_isa_t *isa; /**< The isa about which everything is. */ - - arch_get_irn_ops_t *handlers[ARCH_MAX_HANDLERS]; /**< The handlers are organized as - a stack. */ + arch_isa_t *isa; /**< The isa about which everything is. */ - int handlers_tos; /**< The stack pointer of the handler - stack. */ + arch_get_irn_ops_t *arch_handler; /**< The get_irn_ops handler for the selected architecture. */ }; /** diff --git a/ir/be/bemain.c b/ir/be/bemain.c index f34dacb62..8e77a74d8 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -267,17 +267,9 @@ static be_main_env_t *be_init_env(be_main_env_t *env, FILE *file_handle) /* Register the irn handler of the architecture */ handler = arch_isa_get_irn_handler(env->arch_env.isa); - if (handler != NULL) - arch_env_push_irn_handler(&env->arch_env, handler); + arch_env_set_irn_handler(&env->arch_env, handler); - /* - * Register the node handler of the back end infrastructure. - * This irn handler takes care of the platform independent - * spill, reload and perm nodes. - */ - 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.get_irn_ops); be_dbg_open(); return env; diff --git a/ir/be/benode.c b/ir/be/benode.c index 9475b29ce..9881d7d02 100644 --- a/ir/be/benode.c +++ b/ir/be/benode.c @@ -1340,8 +1340,15 @@ static const arch_irn_ops_t be_node_irn_ops = { &be_node_irn_ops_if }; +/* * irn handler for common be nodes and Phi's. */ const void *be_node_get_irn_ops(const ir_node *irn) { + if (is_Phi(irn)) { + if (mode_is_datab(get_irn_mode(irn))) + return &curr_phi_handler->irn_ops; + return NULL; + } + if (is_Proj(irn)) { irn = get_Proj_pred(irn); if (is_Proj(irn)) { @@ -1367,18 +1374,8 @@ typedef struct { arch_irn_flags_t flags; } phi_attr_t; -#define get_phi_handler_from_handler(h) container_of(h, phi_handler_t, irn_handler) #define get_phi_handler_from_ops(h) container_of(h, phi_handler_t, irn_ops) -static -const void *phi_get_irn_ops(const ir_node *irn) -{ - if (!is_Phi(irn) || !mode_is_datab(get_irn_mode(irn))) - return NULL; - - return &curr_phi_handler->irn_ops; -} - static INLINE phi_attr_t *get_Phi_attr(const phi_handler_t *handler, const ir_node *phi) { @@ -1580,7 +1577,6 @@ 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->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(); diff --git a/ir/be/benode_t.h b/ir/be/benode_t.h index 3999fb683..04de75235 100644 --- a/ir/be/benode_t.h +++ b/ir/be/benode_t.h @@ -535,7 +535,7 @@ void be_set_phi_flags(const arch_env_t *arch_env, ir_node *phi, arch_irn_flags_t flags); /** - * irn handler for common be nodes. + * irn handler for common be nodes and Phi's. */ const void *be_node_get_irn_ops(const ir_node *irn); -- 2.20.1