#include <string.h>
#endif
-# include "irnode_t.h"
-# include "irgraph_t.h"
-# include "iredges_t.h"
-# include "irmode_t.h"
-# include "iropt_t.h"
-# include "ircons_t.h"
-# include "irgmod.h"
-# include "irvrfy.h"
-# include "tv_t.h"
-# include "dbginfo_t.h"
-# include "iropt_dbg.h"
-# include "irflag_t.h"
-# include "irhooks.h"
-# include "irarch.h"
-# include "hashptr.h"
-# include "archop.h"
-# include "opt_polymorphy.h"
-# include "opt_confirms.h"
+#include "irnode_t.h"
+#include "irgraph_t.h"
+#include "iredges_t.h"
+#include "irmode_t.h"
+#include "iropt_t.h"
+#include "ircons_t.h"
+#include "irgmod.h"
+#include "irvrfy.h"
+#include "tv_t.h"
+#include "dbginfo_t.h"
+#include "iropt_dbg.h"
+#include "irflag_t.h"
+#include "irhooks.h"
+#include "irarch.h"
+#include "hashptr.h"
+#include "archop.h"
+#include "opt_polymorphy.h"
+#include "opt_confirms.h"
/* Make types visible to allow most efficient access */
# include "entity_t.h"
*/
tarval *computed_value(ir_node *n)
{
- if (n->op->computed_value)
- return n->op->computed_value(n);
+ if (n->op->ops.computed_value)
+ return n->op->ops.computed_value(n);
return tarval_bad;
}
/**
- * set the default computed_value evaluator
+ * 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 *firm_set_default_computed_value(ir_op *op)
+static ir_op_ops *firm_set_default_computed_value(opcode code, ir_op_ops *ops)
{
#define CASE(a) \
case iro_##a: \
- op->computed_value = computed_value_##a; \
+ ops->computed_value = computed_value_##a; \
break
- switch (op->code) {
+ switch (code) {
CASE(Const);
CASE(SymConst);
CASE(Add);
CASE(Mux);
CASE(Confirm);
default:
- op->computed_value = NULL;
+ /* leave NULL */;
}
- return op;
+ return ops;
#undef CASE
}
/**
* Optimize an "idempotent unary op", ie op(op(n)) = n.
*
- * @fixme -(-a) == a, but might overflow two times.
- * We handle it anyway here but the better way would be a
- * flag. This would be needed for Pascal for instance.
+ * @todo
+ * -(-a) == a, but might overflow two times.
+ * We handle it anyway here but the better way would be a
+ * flag. This would be needed for Pascal for instance.
*/
static ir_node *equivalent_node_idempotent_unop(ir_node *n)
{
return bound;
}
}
- return get_opt_remove_Confirm() ? get_Confirm_value(n) : n;
+ return get_opt_remove_confirm() ? get_Confirm_value(n) : n;
}
/**
ir_node *
equivalent_node(ir_node *n)
{
- if (n->op->equivalent_node)
- return n->op->equivalent_node(n);
+ if (n->op->ops.equivalent_node)
+ return n->op->ops.equivalent_node(n);
return n;
}
/**
- * set the default equivalent node operation
+ * 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 *firm_set_default_equivalent_node(ir_op *op)
+static ir_op_ops *firm_set_default_equivalent_node(opcode code, ir_op_ops *ops)
{
#define CASE(a) \
case iro_##a: \
- op->equivalent_node = equivalent_node_##a; \
+ ops->equivalent_node = equivalent_node_##a; \
break
- switch (op->code) {
+ switch (code) {
CASE(Block);
CASE(Jmp);
CASE(Raise);
CASE(Confirm);
CASE(CopyB);
default:
- op->equivalent_node = NULL;
+ /* leave NULL */;
}
- return op;
+ return ops;
#undef CASE
}
static ir_node *transform_node_Cast(ir_node *n) {
ir_node *oldn = n;
ir_node *pred = get_Cast_op(n);
- type *tp = get_irn_type(n);
+ ir_type *tp = get_irn_type(n);
if (get_irn_op(pred) == op_Const && get_Const_type(pred) != tp) {
n = new_rd_Const_type(NULL, current_ir_graph, get_irn_n(pred, -1), get_irn_mode(pred),
*/
static ir_node *transform_node(ir_node *n)
{
- if (n->op->transform_node)
- n = n->op->transform_node(n);
+ if (n->op->ops.transform_node)
+ n = n->op->ops.transform_node(n);
return n;
}
/**
- * set the default transform node operation
+ * sSets 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 *firm_set_default_transform_node(ir_op *op)
+static ir_op_ops *firm_set_default_transform_node(opcode code, ir_op_ops *ops)
{
#define CASE(a) \
case iro_##a: \
- op->transform_node = transform_node_##a; \
+ ops->transform_node = transform_node_##a; \
break
- switch (op->code) {
+ switch (code) {
CASE(Add);
CASE(Sub);
CASE(Mul);
CASE(End);
CASE(Mux);
default:
- op->transform_node = NULL;
+ /* leave NULL */;
}
- return op;
+ return ops;
#undef CASE
}
}
/**
- * set the default node attribute compare operation
+ * 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 *firm_set_default_node_cmp_attr(ir_op *op)
+static ir_op_ops *firm_set_default_node_cmp_attr(opcode code, ir_op_ops *ops)
{
-#define CASE(a) \
- case iro_##a: \
- op->node_cmp_attr = node_cmp_attr_##a; \
+#define CASE(a) \
+ case iro_##a: \
+ ops->node_cmp_attr = node_cmp_attr_##a; \
break
- switch (op->code) {
+ switch (code) {
CASE(Const);
CASE(Proj);
CASE(Filter);
CASE(Store);
CASE(Confirm);
default:
- op->node_cmp_attr = NULL;
+ /* leave NULL */;
}
- return op;
+ return ops;
#undef CASE
}
* here, we already now that the nodes are identical except their
* attributes
*/
- if (a->op->node_cmp_attr)
- return a->op->node_cmp_attr(a, b);
+ if (a->op->ops.node_cmp_attr)
+ return a->op->ops.node_cmp_attr(a, b);
return 0;
}
tv = computed_value(n);
if (tv != tarval_bad) {
ir_node *nw;
- type *old_tp = get_irn_type(n);
+ ir_type *old_tp = get_irn_type(n);
int i, arity = get_irn_arity(n);
int node_size;
tv = computed_value(n);
if (tv != tarval_bad) {
/* evaluation was successful -- replace the node. */
- type *old_tp = get_irn_type(n);
+ ir_type *old_tp = get_irn_type(n);
int i, arity = get_irn_arity(n);
/*
return optimize_in_place_2 (n);
}
-/**
- * set the default ir op operations
+/*
+ * Sets the default operation for an ir_ops.
*/
-ir_op *firm_set_default_operations(ir_op *op)
+ir_op_ops *firm_set_default_operations(opcode code, ir_op_ops *ops)
{
- op = firm_set_default_computed_value(op);
- op = firm_set_default_equivalent_node(op);
- op = firm_set_default_transform_node(op);
- op = firm_set_default_node_cmp_attr(op);
- op = firm_set_default_get_type(op);
+ 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(code, ops);
+ ops = firm_set_default_get_type_attr(code, ops);
+ ops = firm_set_default_get_entity_attr(code, ops);
- return op;
+ return ops;
}