[clang] [CIR] Standardize element type name between Array and Vector Types (PR #137465)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 26 09:55:53 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangir
Author: Amr Hesham (AmrDeveloper)
<details>
<summary>Changes</summary>
Standardize the element type name
---
Full diff: https://github.com/llvm/llvm-project/pull/137465.diff
6 Files Affected:
- (modified) clang/include/clang/CIR/Dialect/IR/CIRTypes.td (+4-4)
- (modified) clang/lib/CIR/CodeGen/CIRGenBuilder.cpp (+1-1)
- (modified) clang/lib/CIR/Dialect/IR/CIRAttrs.cpp (+1-1)
- (modified) clang/lib/CIR/Dialect/IR/CIRTypes.cpp (+2-2)
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+1-1)
- (modified) clang/lib/CIR/Lowering/LoweringHelpers.cpp (+2-2)
``````````diff
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()))
``````````
</details>
https://github.com/llvm/llvm-project/pull/137465
More information about the cfe-commits
mailing list