This is commit 1 of 4 for the multi-root matching in PDL, discussed in https://llvm.discourse.group/t/rfc-multi-root-pdl-patterns-for-kernel-matching/4148 (topic flagged for review).
These operations are:
- pdl.get_accepting_ops: Returns a list of operations accepting the given value or a range of values at the specified position. Thus if there are two operations %op1 = "foo"(%val) and %op2 = "bar"(%val) accepting a value at position 0, %ops = pdl_interp.get_accepting_ops of %val : !pdl.value at 0 will return both of them. This allows us to traverse upwards from a value to operations accepting the value.
- pdl.choose_op: Iteratively chooses one operation from a range of operations. Therefore, writing %op = pdl_interp.choose_op from %ops in the example above will select either %op1or %op2.
Testing: Added the corresponding test cases to mlir/test/Dialect/PDLInterp/ops.mlir.
Is there a longer more descriptive name we can go for here? Possibly something that also capture the iterative nature of this?
Also, I'm not entirely sure we should mark this NoSideEffect. Or more specifically, I feel like transformations to this operation have a much greater cost than other "no side effect" operations (and I'm not sure if something will negatively take advantage of that). Say if we hoisted this operation higher up, wouldn't we end up executing much more bitcode than before?