================ @@ -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)) ---------------- andykaylor wrote:
I see this check in `mlir::LLVM::isCompatibleVectorType()`: ``` if (auto intType = llvm::dyn_cast<IntegerType>(elementType)) return intType.isSignless(); return llvm::isa<BFloat16Type, Float16Type, Float32Type, Float64Type, Float80Type, Float128Type>(elementType); ``` So that's not necessarily compatible with `isAnyFloatingPointType` to match the error message below. I don't know if we want to form an LLVM type here and call that function directly, but it seems like we otherwise run the risk of this getting out of sync. On the other hand, I'd like to be able to create CIR vectors of other types like float8 without requiring that the LLVM dialect support them. https://github.com/llvm/llvm-project/pull/136488 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits