1//===- MatchInterfaces.td - Transform dialect interfaces ---*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9include "mlir/IR/OpBase.td" 10include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.td" 11 12def MatchOpInterface 13 : OpInterface<"MatchOpInterface", [TransformOpInterface]> { 14 let cppNamespace = "::mlir::transform"; 15} 16 17// Trait for "matcher" transform operations that apply to an operation handle 18// associated with at most one payload operation. Checks that it is indeed 19// the case and produces a definite failure when it is not. The matching logic 20// is implemented in the `matchOperation` function instead of `apply`. The op 21// with this trait must provide a `Value getOperandHandle()` function that 22// returns the handle to be used for matching. 23def AtMostOneOpMatcher : NativeOpTrait<"AtMostOneOpMatcherOpTrait"> { 24 let cppNamespace = "::mlir::transform"; 25 26 string extraDeclaration = [{ 27 ::mlir::DiagnosedSilenceableFailure matchOperation( 28 ::std::optional<::mlir::Operation *> maybeCurrent, 29 ::mlir::transform::TransformResults &results, 30 ::mlir::transform::TransformState &state); 31 }]; 32} 33 34// Trait for "matcher" transform operations that apply to an operation handle 35// associated with exactly one payload operation. Checks that it is indeed 36// the case and produces a definite failure when it is not. The matching logic 37// is implemented in the `matchOperation` function instead of `apply`. The op 38// with this trait must provide a `Value getOperandHandle()` function that 39// returns the handle to be used for matching. 40def SingleOpMatcher : NativeOpTrait<"SingleOpMatcherOpTrait"> { 41 let cppNamespace = "::mlir::transform"; 42 43 string extraDeclaration = [{ 44 ::mlir::DiagnosedSilenceableFailure matchOperation( 45 ::mlir::Operation *current, 46 ::mlir::transform::TransformResults &results, 47 ::mlir::transform::TransformState &state); 48 }]; 49} 50 51// Trait for "matcher" transform operations that apply to a value handle 52// associated with exactly one payload value. Checks that it is indeed 53// the case and produces a definite failure when it is not. The matching logic 54// is implemented in the `matchValue` function instead of `apply`. The op 55// with this trait must provide a `Value getOperandHandle()` function that 56// returns the handle to be used for matching. 57def SingleValueMatcher : NativeOpTrait<"SingleValueMatcherOpTrait"> { 58 let cppNamespace = "::mlir::transform"; 59 60 string extraDeclaration = [{ 61 ::mlir::DiagnosedSilenceableFailure matchValue( 62 ::mlir::Value current, 63 ::mlir::transform::TransformResults &results, 64 ::mlir::transform::TransformState &state); 65 }]; 66} 67