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
|
|
|
|
2019-06-03 23:03:20 +08:00
|
|
|
// CHECK: OpAOperandAdaptor::OpAOperandAdaptor
|
|
|
|
// CHECK-NEXT: tblgen_operands = values
|
|
|
|
|
2019-04-10 23:00:34 +08:00
|
|
|
// CHECK: void OpA::build
|
2019-12-24 06:45:01 +08:00
|
|
|
// CHECK: Value input
|
2019-09-21 10:47:05 +08:00
|
|
|
// CHECK: tblgen_state.addOperands(input);
|
2019-03-28 05:09:19 +08:00
|
|
|
|
2019-04-10 23:00:34 +08:00
|
|
|
// CHECK: void OpA::build
|
2019-12-13 06:22:40 +08:00
|
|
|
// CHECK: ValueRange operands
|
2019-03-28 05:09:19 +08:00
|
|
|
// CHECK: assert(operands.size() == 1u && "mismatched number of parameters");
|
2019-09-21 10:47:05 +08:00
|
|
|
// CHECK: tblgen_state.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
|
2019-12-13 06:22:40 +08:00
|
|
|
// CHECK: ValueRange input
|
2019-04-26 05:45:37 +08:00
|
|
|
// CHECK-NOT: assert
|
2019-09-21 10:47:05 +08:00
|
|
|
// CHECK: tblgen_state.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
|
|
|
}
|
|
|
|
|
2019-12-24 06:45:01 +08:00
|
|
|
// CHECK-LABEL: ArrayRef<Value> OpDOperandAdaptor::input1
|
2019-06-09 20:50:09 +08:00
|
|
|
// CHECK-NEXT: return getODSOperands(0);
|
2019-06-03 23:03:20 +08:00
|
|
|
|
2019-12-24 06:45:01 +08:00
|
|
|
// CHECK-LABEL: Value OpDOperandAdaptor::input2
|
2019-06-09 20:50:09 +08:00
|
|
|
// CHECK-NEXT: return *getODSOperands(1).begin();
|
2019-06-03 23:03:20 +08:00
|
|
|
|
2019-12-24 06:45:01 +08:00
|
|
|
// CHECK-LABEL: ArrayRef<Value> OpDOperandAdaptor::input3
|
2019-06-09 20:50:09 +08:00
|
|
|
// CHECK-NEXT: return getODSOperands(2);
|
2019-04-26 05:45:37 +08:00
|
|
|
|
2019-06-09 20:50:09 +08:00
|
|
|
// CHECK-LABEL: Operation::operand_range OpD::input1
|
|
|
|
// CHECK-NEXT: return getODSOperands(0);
|
2019-04-26 05:45:37 +08:00
|
|
|
|
2019-12-24 06:45:01 +08:00
|
|
|
// CHECK-LABEL: 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
|
2019-09-21 10:47:05 +08:00
|
|
|
// CHECK-NEXT: tblgen_state.addOperands(input1);
|
|
|
|
// CHECK-NEXT: tblgen_state.addOperands(input2);
|
|
|
|
// CHECK-NEXT: tblgen_state.addOperands(input3);
|