Skip to content
Merged
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
26 changes: 7 additions & 19 deletions mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,13 @@ Type CompositeType::getElementType(unsigned index) const {
}

unsigned CompositeType::getNumElements() const {
if (auto arrayType = llvm::dyn_cast<ArrayType>(*this))
return arrayType.getNumElements();
if (auto matrixType = llvm::dyn_cast<MatrixType>(*this))
return matrixType.getNumColumns();
if (auto structType = llvm::dyn_cast<StructType>(*this))
return structType.getNumElements();
if (auto vectorType = llvm::dyn_cast<VectorType>(*this))
return vectorType.getNumElements();
if (auto tensorArmType = dyn_cast<TensorArmType>(*this))
return tensorArmType.getNumElements();
if (llvm::isa<CooperativeMatrixType>(*this)) {
llvm_unreachable(
"invalid to query number of elements of spirv Cooperative Matrix type");
}
if (llvm::isa<RuntimeArrayType>(*this)) {
llvm_unreachable(
"invalid to query number of elements of spirv::RuntimeArray type");
}
llvm_unreachable("invalid composite type");
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");
});
}

bool CompositeType::hasCompileTimeKnownNumElements() const {
Expand Down
Loading