19f3f6d7bSStella Laurenzo//===-- python_test_ops.td - Python test Op definitions ----*- tablegen -*-===// 29f3f6d7bSStella Laurenzo// 39f3f6d7bSStella Laurenzo// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 49f3f6d7bSStella Laurenzo// See https://llvm.org/LICENSE.txt for license information. 59f3f6d7bSStella Laurenzo// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 69f3f6d7bSStella Laurenzo// 79f3f6d7bSStella Laurenzo//===----------------------------------------------------------------------===// 89f3f6d7bSStella Laurenzo 99f3f6d7bSStella Laurenzo#ifndef PYTHON_TEST_OPS 109f3f6d7bSStella Laurenzo#define PYTHON_TEST_OPS 119f3f6d7bSStella Laurenzo 129f3f6d7bSStella Laurenzoinclude "mlir/Bindings/Python/Attributes.td" 139f3f6d7bSStella Laurenzoinclude "mlir/IR/OpBase.td" 14*14c92070SAlex Zinenkoinclude "mlir/Interfaces/InferTypeOpInterface.td" 159f3f6d7bSStella Laurenzo 169f3f6d7bSStella Laurenzodef Python_Test_Dialect : Dialect { 179f3f6d7bSStella Laurenzo let name = "python_test"; 18*14c92070SAlex Zinenko let cppNamespace = "python_test"; 199f3f6d7bSStella Laurenzo} 209f3f6d7bSStella Laurenzoclass TestOp<string mnemonic, list<OpTrait> traits = []> 219f3f6d7bSStella Laurenzo : Op<Python_Test_Dialect, mnemonic, traits>; 229f3f6d7bSStella Laurenzo 239f3f6d7bSStella Laurenzodef AttributedOp : TestOp<"attributed_op"> { 249f3f6d7bSStella Laurenzo let arguments = (ins I32Attr:$mandatory_i32, 259f3f6d7bSStella Laurenzo OptionalAttr<I32Attr>:$optional_i32, 269f3f6d7bSStella Laurenzo UnitAttr:$unit); 279f3f6d7bSStella Laurenzo} 289f3f6d7bSStella Laurenzo 29b4c93eceSJohn Demmedef PropertyOp : TestOp<"property_op"> { 30b4c93eceSJohn Demme let arguments = (ins I32Attr:$property, 31b4c93eceSJohn Demme I32:$idx); 32b4c93eceSJohn Demme} 33b4c93eceSJohn Demme 34*14c92070SAlex Zinenkodef DummyOp : TestOp<"dummy_op"> { 35*14c92070SAlex Zinenko} 36*14c92070SAlex Zinenko 37*14c92070SAlex Zinenkodef InferResultsOp : TestOp<"infer_results_op", [InferTypeOpInterface]> { 38*14c92070SAlex Zinenko let arguments = (ins); 39*14c92070SAlex Zinenko let results = (outs AnyInteger:$single, AnyInteger:$doubled); 40*14c92070SAlex Zinenko 41*14c92070SAlex Zinenko let extraClassDeclaration = [{ 42*14c92070SAlex Zinenko static ::mlir::LogicalResult inferReturnTypes( 43*14c92070SAlex Zinenko ::mlir::MLIRContext *context, ::llvm::Optional<::mlir::Location> location, 44*14c92070SAlex Zinenko ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, 45*14c92070SAlex Zinenko ::mlir::RegionRange regions, 46*14c92070SAlex Zinenko ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { 47*14c92070SAlex Zinenko ::mlir::Builder b(context); 48*14c92070SAlex Zinenko inferredReturnTypes.push_back(b.getI32Type()); 49*14c92070SAlex Zinenko inferredReturnTypes.push_back(b.getI64Type()); 50*14c92070SAlex Zinenko return ::mlir::success(); 51*14c92070SAlex Zinenko } 52*14c92070SAlex Zinenko }]; 53*14c92070SAlex Zinenko} 54*14c92070SAlex Zinenko 559f3f6d7bSStella Laurenzo#endif // PYTHON_TEST_OPS 56