@@ -20,12 +20,12 @@ BufferizeTypeConverter::BufferizeTypeConverter() {
20
20
// Keep all types unchanged.
21
21
addConversion ([](Type type) { return type; });
22
22
// Convert RankedTensorType to MemRefType.
23
- addConversion ([](RankedTensorType type) {
24
- return (Type) MemRefType::get (type.getShape (), type.getElementType ());
23
+ addConversion ([](RankedTensorType type) -> Type {
24
+ return MemRefType::get (type.getShape (), type.getElementType ());
25
25
});
26
26
// Convert UnrankedTensorType to UnrankedMemRefType.
27
- addConversion ([](UnrankedTensorType type) {
28
- return (Type) UnrankedMemRefType::get (type.getElementType (), 0 );
27
+ addConversion ([](UnrankedTensorType type) -> Type {
28
+ return UnrankedMemRefType::get (type.getElementType (), 0 );
29
29
});
30
30
}
31
31
@@ -35,8 +35,8 @@ BufferizeTypeConverter::BufferizeTypeConverter() {
35
35
void BufferizeTypeConverter::tryDecomposeValue (
36
36
OpBuilder &builder, Location loc, Type type, Value value,
37
37
SmallVectorImpl<Value> &results) {
38
- for (auto conversion : decomposeValueConversions)
39
- if (conversion (builder, loc, type, value, results) != llvm::None )
38
+ for (auto & conversion : decomposeValueConversions)
39
+ if (conversion (builder, loc, type, value, results))
40
40
return ;
41
41
results.push_back (value);
42
42
}
@@ -45,20 +45,18 @@ void BufferizeTypeConverter::tryDecomposeValue(
45
45
// / functions. If it is unable to do so, the original type is returned.
46
46
void BufferizeTypeConverter::tryDecomposeType (Type type,
47
47
SmallVectorImpl<Type> &types) {
48
- for (auto conversion : decomposeTypeConversions)
49
- if (conversion (type, types) != llvm::None )
48
+ for (auto & conversion : decomposeTypeConversions)
49
+ if (conversion (type, types))
50
50
return ;
51
51
types.push_back (type);
52
52
}
53
53
54
54
// / This method returns ResultConversionKind for the input type.
55
55
BufferizeTypeConverter::ResultConversionKind
56
56
BufferizeTypeConverter::getResultConversionKind (Type origin, Type converted) {
57
- for (auto conversion : resultTypeConversions) {
58
- auto res = conversion (origin, converted);
59
- if (res != llvm::None)
57
+ for (auto &conversion : resultTypeConversions)
58
+ if (auto res = conversion (origin, converted))
60
59
return res.getValue ();
61
- }
62
60
return KeepAsFunctionResult;
63
61
}
64
62
@@ -90,11 +88,12 @@ LogicalResult BufferizeFuncOpConverter::matchAndRewrite(
90
88
for (auto origin : originTypes) {
91
89
Type converted = converter.convertType (origin);
92
90
auto kind = converter.getResultConversionKind (origin, converted);
93
- if (kind == BufferizeTypeConverter::AppendToArgumentsList)
91
+ if (kind == BufferizeTypeConverter::AppendToArgumentsList) {
94
92
conversion.addInputs (converted);
95
- else
96
- // kind = BufferizeTypeConverter::KeepAsFunctionResult
93
+ } else {
94
+ assert ( kind == BufferizeTypeConverter::KeepAsFunctionResult);
97
95
newResultTypes.push_back (converted);
96
+ }
98
97
}
99
98
}
100
99
@@ -140,21 +139,19 @@ class CallOpResultMapping {
140
139
SmallVector<std::pair<unsigned , Value>, 2 > res (toValuesMapping.begin (),
141
140
toValuesMapping.end ());
142
141
// Replace the indices with the actual values.
143
- llvm::for_each (
144
- toIndicesMapping, [&](const std::pair<unsigned , unsigned > &entry) {
145
- assert (entry.second < valuesToReplaceIndices.size () &&
146
- " The value index is out of range." );
147
- res.push_back ({entry.first , valuesToReplaceIndices[entry.second ]});
148
- });
142
+ for (const std::pair<unsigned , unsigned > &entry : toIndicesMapping) {
143
+ assert (entry.second < valuesToReplaceIndices.size () &&
144
+ " The value index is out of range." );
145
+ res.push_back ({entry.first , valuesToReplaceIndices[entry.second ]});
146
+ }
149
147
// Sort the values based on their adding orders.
150
148
llvm::sort (res, [](const std::pair<unsigned , Value> &v1,
151
149
const std::pair<unsigned , Value> &v2) {
152
150
return v1.first < v2.first ;
153
151
});
154
152
// Fill the values.
155
- llvm::for_each (res, [&] (const std::pair<unsigned , Value> &entry) {
153
+ for (const std::pair<unsigned , Value> &entry : res)
156
154
values.push_back (entry.second );
157
- });
158
155
}
159
156
160
157
private:
@@ -187,8 +184,8 @@ LogicalResult BufferizeCallOpConverter::matchAndRewrite(
187
184
// values if a decompose callback function has been provided by the user.
188
185
for (auto operand : operands) {
189
186
SmallVector<Value, 2 > values;
190
- this -> converter .tryDecomposeValue (builder, loc, operand.getType (), operand,
191
- values);
187
+ converter.tryDecomposeValue (builder, loc, operand.getType (), operand,
188
+ values);
192
189
newOperands.append (values.begin (), values.end ());
193
190
}
194
191
0 commit comments