X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Freassoc.c;h=a12f5e1cd438496fcd2a5047327340105e9d62db;hb=3df3d2e3436415a80afaa2a04bf9e02378888101;hp=b7cfe70133f5ff43bb3b55ce015ca5f4afc0d007;hpb=7583c9feb0b5e90bed8e3f9a666718a7d9d3f56f;p=libfirm diff --git a/ir/opt/reassoc.c b/ir/opt/reassoc.c index b7cfe7013..a12f5e1cd 100644 --- a/ir/opt/reassoc.c +++ b/ir/opt/reassoc.c @@ -337,8 +337,8 @@ static void do_reassociation(ir_node *n, void *env) 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; } @@ -387,17 +387,28 @@ void optimize_reassociation(ir_graph *irg) } } +/* 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"); }