[Mlir-commits] [mlir] [mlir][Transform] Add a transform.match.operation_empty op to allow s… (PR #68319)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Thu Oct 5 10:32:46 PDT 2023
================
@@ -55,12 +89,15 @@ class SingleOpMatcherOpTrait
TransformState &state) {
Value operandHandle = cast<OpTy>(this->getOperation()).getOperandHandle();
auto payload = state.getPayloadOps(operandHandle);
- if (!llvm::hasSingleElement(payload)) {
+ if (!payload.empty() && !llvm::hasSingleElement(payload)) {
return emitDefiniteFailure(this->getOperation()->getLoc())
- << "SingleOpMatchOpTrait requires the operand handle to point to "
- "a single payload op";
+ << "AtMostOneOpMatcherOpTrait requires the operand handle to "
+ "point to at most one payload op";
+ }
+ if (payload.empty()) {
+ return detail::matchOptionalOperation(cast<OpTy>(this->getOperation()),
----------------
ftynse wrote:
Since `this->getOperation()` isn't actually used in the call, we can just do explicit `detail::matchOptionalOperation<OpTy>(results, state)` here that will be shorter.
https://github.com/llvm/llvm-project/pull/68319
More information about the Mlir-commits
mailing list