[code-reflection] RFR: Examples Improved - FMA Dialect refactored
Juan Fumero
jfumero at openjdk.org
Wed Sep 17 18:07:45 UTC 2025
On Wed, 17 Sep 2025 17:06:54 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
>> - Examples Improved - FMA Dialect refactored
>> - README fixed
>> - Documentation fixed
>
> 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.)
Thanks, good point. Yes, I think pattern matching will help here.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/570#discussion_r2356329872
More information about the babylon-dev
mailing list