2019-03-21 08:25:34 +08:00
|
|
|
// RUN: mlir-tblgen -gen-op-defs -I %S/../../include %s | FileCheck %s
|
2019-03-07 04:50:01 +08:00
|
|
|
|
|
|
|
include "mlir/IR/OpBase.td"
|
|
|
|
|
2019-04-30 00:24:09 +08:00
|
|
|
def Test_Dialect : Dialect {
|
|
|
|
let name = "test";
|
|
|
|
}
|
|
|
|
class NS_Op<string mnemonic, list<OpTrait> traits> :
|
|
|
|
Op<Test_Dialect, mnemonic, traits>;
|
|
|
|
|
|
|
|
def OpA : NS_Op<"one_normal_operand_op", []> {
|
2019-03-07 04:50:01 +08:00
|
|
|
let arguments = (ins I32:$input);
|
|
|
|
}
|
|
|
|
|
2019-04-10 23:00:34 +08:00
|
|
|
// CHECK-LABEL: OpA definitions
|
2019-03-28 05:09:19 +08:00
|
|
|
|
2020-06-15 21:01:31 +08:00
|
|
|
// CHECK: OpAAdaptor::OpAAdaptor
|
2020-05-29 00:05:24 +08:00
|
|
|
// CHECK-SAME: odsOperands(values), odsAttrs(attrs)
|
2019-06-03 23:03:20 +08:00
|
|
|
|
2019-04-10 23:00:34 +08:00
|
|
|
// CHECK: void OpA::build
|
2020-06-26 19:20:44 +08:00
|
|
|
// CHECK: ::mlir::Value input
|
2020-01-09 10:48:38 +08:00
|
|
|
// CHECK: odsState.addOperands(input);
|
2019-03-28 05:09:19 +08:00
|
|
|
|
2019-04-10 23:00:34 +08:00
|
|
|
// CHECK: void OpA::build
|
2020-06-26 19:20:44 +08:00
|
|
|
// CHECK: ::mlir::ValueRange operands
|
2019-03-28 05:09:19 +08:00
|
|
|
// CHECK: assert(operands.size() == 1u && "mismatched number of parameters");
|
2020-01-09 10:48:38 +08:00
|
|
|
// CHECK: odsState.addOperands(operands);
|
2019-03-28 05:09:19 +08:00
|
|
|
|
2019-04-30 00:24:09 +08:00
|
|
|
def OpB : NS_Op<"one_variadic_operand_op", []> {
|
2019-04-10 23:00:34 +08:00
|
|
|
let arguments = (ins Variadic<I32>:$input);
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: OpB::build
|
2020-06-26 19:20:44 +08:00
|
|
|
// CHECK: ::mlir::ValueRange input
|
2019-04-26 05:45:37 +08:00
|
|
|
// CHECK-NOT: assert
|
2020-01-09 10:48:38 +08:00
|
|
|
// CHECK: odsState.addOperands(input);
|
2019-04-26 05:45:37 +08:00
|
|
|
|
2019-06-09 20:50:09 +08:00
|
|
|
def OpD : NS_Op<"mix_variadic_and_normal_inputs_op", [SameVariadicOperandSize]> {
|
|
|
|
let arguments = (ins Variadic<AnyTensor>:$input1, AnyTensor:$input2, Variadic<AnyTensor>:$input3);
|
2019-04-26 05:45:37 +08:00
|
|
|
}
|
|
|
|
|
2020-06-26 19:20:44 +08:00
|
|
|
// CHECK-LABEL: ::mlir::ValueRange OpDAdaptor::input1
|
2019-06-09 20:50:09 +08:00
|
|
|
// CHECK-NEXT: return getODSOperands(0);
|
2019-06-03 23:03:20 +08:00
|
|
|
|
2020-06-26 19:20:44 +08:00
|
|
|
// CHECK-LABEL: ::mlir::Value OpDAdaptor::input2
|
2019-06-09 20:50:09 +08:00
|
|
|
// CHECK-NEXT: return *getODSOperands(1).begin();
|
2019-06-03 23:03:20 +08:00
|
|
|
|
2020-06-26 19:20:44 +08:00
|
|
|
// CHECK-LABEL: ::mlir::ValueRange OpDAdaptor::input3
|
2019-06-09 20:50:09 +08:00
|
|
|
// CHECK-NEXT: return getODSOperands(2);
|
2019-04-26 05:45:37 +08:00
|
|
|
|
2020-06-26 19:20:44 +08:00
|
|
|
// CHECK-LABEL: ::mlir::Operation::operand_range OpD::input1
|
2019-06-09 20:50:09 +08:00
|
|
|
// CHECK-NEXT: return getODSOperands(0);
|
2019-04-26 05:45:37 +08:00
|
|
|
|
2020-06-26 19:20:44 +08:00
|
|
|
// CHECK-LABEL: ::mlir::Value OpD::input2
|
2019-06-09 20:50:09 +08:00
|
|
|
// CHECK-NEXT: return *getODSOperands(1).begin();
|
2019-04-26 05:45:37 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: OpD::build
|
2020-01-09 10:48:38 +08:00
|
|
|
// CHECK-NEXT: odsState.addOperands(input1);
|
|
|
|
// CHECK-NEXT: odsState.addOperands(input2);
|
|
|
|
// CHECK-NEXT: odsState.addOperands(input3);
|