//===- TestTransformDialectExtension.td --------------------*- tablegen -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file declares the operations that are injected into the Transform // dialect through the extension mechanism, as a test. // //===----------------------------------------------------------------------===// #ifndef MLIR_TESTTRANSFORMDIALECTEXTENSION_TD #define MLIR_TESTTRANSFORMDIALECTEXTENSION_TD include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/IR/AttrTypeBase.td" include "mlir/IR/OpBase.td" include "mlir/Dialect/Transform/IR/TransformDialect.td" include "mlir/Dialect/Transform/IR/TransformInterfaces.td" include "mlir/Dialect/PDL/IR/PDLTypes.td" def TestTransformTestDialectHandleType : TypeDef]> { let description = [{Handle pointing to an op from the Test dialect.}]; let mnemonic = "test_dialect_op"; let assemblyFormat = ""; } def TestTransformTestDialectParamType : TypeDef]> { let description = [{ Parameter associated with an i32 attribute for testing purposes. }]; let mnemonic = "test_dialect_param"; let assemblyFormat = ""; } def TestProduceSelfHandleOrForwardOperandOp : Op, DeclareOpInterfaceMethods]> { let arguments = (ins Optional:$operand); let results = (outs PDL_Operation:$res); let assemblyFormat = "($operand^)? attr-dict"; let cppNamespace = "::mlir::test"; } def TestProduceValueHandleToSelfOperand : Op, DeclareOpInterfaceMethods]> { let arguments = (ins TransformHandleTypeInterface:$in); let results = (outs TransformValueHandleTypeInterface:$out); let assemblyFormat = "$in attr-dict `:` functional-type(operands, results)"; let cppNamespace = "::mlir::test"; } def TestProduceValueHandleToResult : Op]> { let arguments = (ins TransformHandleTypeInterface:$in, I64Attr:$number); let results = (outs TransformValueHandleTypeInterface:$out); let assemblyFormat = "$in `,` $number attr-dict `:` functional-type(operands, results)"; let cppNamespace = "::mlir::test"; let extraClassDeclaration = [{ ::mlir::DiagnosedSilenceableFailure applyToOne( ::mlir::Operation *target, ::mlir::transform::ApplyToEachResultList &results, ::mlir::transform::TransformState &state); }]; } def TestProduceValueHandleToArgumentOfParentBlock : Op]> { let arguments = (ins TransformHandleTypeInterface:$in, I64Attr:$number); let results = (outs TransformValueHandleTypeInterface:$out); let assemblyFormat = "$in `,` $number attr-dict `:` functional-type(operands, results)"; let cppNamespace = "::mlir::test"; let extraClassDeclaration = [{ ::mlir::DiagnosedSilenceableFailure applyToOne( ::mlir::Operation *target, ::mlir::transform::ApplyToEachResultList &results, ::mlir::transform::TransformState &state); }]; } def TestConsumeOperand : Op, DeclareOpInterfaceMethods]> { let arguments = (ins Transform_AnyHandleOrParamType:$operand, Optional:$second_operand); let assemblyFormat = "$operand (`,` $second_operand^)? attr-dict `:` type($operand)"; let cppNamespace = "::mlir::test"; } def TestConsumeOperandOfOpKindOrFail : Op, DeclareOpInterfaceMethods]> { let arguments = (ins PDL_Operation:$operand, StrAttr:$op_kind); let assemblyFormat = "$operand `,` $op_kind attr-dict"; let cppNamespace = "::mlir::test"; } def TestPrintRemarkAtOperandOp : Op, DeclareOpInterfaceMethods]> { let arguments = (ins TransformHandleTypeInterface:$operand, StrAttr:$message); let assemblyFormat = "$operand `,` $message attr-dict `:` type($operand)"; let cppNamespace = "::mlir::test"; } def TestPrintRemarkAtOperandValue : Op, DeclareOpInterfaceMethods]> { let arguments = (ins TransformValueHandleTypeInterface:$in, StrAttr:$message); let assemblyFormat = "$in `,` $message attr-dict `:` type($in)"; let cppNamespace = "::mlir::test"; } def TestAddTestExtensionOp : Op, NoMemoryEffect]> { let arguments = (ins StrAttr:$message); let assemblyFormat = "$message attr-dict"; let cppNamespace = "::mlir::test"; } def TestCheckIfTestExtensionPresentOp : Op, DeclareOpInterfaceMethods]> { let arguments = (ins PDL_Operation:$operand); let assemblyFormat = "$operand attr-dict"; let cppNamespace = "::mlir::test"; } def TestRemapOperandPayloadToSelfOp : Op, DeclareOpInterfaceMethods]> { let arguments = (ins PDL_Operation:$operand); let results = (outs Optional:$out); let assemblyFormat = "$operand attr-dict (`:` type($out)^)?"; let cppNamespace = "::mlir::test"; } def TestRemoveTestExtensionOp : Op, NoMemoryEffect]> { let assemblyFormat = "attr-dict"; let cppNamespace = "::mlir::test"; } def TestReversePayloadOpsOp : Op]> { let arguments = (ins PDL_Operation:$target); let results = (outs PDL_Operation:$result); let assemblyFormat = "$target attr-dict"; let cppNamespace = "::mlir::test"; } def TestTransformOpWithRegions : Op, DeclareOpInterfaceMethods]> { let regions = (region AnyRegion:$first, AnyRegion:$second); let assemblyFormat = "attr-dict-with-keyword regions"; let cppNamespace = "::mlir::test"; } def TestBranchingTransformOpTerminator : Op, DeclareOpInterfaceMethods]> { let successors = (successor VariadicSuccessor:$succ); let cppNamespace = "::mlir::test"; } def TestEmitRemarkAndEraseOperandOp : Op, MemoryEffectsOpInterface, FunctionalStyleTransformOpTrait]> { let arguments = (ins PDL_Operation:$target, StrAttr:$remark, UnitAttr:$fail_after_erase); let assemblyFormat = "$target `,` $remark attr-dict"; let cppNamespace = "::mlir::test"; } def TestWrongNumberOfResultsOp : Op { let arguments = (ins PDL_Operation:$target); let results = (outs PDL_Operation:$a, PDL_Operation:$b, PDL_Operation:$c); let assemblyFormat = "$target attr-dict"; let cppNamespace = "::mlir::test"; let extraClassDeclaration = [{ ::mlir::DiagnosedSilenceableFailure applyToOne( ::mlir::Operation * target, ::mlir::transform::ApplyToEachResultList &results, ::mlir::transform::TransformState &state); }]; } def TestWrongNumberOfMultiResultsOp : Op { let arguments = (ins PDL_Operation:$target); let results = (outs PDL_Operation:$result); let assemblyFormat = "$target attr-dict"; let cppNamespace = "::mlir::test"; let extraClassDeclaration = [{ ::mlir::DiagnosedSilenceableFailure applyToOne( ::mlir::Operation * target, ::mlir::transform::ApplyToEachResultList &results, ::mlir::transform::TransformState &state); }]; } def TestCorrectNumberOfMultiResultsOp : Op { let arguments = (ins PDL_Operation:$target); let results = (outs PDL_Operation:$result1, PDL_Operation:$result2); let assemblyFormat = "$target attr-dict"; let cppNamespace = "::mlir::test"; let extraClassDeclaration = [{ ::mlir::DiagnosedSilenceableFailure applyToOne( ::mlir::Operation * target, ::mlir::transform::ApplyToEachResultList &results, ::mlir::transform::TransformState &state); }]; } def TestMixedNullAndNonNullResultsOp : Op { let arguments = (ins PDL_Operation:$target); let results = (outs PDL_Operation:$null, PDL_Operation:$non_null); let assemblyFormat = "$target attr-dict"; let cppNamespace = "::mlir::test"; let extraClassDeclaration = [{ ::mlir::DiagnosedSilenceableFailure applyToOne( ::mlir::Operation * target, ::mlir::transform::ApplyToEachResultList &results, ::mlir::transform::TransformState &state); }]; } def TestMixedSuccessAndSilenceableOp : Op { let arguments = (ins PDL_Operation:$target); let results = (outs); let assemblyFormat = "$target attr-dict"; let cppNamespace = "::mlir::test"; let extraClassDeclaration = [{ ::mlir::DiagnosedSilenceableFailure applyToOne( ::mlir::Operation * target, ::mlir::transform::ApplyToEachResultList &results, ::mlir::transform::TransformState &state); }]; } def TestPrintNumberOfAssociatedPayloadIROps : Op, DeclareOpInterfaceMethods]> { let arguments = (ins PDL_Operation:$handle); let assemblyFormat = "$handle attr-dict"; let cppNamespace = "::mlir::test"; } def TestCopyPayloadOp : Op, DeclareOpInterfaceMethods]> { let arguments = (ins PDL_Operation:$handle); let results = (outs PDL_Operation:$copy); let cppNamespace = "::mlir::test"; let assemblyFormat = "$handle attr-dict"; } def TestReportNumberOfTrackedHandlesNestedUnder : Op, DeclareOpInterfaceMethods]> { let arguments = (ins PDL_Operation:$target); let assemblyFormat = "$target attr-dict"; let cppNamespace = "::mlir::test"; } def TestPrintParamOp : Op, DeclareOpInterfaceMethods]> { let arguments = (ins TransformParamTypeInterface:$param); let assemblyFormat = "$param attr-dict `:` type($param)"; let cppNamespace = "::mlir::test"; } def TestAddToParamOp : Op]> { let arguments = (ins Optional:$param, I32Attr:$addendum); let results = (outs TestTransformTestDialectParamType:$result); let assemblyFormat = "($param^ `,`)? $addendum attr-dict"; let cppNamespace = "::mlir::test"; } def TestProduceParamWithNumberOfTestOps : Op]> { let arguments = (ins TransformHandleTypeInterface:$handle); let results = (outs TestTransformTestDialectParamType:$result); let assemblyFormat = "$handle attr-dict `:` type($handle)"; let cppNamespace = "::mlir::test"; } def TestProduceIntegerParamWithTypeOp : Op]> { let arguments = (ins TypeAttr:$type); let results = (outs TransformParamTypeInterface:$result); let assemblyFormat = "$type attr-dict `:` type($result)"; let cppNamespace = "::mlir::test"; let hasVerifier = 1; } def TestProduceTransformParamOrForwardOperandOp : Op, TransformEachOpTrait, TransformOpInterface]> { let arguments = (ins TransformHandleTypeInterface:$in, UnitAttr:$first_result_is_param, UnitAttr:$first_result_is_null, UnitAttr:$second_result_is_handle); let results = (outs AnyType:$out, TransformParamTypeInterface:$param); let assemblyFormat = "$in attr-dict `:` functional-type(operands, results)"; let cppNamespace = "::mlir::test"; let extraClassDeclaration = [{ ::mlir::DiagnosedSilenceableFailure applyToOne( ::mlir::Operation *target, ::mlir::transform::ApplyToEachResultList &results, ::mlir::transform::TransformState &state); }]; } def TestProduceNullPayloadOp : Op, DeclareOpInterfaceMethods]> { let results = (outs TransformHandleTypeInterface:$out); let assemblyFormat = "attr-dict `:` type($out)"; let cppNamespace = "::mlir::test"; } def TestProduceNullParamOp : Op, DeclareOpInterfaceMethods]> { let results = (outs TransformParamTypeInterface:$out); let assemblyFormat = "attr-dict `:` type($out)"; let cppNamespace = "::mlir::test"; } def TestProduceNullValueOp : Op, DeclareOpInterfaceMethods]> { let results = (outs TransformValueHandleTypeInterface:$out); let assemblyFormat = "attr-dict `:` type($out)"; let cppNamespace = "::mlir::test"; } def TestRequiredMemoryEffectsOp : Op, DeclareOpInterfaceMethods]> { let arguments = (ins TransformHandleTypeInterface:$in, UnitAttr:$has_operand_effect, UnitAttr:$has_result_effect, UnitAttr:$modifies_payload); let results = (outs TransformHandleTypeInterface:$out); let assemblyFormat = "$in attr-dict `:` functional-type(operands, results)"; let cppNamespace = "::mlir::test"; } #endif // MLIR_TESTTRANSFORMDIALECTEXTENSION_TD