Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,10 +1118,7 @@ StringRef getTypeMangling(Type type, bool isSigned) {
llvm_unreachable("Unsupported integer width");
}
})
.Default([](auto) {
llvm_unreachable("No mangling defined");
return "";
});
.DefaultUnreachable("No mangling defined");
}

template <typename ReduceOp>
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ void SPIRVDialect::printType(Type type, DialectAsmPrinter &os) const {
.Case<ArrayType, CooperativeMatrixType, PointerType, RuntimeArrayType,
ImageType, SampledImageType, StructType, MatrixType, TensorArmType>(
[&](auto type) { print(type, os); })
.Default([](Type) { llvm_unreachable("unhandled SPIR-V type"); });
.DefaultUnreachable("Unhandled SPIR-V type");
}

//===----------------------------------------------------------------------===//
Expand Down
11 changes: 4 additions & 7 deletions mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TypeExtensionVisitor {
for (Type elementType : concreteType.getElementTypes())
add(elementType);
})
.Default([](SPIRVType) { llvm_unreachable("Unhandled type"); });
.DefaultUnreachable("Unhandled type");
}

void add(Type type) { add(cast<SPIRVType>(type)); }
Expand Down Expand Up @@ -107,7 +107,7 @@ class TypeCapabilityVisitor {
for (Type elementType : concreteType.getElementTypes())
add(elementType);
})
.Default([](SPIRVType) { llvm_unreachable("Unhandled type"); });
.DefaultUnreachable("Unhandled type");
}

void add(Type type) { add(cast<SPIRVType>(type)); }
Expand Down Expand Up @@ -198,18 +198,15 @@ Type CompositeType::getElementType(unsigned index) const {
.Case<MatrixType>([](MatrixType type) { return type.getColumnType(); })
.Case<StructType>(
[index](StructType type) { return type.getElementType(index); })
.Default(
[](Type) -> Type { llvm_unreachable("invalid composite type"); });
.DefaultUnreachable("Invalid composite type");
}

unsigned CompositeType::getNumElements() const {
return TypeSwitch<SPIRVType, unsigned>(*this)
.Case<ArrayType, StructType, TensorArmType, VectorType>(
[](auto type) { return type.getNumElements(); })
.Case<MatrixType>([](MatrixType type) { return type.getNumColumns(); })
.Default([](SPIRVType) -> unsigned {
llvm_unreachable("Invalid type for number of elements query");
});
.DefaultUnreachable("Invalid type for number of elements query");
}

bool CompositeType::hasCompileTimeKnownNumElements() const {
Expand Down
8 changes: 2 additions & 6 deletions mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ static spirv::Dim convertRank(int64_t rank) {
}

static spirv::ImageFormat getImageFormat(Type elementType) {
return llvm::TypeSwitch<Type, spirv::ImageFormat>(elementType)
return TypeSwitch<Type, spirv::ImageFormat>(elementType)
.Case<Float16Type>([](Float16Type) { return spirv::ImageFormat::R16f; })
.Case<Float32Type>([](Float32Type) { return spirv::ImageFormat::R32f; })
.Case<IntegerType>([](IntegerType intType) {
Expand All @@ -639,11 +639,7 @@ static spirv::ImageFormat getImageFormat(Type elementType) {
llvm_unreachable("Unhandled integer type!");
}
})
.Default([](Type) {
llvm_unreachable("Unhandled element type!");
// We need to return something here to satisfy the type switch.
return spirv::ImageFormat::R32f;
});
.DefaultUnreachable("Unhandled element type!");
#undef BIT_WIDTH_CASE
}

Expand Down