[PATCH] D77258: Clean up usages of asserting vector getters in Type
Christopher Tetreault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 6 10:18:58 PDT 2020
ctetreau updated this revision to Diff 255392.
ctetreau added a comment.
Update commit message to mention MLIR
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77258/new/
https://reviews.llvm.org/D77258
Files:
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
Index: mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
===================================================================
--- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -169,14 +169,15 @@
return LLVMType::getArrayTy(elementType, type->getArrayNumElements());
}
case llvm::Type::VectorTyID: {
- if (type->getVectorIsScalable()) {
+ auto *typeVTy = llvm::cast<llvm::VectorType>(type);
+ if (typeVTy->isScalable()) {
emitError(unknownLoc) << "scalable vector types not supported";
return nullptr;
}
- LLVMType elementType = processType(type->getVectorElementType());
+ LLVMType elementType = processType(typeVTy->getElementType());
if (!elementType)
return nullptr;
- return LLVMType::getVectorTy(elementType, type->getVectorNumElements());
+ return LLVMType::getVectorTy(elementType, typeVTy->getNumElements());
}
case llvm::Type::VoidTyID:
return LLVMType::getVoidTy(dialect);
@@ -243,7 +244,8 @@
// LLVM vectors can only contain scalars.
if (type.isVectorTy()) {
- auto numElements = type.getUnderlyingType()->getVectorElementCount();
+ auto numElements = llvm::cast<llvm::VectorType>(type.getUnderlyingType())
+ ->getElementCount();
if (numElements.Scalable) {
emitError(unknownLoc) << "scalable vectors not supported";
return nullptr;
@@ -269,7 +271,8 @@
if (type.getArrayElementType().isVectorTy()) {
LLVMType vectorType = type.getArrayElementType();
auto numElements =
- vectorType.getUnderlyingType()->getVectorElementCount();
+ llvm::cast<llvm::VectorType>(vectorType.getUnderlyingType())
+ ->getElementCount();
if (numElements.Scalable) {
emitError(unknownLoc) << "scalable vectors not supported";
return nullptr;
Index: mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
===================================================================
--- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -102,7 +102,8 @@
return parser.emitError(trailingTypeLoc, "expected LLVM IR dialect type");
if (argType.getUnderlyingType()->isVectorTy())
resultType = LLVMType::getVectorTy(
- resultType, argType.getUnderlyingType()->getVectorNumElements());
+ resultType, llvm::cast<llvm::VectorType>(argType.getUnderlyingType())
+ ->getNumElements());
result.addTypes({resultType});
return success();
@@ -1772,7 +1773,9 @@
/// Vector type utilities.
LLVMType LLVMType::getVectorElementType() {
- return get(getContext(), getUnderlyingType()->getVectorElementType());
+ return get(
+ getContext(),
+ llvm::cast<llvm::VectorType>(getUnderlyingType())->getElementType());
}
bool LLVMType::isVectorTy() { return getUnderlyingType()->isVectorTy(); }
Index: mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
===================================================================
--- mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -1594,9 +1594,10 @@
op, operands, typeConverter,
[&](LLVM::LLVMType llvmVectorTy, ValueRange operands) {
auto splatAttr = SplatElementsAttr::get(
- mlir::VectorType::get(
- {llvmVectorTy.getUnderlyingType()->getVectorNumElements()},
- floatType),
+ mlir::VectorType::get({(unsigned)cast<llvm::VectorType>(
+ llvmVectorTy.getUnderlyingType())
+ ->getNumElements()},
+ floatType),
floatOne);
auto one =
rewriter.create<LLVM::ConstantOp>(loc, llvmVectorTy, splatAttr);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77258.255392.patch
Type: text/x-patch
Size: 3864 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200406/da1f8076/attachment.bin>
More information about the llvm-commits
mailing list