-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[CIR] Standardize element type name between Array and Vector Types #137465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CIR] Standardize element type name between Array and Vector Types #137465
Conversation
@llvm/pr-subscribers-clang Author: Amr Hesham (AmrDeveloper) ChangesStandardize the element type name Full diff: https://github.com/llvm/llvm-project/pull/137465.diff 6 Files Affected:
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()))
|
@llvm/pr-subscribers-clangir Author: Amr Hesham (AmrDeveloper) ChangesStandardize the element type name Full diff: https://github.com/llvm/llvm-project/pull/137465.diff 6 Files Affected:
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()))
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, please backport this to incubator once merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…lvm#137465) Standardize the element type name
…lvm#137465) Standardize the element type name
…lvm#137465) Standardize the element type name
…lvm#137465) Standardize the element type name
…lvm#137465) Standardize the element type name
Standardize the element type name