greater function...
[r19732]
}
}
-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)
* @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"
}
}
-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) {
};
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;
}
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];
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;
}
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;
#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.
* @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
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.
*/
* 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.
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
*/
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;
* 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;
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;
&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);
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
-};
-
/*
____ _ _ ___ ____ _ _ _ _ _ _
| _ \| |__ (_) |_ _| _ \| \ | | | | | | __ _ _ __ __| | | ___ _ __
#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
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)
/**
* 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 ; }
}
-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)
}
}
-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;
}
/**
}
}
-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) {