Skip to content

[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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions clang/include/clang/CIR/Dialect/IR/CIRTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -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 `>`
}];
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CIR/Dialect/IR/CIRTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CIR/Lowering/LoweringHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()))
Expand Down
Loading