diff options
author | Jacques Pienaar <jpienaar@google.com> | 2020-05-24 20:42:58 -0700 |
---|---|---|
committer | Jacques Pienaar <jpienaar@google.com> | 2020-05-24 21:06:47 -0700 |
commit | 4b8632e174d5ba79c4858a1245b96efd3ed281fb (patch) | |
tree | 0b3b52065f67fd7c4efdde22bcd84048b2cd7ffc /mlir/test/mlir-tblgen | |
parent | 838d12207b04b7be7245fdff0ce93335bafe5b78 (diff) | |
download | llvm-4b8632e174d5ba79c4858a1245b96efd3ed281fb.zip llvm-4b8632e174d5ba79c4858a1245b96efd3ed281fb.tar.gz llvm-4b8632e174d5ba79c4858a1245b96efd3ed281fb.tar.bz2 |
[mlir] Expand operand adapter to take attributes
* Enables using with more variadic sized operands;
* Generate convenience accessors for attributes;
- The accessor are named the same as their name in ODS and returns attribute
type (not convenience type) and no derived attributes.
This is first step to changing adapter to support verifying argument
constraints before the op is even created. This does not change the name of
adaptor nor does it require it except for ops with variadic operands to keep this change smaller.
Considered creating separate adapter but decided against that given operands also require attributes in general (and definitely for verification of operands and attributes).
Differential Revision: https://reviews.llvm.org/D80420
Diffstat (limited to 'mlir/test/mlir-tblgen')
-rw-r--r-- | mlir/test/mlir-tblgen/op-decl.td | 30 | ||||
-rw-r--r-- | mlir/test/mlir-tblgen/op-operand.td | 2 |
2 files changed, 29 insertions, 3 deletions
diff --git a/mlir/test/mlir-tblgen/op-decl.td b/mlir/test/mlir-tblgen/op-decl.td index 0b9bac2..c68d03c 100644 --- a/mlir/test/mlir-tblgen/op-decl.td +++ b/mlir/test/mlir-tblgen/op-decl.td @@ -50,12 +50,14 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> { // CHECK: class AOpOperandAdaptor { // CHECK: public: -// CHECK: AOpOperandAdaptor(ArrayRef<Value> values); +// CHECK: AOpOperandAdaptor(ArrayRef<Value> values // CHECK: ArrayRef<Value> getODSOperands(unsigned index); // CHECK: Value a(); // CHECK: ArrayRef<Value> b(); +// CHECK: IntegerAttr attr1(); +// CHECL: FloatAttr attr2(); // CHECK: private: -// CHECK: ArrayRef<Value> tblgen_operands; +// CHECK: ArrayRef<Value> odsOperands; // CHECK: }; // CHECK: class AOp : public Op<AOp, OpTrait::AtLeastNRegions<1>::Impl, OpTrait::AtLeastNResults<1>::Impl, OpTrait::ZeroSuccessor, OpTrait::AtLeastNOperands<1>::Impl, OpTrait::IsIsolatedFromAbove @@ -90,6 +92,29 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> { // CHECK: void displayGraph(); // CHECK: }; +// Check AttrSizedOperandSegments +// --- + +def NS_AttrSizedOperandOp : NS_Op<"attr_sized_operands", + [AttrSizedOperandSegments]> { + let arguments = (ins + Variadic<I32>:$a, + Variadic<I32>:$b, + I32:$c, + Variadic<I32>:$d, + I32ElementsAttr:$operand_segment_sizes + ); +} + +// CHECK-LABEL: AttrSizedOperandOpOperandAdaptor( +// CHECK-SAME: ArrayRef<Value> values +// CHECK-SAME: DictionaryAttr attrs +// CHECK: ArrayRef<Value> a(); +// CHECK: ArrayRef<Value> b(); +// CHECK: Value c(); +// CHECK: ArrayRef<Value> d(); +// CHECK: DenseIntElementsAttr operand_segment_sizes(); + // Check op trait for different number of operands // --- @@ -150,3 +175,4 @@ def _BOp : NS_Op<"_op_with_leading_underscore_and_no_namespace", []>; // CHECK-LABEL: _BOp declarations // CHECK: class _BOp : public Op<_BOp + diff --git a/mlir/test/mlir-tblgen/op-operand.td b/mlir/test/mlir-tblgen/op-operand.td index 2ffde33..5f0bfae 100644 --- a/mlir/test/mlir-tblgen/op-operand.td +++ b/mlir/test/mlir-tblgen/op-operand.td @@ -15,7 +15,7 @@ def OpA : NS_Op<"one_normal_operand_op", []> { // CHECK-LABEL: OpA definitions // CHECK: OpAOperandAdaptor::OpAOperandAdaptor -// CHECK-NEXT: tblgen_operands = values +// CHECK-NEXT: odsOperands = values // CHECK: void OpA::build // CHECK: Value input |