[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
================
@@ -11,14 +11,46 @@
#include "mlir/Dialect/Transform/IR/TransformInterfaces.h"
#include "mlir/IR/OpDefinition.h"
+#include "llvm/ADT/STLExtras.h"
+#include <optional>
+#include <type_traits>
namespace mlir {
namespace transform {
class MatchOpInterface;
+namespace detail {
template <typename OpTy>
-class SingleOpMatcherOpTrait
- : public OpTrait::TraitBase<OpTy, SingleOpMatcherOpTrait> {
+DiagnosedSilenceableFailure
+matchOptionalOperationImpl(OpTy op, TransformResults &results,
+ TransformState &state, std::false_type) {
+ return op.matchOperation(std::nullopt, results, state);
+}
+
+template <typename OpTy>
+DiagnosedSilenceableFailure
+matchOptionalOperationImpl(OpTy op, TransformResults &results,
+ TransformState &state, std::true_type) {
+ return op.matchOperation(nullptr, results, state);
+}
+
+/// Dispatch `matchOperation` based on Operation* or std::optional<Operation*>
+/// first operand.
+template <typename OpTy, typename... Args>
----------------
ftynse wrote:
Args... is unused here, let's drop.
https://github.com/llvm/llvm-project/pull/68319
More information about the Mlir-commits
mailing list