[code-reflection] RFR: Examples Improved - FMA Dialect refactored

Paul Sandoz psandoz at openjdk.org
Wed Sep 17 17:10:10 UTC 2025


On Tue, 16 Sep 2025 14:49:34 GMT, Juan Fumero <jfumero at openjdk.org> wrote:

> - Examples Improved - FMA Dialect refactored
> - README fixed 
> - Documentation fixed

You can remove the local variable `pending`.

cr-examples/samples/src/main/java/oracle/code/samples/DialectFMAOp.java line 159:

> 157:         CoreOp.FuncOp dialectModel = functionModel.transform((builder, op) -> {
> 158:             CopyContext context = builder.context();
> 159:             if (op instanceof JavaOp.MulOp mulOp && nodesInvolved.contains(mulOp)) {

It might be clearer if you do this:

if (!nodesInvolved.contains(op)) {
    builder.op(op);
} else if (op instanceof JavaOp.MulOp) {
} else if (op instanceof JavaOp.AddOp) {
  // We know at this point the add op is the root of the expression `add(mul(a, b), c)` 
}


It would nice if we could easily accumulate the operand values a, b, c, we need pattern matching. I original thought Value::dependsOn could help, but that is different since it returns a Set since one or more operands could be the same value. We need an easier way to traverse up the tree of the expression e.g. value -> List<value> (represents the operands of an op if value is a result of that op, otherwise empty.)

-------------

PR Review: https://git.openjdk.org/babylon/pull/570#pullrequestreview-3235430823
PR Review Comment: https://git.openjdk.org/babylon/pull/570#discussion_r2356177455


More information about the babylon-dev mailing list