61 lines · plain
1// RUN: mlir-tblgen -gen-op-defs -I %S/../../include %s | FileCheck %s2// RUN: mlir-tblgen -gen-op-decls -I %S/../../include %s | FileCheck %s --check-prefix=DECL3 4include "mlir/IR/OpBase.td"5 6def Test_Dialect : Dialect {7 let name = "test";8}9class NS_Op<string mnemonic, list<Trait> traits> :10 Op<Test_Dialect, mnemonic, traits>;11 12def OpA : NS_Op<"one_normal_operand_op", []> {13 let arguments = (ins I32:$input);14}15 16// DECL-LABEL: class OpA : {{.*}} {17// DECL: static constexpr int odsIndex_input = 0;18 19// CHECK-LABEL: OpA definitions20 21// CHECK: void OpA::build22// CHECK: ::mlir::Value input23// CHECK: odsState.addOperands(input);24 25// CHECK: void OpA::build26// CHECK: ::mlir::ValueRange operands27// CHECK: assert(operands.size() == 1u && "mismatched number of parameters");28// CHECK: odsState.addOperands(operands);29 30def OpB : NS_Op<"one_variadic_operand_op", []> {31 let arguments = (ins Variadic<I32>:$input);32}33 34// DECL-LABEL: class OpB : {{.*}} {35// DECL: static constexpr int odsIndex_input = 0;36 37// CHECK-LABEL: OpB::build38// CHECK: ::mlir::ValueRange input39// CHECK-NOT: assert40// CHECK: odsState.addOperands(input);41 42def OpD : NS_Op<"mix_variadic_and_normal_inputs_op", [SameVariadicOperandSize]> {43 let arguments = (ins Variadic<AnyTensor>:$input1, AnyTensor:$input2, Variadic<AnyTensor>:$input3);44}45 46// DECL-LABEL: class OpD : {{.*}} {47// DECL: static constexpr int odsIndex_input1 = 0;48// DECL: static constexpr int odsIndex_input2 = 1;49// DECL: static constexpr int odsIndex_input3 = 2;50 51// DECL-LABEL: ::mlir::Operation::operand_range getInput152// DECL-NEXT: return getODSOperands(0);53 54// DECL-LABEL: ::mlir::TypedValue<::mlir::TensorType> getInput255// DECL-NEXT: return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin());56 57// CHECK-LABEL: OpD::build58// CHECK-NEXT: odsState.addOperands(input1);59// CHECK-NEXT: odsState.addOperands(input2);60// CHECK-NEXT: odsState.addOperands(input3);61