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
4 include "mlir/IR/OpBase.td"
6 def Test_Dialect : Dialect {
9 class NS_Op<string mnemonic, list<Trait> traits> :
10 Op<Test_Dialect, mnemonic, traits>;
12 def OpA : NS_Op<"one_normal_operand_op", []> {
13 let arguments = (ins I32:$input);
16 // CHECK-LABEL: OpA definitions
18 // CHECK: void OpA::build
19 // CHECK: ::mlir::Value input
20 // CHECK: odsState.addOperands(input);
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);
27 def OpB : NS_Op<"one_variadic_operand_op", []> {
28 let arguments = (ins Variadic<I32>:$input);
31 // CHECK-LABEL: OpB::build
32 // CHECK: ::mlir::ValueRange input
34 // CHECK: odsState.addOperands(input);
36 def OpD : NS_Op<"mix_variadic_and_normal_inputs_op", [SameVariadicOperandSize]> {
37 let arguments = (ins Variadic<AnyTensor>:$input1, AnyTensor:$input2, Variadic<AnyTensor>:$input3);
40 // DECL-LABEL: ::mlir::Operation::operand_range getInput1
41 // DECL-NEXT: return getODSOperands(0);
43 // DECL-LABEL: ::mlir::TypedValue<::mlir::TensorType> getInput2
44 // DECL-NEXT: return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin());
46 // CHECK-LABEL: OpD::build
47 // CHECK-NEXT: odsState.addOperands(input1);
48 // CHECK-NEXT: odsState.addOperands(input2);
49 // CHECK-NEXT: odsState.addOperands(input3);