1// RUN: mlir-tblgen -gen-op-defs -I %S/../../include %s | FileCheck %s 2// RUN: mlir-tblgen -gen-op-decls -I %S/../../include %s | FileCheck %s --check-prefix=DECL 3 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// CHECK-LABEL: OpA definitions 17 18// CHECK: void OpA::build 19// CHECK: ::mlir::Value input 20// CHECK: odsState.addOperands(input); 21 22// CHECK: void OpA::build 23// CHECK: ::mlir::ValueRange operands 24// CHECK: assert(operands.size() == 1u && "mismatched number of parameters"); 25// CHECK: odsState.addOperands(operands); 26 27def OpB : NS_Op<"one_variadic_operand_op", []> { 28 let arguments = (ins Variadic<I32>:$input); 29} 30 31// CHECK-LABEL: OpB::build 32// CHECK: ::mlir::ValueRange input 33// CHECK-NOT: assert 34// CHECK: odsState.addOperands(input); 35 36def OpD : NS_Op<"mix_variadic_and_normal_inputs_op", [SameVariadicOperandSize]> { 37 let arguments = (ins Variadic<AnyTensor>:$input1, AnyTensor:$input2, Variadic<AnyTensor>:$input3); 38} 39 40// DECL-LABEL: ::mlir::Operation::operand_range getInput1 41// DECL-NEXT: return getODSOperands(0); 42 43// DECL-LABEL: ::mlir::TypedValue<::mlir::TensorType> getInput2 44// DECL-NEXT: return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); 45 46// CHECK-LABEL: OpD::build 47// CHECK-NEXT: odsState.addOperands(input1); 48// CHECK-NEXT: odsState.addOperands(input2); 49// CHECK-NEXT: odsState.addOperands(input3); 50