@@ -12,10 +12,16 @@ public:
1212 struct Properties {
1313 };
1414public:
15- __OP_CPP_NAME__GenericAdaptorBase(::mlir::Operation *op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), odsRegions(op->getRegions()) {}
16-
17- /// Return the unstructured operand index of a structured operand along with the amount of unstructured operands it contains.
18- std::pair<unsigned, unsigned> getStructuredOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
15+ __OP_CPP_NAME__GenericAdaptorBase(::mlir::Operation *op)
16+ : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()),
17+ odsRegions(op->getRegions())
18+ {}
19+
20+ /// Return the unstructured operand index of a structured operand along with
21+ // the amount of unstructured operands it contains.
22+ std::pair<unsigned, unsigned>
23+ getStructuredOperandIndexAndLength (unsigned index,
24+ unsigned odsOperandsSize) {
1925 return {index, 1};
2026 }
2127
@@ -36,28 +42,43 @@ protected:
3642} // namespace detail
3743
3844template <typename RangeT>
39- class __OP_CPP_NAME__GenericAdaptor : public detail::__OP_CPP_NAME__GenericAdaptorBase {
45+ class __OP_CPP_NAME__GenericAdaptor
46+ : public detail::__OP_CPP_NAME__GenericAdaptorBase {
4047 using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
4148 using Base = detail::__OP_CPP_NAME__GenericAdaptorBase;
4249public:
43- __OP_CPP_NAME__GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : __OP_CPP_NAME__GenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {}
44-
45- __OP_CPP_NAME__GenericAdaptor(RangeT values, const __OP_CPP_NAME__GenericAdaptorBase &base) : Base(base), odsOperands(values) {}
46-
47- // This template parameter allows using __OP_CPP_NAME__ which is declared later.
48- template <typename LateInst = __OP_CPP_NAME__, typename = std::enable_if_t<std::is_same_v<LateInst, __OP_CPP_NAME__>>>
49- __OP_CPP_NAME__GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
50-
51- /// Return the unstructured operand index of a structured operand along with the amount of unstructured operands it contains.
52- std::pair<unsigned, unsigned> getStructuredOperandIndexAndLength(unsigned index) {
50+ __OP_CPP_NAME__GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs,
51+ ::mlir::OpaqueProperties properties,
52+ ::mlir::RegionRange regions = {})
53+ : __OP_CPP_NAME__GenericAdaptor(values, attrs,
54+ (properties ? *properties.as<::mlir::EmptyProperties *>()
55+ : ::mlir::EmptyProperties{}), regions) {}
56+
57+ __OP_CPP_NAME__GenericAdaptor(RangeT values,
58+ const __OP_CPP_NAME__GenericAdaptorBase &base)
59+ : Base(base), odsOperands(values) {}
60+
61+ // This template parameter allows using __OP_CPP_NAME__ which is declared
62+ // later.
63+ template <typename LateInst = __OP_CPP_NAME__,
64+ typename = std::enable_if_t<
65+ std::is_same_v<LateInst, __OP_CPP_NAME__>>>
66+ __OP_CPP_NAME__GenericAdaptor(RangeT values, LateInst op)
67+ : Base(op), odsOperands(values) {}
68+
69+ /// Return the unstructured operand index of a structured operand along with
70+ // the amount of unstructured operands it contains.
71+ std::pair<unsigned, unsigned>
72+ getStructuredOperandIndexAndLength(unsigned index) {
5373 return Base::getStructuredOperandIndexAndLength(index, odsOperands.size());
5474 }
5575
5676 /// Get the n-th structured operand (single value, variadic or optional).
5777 RangeT getStructuredOperands(unsigned index) {
5878 auto valueRange = getStructuredOperandIndexAndLength(index);
5979 return {std::next(odsOperands.begin(), valueRange.first),
60- std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
80+ std::next(odsOperands.begin(),
81+ valueRange.first + valueRange.second)};
6182 }
6283
6384 RangeT getOperands() {
@@ -70,7 +91,8 @@ private:
7091 RangeT odsOperands;
7192};
7293
73- class __OP_CPP_NAME__Adaptor : public __OP_CPP_NAME__GenericAdaptor<::mlir::ValueRange> {
94+ class __OP_CPP_NAME__Adaptor
95+ : public __OP_CPP_NAME__GenericAdaptor<::mlir::ValueRange> {
7496public:
7597 using __OP_CPP_NAME__GenericAdaptor::__OP_CPP_NAME__GenericAdaptor;
7698 __OP_CPP_NAME__Adaptor(__OP_CPP_NAME__ op);
@@ -114,35 +136,45 @@ public:
114136 return getResultNames()[index];
115137 }
116138
117- /// Return the unstructured operand index of a structured operand along with the amount of unstructured operands it contains.
118- std::pair<unsigned, unsigned> getStructuredOperandIndexAndLength(unsigned index) {
139+ /// Return the unstructured operand index of a structured operand along with
140+ // the amount of unstructured operands it contains.
141+ std::pair<unsigned, unsigned>
142+ getStructuredOperandIndexAndLength(unsigned index) {
119143 return {index, 1};
120144 }
121145
122146 /// Get the n-th structured operand (single value, variadic or optional).
123147 ::mlir::Operation::operand_range getStructuredOperands(unsigned index) {
124148 auto valueRange = getStructuredOperandIndexAndLength(index);
125149 return {std::next(getOperation()->operand_begin(), valueRange.first),
126- std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
150+ std::next(getOperation()->operand_begin(),
151+ valueRange.first + valueRange.second)};
127152 }
128153
129- /// Return the unstructured result index of a structured result along with the amount of unstructured results it contains.
130- std::pair<unsigned, unsigned> getStructuredResultIndexAndLength(unsigned index) {
154+ /// Return the unstructured result index of a structured result along with
155+ // the amount of unstructured results it contains.
156+ std::pair<unsigned, unsigned>
157+ getStructuredResultIndexAndLength(unsigned index) {
131158 return {index, 1};
132159 }
133160
134161 /// Get the n-th structured result (single value, variadic or optional).
135162 ::mlir::Operation::result_range getStructuredResults(unsigned index) {
136163 auto valueRange = getStructuredResultIndexAndLength(index);
137164 return {std::next(getOperation()->result_begin(), valueRange.first),
138- std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
165+ std::next(getOperation()->result_begin(),
166+ valueRange.first + valueRange.second)};
139167 }
140168
141169 __OP_OPERAND_GETTER_DECLS__
142170 __OP_RESULT_GETTER_DECLS__
143171
144172 __OP_BUILD_DECLS__
145- static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});
173+ static void build(::mlir::OpBuilder &odsBuilder,
174+ ::mlir::OperationState &odsState,
175+ ::mlir::TypeRange resultTypes,
176+ ::mlir::ValueRange operands,
177+ ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});
146178};
147179
148180
0 commit comments