26 if (Ty->isInteger() || Ty->isFloat() || Ty->isPointer() || Ty->isVector() ||
34 if (AT->isMatrixType())
44 unsigned BitWidth =
IT->getSizeInBits().getFixedValue();
54 assert(NumBytes != 0 &&
"empty padding");
56 return TB.getArrayType(I8, NumBytes, NumBytes * 8);
64 for (
const Type *Elt : Elems)
87 return Ty->getAlignment();
93 {RT->getFields(), RT->getBaseClasses()}) {
95 if (!Member.isEmpty())
104 if (AT->isMatrixType())
107 if (Elt == AT->getElementType())
109 assert(AT->getSizeInBits().isFixed() &&
110 "converted array element changes a scalable size");
111 return TB.getArrayType(Elt, AT->getNumElements(),
116 if (!RT || RT->isUnion())
121 assert(RT->getNumVirtualBaseClasses() == 0 &&
"record has a virtual base");
123 struct ConvertedMember {
133 auto addMember = [&](
const Type *MemberTy, uint64_t
Offset) {
136 "scalable member has no fixed offset");
138 if (
Offset % (Alignment.value() * 8) != 0)
140 MaxAlign = std::max(MaxAlign, Alignment);
144 if (!
Base.FieldType->isEmptyRecord())
145 addMember(
Base.FieldType,
Base.OffsetInBits);
148 if (!
Field.isEmpty())
149 addMember(
Field.FieldType,
Field.OffsetInBits);
152 [](
const ConvertedMember &
A,
const ConvertedMember &
B) {
153 return A.Offset <
B.Offset;
157 if (RecordSize.isFixed() &&
158 RecordSize.getFixedValue() % (MaxAlign.
value() * 8) != 0)
162 uint64_t Current = 0;
167 uint64_t AlignBits =
Packed ? 8 : Alignment.value() * 8;
170 for (
const ConvertedMember &Member : Members) {
171 if (Member.Offset > Current &&
172 needsPadding(Member.Offset, Member.Alignment)) {
173 uint64_t PadBits = Member.Offset - Current;
174 assert(PadBits % 8 == 0 &&
"padding is not a whole number of bytes");
178 Current = std::max(Current, Member.Offset +
179 Member.Ty->getSizeInBits().getFixedValue());
184 if (RecordSize.isFixed()) {
185 uint64_t
Size = RecordSize.getFixedValue();
187 if (
Size > Current && needsPadding(
Size, TailAlign)) {
188 uint64_t PadBits =
Size - Current;
189 assert(PadBits % 8 == 0 &&
"tail padding is not a whole number of bytes");
195 return TB.getRecordType(Fields, RecordSize, RT->getAlignment(),
196 RT->getUnadjustedAlignment(), Pack);
216 if (RT->isUnion() && RT->isTransparentUnion()) {
217 auto Fields = RT->getFields();
218 assert(!Fields.empty() &&
"transparent union cannot be empty");
219 return Fields.front().FieldType;
230 if (RT->hasFlexibleArrayMember())
233 const Type *Found =
nullptr;
235 for (
const auto &
Base : RT->getBaseClasses()) {
236 const Type *BaseTy =
Base.FieldType;
239 if (!BaseRT || BaseRT->isEmpty())
248 for (
const auto &FI : RT->getFields()) {
252 const Type *FTy = FI.FieldType;
256 if (AT->getNumElements() != 1)
258 FTy = AT->getElementType();
288 if (!RT->canPassInRegisters()) {
303 uint64_t &Members)
const {
306 if (!isMatrixHA && AT->isMatrixType())
308 uint64_t NElements = AT->getNumElements();
313 Members *= NElements;
315 if (RT->hasFlexibleArrayMember())
321 if (RT->isCXXRecord()) {
325 for (
const FieldInfo &BaseField : RT->getBaseClasses()) {
326 if (BaseField.FieldType->isEmptyRecord())
329 uint64_t FldMembers = 0;
333 Members += FldMembers;
337 for (
const FieldInfo &FD : RT->getFields()) {
339 const Type *FT = FD.FieldType;
343 if (AT->isMatrixType())
345 if (AT->getNumElements() == 0)
347 FT = AT->getElementType();
353 FD.IsBitField && FD.BitFieldWidth == 0)
356 uint64_t FldMembers = 0;
361 RT->isUnion() ? std::max(Members, FldMembers) : Members + FldMembers;
368 if (
Base->getTypeAllocSize() * Members != Ty->getTypeAllocSize())
375 ElemTy = CT->getElementType();
389 assert(VT->isFixedLength() &&
390 "scalable vectors are never homogeneous aggregates");
392 VT->getElementType()->getSizeInBits().getFixedValue();
393 unsigned NumElements =
394 VT->getTypeAllocSize().getFixedValue() * 8 / EltSize;
395 if (NumElements != VT->getNumElements().getKnownMinValue())
396 Base =
TB.getVectorType(VT->getElementType(),
403 Base->getTypeAllocSize() !=
ElemTy->getTypeAllocSize())
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
OptimizedStructLayoutField Field
This file defines the SmallVector class.
static llvm::Align getConvertedAlign(const Type *Ty)
Target-specific ABI information and factory functions.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
static constexpr ElementCount getFixed(ScalarTy MinVal)
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
Helper class to encapsulate information about how a specific type should be passed to or returned fro...
static ArgInfo getIndirect(Align Align, bool ByVal, unsigned AddrSpace=0, bool Realign=false)
Realign: the caller couldn't guarantee sufficient alignment - the callee must copy the argument to a ...
ArgInfo & getReturnInfo()
const Type * getReturnType() const
bool canPassInRegisters() const
LLVM_ABI const Type * isSingleElementStruct(const Type *Ty) const
Returns the scalar a single-element struct reduces to, else null.
virtual bool isPermittedToBeHomogeneousAggregate(const RecordType *RT) const
Return true if the C++ ABI permits RT to be a homogeneous aggregate.
virtual const ABICompatInfo & getABICompatInfo() const =0
Return this target's ABI compatibility flags.
virtual bool isHomogeneousAggregateSmallEnough(const Type *Base, uint64_t Members) const
Return true if a homogeneous aggregate with Members copies of Base is small enough to be passed in re...
LLVM_ABI bool isHomogeneousAggregate(const Type *Ty, const Type *&Base, uint64_t &Members) const
Return true if Ty is an ELFv2-style homogeneous aggregate.
LLVM_ABI bool isPromotableInteger(const IntegerType *IT) const
virtual bool isZeroLengthBitfieldPermittedInHomogeneousAggregate() const
Return true if zero-length bitfields should be ignored when deciding whether an aggregate is homogene...
virtual bool isHomogeneousAggregateBaseType(const Type *Ty) const
Return true if Ty is a valid base type for a homogeneous aggregate.
LLVM_ABI const Type * getStructOfTypes(ArrayRef< const Type * > Elems, bool Packed) const
A record with one field per element of Elems, each at offset 0.
LLVM_ABI bool maybeCommonClassifyReturnType(FunctionInfo &FI) const
Apply rules for classifying return types that are common to all targets.
LLVM_ABI bool isAggregateTypeForABI(const Type *Ty) const
LLVM_ABI const Type * useFirstFieldIfTransparentUnion(const Type *Ty) const
If Ty is a transparent union, return its first field type; otherwise return Ty unchanged.
LLVM_ABI ArgInfo getNaturalAlignIndirect(const Type *Ty, unsigned AddrSpace, bool ByVal=true) const
LLVM_ABI RecordArgABI getRecordArgABI(const RecordType *RT) const
LLVM_ABI const Type * convertTypeForMem(const Type *Ty) const
In-memory form of Ty.
virtual llvm::Align getMaxIntegerAlign() const
Alignment of the widest integer the target's data layout gives an alignment to.
LLVM_ABI const Type * getI8Array(uint64_t NumBytes) const
An array of NumBytes i8 elements, the padding element of a coerce-and-expand type.
Represents the ABI-specific view of a type in LLVM.
LLVM_ABI bool isEmptyRecord() const
True if this type is a record that is empty for ABI purposes.
TypeSize getSizeInBits() const
LLVM_ABI uint64_t getABISizeInBits() const
Returns the size in bits that the source language gives this type, including any padding.
constexpr ScalarTy getFixedValue() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
@ RAA_Indirect
Pass it as a pointer to temporary memory.
@ RAA_Default
Pass it using the normal C aggregate rules for the ABI, potentially introducing extra copies and pass...
void stable_sort(R &&Range)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
constexpr unsigned BitWidth
This struct is a compact representation of a valid (non-zero power of two) alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
bool IsMatrixHA
Whether a matrix type may be the base type of a homogeneous aggregate.