Commit 3011d96c authored by Matthias Braun's avatar Matthias Braun
Browse files

irop: refactor default_operation setting

parent 6ee09e39
......@@ -1642,7 +1642,7 @@ static ir_type *get_Null_type(const ir_node *n)
}
/* Sets the get_type operation for an ir_op_ops. */
ir_op_ops *firm_set_default_get_type_attr(unsigned code, ir_op_ops *ops)
void firm_set_default_get_type_attr(unsigned code, ir_op_ops *ops)
{
switch (code) {
case iro_SymConst: ops->get_type_attr = get_SymConst_attr_type; break;
......@@ -1656,7 +1656,6 @@ ir_op_ops *firm_set_default_get_type_attr(unsigned code, ir_op_ops *ops)
ops->get_type_attr = get_Null_type;
break;
}
return ops;
}
/** the get_entity_attr operation must be always implemented */
......@@ -1667,7 +1666,7 @@ static ir_entity *get_Null_ent(const ir_node *n)
}
/* Sets the get_type operation for an ir_op_ops. */
ir_op_ops *firm_set_default_get_entity_attr(unsigned code, ir_op_ops *ops)
void firm_set_default_get_entity_attr(unsigned code, ir_op_ops *ops)
{
switch (code) {
case iro_SymConst: ops->get_entity_attr = get_SymConst_attr_entity; break;
......@@ -1678,7 +1677,6 @@ ir_op_ops *firm_set_default_get_entity_attr(unsigned code, ir_op_ops *ops)
ops->get_entity_attr = get_Null_ent;
break;
}
return ops;
}
/* Sets the debug information of a node. */
......
......@@ -55,7 +55,7 @@ extern unsigned firm_add_node_size;
* @return
* The operations.
*/
ir_op_ops *firm_set_default_get_type_attr(unsigned code, ir_op_ops *ops);
void firm_set_default_get_type_attr(unsigned code, ir_op_ops *ops);
/**
* Sets the get_entity_attr operation for an ir_op_ops.
......@@ -66,7 +66,7 @@ ir_op_ops *firm_set_default_get_type_attr(unsigned code, ir_op_ops *ops);
* @return
* The operations.
*/
ir_op_ops *firm_set_default_get_entity_attr(unsigned code, ir_op_ops *ops);
void firm_set_default_get_entity_attr(unsigned code, ir_op_ops *ops);
/**
* Returns an array with the predecessors of the Block. Depending on
......
......@@ -133,7 +133,7 @@ static void switch_copy_attr(ir_graph *irg, const ir_node *old_node,
* @return
* The operations.
*/
static ir_op_ops *firm_set_default_copy_attr(unsigned code, ir_op_ops *ops)
static void firm_set_default_copy_attr(unsigned code, ir_op_ops *ops)
{
switch (code) {
case iro_Call: ops->copy_attr = call_copy_attr; break;
......@@ -145,7 +145,23 @@ static ir_op_ops *firm_set_default_copy_attr(unsigned code, ir_op_ops *ops)
if (ops->copy_attr == NULL)
ops->copy_attr = default_copy_attr;
}
return ops;
}
/*
* Sets the default operation for an ir_ops.
*/
static void set_default_operations(unsigned code, ir_op_ops *ops)
{
firm_set_default_hash(code, ops);
firm_set_default_computed_value(code, ops);
firm_set_default_equivalent_node(code, ops);
firm_set_default_transform_node(code, ops);
firm_set_default_node_cmp_attr(code, ops);
firm_set_default_get_type_attr(code, ops);
firm_set_default_get_entity_attr(code, ops);
firm_set_default_copy_attr(code, ops);
firm_set_default_verifier(code, ops);
firm_set_default_reassoc(code, ops);
}
/* Creates a new ir operation. */
......@@ -169,10 +185,7 @@ ir_op *new_ir_op(unsigned code, const char *name, op_pin_state p,
else /* no given ops, set all operations to NULL */
memset(&res->ops, 0, sizeof(res->ops));
firm_set_default_operations(code, &res->ops);
firm_set_default_copy_attr(code, &res->ops);
firm_set_default_verifier(code, &res->ops);
firm_set_default_reassoc(code, &res->ops);
set_default_operations(code, &res->ops);
add_irp_opcode(res);
......
......@@ -728,16 +728,7 @@ ir_tarval *computed_value(const ir_node *n)
return tarval_bad;
}
/**
* Set the default computed_value evaluator in an ir_op_ops.
*
* @param code the opcode for the default operation
* @param ops the operations initialized
*
* @return
* The operations.
*/
static ir_op_ops *firm_set_default_computed_value(ir_opcode code, ir_op_ops *ops)
void firm_set_default_computed_value(ir_opcode code, ir_op_ops *ops)
{
#define CASE(a) \
case iro_##a: \
......@@ -776,8 +767,6 @@ static ir_op_ops *firm_set_default_computed_value(ir_opcode code, ir_op_ops *ops
/* leave NULL */
break;
}
return ops;
#undef CASE_PROJ
#undef CASE
}
......@@ -1616,16 +1605,7 @@ ir_node *equivalent_node(ir_node *n)
return n;
}
/**
* Sets the default equivalent node operation for an ir_op_ops.
*
* @param code the opcode for the default operation
* @param ops the operations initialized
*
* @return
* The operations.
*/
static ir_op_ops *firm_set_default_equivalent_node(ir_opcode code, ir_op_ops *ops)
void firm_set_default_equivalent_node(ir_opcode code, ir_op_ops *ops)
{
#define CASE(a) \
case iro_##a: \
......@@ -1663,8 +1643,6 @@ static ir_op_ops *firm_set_default_equivalent_node(ir_opcode code, ir_op_ops *op
/* leave NULL */
break;
}
return ops;
#undef CASE
#undef CASE_PROJ
}
......@@ -6360,16 +6338,7 @@ static ir_node *transform_node_Call(ir_node *call)
return res;
}
/**
* Sets the default transform node operation for an ir_op_ops.
*
* @param code the opcode for the default operation
* @param ops the operations initialized
*
* @return
* The operations.
*/
static ir_op_ops *firm_set_default_transform_node(ir_opcode code, ir_op_ops *ops)
void firm_set_default_transform_node(ir_opcode code, ir_op_ops *ops)
{
#define CASE(a) \
case iro_##a: \
......@@ -6419,8 +6388,6 @@ static ir_op_ops *firm_set_default_transform_node(ir_opcode code, ir_op_ops *ops
default:
break;
}
return ops;
#undef CASE_PROJ_EX
#undef CASE_PROJ
#undef CASE
......@@ -6730,16 +6697,7 @@ static int node_cmp_attr_InstOf(const ir_node *a, const ir_node *b)
return node_cmp_exception(a, b);
}
/**
* Set the default node attribute compare operation for an ir_op_ops.
*
* @param code the opcode for the default operation
* @param ops the operations initialized
*
* @return
* The operations.
*/
static ir_op_ops *firm_set_default_node_cmp_attr(ir_opcode code, ir_op_ops *ops)
void firm_set_default_node_cmp_attr(ir_opcode code, ir_op_ops *ops)
{
#define CASE(a) \
case iro_##a: \
......@@ -6773,8 +6731,6 @@ static ir_op_ops *firm_set_default_node_cmp_attr(ir_opcode code, ir_op_ops *ops)
/* leave NULL */
break;
}
return ops;
#undef CASE
}
......@@ -7158,16 +7114,7 @@ static unsigned hash_SymConst(const ir_node *node)
return h;
}
/**
* Set the default hash operation in an ir_op_ops.
*
* @param code the opcode for the default operation
* @param ops the operations initialized
*
* @return
* The operations.
*/
static ir_op_ops *firm_set_default_hash(unsigned code, ir_op_ops *ops)
void firm_set_default_hash(unsigned code, ir_op_ops *ops)
{
#define CASE(a) \
case iro_##a: \
......@@ -7176,7 +7123,7 @@ static ir_op_ops *firm_set_default_hash(unsigned code, ir_op_ops *ops)
/* hash function already set */
if (ops->hash != NULL)
return ops;
return;
switch (code) {
CASE(Const);
......@@ -7185,23 +7132,5 @@ static ir_op_ops *firm_set_default_hash(unsigned code, ir_op_ops *ops)
/* use input/mode default hash if no function was given */
ops->hash = firm_default_hash;
}
return ops;
#undef CASE
}
/*
* Sets the default operation for an ir_ops.
*/
ir_op_ops *firm_set_default_operations(unsigned code, ir_op_ops *ops)
{
ops = firm_set_default_hash(code, ops);
ops = firm_set_default_computed_value(code, ops);
ops = firm_set_default_equivalent_node(code, ops);
ops = firm_set_default_transform_node(code, ops);
ops = firm_set_default_node_cmp_attr(code, ops);
ops = firm_set_default_get_type_attr(code, ops);
ops = firm_set_default_get_entity_attr(code, ops);
return ops;
}
......@@ -124,17 +124,6 @@ static inline ir_tarval *value_of(const ir_node *n)
*/
bool ir_zero_when_converted(const ir_node *node, ir_mode *dest_mode);
/**
* Sets the default operations for an ir_op_ops.
*
* @param code the opcode for the default operation
* @param ops the operations initialized
*
* @return
* The operations.
*/
ir_op_ops *firm_set_default_operations(unsigned code, ir_op_ops *ops);
int ir_mux_is_abs(const ir_node *sel, const ir_node *mux_false,
const ir_node *mux_true);
......@@ -149,4 +138,45 @@ ir_node *ir_get_abs_op(const ir_node *sel, ir_node *mux_false,
bool ir_is_optimizable_mux(const ir_node *sel, const ir_node *mux_false,
const ir_node *mux_true);
/**
* Set the default hash operation in an ir_op_ops.
*
* @param code the opcode for the default operation
* @param ops the operations initialized
*/
void firm_set_default_hash(unsigned code, ir_op_ops *ops);
/**
* Set the default computed_value evaluator in an ir_op_ops.
*
* @param code the opcode for the default operation
* @param ops the operations initialized
*/
void firm_set_default_computed_value(ir_opcode code, ir_op_ops *ops);
/**
* Sets the default equivalent node operation for an ir_op_ops.
*
* @param code the opcode for the default operation
* @param ops the operations initialized
*/
void firm_set_default_equivalent_node(ir_opcode code, ir_op_ops *ops);
/**
* Sets the default transform node operation for an ir_op_ops.
*
* @param code the opcode for the default operation
* @param ops the operations initialized
*/
void firm_set_default_transform_node(ir_opcode code, ir_op_ops *ops);
/**
* Set the default node attribute compare operation for an ir_op_ops.
*
* @param code the opcode for the default operation
* @param ops the operations initialized
*/
void firm_set_default_node_cmp_attr(ir_opcode code, ir_op_ops *ops);
#endif
Markdown is supported
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