res = 0;
/* reassociation works only for integer or reference modes */
- if (op->reassociate && (mode_is_int(mode) || mode_is_reference(mode))) {
- res = op->reassociate(&n);
+ if (op->ops.reassociate && (mode_is_int(mode) || mode_is_reference(mode))) {
+ res = op->ops.reassociate(&n);
wenv->changes |= res;
}
}
}
+/* Sets the default reassociation operation for an ir_op_ops. */
+ir_op_ops *firm_set_default_reassoc(opcode code, ir_op_ops *ops)
+{
+#define CASE(a) case iro_##a: ops->reassociate = reassoc_##a; break
+
+ switch (code) {
+ CASE(Mul);
+ CASE(Add);
+ CASE(Sub);
+ CASE(And);
+ CASE(Or);
+ CASE(Eor);
+ default:
+ /* leave NULL */;
+ }
+
+ return ops;
+#undef CASE
+}
+
/* initialize the reassociation by adding operations to some opcodes */
void firm_init_reassociation(void)
{
-#define INIT(a) op_##a->reassociate = reassoc_##a;
- INIT(Mul);
- INIT(Add);
- INIT(Sub);
- INIT(And);
- INIT(Or);
- INIT(Eor);
-#undef INIT
-
dbg = firm_dbg_register("firm.opt.reassoc");
}
#include "reassoc.h"
+/**
+ * Sets the default reassociation operation 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_reassoc(opcode code, ir_op_ops *ops);
+
/** Initialise the ressociation optimization */
void firm_init_reassociation(void);