Commit f7542603 authored by Christian Würdig's avatar Christian Würdig
Browse files

added interface layer for irn_ops

parent 7522048d
......@@ -82,7 +82,7 @@ const arch_register_req_t *arch_get_register_req(const arch_env_t *env,
{
const arch_irn_ops_t *ops = get_irn_ops(env, irn);
req->type = arch_register_req_type_none;
return ops->get_irn_reg_req(ops, req, irn, pos);
return ops->impl->get_irn_reg_req(ops, req, irn, pos);
}
int arch_get_allocatable_regs(const arch_env_t *env, const ir_node *irn,
......@@ -90,7 +90,7 @@ int arch_get_allocatable_regs(const arch_env_t *env, const ir_node *irn,
{
arch_register_req_t local_req;
const arch_irn_ops_t *ops = get_irn_ops(env, irn);
const arch_register_req_t *req = ops->get_irn_reg_req(ops, &local_req, irn, pos);
const arch_register_req_t *req = ops->impl->get_irn_reg_req(ops, &local_req, irn, pos);
if(req->type == arch_register_req_type_none) {
bitset_clear_all(bs);
......@@ -109,7 +109,7 @@ int arch_is_register_operand(const arch_env_t *env,
{
arch_register_req_t local_req;
const arch_irn_ops_t *ops = get_irn_ops(env, irn);
const arch_register_req_t *req = ops->get_irn_reg_req(ops, &local_req, irn, pos);
const arch_register_req_t *req = ops->impl->get_irn_reg_req(ops, &local_req, irn, pos);
return req != NULL;
}
......@@ -137,7 +137,7 @@ arch_get_irn_reg_class(const arch_env_t *env, const ir_node *irn, int pos)
{
arch_register_req_t local_req;
const arch_irn_ops_t *ops = get_irn_ops(env, irn);
const arch_register_req_t *req = ops->get_irn_reg_req(ops, &local_req, irn, pos);
const arch_register_req_t *req = ops->impl->get_irn_reg_req(ops, &local_req, irn, pos);
return req ? req->cls : NULL;
}
......@@ -145,24 +145,24 @@ extern const arch_register_t *
arch_get_irn_register(const arch_env_t *env, const ir_node *irn)
{
const arch_irn_ops_t *ops = get_irn_ops(env, irn);
return ops->get_irn_reg(ops, irn);
return ops->impl->get_irn_reg(ops, irn);
}
extern void arch_set_irn_register(const arch_env_t *env,
ir_node *irn, const arch_register_t *reg)
{
const arch_irn_ops_t *ops = get_irn_ops(env, irn);
ops->set_irn_reg(ops, irn, reg);
ops->impl->set_irn_reg(ops, irn, reg);
}
extern arch_irn_class_t arch_irn_classify(const arch_env_t *env, const ir_node *irn)
{
const arch_irn_ops_t *ops = get_irn_ops(env, irn);
return ops->classify(ops, irn);
return ops->impl->classify(ops, irn);
}
extern arch_irn_flags_t arch_irn_get_flags(const arch_env_t *env, const ir_node *irn)
{
const arch_irn_ops_t *ops = get_irn_ops(env, irn);
return ops->get_flags(ops, irn);
return ops->impl->get_flags(ops, irn);
}
......@@ -27,6 +27,7 @@ typedef struct _arch_register_t arch_register_t;
typedef struct _arch_isa_if_t arch_isa_if_t;
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;
......@@ -197,7 +198,7 @@ typedef enum _arch_irn_flags_t {
arch_irn_flags_rematerializable = 2
} arch_irn_flags_t;
struct _arch_irn_ops_t {
struct _arch_irn_ops_if_t {
/**
* Get the register requirements for a given operand.
......@@ -209,7 +210,7 @@ struct _arch_irn_ops_t {
* @return The register requirements for the selected operand.
* The pointer returned is never NULL.
*/
const arch_register_req_t *(*get_irn_reg_req)(const arch_irn_ops_t *self,
const arch_register_req_t *(*get_irn_reg_req)(const void *self,
arch_register_req_t *req, const ir_node *irn, int pos);
/**
......@@ -219,7 +220,7 @@ struct _arch_irn_ops_t {
* @note If the operand is not a register operand,
* the call is ignored.
*/
void (*set_irn_reg)(const arch_irn_ops_t *self, ir_node *irn, const arch_register_t *reg);
void (*set_irn_reg)(const void *self, ir_node *irn, const arch_register_t *reg);
/**
* Get the register allocated for an output operand.
......@@ -229,14 +230,14 @@ struct _arch_irn_ops_t {
* @c arch_register_invalid, if no register has yet been
* allocated for this node.
*/
const arch_register_t *(*get_irn_reg)(const arch_irn_ops_t *self, const ir_node *irn);
const arch_register_t *(*get_irn_reg)(const void *self, const ir_node *irn);
/**
* Classify the node.
* @param irn The node.
* @return A classification.
*/
arch_irn_class_t (*classify)(const arch_irn_ops_t *self, const ir_node *irn);
arch_irn_class_t (*classify)(const void *self, const ir_node *irn);
/**
* Get the flags of a node.
......@@ -244,8 +245,15 @@ struct _arch_irn_ops_t {
* @param irn The node.
* @return A set of flags.
*/
arch_irn_flags_t (*get_flags)(const arch_irn_ops_t *self, const ir_node *irn);
arch_irn_flags_t (*get_flags)(const void *self, const ir_node *irn);
};
/**
* irn_ops base class.
*/
struct _arch_irn_ops_t {
const arch_irn_ops_if_t *impl;
};
/**
......@@ -361,7 +369,7 @@ struct _arch_irn_handler_t {
* @param irn Some node.
* @return Operations for that irn.
*/
const arch_irn_ops_t *(*get_irn_ops)(const arch_irn_handler_t *handler,
const void *(*get_irn_ops)(const arch_irn_handler_t *handler,
const ir_node *irn);
};
......
......@@ -399,7 +399,7 @@ static void *put_in_reg_req(arch_register_req_t *req, const ir_node *irn, int po
}
static const arch_register_req_t *
be_node_get_irn_reg_req(const arch_irn_ops_t *self, arch_register_req_t *req, const ir_node *irn, int pos)
be_node_get_irn_reg_req(const void *self, arch_register_req_t *req, const ir_node *irn, int pos)
{
int out_pos = pos;
......@@ -420,7 +420,7 @@ be_node_get_irn_reg_req(const arch_irn_ops_t *self, arch_register_req_t *req, co
}
static void
be_node_set_irn_reg(const arch_irn_ops_t *_self, ir_node *irn, const arch_register_t *reg)
be_node_set_irn_reg(const void *_self, ir_node *irn, const arch_register_t *reg)
{
int out_pos;
be_node_attr_t *a;
......@@ -434,7 +434,7 @@ be_node_set_irn_reg(const arch_irn_ops_t *_self, ir_node *irn, const arch_regist
}
const arch_register_t *
be_node_get_irn_reg(const arch_irn_ops_t *_self, const ir_node *irn)
be_node_get_irn_reg(const void *_self, const ir_node *irn)
{
int out_pos;
be_node_attr_t *a;
......@@ -448,7 +448,7 @@ be_node_get_irn_reg(const arch_irn_ops_t *_self, const ir_node *irn)
return a->reg_data[out_pos].reg;
}
arch_irn_class_t be_node_classify(const arch_irn_ops_t *_self, const ir_node *irn)
arch_irn_class_t be_node_classify(const void *_self, const ir_node *irn)
{
redir_proj(&irn, -1);
......@@ -466,12 +466,12 @@ arch_irn_class_t be_node_classify(const arch_irn_ops_t *_self, const ir_node *ir
return 0;
}
arch_irn_class_t be_node_get_flags(const arch_irn_ops_t *_self, const ir_node *irn)
arch_irn_class_t be_node_get_flags(const void *_self, const ir_node *irn)
{
return 0;
}
static const arch_irn_ops_t be_node_irn_ops = {
static const arch_irn_ops_if_t be_node_irn_ops_if = {
be_node_get_irn_reg_req,
be_node_set_irn_reg,
be_node_get_irn_reg,
......@@ -479,7 +479,11 @@ static const arch_irn_ops_t be_node_irn_ops = {
be_node_get_flags,
};
const arch_irn_ops_t *be_node_get_arch_ops(const arch_irn_handler_t *self, const ir_node *irn)
static const arch_irn_ops_t be_node_irn_ops = {
&be_node_irn_ops_if
};
const void *be_node_get_arch_ops(const arch_irn_handler_t *self, const ir_node *irn)
{
redir_proj((const ir_node **) &irn, -1);
return is_be_node(irn) ? &be_node_irn_ops : NULL;
......
......@@ -204,7 +204,7 @@ static const arch_register_req_t firm_std_reg_req = {
};
static const arch_register_req_t *
firm_get_irn_reg_req(const arch_irn_ops_t *self,
firm_get_irn_reg_req(const void *self,
arch_register_req_t *req, const ir_node *irn, int pos)
{
if(is_firm_be_mode(get_irn_mode(irn)))
......@@ -242,19 +242,19 @@ static struct irn_reg_assoc *get_irn_reg_assoc(const ir_node *irn)
return set_insert(reg_set, &templ, sizeof(templ), HASH_PTR(irn));
}
static void firm_set_irn_reg(const arch_irn_ops_t *self, ir_node *irn, const arch_register_t *reg)
static void firm_set_irn_reg(const void *self, ir_node *irn, const arch_register_t *reg)
{
struct irn_reg_assoc *assoc = get_irn_reg_assoc(irn);
assoc->reg = reg;
}
static const arch_register_t *firm_get_irn_reg(const arch_irn_ops_t *self, const ir_node *irn)
static const arch_register_t *firm_get_irn_reg(const void *self, const ir_node *irn)
{
struct irn_reg_assoc *assoc = get_irn_reg_assoc(irn);
return assoc->reg;
}
static arch_irn_class_t firm_classify(const arch_irn_ops_t *self, const ir_node *irn)
static arch_irn_class_t firm_classify(const void *self, const ir_node *irn)
{
arch_irn_class_t res;
......@@ -273,7 +273,7 @@ static arch_irn_class_t firm_classify(const arch_irn_ops_t *self, const ir_node
return res;
}
static arch_irn_flags_t firm_get_flags(const arch_irn_ops_t *self, const ir_node *irn)
static arch_irn_flags_t firm_get_flags(const void *self, const ir_node *irn)
{
arch_irn_flags_t res = arch_irn_flags_spillable;
......@@ -298,22 +298,26 @@ static arch_irn_flags_t firm_get_flags(const arch_irn_ops_t *self, const ir_node
return res;
}
static const arch_irn_ops_t irn_ops = {
firm_get_irn_reg_req,
firm_set_irn_reg,
firm_get_irn_reg,
firm_classify,
static const arch_irn_ops_if_t firm_irn_ops_if = {
firm_get_irn_reg_req,
firm_set_irn_reg,
firm_get_irn_reg,
firm_classify,
firm_get_flags
};
static const arch_irn_ops_t *firm_get_irn_ops(const arch_irn_handler_t *self,
const ir_node *irn)
static const arch_irn_ops_t firm_irn_ops = {
&firm_irn_ops_if
};
static const void *firm_get_irn_ops(const arch_irn_handler_t *self,
const ir_node *irn)
{
return &irn_ops;
return &firm_irn_ops;
}
const arch_irn_handler_t firm_irn_handler = {
firm_get_irn_ops,
firm_get_irn_ops,
};
static ir_node *new_Push(ir_graph *irg, ir_node *bl, ir_node *push, ir_node *arg)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment