1 //===-- MyExtension.td - Transform dialect tutorial --------*- tablegen -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines Transform dialect extension operations used in the
10 // Chapter 2 of the Transform dialect tutorial.
12 //===----------------------------------------------------------------------===//
17 include "mlir/Dialect/Transform/IR/TransformDialect.td"
18 include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.td"
19 include "mlir/IR/OpBase.td"
20 include "mlir/Interfaces/SideEffectInterfaces.td"
22 // Define the new operation. By convention, prefix its name with the name of the dialect
23 // extension, "my.". The full operation name will be further prefixed with "transform.".
24 def ChangeCallTargetOp : Op<Transform_Dialect, "my.change_call_target",
25 // Indicate that the operation implements the required TransformOpInterface and
26 // MemoryEffectsOpInterface.
27 [DeclareOpInterfaceMethods<TransformOpInterface>,
28 DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
29 // Provide a brief and a full description. It is recommended that the latter describes
30 // the effects on the operands and how the operation processes various failure modes.
31 let summary = "Changes the callee of a call operation to the specified one";
33 For each `func.call` payload operation associated with the handle, changes its
34 callee to be the symbol whose name is provided as an attribute to this operation.
36 Generates a silenceable failure if the operand is associated with payload operations
37 that are not `func.call`.
38 Only reads the operand.
41 // The arguments include the handle to the payload operations and the attribute that
42 // specifies the new callee. The handle must implement TransformHandleTypeInterface.
43 // We use a string attribute as the symbol may not exist in the transform IR so the
44 // verification may fail.
46 TransformHandleTypeInterface:$call,
49 // The results are empty as the transformation does not produce any new payload.
52 // Provide nice syntax.
53 let assemblyFormat = "$call `,` $new_target attr-dict `:` type($call)";
56 #endif // MY_EXTENSION