1//===-- MyExtension.td - Transform dialect tutorial --------*- 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// 9// This file defines Transform dialect extension operations used in the 10// Chapter 4 of the Transform dialect tutorial. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef MY_EXTENSION 15#define MY_EXTENSION 16 17include "mlir/Dialect/Transform/Interfaces/MatchInterfaces.td" 18include "mlir/Dialect/Transform/IR/TransformDialect.td" 19include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.td" 20include "mlir/IR/OpBase.td" 21include "mlir/Interfaces/SideEffectInterfaces.td" 22 23// Define the new operation. By convention, prefix its name with `match` 24// followed by the name of the dialect extension. 25def HasOperandSatisfyingOp : TransformDialectOp<"match.my.has_operand_satisfying", 26 [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>, 27 DeclareOpInterfaceMethods<TransformOpInterface>, 28 // Indicate that the operation implements MatchOpInterface in addition to 29 // the TransformOpInterface. This interface is only used as a tag at this 30 // point and has no methods that are mandatory to implement. 31 MatchOpInterface, 32 SingleBlockImplicitTerminator<"::mlir::transform::YieldOp">]> { 33 let summary = "Succeed if any of the operands matches all nested criteria"; 34 let arguments = (ins TransformHandleTypeInterface:$op); 35 let results = (outs TransformParamTypeInterface:$position, 36 Variadic<Transform_AnyHandleOrParamType>:$results); 37 38 // Match operations can be arbitrarily complex, e.g., containing regions. 39 let regions = (region SizedRegion<1>:$body); 40 let hasVerifier = 1; 41 let assemblyFormat = [{ 42 $op `:` functional-type($op, results) attr-dict-with-keyword $body 43 }]; 44} 45 46#endif // MY_EXTENSION 47