20 bitIntMaxAlignBits = cir::IntType::getBitIntMaxAlignBits({});
21 vectorMaxAlignBits = 0;
23 bitIntMaxAlignBits = cir::IntType::getBitIntMaxAlignBits(
24 spec.getSpecForType(cir::IntType::getTypeID()));
25 vectorMaxAlignBits = cir::VectorType::getMaxAlignBits(
26 spec.getSpecForType(cir::VectorType::getTypeID()));
28 mlir::StringAttr key = mlir::StringAttr::get(
29 spec.getContext(), mlir::DLTIDialect::kDataLayoutEndiannessKey);
30 if (mlir::DataLayoutEntryInterface entry = spec.getSpecForIdentifier(key))
31 if (
auto str = llvm::dyn_cast<mlir::StringAttr>(entry.getValue()))
32 bigEndian = str == mlir::DLTIDialect::kDataLayoutEndiannessBig;
34 mlir::StringAttr addrSpKey = mlir::StringAttr::get(
35 spec.getContext(), mlir::DLTIDialect::kDataLayoutProgramMemorySpaceKey);
36 if (mlir::DataLayoutEntryInterface entry =
37 spec.getSpecForIdentifier(addrSpKey))
38 if (
auto val = llvm::dyn_cast<mlir::IntegerAttr>(entry.getValue()))
39 programAddrSpace = val.getUInt();
57 for (mlir::Type member : members)
61 return llvm::TypeSwitch<mlir::Type, uint64_t>(ty)
62 .Case([&](cir::IntType intTy) -> uint64_t {
64 return intTy.getBitIntAlignRequirement(bitIntMaxAlignBits);
65 return layout.getTypeABIAlignment(intTy);
68 if (cir::RecordLayoutAttr recLayout =
70 return recLayout.getRecordAlign();
72 assert(recTy.
isComplete() &&
"Cannot get layout of incomplete records");
77 .Case([&](cir::VectorType vecTy) -> uint64_t {
80 if (vecTy.getKind() == cir::VectorAbiKind::SVEData)
82 if (vecTy.getKind() == cir::VectorAbiKind::SVEPredicate)
84 uint64_t align =
layout.getTypeABIAlignment(vecTy);
85 if (vectorMaxAlignBits)
86 return std::min(align, vectorMaxAlignBits / 8);
89 .Case<cir::ArrayType, cir::ComplexType, cir::MatrixType>(
90 [&](
auto elementsTy) -> uint64_t {
93 .Case([&](cir::BitFieldType bitFieldTy) -> uint64_t {
94 if (mlir::Type storage = bitFieldTy.getStorageType())
98 .Default([&](mlir::Type ty) {
return layout.getTypeABIAlignment(ty); });
RecordLayoutAttr tryGetRecordLayout(mlir::ModuleOp mod, mlir::StringAttr name)
Same lookup as getRecordLayout, but returns a null attribute instead of asserting when the record has...