26 if (Ty->isInteger() || Ty->isFloat() || Ty->isOpaqueFloat8() ||
27 Ty->isPointer() || Ty->isVector() || Ty->isTuple())
32 return MPT->isFunctionPointer();
38 if (AT->isMatrixType())
48 unsigned BitWidth =
IT->getSizeInBits().getFixedValue();
58 assert(NumBytes != 0 &&
"empty padding");
60 return TB.getArrayType(I8, NumBytes, NumBytes * 8);
68 for (
const Type *Elt : Elems)
91 return Ty->getAlignment();
97 {RT->getFields(), RT->getBaseClasses()}) {
99 if (!Member.isEmpty())
108 if (AT->isMatrixType())
111 if (Elt == AT->getElementType())
113 assert(AT->getSizeInBits().isFixed() &&
114 "converted array element changes a scalable size");
115 return TB.getArrayType(Elt, AT->getNumElements(),
120 if (!RT || RT->isUnion())
125 assert(RT->getNumVirtualBaseClasses() == 0 &&
"record has a virtual base");
127 struct ConvertedMember {
137 auto addMember = [&](
const Type *MemberTy, uint64_t
Offset) {
140 "scalable member has no fixed offset");
142 if (
Offset % (Alignment.value() * 8) != 0)
144 MaxAlign = std::max(MaxAlign, Alignment);
148 if (!
Base.FieldType->isEmptyRecord())
149 addMember(
Base.FieldType,
Base.OffsetInBits);
152 if (!
Field.isEmpty())
153 addMember(
Field.FieldType,
Field.OffsetInBits);
156 [](
const ConvertedMember &
A,
const ConvertedMember &
B) {
157 return A.Offset <
B.Offset;
161 if (RecordSize.isFixed() &&
162 RecordSize.getFixedValue() % (MaxAlign.
value() * 8) != 0)
166 uint64_t Current = 0;
171 uint64_t AlignBits =
Packed ? 8 : Alignment.value() * 8;
174 for (
const ConvertedMember &Member : Members) {
175 if (Member.Offset > Current &&
176 needsPadding(Member.Offset, Member.Alignment)) {
177 uint64_t PadBits = Member.Offset - Current;
178 assert(PadBits % 8 == 0 &&
"padding is not a whole number of bytes");
182 Current = std::max(Current, Member.Offset +
183 Member.Ty->getSizeInBits().getFixedValue());
188 if (RecordSize.isFixed()) {
189 uint64_t
Size = RecordSize.getFixedValue();
191 if (
Size > Current && needsPadding(
Size, TailAlign)) {
192 uint64_t PadBits =
Size - Current;
193 assert(PadBits % 8 == 0 &&
"tail padding is not a whole number of bytes");
199 return TB.getRecordType(Fields, RecordSize, RT->getAlignment(),
200 RT->getUnadjustedAlignment(), Pack);
220 if (RT->isUnion() && RT->isTransparentUnion()) {
221 auto Fields = RT->getFields();
222 assert(!Fields.empty() &&
"transparent union cannot be empty");
223 return Fields.front().FieldType;
234 if (RT->hasFlexibleArrayMember())
237 const Type *Found =
nullptr;
239 for (
const auto &
Base : RT->getBaseClasses()) {
240 const Type *BaseTy =
Base.FieldType;
243 if (!BaseRT || BaseRT->isEmpty())
252 for (
const auto &FI : RT->getFields()) {
256 const Type *FTy = FI.FieldType;
260 if (AT->getNumElements() != 1)
262 FTy = AT->getElementType();
292 if (!RT->canPassInRegisters()) {
307 uint64_t &Members)
const {
310 if (!isMatrixHA && AT->isMatrixType())
312 uint64_t NElements = AT->getNumElements();
317 Members *= NElements;
319 if (RT->hasFlexibleArrayMember())
325 if (RT->isCXXRecord()) {
329 for (
const FieldInfo &BaseField : RT->getBaseClasses()) {
330 if (BaseField.FieldType->isEmptyRecord())
333 uint64_t FldMembers = 0;
337 Members += FldMembers;
341 for (
const FieldInfo &FD : RT->getFields()) {
343 const Type *FT = FD.FieldType;
347 if (AT->isMatrixType())
349 if (AT->getNumElements() == 0)
351 FT = AT->getElementType();
357 FD.IsBitField && FD.BitFieldWidth == 0)
360 uint64_t FldMembers = 0;
365 RT->isUnion() ? std::max(Members, FldMembers) : Members + FldMembers;
372 if (
Base->getTypeAllocSize() * Members != Ty->getTypeAllocSize())
379 ElemTy = CT->getElementType();
393 assert(VT->isFixedLength() &&
394 "scalable vectors are never homogeneous aggregates");
396 VT->getElementType()->getSizeInBits().getFixedValue();
397 unsigned NumElements =
398 VT->getTypeAllocSize().getFixedValue() * 8 / EltSize;
399 if (NumElements != VT->getNumElements().getKnownMinValue())
400 Base =
TB.getVectorType(VT->getElementType(),
407 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.
virtual unsigned getSRetAddrSpace() const
Address space of the sret pointer of a record that cannot be passed in registers (e....
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.