https://github.com/AmrDeveloper created https://github.com/llvm/llvm-project/pull/137465
Standardize the element type name >From c9cca01b36db0d449905ebefe2f2c953ec2e5746 Mon Sep 17 00:00:00 2001 From: AmrDeveloper <am...@programmer.net> Date: Sat, 26 Apr 2025 18:54:05 +0200 Subject: [PATCH] [CIR] Standardize element type name between Array and Vector Types --- clang/include/clang/CIR/Dialect/IR/CIRTypes.td | 8 ++++---- clang/lib/CIR/CodeGen/CIRGenBuilder.cpp | 2 +- clang/lib/CIR/Dialect/IR/CIRAttrs.cpp | 2 +- clang/lib/CIR/Dialect/IR/CIRTypes.cpp | 4 ++-- clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 2 +- clang/lib/CIR/Lowering/LoweringHelpers.cpp | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index c752bc822f5c0..de754a982edcd 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -292,18 +292,18 @@ def CIR_ArrayType : CIR_Type<"Array", "array", `CIR.array` represents C/C++ constant arrays. }]; - let parameters = (ins "mlir::Type":$eltType, "uint64_t":$size); + let parameters = (ins "mlir::Type":$elementType, "uint64_t":$size); let builders = [ TypeBuilderWithInferredContext<(ins - "mlir::Type":$eltType, "uint64_t":$size + "mlir::Type":$elementType, "uint64_t":$size ), [{ - return $_get(eltType.getContext(), eltType, size); + return $_get(elementType.getContext(), elementType, size); }]>, ]; let assemblyFormat = [{ - `<` $eltType `x` $size `>` + `<` $elementType `x` $size `>` }]; } diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp index 2f1940e656172..5620821a5375a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp @@ -17,7 +17,7 @@ mlir::Value CIRGenBuilderTy::maybeBuildArrayDecay(mlir::Location loc, const auto arrayTy = mlir::dyn_cast<cir::ArrayType>(arrayPtrTy.getPointee()); if (arrayTy) { - const cir::PointerType flatPtrTy = getPointerTo(arrayTy.getEltType()); + const cir::PointerType flatPtrTy = getPointerTo(arrayTy.getElementType()); return create<cir::CastOp>(loc, flatPtrTy, cir::CastKind::array_to_ptrdecay, arrayPtr); } diff --git a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp index a8d9f6a0e6e9b..a940651f1e9eb 100644 --- a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp @@ -203,7 +203,7 @@ ConstArrayAttr::verify(function_ref<::mlir::InFlightDiagnostic()> emitError, if (auto strAttr = mlir::dyn_cast<StringAttr>(elts)) { const auto arrayTy = mlir::cast<ArrayType>(type); - const auto intTy = mlir::dyn_cast<IntType>(arrayTy.getEltType()); + const auto intTy = mlir::dyn_cast<IntType>(arrayTy.getElementType()); // TODO: add CIR type for char. if (!intTy || intTy.getWidth() != 8) { diff --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp index 1574f40a0e74c..b35442964c169 100644 --- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp @@ -658,13 +658,13 @@ BoolType::getABIAlignment(const ::mlir::DataLayout &dataLayout, llvm::TypeSize ArrayType::getTypeSizeInBits(const ::mlir::DataLayout &dataLayout, ::mlir::DataLayoutEntryListRef params) const { - return getSize() * dataLayout.getTypeSizeInBits(getEltType()); + return getSize() * dataLayout.getTypeSizeInBits(getElementType()); } uint64_t ArrayType::getABIAlignment(const ::mlir::DataLayout &dataLayout, ::mlir::DataLayoutEntryListRef params) const { - return dataLayout.getTypeABIAlignment(getEltType()); + return dataLayout.getTypeABIAlignment(getElementType()); } //===----------------------------------------------------------------------===// diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index 102438c2ded02..2c87255045df8 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -1390,7 +1390,7 @@ static void prepareTypeConverter(mlir::LLVMTypeConverter &converter, }); converter.addConversion([&](cir::ArrayType type) -> mlir::Type { mlir::Type ty = - convertTypeForMemory(converter, dataLayout, type.getEltType()); + convertTypeForMemory(converter, dataLayout, type.getElementType()); return mlir::LLVM::LLVMArrayType::get(ty, type.getSize()); }); converter.addConversion([&](cir::VectorType type) -> mlir::Type { diff --git a/clang/lib/CIR/Lowering/LoweringHelpers.cpp b/clang/lib/CIR/Lowering/LoweringHelpers.cpp index 0320bc40509b0..b4ae9f1909f41 100644 --- a/clang/lib/CIR/Lowering/LoweringHelpers.cpp +++ b/clang/lib/CIR/Lowering/LoweringHelpers.cpp @@ -63,7 +63,7 @@ void convertToDenseElementsAttrImpl( if (auto stringAttr = mlir::dyn_cast<mlir::StringAttr>(attr.getElts())) { if (auto arrayType = mlir::dyn_cast<cir::ArrayType>(attr.getType())) { for (auto element : stringAttr) { - auto intAttr = cir::IntAttr::get(arrayType.getEltType(), element); + auto intAttr = cir::IntAttr::get(arrayType.getElementType(), element); values[currentIndex++] = mlir::dyn_cast<AttrTy>(intAttr).getValue(); } return; @@ -128,7 +128,7 @@ lowerConstArrayAttr(cir::ConstArrayAttr constArr, auto dims = llvm::SmallVector<int64_t, 2>{}; while (auto arrayType = mlir::dyn_cast<cir::ArrayType>(type)) { dims.push_back(arrayType.getSize()); - type = arrayType.getEltType(); + type = arrayType.getElementType(); } if (mlir::isa<mlir::StringAttr>(constArr.getElts())) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits