Skip to content

Commit 2abd9dc

Browse files
committed
wrap at 80 cols
1 parent fafc0ee commit 2abd9dc

File tree

5 files changed

+73
-29
lines changed

5 files changed

+73
-29
lines changed

mlir/lib/Target/IRDLToCpp/Templates/DialectDef.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ R"(
33
__NAMESPACE_OPEN__
44

55
__DIALECT_CPP_NAME__::__DIALECT_CPP_NAME__(::mlir::MLIRContext *context)
6-
: ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get<__DIALECT_CPP_NAME__>())
6+
: ::mlir::Dialect(getDialectNamespace(), context,
7+
::mlir::TypeID::get<__DIALECT_CPP_NAME__>())
78
{
89
initialize();
910
}

mlir/lib/Target/IRDLToCpp/Templates/PerOperationDecl.txt

Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ public:
1212
struct Properties {
1313
};
1414
public:
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

3844
template <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;
4249
public:
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> {
7496
public:
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

mlir/lib/Target/IRDLToCpp/Templates/PerOperationDef.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ __NAMESPACE_OPEN__
88

99
__OP_BUILD_DEFS__
1010

11-
void __OP_CPP_NAME__::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
11+
void __OP_CPP_NAME__::build(::mlir::OpBuilder &odsBuilder,
12+
::mlir::OperationState &odsState,
13+
::mlir::TypeRange resultTypes,
14+
::mlir::ValueRange operands,
15+
::llvm::ArrayRef<::mlir::NamedAttribute> attributes)
16+
{
1217
assert(operands.size() == __OP_OPERAND_COUNT__);
1318
assert(resultTypes.size() == __OP_RESULT_COUNT__);
1419
odsState.addOperands(operands);

mlir/lib/Target/IRDLToCpp/Templates/TypeDecl.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ R"(
66

77
__NAMESPACE_OPEN__
88

9-
class __TYPE_CPP_NAME__ : public ::mlir::Type::TypeBase<__TYPE_CPP_NAME__, __DIALECT_BASE_TYPE_NAME__, ::mlir::TypeStorage> {
9+
class __TYPE_CPP_NAME__
10+
: public ::mlir::Type::TypeBase<__TYPE_CPP_NAME__,
11+
__DIALECT_BASE_TYPE_NAME__,
12+
::mlir::TypeStorage> {
1013
public:
1114
using Base::Base;
12-
static constexpr ::llvm::StringLiteral name = "__DIALECT_NAME__.__TYPE_NAME__";
15+
static constexpr ::llvm::StringLiteral name =
16+
"__DIALECT_NAME__.__TYPE_NAME__";
1317
static constexpr ::llvm::StringLiteral dialectName = "__DIALECT_NAME__";
1418
static constexpr ::llvm::StringLiteral getMnemonic() {
1519
return {"__TYPE_NAME__"};

mlir/lib/Target/IRDLToCpp/Templates/TypeDef.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ __TYPE_PARSER__
99
__TYPE_PRINTER__
1010

1111
/// Parse a type registered to this dialect.
12-
::mlir::Type __DIALECT_CPP_NAME__::parseType(::mlir::DialectAsmParser &parser) const {
12+
::mlir::Type __DIALECT_CPP_NAME__::parseType(::mlir::DialectAsmParser &parser)
13+
const
14+
{
1315
::llvm::SMLoc typeLoc = parser.getCurrentLocation();
1416
::llvm::StringRef mnemonic;
1517
::mlir::Type genType;

0 commit comments

Comments
 (0)