[clang] [CIR] Upstream initial support for fixed size VectorType (PR #136488)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 22 11:02:30 PDT 2025
================
@@ -637,6 +637,42 @@ ArrayType::getABIAlignment(const ::mlir::DataLayout &dataLayout,
return dataLayout.getTypeABIAlignment(getEltType());
}
+//===----------------------------------------------------------------------===//
+// VectorType Definitions
+//===----------------------------------------------------------------------===//
+
+llvm::TypeSize cir::VectorType::getTypeSizeInBits(
+ const ::mlir::DataLayout &dataLayout,
+ ::mlir::DataLayoutEntryListRef params) const {
+ return llvm::TypeSize::getFixed(
+ getSize() * dataLayout.getTypeSizeInBits(getElementType()));
+}
+
+uint64_t
+cir::VectorType::getABIAlignment(const ::mlir::DataLayout &dataLayout,
+ ::mlir::DataLayoutEntryListRef params) const {
+ return llvm::NextPowerOf2(dataLayout.getTypeSizeInBits(*this));
+}
+
+mlir::LogicalResult cir::VectorType::verify(
+ llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
+ mlir::Type elementType, uint64_t size) {
+ if (size == 0)
+ return emitError() << "the number of vector elements must be non-zero";
+
+ // Check if it a valid FixedVectorType
+ if (mlir::isa<cir::PointerType, cir::FP128Type>(elementType))
+ return success();
+
+ // Check if it a valid VectorType
+ if (mlir::isa<cir::IntType>(elementType) ||
+ isAnyFloatingPointType(elementType))
----------------
AmrDeveloper wrote:
Mmmmmm maybe we should put our checks like it isa (Int, Index, Ptr, Float) 🤔
https://github.com/llvm/llvm-project/pull/136488
More information about the cfe-commits
mailing list