14cb2ef4fSOleksandr "Alex" Zinenko//===-- MyExtension.td - Transform dialect tutorial --------*- tablegen -*-===// 24cb2ef4fSOleksandr "Alex" Zinenko// 34cb2ef4fSOleksandr "Alex" Zinenko// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 44cb2ef4fSOleksandr "Alex" Zinenko// See https://llvm.org/LICENSE.txt for license information. 54cb2ef4fSOleksandr "Alex" Zinenko// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 64cb2ef4fSOleksandr "Alex" Zinenko// 74cb2ef4fSOleksandr "Alex" Zinenko//===----------------------------------------------------------------------===// 84cb2ef4fSOleksandr "Alex" Zinenko// 94cb2ef4fSOleksandr "Alex" Zinenko// This file defines Transform dialect extension operations used in the 104cb2ef4fSOleksandr "Alex" Zinenko// Chapter 4 of the Transform dialect tutorial. 114cb2ef4fSOleksandr "Alex" Zinenko// 124cb2ef4fSOleksandr "Alex" Zinenko//===----------------------------------------------------------------------===// 134cb2ef4fSOleksandr "Alex" Zinenko 144cb2ef4fSOleksandr "Alex" Zinenko#ifndef MY_EXTENSION 154cb2ef4fSOleksandr "Alex" Zinenko#define MY_EXTENSION 164cb2ef4fSOleksandr "Alex" Zinenko 17*91856b34SOleksandr "Alex" Zinenkoinclude "mlir/Dialect/Transform/Interfaces/MatchInterfaces.td" 184cb2ef4fSOleksandr "Alex" Zinenkoinclude "mlir/Dialect/Transform/IR/TransformDialect.td" 195a9bdd85SOleksandr "Alex" Zinenkoinclude "mlir/Dialect/Transform/Interfaces/TransformInterfaces.td" 204cb2ef4fSOleksandr "Alex" Zinenkoinclude "mlir/IR/OpBase.td" 214cb2ef4fSOleksandr "Alex" Zinenkoinclude "mlir/Interfaces/SideEffectInterfaces.td" 224cb2ef4fSOleksandr "Alex" Zinenko 234cb2ef4fSOleksandr "Alex" Zinenko// Define the new operation. By convention, prefix its name with `match` 244cb2ef4fSOleksandr "Alex" Zinenko// followed by the name of the dialect extension. 254cb2ef4fSOleksandr "Alex" Zinenkodef HasOperandSatisfyingOp : TransformDialectOp<"match.my.has_operand_satisfying", 264cb2ef4fSOleksandr "Alex" Zinenko [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>, 274cb2ef4fSOleksandr "Alex" Zinenko DeclareOpInterfaceMethods<TransformOpInterface>, 284cb2ef4fSOleksandr "Alex" Zinenko // Indicate that the operation implements MatchOpInterface in addition to 294cb2ef4fSOleksandr "Alex" Zinenko // the TransformOpInterface. This interface is only used as a tag at this 304cb2ef4fSOleksandr "Alex" Zinenko // point and has no methods that are mandatory to implement. 314cb2ef4fSOleksandr "Alex" Zinenko MatchOpInterface, 324cb2ef4fSOleksandr "Alex" Zinenko SingleBlockImplicitTerminator<"::mlir::transform::YieldOp">]> { 334cb2ef4fSOleksandr "Alex" Zinenko let summary = "Succeed if any of the operands matches all nested criteria"; 344cb2ef4fSOleksandr "Alex" Zinenko let arguments = (ins TransformHandleTypeInterface:$op); 354cb2ef4fSOleksandr "Alex" Zinenko let results = (outs TransformParamTypeInterface:$position, 364cb2ef4fSOleksandr "Alex" Zinenko Variadic<Transform_AnyHandleOrParamType>:$results); 374cb2ef4fSOleksandr "Alex" Zinenko 384cb2ef4fSOleksandr "Alex" Zinenko // Match operations can be arbitrarily complex, e.g., containing regions. 394cb2ef4fSOleksandr "Alex" Zinenko let regions = (region SizedRegion<1>:$body); 404cb2ef4fSOleksandr "Alex" Zinenko let hasVerifier = 1; 414cb2ef4fSOleksandr "Alex" Zinenko let assemblyFormat = [{ 424cb2ef4fSOleksandr "Alex" Zinenko $op `:` functional-type($op, results) attr-dict-with-keyword $body 434cb2ef4fSOleksandr "Alex" Zinenko }]; 444cb2ef4fSOleksandr "Alex" Zinenko} 454cb2ef4fSOleksandr "Alex" Zinenko 464cb2ef4fSOleksandr "Alex" Zinenko#endif // MY_EXTENSION 47