Skip to content

Commit 213eeb9

Browse files
authored
[MLIR][SPIRV] Replace some auto to concrete type (#113877)
Resolve #112018 (comment) As described in clang-tidy, the auto type specifier will only be introduced in - Iterators - New expressions - Cast expressions https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-auto.html
1 parent 217f622 commit 213eeb9

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

mlir/lib/Dialect/SPIRV/Utils/LayoutUtils.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ VulkanLayoutUtils::decorateType(spirv::StructType structType,
4343
Size memberSize = 0;
4444
Size memberAlignment = 1;
4545

46-
auto memberType =
46+
Type memberType =
4747
decorateType(structType.getElementType(i), memberSize, memberAlignment);
4848
structMemberOffset = llvm::alignTo(structMemberOffset, memberAlignment);
4949
memberTypes.push_back(memberType);
@@ -107,12 +107,12 @@ Type VulkanLayoutUtils::decorateType(Type type, VulkanLayoutUtils::Size &size,
107107
Type VulkanLayoutUtils::decorateType(VectorType vectorType,
108108
VulkanLayoutUtils::Size &size,
109109
VulkanLayoutUtils::Size &alignment) {
110-
const auto numElements = vectorType.getNumElements();
111-
auto elementType = vectorType.getElementType();
110+
const unsigned numElements = vectorType.getNumElements();
111+
Type elementType = vectorType.getElementType();
112112
Size elementSize = 0;
113113
Size elementAlignment = 1;
114114

115-
auto memberType = decorateType(elementType, elementSize, elementAlignment);
115+
Type memberType = decorateType(elementType, elementSize, elementAlignment);
116116
// According to the Vulkan spec:
117117
// 1. "A two-component vector has a base alignment equal to twice its scalar
118118
// alignment."
@@ -126,12 +126,12 @@ Type VulkanLayoutUtils::decorateType(VectorType vectorType,
126126
Type VulkanLayoutUtils::decorateType(spirv::ArrayType arrayType,
127127
VulkanLayoutUtils::Size &size,
128128
VulkanLayoutUtils::Size &alignment) {
129-
const auto numElements = arrayType.getNumElements();
130-
auto elementType = arrayType.getElementType();
129+
const unsigned numElements = arrayType.getNumElements();
130+
Type elementType = arrayType.getElementType();
131131
Size elementSize = 0;
132132
Size elementAlignment = 1;
133133

134-
auto memberType = decorateType(elementType, elementSize, elementAlignment);
134+
Type memberType = decorateType(elementType, elementSize, elementAlignment);
135135
// According to the Vulkan spec:
136136
// "An array has a base alignment equal to the base alignment of its element
137137
// type."
@@ -161,10 +161,10 @@ Type VulkanLayoutUtils::decorateType(spirv::MatrixType matrixType,
161161

162162
Type VulkanLayoutUtils::decorateType(spirv::RuntimeArrayType arrayType,
163163
VulkanLayoutUtils::Size &alignment) {
164-
auto elementType = arrayType.getElementType();
164+
Type elementType = arrayType.getElementType();
165165
Size elementSize = 0;
166166

167-
auto memberType = decorateType(elementType, elementSize, alignment);
167+
Type memberType = decorateType(elementType, elementSize, alignment);
168168
return spirv::RuntimeArrayType::get(memberType, elementSize);
169169
}
170170

@@ -175,7 +175,7 @@ VulkanLayoutUtils::getScalarTypeAlignment(Type scalarType) {
175175
// 2. "A scalar has a base alignment equal to its scalar alignment."
176176
// 3. "A scalar, vector or matrix type has an extended alignment equal to its
177177
// base alignment."
178-
auto bitWidth = scalarType.getIntOrFloatBitWidth();
178+
unsigned bitWidth = scalarType.getIntOrFloatBitWidth();
179179
if (bitWidth == 1)
180180
return 1;
181181
return bitWidth / 8;
@@ -187,7 +187,7 @@ bool VulkanLayoutUtils::isLegalType(Type type) {
187187
return true;
188188
}
189189

190-
auto storageClass = ptrType.getStorageClass();
190+
const spirv::StorageClass storageClass = ptrType.getStorageClass();
191191
auto structType = dyn_cast<spirv::StructType>(ptrType.getPointeeType());
192192
if (!structType) {
193193
return true;

0 commit comments

Comments
 (0)