LLVM 24.0.0git
Types.h
Go to the documentation of this file.
1//===- ABI/Types.h ----------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file defines the type system for the LLVMABI library, which mirrors
11/// ABI-relevant aspects of frontend types.
12///
13//===----------------------------------------------------------------------===//
14#ifndef LLVM_ABI_TYPES_H
15#define LLVM_ABI_TYPES_H
16
17#include "llvm/ADT/APFloat.h"
18#include "llvm/ADT/ArrayRef.h"
25
26namespace llvm {
27namespace abi {
28
42
43/// Represents the ABI-specific view of a type in LLVM.
44///
45/// This abstracts platform and language-specific ABI details from the
46/// frontend, providing a consistent interface for the ABI Library.
47class Type {
48private:
49 TypeSize getTypeStoreSize() const {
50 TypeSize StoreSizeInBits = getTypeStoreSizeInBits();
51 return {StoreSizeInBits.getKnownMinValue() / 8,
52 StoreSizeInBits.isScalable()};
53 }
54 TypeSize getTypeStoreSizeInBits() const {
55 TypeSize BaseSize = getSizeInBits();
56 uint64_t AlignedSizeInBits =
57 alignToPowerOf2(BaseSize.getKnownMinValue(), 8);
58 return {AlignedSizeInBits, BaseSize.isScalable()};
59 }
60
61protected:
66
68 : Type(K, SizeInBits, ABIAlign, ABIAlign) {}
69 Type(TypeKind K, TypeSize SizeInBits, Align ABIAlign, Align UnadjustedAlign)
70 : Kind(K), SizeInBits(SizeInBits), ABIAlignment(ABIAlign),
71 UnadjustedAlignment(UnadjustedAlign) {}
72
73public:
74 TypeKind getKind() const { return Kind; }
75 TypeSize getSizeInBits() const { return SizeInBits; }
76
77 /// Returns the size in bits if it is fixed, otherwise 0.
79 return SizeInBits.isFixed() ? SizeInBits.getFixedValue() : 0;
80 }
81
82 /// Returns the size in bits that the source language gives this type,
83 /// including any padding.
84 ///
85 /// An integer is rounded up to whole bytes. A _BitInt or a floating-point
86 /// type is rounded up further, to its alignment. That alignment must be the
87 /// one its size is padded to, not one an aligned attribute raised or lowered.
88 /// A complex type is twice the ABI size of its element type. A fixed-length
89 /// vector counts an integer element other than a _BitInt at its bit width and
90 /// every other element at its own ABI size, so a bool element takes one bit.
91 /// The total is rounded up to a power of two of at least 8 bits. Any other
92 /// type returns the size it was created with, and a scalable type returns 0.
94
95 Align getAlignment() const { return ABIAlignment; }
96
97 /// Alignment before record-level adjustments such as aligned attributes.
98 /// Equal to getAlignment() unless a distinct unadjusted alignment was
99 /// provided when the type was created.
101
103 return alignTo(getTypeStoreSize(), getAlignment().value());
104 }
105
106 bool isVoid() const { return Kind == TypeKind::Void; }
107 bool isAtomic() const { return Kind == TypeKind::Atomic; }
108 bool isInteger() const { return Kind == TypeKind::Integer; }
109 bool isFloat() const { return Kind == TypeKind::Float; }
110 bool isPointer() const { return Kind == TypeKind::Pointer; }
111 bool isArray() const { return Kind == TypeKind::Array; }
112 bool isVector() const { return Kind == TypeKind::Vector; }
113 bool isTuple() const { return Kind == TypeKind::Tuple; }
114 bool isRecord() const { return Kind == TypeKind::Record; }
115 bool isMemberPointer() const { return Kind == TypeKind::MemberPointer; }
116 bool isComplex() const { return Kind == TypeKind::Complex; }
117 bool isZeroSize() const { return getSizeInBits().isZero(); }
118
119 LLVM_ABI bool isSVESizelessType() const;
120
121 /// True if this type is a record that is empty for ABI purposes.
122 LLVM_ABI bool isEmptyRecord() const;
123};
124
125class VoidType : public Type {
126public:
127 VoidType() : Type(TypeKind::Void, TypeSize::getFixed(0), Align(1)) {}
128
129 static bool classof(const Type *T) { return T->getKind() == TypeKind::Void; }
130};
131
132class AtomicType : public Type {
133public:
134 AtomicType(const Type *ValueType, uint64_t SizeInBits, Align Alignment)
135 : Type(TypeKind::Atomic, TypeSize::getFixed(SizeInBits), Alignment),
136 ValueType(ValueType) {}
137
138 const Type *getValueType() const { return ValueType; }
139
140 static bool classof(const Type *T) {
141 return T->getKind() == TypeKind::Atomic;
142 }
143
144private:
145 const Type *ValueType;
146};
147
148class ComplexType : public Type {
149public:
150 ComplexType(const Type *ElementType, uint64_t SizeInBits, Align Alignment)
151 : Type(TypeKind::Complex, TypeSize::getFixed(SizeInBits), Alignment),
152 ElementType(ElementType) {}
153
154 const Type *getElementType() const { return ElementType; }
155
156 static bool classof(const Type *T) {
157 return T->getKind() == TypeKind::Complex;
158 }
159
160private:
161 const Type *ElementType;
162};
163
164class IntegerType : public Type {
165private:
166 bool IsSigned;
167 bool IsBitInt;
168
169public:
170 IntegerType(uint64_t BitWidth, Align ABIAlign, bool IsSigned,
171 bool IsBitInt = false)
172 : Type(TypeKind::Integer, TypeSize::getFixed(BitWidth), ABIAlign),
173 IsSigned(IsSigned), IsBitInt(IsBitInt) {}
174
175 bool isSigned() const { return IsSigned; }
176 bool isBitInt() const { return IsBitInt; }
177 bool isBool() const {
178 return getSizeInBits().getFixedValue() == 1 && !IsBitInt;
179 }
180
181 static bool classof(const Type *T) {
182 return T->getKind() == TypeKind::Integer;
183 }
184};
185
186class FloatType : public Type {
187private:
188 const fltSemantics *Semantics;
189
190public:
191 FloatType(const fltSemantics &FloatSemantics, Align ABIAlign)
193 TypeSize::getFixed(APFloat::getSizeInBits(FloatSemantics)),
194 ABIAlign),
195 Semantics(&FloatSemantics) {}
196
197 const fltSemantics *getSemantics() const { return Semantics; }
198 static bool classof(const Type *T) { return T->getKind() == TypeKind::Float; }
199};
200
201class PointerLikeType : public Type {
202protected:
203 unsigned AddrSpace;
205 : Type(K, SizeInBits, ABIAlign), AddrSpace(AS) {}
206
207public:
208 unsigned getAddrSpace() const { return AddrSpace; }
209 bool isMemberPointer() const { return getKind() == TypeKind::MemberPointer; }
210
211 static bool classof(const Type *T) {
212 return T->getKind() == TypeKind::Pointer ||
213 T->getKind() == TypeKind::MemberPointer;
214 }
215};
216
218 bool HasAddressSpaceQualifier;
219
220public:
221 PointerType(uint64_t Size, Align ABIAlign, unsigned AddressSpace = 0,
222 bool HasAddressSpaceQualifier = false)
223 : PointerLikeType(TypeKind::Pointer, TypeSize::getFixed(Size), ABIAlign,
225 HasAddressSpaceQualifier(HasAddressSpaceQualifier) {
226 assert((HasAddressSpaceQualifier || AddressSpace == 0) &&
227 "an unqualified pointer is in address space 0");
228 }
229
230 bool hasAddressSpaceQualifier() const { return HasAddressSpaceQualifier; }
231
232 static bool classof(const Type *T) {
233 return T->getKind() == TypeKind::Pointer;
234 }
235};
236
238private:
239 bool IsFunctionPointer;
240
241public:
242 MemberPointerType(bool IsFunctionPointer, uint64_t SizeInBits, Align ABIAlign,
243 unsigned AddressSpace = 0)
245 ABIAlign, AddressSpace),
246 IsFunctionPointer(IsFunctionPointer) {}
247 bool isFunctionPointer() const { return IsFunctionPointer; }
248
249 static bool classof(const Type *T) {
250 return T->getKind() == TypeKind::MemberPointer;
251 }
252};
253
254class ArrayType : public Type {
255private:
256 const Type *ElementType;
257 uint64_t NumElements;
258 bool IsMatrix;
259
260public:
261 ArrayType(const Type *ElementType, uint64_t NumElements, uint64_t SizeInBits,
262 bool IsMatrixType = false)
263 : Type(TypeKind::Array, TypeSize::getFixed(SizeInBits),
264 ElementType->getAlignment()),
265 ElementType(ElementType), NumElements(NumElements),
266 IsMatrix(IsMatrixType) {}
267
268 const Type *getElementType() const { return ElementType; }
269 uint64_t getNumElements() const { return NumElements; }
270 bool isMatrixType() const { return IsMatrix; }
271
272 static bool classof(const Type *T) { return T->getKind() == TypeKind::Array; }
273};
274
275/// Distinguishes the vector flavors that ABIs have to treat differently.
276/// Scalability is not part of the kind. It is tracked by the vector's
277/// ElementCount, because some flavors have both a scalable and a
278/// fixed-length spelling.
279enum class VectorKind {
280 /// A plain vector, such as a Neon vector or a GCC vector_size vector.
282
283 /// An AArch64 SVE data vector, such as svint32_t. Data vectors are
284 /// passed in Z registers. Tuples of these vectors use TupleType.
286
287 /// An AArch64 SVE predicate vector, such as svbool_t. These are passed
288 /// in P registers. Sizeless predicates have one-bit elements; the
289 /// fixed-length arm_sve_vector_bits form keeps unsigned char (i8)
290 /// elements, matching the Clang AST. Both use this kind. Tuples of
291 /// these vectors use TupleType.
293
294 /// The AArch64 __SVCount_t type. It is opaque rather than a real vector,
295 /// but it occupies a predicate register, so it is given the same shape as
296 /// svbool_t.
298};
299
300class VectorType : public Type {
301private:
302 const Type *ElementType;
303 ElementCount NumElements;
304 VectorKind VecKind;
305
306 static TypeSize computeSizeInBits(const Type *ElementType,
307 ElementCount NumElements) {
308 return TypeSize(ElementType->getSizeInBits().getFixedValue() *
309 NumElements.getKnownMinValue(),
310 NumElements.isScalable());
311 }
312
313public:
314 VectorType(const Type *ElementType, ElementCount NumElements, Align ABIAlign,
316 : Type(TypeKind::Vector, computeSizeInBits(ElementType, NumElements),
317 ABIAlign),
318 ElementType(ElementType), NumElements(NumElements), VecKind(VecKind) {}
319
320 const Type *getElementType() const { return ElementType; }
321 ElementCount getNumElements() const { return NumElements; }
322
323 VectorKind getVectorKind() const { return VecKind; }
324
325 bool isScalable() const { return NumElements.isScalable(); }
326 bool isFixedLength() const { return !NumElements.isScalable(); }
327
328 bool isSVEData() const { return VecKind == VectorKind::SVEData; }
329 bool isSVEPredicate() const { return VecKind == VectorKind::SVEPredicate; }
330 bool isSVECount() const { return VecKind == VectorKind::SVECount; }
331
332 bool isFixedLengthSVEData() const { return isFixedLength() && isSVEData(); }
334 return isFixedLength() && isSVEPredicate();
335 }
336
337 /// Returns true for any of the AArch64 SVE flavors.
338 bool isSVEType() const { return VecKind != VectorKind::Generic; }
339
340 static bool classof(const Type *T) {
341 return T->getKind() == TypeKind::Vector;
342 }
343};
344
345/// A homogeneous tuple of 2, 3, or 4 identical vectors, such as the
346/// AArch64 SVE types svint32x3_t and svboolx2_t.
347///
348/// The contained vector describes one register-shaped member. Size and
349/// alignment of the tuple cover the whole group: size is NumVectors times
350/// the vector size, and alignment matches the contained vector.
351class TupleType : public Type {
352private:
353 const VectorType *Vec;
354 unsigned NumVectors;
355
356public:
357 TupleType(const VectorType *Vec, unsigned NumVectors)
358 : Type(TypeKind::Tuple, (Vec->getSizeInBits() * NumVectors),
359 Vec->getAlignment()),
360 Vec(Vec), NumVectors(NumVectors) {}
361
362 const VectorType *getVectorType() const { return Vec; }
363 unsigned getNumVectors() const { return NumVectors; }
364
365 static bool classof(const Type *T) { return T->getKind() == TypeKind::Tuple; }
366};
367
386
388
389enum RecordFlags : unsigned {
390 None = 0,
392 IsUnion = 1 << 1,
394 IsCXXRecord = 1 << 3,
398};
399
400class RecordType : public Type {
401private:
402 ArrayRef<FieldInfo> Fields;
403 ArrayRef<FieldInfo> BaseClasses;
404 ArrayRef<FieldInfo> VirtualBaseClasses;
405 StructPacking Packing;
406 RecordFlags Flags;
407
408public:
410 ArrayRef<FieldInfo> VBases, TypeSize Size, Align ABIAlign,
411 Align UnadjustedAlign, StructPacking Pack = StructPacking::Default,
413 : Type(TypeKind::Record, Size, ABIAlign, UnadjustedAlign),
414 Fields(StructFields), BaseClasses(Bases), VirtualBaseClasses(VBases),
415 Packing(Pack), Flags(RecFlags) {}
416 uint32_t getNumFields() const { return Fields.size(); }
417 StructPacking getPacking() const { return Packing; }
418
419 bool isUnion() const {
420 return static_cast<unsigned>(Flags & RecordFlags::IsUnion) != 0;
421 }
422 bool isCXXRecord() const {
423 return static_cast<unsigned>(Flags & RecordFlags::IsCXXRecord) != 0;
424 }
425 bool isPolymorphic() const {
426 return static_cast<unsigned>(Flags & RecordFlags::IsPolymorphic) != 0;
427 }
428 bool canPassInRegisters() const {
429 return static_cast<unsigned>(Flags & RecordFlags::CanPassInRegisters) != 0;
430 }
432 return static_cast<unsigned>(Flags & RecordFlags::HasFlexibleArrayMember) !=
433 0;
434 }
435 uint32_t getNumBaseClasses() const { return BaseClasses.size(); }
437 return VirtualBaseClasses.size();
438 }
439 bool isTransparentUnion() const {
440 return static_cast<unsigned>(Flags & RecordFlags::IsTransparent) != 0;
441 }
442 ArrayRef<FieldInfo> getFields() const { return Fields; }
443 ArrayRef<FieldInfo> getBaseClasses() const { return BaseClasses; }
445 return VirtualBaseClasses;
446 }
447
448 LLVM_ABI bool isEmpty() const;
449
450 /// Returns the field, base, or virtual base whose extent contains
451 /// \p OffsetInBits, or nullptr if no such element exists. Empty bases and
452 /// unnamed bitfields are skipped.
453 LLVM_ABI const FieldInfo *
454 getElementContainingOffset(unsigned OffsetInBits) const;
455
456 static bool classof(const Type *T) {
457 return T->getKind() == TypeKind::Record;
458 }
459};
460
461/// TypeBuilder manages the lifecycle of ABI types using bump pointer
462/// allocation. Types created by a TypeBuilder are valid for the lifetime of the
463/// allocator.
464///
465/// Example usage:
466/// \code
467/// BumpPtrAllocator Alloc;
468/// TypeBuilder Builder(Alloc);
469/// const auto *IntTy = Builder.getIntegerType(32, Align(4), true);
470/// \endcode
472private:
473 BumpPtrAllocator &Allocator;
474
475public:
476 explicit TypeBuilder(BumpPtrAllocator &Alloc) : Allocator(Alloc) {}
477
479 return new (Allocator.Allocate<VoidType>()) VoidType();
480 }
481
482 const AtomicType *getAtomicType(const Type *ValueType, uint64_t SizeInBits,
483 Align Align) {
484 return new (Allocator.Allocate<AtomicType>())
485 AtomicType(ValueType, SizeInBits, Align);
486 }
487
489 bool IsBitInt = false) {
490 return new (Allocator.Allocate<IntegerType>())
491 IntegerType(BitWidth, Align, Signed, IsBitInt);
492 }
493
494 const FloatType *getFloatType(const fltSemantics &Semantics, Align Align) {
495 return new (Allocator.Allocate<FloatType>()) FloatType(Semantics, Align);
496 }
497
499 unsigned Addrspace = 0,
500 bool HasAddressSpaceQualifier = false) {
501 return new (Allocator.Allocate<PointerType>())
502 PointerType(Size, Align, Addrspace, HasAddressSpaceQualifier);
503 }
504
505 const ArrayType *getArrayType(const Type *ElementType, uint64_t NumElements,
506 uint64_t SizeInBits,
507 bool IsMatrixType = false) {
508 return new (Allocator.Allocate<ArrayType>())
509 ArrayType(ElementType, NumElements, SizeInBits, IsMatrixType);
510 }
511
512 const VectorType *getVectorType(const Type *ElementType,
513 ElementCount NumElements, Align Align,
515 return new (Allocator.Allocate<VectorType>())
516 VectorType(ElementType, NumElements, Align, VecKind);
517 }
518
519 /// Creates a homogeneous tuple of \p NumVectors copies of \p Vec.
520 /// \p NumVectors must be 2, 3, or 4.
521 const TupleType *getTupleType(const VectorType *Vec, unsigned NumVectors) {
522 assert(NumVectors >= 2 && NumVectors <= 4 &&
523 "tuple types hold 2, 3, or 4 vectors");
524 return new (Allocator.Allocate<TupleType>()) TupleType(Vec, NumVectors);
525 }
526
527 /// Creates a scalable predicate or count vector.
528 /// Note: The AArch64 __SVCount_t type is opaque, so it is modeled with the
529 /// shape of svbool_t: a scalable vector of 16 one-bit elements.
531 VectorKind Kind) {
533 "expected predicate or count vector kind");
534 const Type *PredicateBit =
535 getIntegerType(1, Align(1), /*Signed=*/false, /*IsBitInt=*/false);
536 return getVectorType(PredicateBit, ElementCount::getScalable(16), ABIAlign,
537 Kind);
538 }
539
541 Align ABIAlign, Align UnadjustedAlign,
543 ArrayRef<FieldInfo> BaseClasses = {},
544 ArrayRef<FieldInfo> VirtualBaseClasses = {},
545 RecordFlags RecFlags = RecordFlags::None) {
546 FieldInfo *FieldArray = Allocator.Allocate<FieldInfo>(Fields.size());
547 std::copy(Fields.begin(), Fields.end(), FieldArray);
548
549 FieldInfo *BaseArray = nullptr;
550 if (!BaseClasses.empty()) {
551 BaseArray = Allocator.Allocate<FieldInfo>(BaseClasses.size());
552 std::copy(BaseClasses.begin(), BaseClasses.end(), BaseArray);
553 }
554
555 FieldInfo *VBaseArray = nullptr;
556 if (!VirtualBaseClasses.empty()) {
557 VBaseArray = Allocator.Allocate<FieldInfo>(VirtualBaseClasses.size());
558 std::copy(VirtualBaseClasses.begin(), VirtualBaseClasses.end(),
559 VBaseArray);
560 }
561
562 ArrayRef<FieldInfo> FieldsRef(FieldArray, Fields.size());
563 ArrayRef<FieldInfo> BasesRef(BaseArray, BaseClasses.size());
564 ArrayRef<FieldInfo> VBasesRef(VBaseArray, VirtualBaseClasses.size());
565
566 return new (Allocator.Allocate<RecordType>())
567 RecordType(FieldsRef, BasesRef, VBasesRef, Size, ABIAlign,
568 UnadjustedAlign, Pack, RecFlags);
569 }
570
572 Align ABIAlign, Align UnadjustedAlign,
574 RecordFlags RecFlags = RecordFlags::None) {
575 FieldInfo *FieldArray = Allocator.Allocate<FieldInfo>(Fields.size());
576
577 for (size_t I = 0, E = Fields.size(); I != E; ++I) {
578 FieldInfo Field = Fields[I];
579 Field.OffsetInBits = 0;
580 new (&FieldArray[I]) FieldInfo(Field);
581 }
582
583 ArrayRef<FieldInfo> FieldsRef(FieldArray, Fields.size());
584
585 return new (Allocator.Allocate<RecordType>()) RecordType(
586 FieldsRef, ArrayRef<FieldInfo>(), ArrayRef<FieldInfo>(), Size, ABIAlign,
587 UnadjustedAlign, Pack, RecFlags | RecordFlags::IsUnion);
588 }
589
590 const ComplexType *getComplexType(const Type *ElementType, Align Align) {
591 // Complex types have two elements (real and imaginary parts)
592 uint64_t ElementSizeInBits = ElementType->getSizeInBits().getFixedValue();
593 uint64_t ComplexSizeInBits = ElementSizeInBits * 2;
594
595 return new (Allocator.Allocate<ComplexType>())
596 ComplexType(ElementType, ComplexSizeInBits, Align);
597 }
598
599 const MemberPointerType *getMemberPointerType(bool IsFunctionPointer,
600 uint64_t SizeInBits,
601 Align Align) {
602 return new (Allocator.Allocate<MemberPointerType>())
603 MemberPointerType(IsFunctionPointer, SizeInBits, Align);
604 }
605};
606
607} // namespace abi
608} // namespace llvm
609
610#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h:211
#define I(x, y, z)
Definition MD5.cpp:57
#define T
OptimizedStructLayoutField Field
Basic Register Allocator
FunctionLoweringInfo::StatepointRelocationRecord RecordType
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
iterator end() const
Definition ArrayRef.h:130
size_t size() const
Get the array size.
Definition ArrayRef.h:141
iterator begin() const
Definition ArrayRef.h:129
bool empty() const
Check if the array is empty.
Definition ArrayRef.h:136
static constexpr ElementCount getScalable(ScalarTy MinVal)
Definition TypeSize.h:309
const Type * getElementType() const
Definition Types.h:268
bool isMatrixType() const
Definition Types.h:270
static bool classof(const Type *T)
Definition Types.h:272
ArrayType(const Type *ElementType, uint64_t NumElements, uint64_t SizeInBits, bool IsMatrixType=false)
Definition Types.h:261
uint64_t getNumElements() const
Definition Types.h:269
const Type * getValueType() const
Definition Types.h:138
AtomicType(const Type *ValueType, uint64_t SizeInBits, Align Alignment)
Definition Types.h:134
static bool classof(const Type *T)
Definition Types.h:140
ComplexType(const Type *ElementType, uint64_t SizeInBits, Align Alignment)
Definition Types.h:150
const Type * getElementType() const
Definition Types.h:154
static bool classof(const Type *T)
Definition Types.h:156
FloatType(const fltSemantics &FloatSemantics, Align ABIAlign)
Definition Types.h:191
const fltSemantics * getSemantics() const
Definition Types.h:197
static bool classof(const Type *T)
Definition Types.h:198
static bool classof(const Type *T)
Definition Types.h:181
bool isBitInt() const
Definition Types.h:176
IntegerType(uint64_t BitWidth, Align ABIAlign, bool IsSigned, bool IsBitInt=false)
Definition Types.h:170
bool isBool() const
Definition Types.h:177
bool isSigned() const
Definition Types.h:175
bool isFunctionPointer() const
Definition Types.h:247
static bool classof(const Type *T)
Definition Types.h:249
MemberPointerType(bool IsFunctionPointer, uint64_t SizeInBits, Align ABIAlign, unsigned AddressSpace=0)
Definition Types.h:242
PointerLikeType(TypeKind K, TypeSize SizeInBits, Align ABIAlign, unsigned AS)
Definition Types.h:204
static bool classof(const Type *T)
Definition Types.h:211
bool isMemberPointer() const
Definition Types.h:209
unsigned getAddrSpace() const
Definition Types.h:208
bool hasAddressSpaceQualifier() const
Definition Types.h:230
static bool classof(const Type *T)
Definition Types.h:232
PointerType(uint64_t Size, Align ABIAlign, unsigned AddressSpace=0, bool HasAddressSpaceQualifier=false)
Definition Types.h:221
bool isPolymorphic() const
Definition Types.h:425
bool isUnion() const
Definition Types.h:419
bool canPassInRegisters() const
Definition Types.h:428
LLVM_ABI const FieldInfo * getElementContainingOffset(unsigned OffsetInBits) const
Returns the field, base, or virtual base whose extent contains OffsetInBits, or nullptr if no such el...
Definition Types.cpp:94
ArrayRef< FieldInfo > getBaseClasses() const
Definition Types.h:443
uint32_t getNumBaseClasses() const
Definition Types.h:435
ArrayRef< FieldInfo > getFields() const
Definition Types.h:442
uint32_t getNumVirtualBaseClasses() const
Definition Types.h:436
bool hasFlexibleArrayMember() const
Definition Types.h:431
bool isCXXRecord() const
Definition Types.h:422
bool isTransparentUnion() const
Definition Types.h:439
static bool classof(const Type *T)
Definition Types.h:456
LLVM_ABI bool isEmpty() const
Definition Types.cpp:69
uint32_t getNumFields() const
Definition Types.h:416
ArrayRef< FieldInfo > getVirtualBaseClasses() const
Definition Types.h:444
StructPacking getPacking() const
Definition Types.h:417
RecordType(ArrayRef< FieldInfo > StructFields, ArrayRef< FieldInfo > Bases, ArrayRef< FieldInfo > VBases, TypeSize Size, Align ABIAlign, Align UnadjustedAlign, StructPacking Pack=StructPacking::Default, RecordFlags RecFlags=RecordFlags::None)
Definition Types.h:409
A homogeneous tuple of 2, 3, or 4 identical vectors, such as the AArch64 SVE types svint32x3_t and sv...
Definition Types.h:351
const VectorType * getVectorType() const
Definition Types.h:362
unsigned getNumVectors() const
Definition Types.h:363
TupleType(const VectorType *Vec, unsigned NumVectors)
Definition Types.h:357
static bool classof(const Type *T)
Definition Types.h:365
const ComplexType * getComplexType(const Type *ElementType, Align Align)
Definition Types.h:590
const FloatType * getFloatType(const fltSemantics &Semantics, Align Align)
Definition Types.h:494
const PointerType * getPointerType(uint64_t Size, Align Align, unsigned Addrspace=0, bool HasAddressSpaceQualifier=false)
Definition Types.h:498
const IntegerType * getIntegerType(uint64_t BitWidth, Align Align, bool Signed, bool IsBitInt=false)
Definition Types.h:488
const VectorType * getScalablePredicateOrCountVectorType(Align ABIAlign, VectorKind Kind)
Creates a scalable predicate or count vector.
Definition Types.h:530
const AtomicType * getAtomicType(const Type *ValueType, uint64_t SizeInBits, Align Align)
Definition Types.h:482
const RecordType * getUnionType(ArrayRef< FieldInfo > Fields, TypeSize Size, Align ABIAlign, Align UnadjustedAlign, StructPacking Pack=StructPacking::Default, RecordFlags RecFlags=RecordFlags::None)
Definition Types.h:571
const MemberPointerType * getMemberPointerType(bool IsFunctionPointer, uint64_t SizeInBits, Align Align)
Definition Types.h:599
TypeBuilder(BumpPtrAllocator &Alloc)
Definition Types.h:476
const TupleType * getTupleType(const VectorType *Vec, unsigned NumVectors)
Creates a homogeneous tuple of NumVectors copies of Vec.
Definition Types.h:521
const VectorType * getVectorType(const Type *ElementType, ElementCount NumElements, Align Align, VectorKind VecKind=VectorKind::Generic)
Definition Types.h:512
const ArrayType * getArrayType(const Type *ElementType, uint64_t NumElements, uint64_t SizeInBits, bool IsMatrixType=false)
Definition Types.h:505
const RecordType * getRecordType(ArrayRef< FieldInfo > Fields, TypeSize Size, Align ABIAlign, Align UnadjustedAlign, StructPacking Pack=StructPacking::Default, ArrayRef< FieldInfo > BaseClasses={}, ArrayRef< FieldInfo > VirtualBaseClasses={}, RecordFlags RecFlags=RecordFlags::None)
Definition Types.h:540
const VoidType * getVoidType()
Definition Types.h:478
Represents the ABI-specific view of a type in LLVM.
Definition Types.h:47
TypeSize getTypeAllocSize() const
Definition Types.h:102
Align ABIAlignment
Definition Types.h:64
bool isMemberPointer() const
Definition Types.h:115
bool isVoid() const
Definition Types.h:106
Type(TypeKind K, TypeSize SizeInBits, Align ABIAlign, Align UnadjustedAlign)
Definition Types.h:69
LLVM_ABI bool isSVESizelessType() const
Definition Types.cpp:51
LLVM_ABI bool isEmptyRecord() const
True if this type is a record that is empty for ABI purposes.
Definition Types.cpp:64
bool isAtomic() const
Definition Types.h:107
TypeSize SizeInBits
Definition Types.h:63
TypeSize getSizeInBits() const
Definition Types.h:75
bool isInteger() const
Definition Types.h:108
Type(TypeKind K, TypeSize SizeInBits, Align ABIAlign)
Definition Types.h:67
bool isTuple() const
Definition Types.h:113
TypeKind Kind
Definition Types.h:62
bool isRecord() const
Definition Types.h:114
bool isArray() const
Definition Types.h:111
bool isZeroSize() const
Definition Types.h:117
bool isVector() const
Definition Types.h:112
bool isFloat() const
Definition Types.h:109
LLVM_ABI uint64_t getABISizeInBits() const
Returns the size in bits that the source language gives this type, including any padding.
Definition Types.cpp:18
Align getAlignment() const
Definition Types.h:95
Align UnadjustedAlignment
Definition Types.h:65
Align getUnadjustedAlignment() const
Alignment before record-level adjustments such as aligned attributes.
Definition Types.h:100
bool isComplex() const
Definition Types.h:116
uint64_t getFixedSizeInBitsOrZero() const
Returns the size in bits if it is fixed, otherwise 0.
Definition Types.h:78
TypeKind getKind() const
Definition Types.h:74
bool isPointer() const
Definition Types.h:110
ElementCount getNumElements() const
Definition Types.h:321
bool isFixedLengthSVEData() const
Definition Types.h:332
const Type * getElementType() const
Definition Types.h:320
VectorKind getVectorKind() const
Definition Types.h:323
static bool classof(const Type *T)
Definition Types.h:340
VectorType(const Type *ElementType, ElementCount NumElements, Align ABIAlign, VectorKind VecKind=VectorKind::Generic)
Definition Types.h:314
bool isSVEType() const
Returns true for any of the AArch64 SVE flavors.
Definition Types.h:338
bool isFixedLength() const
Definition Types.h:326
bool isSVECount() const
Definition Types.h:330
bool isScalable() const
Definition Types.h:325
bool isSVEData() const
Definition Types.h:328
bool isSVEPredicate() const
Definition Types.h:329
bool isFixedLengthSVEPredicate() const
Definition Types.h:333
static bool classof(const Type *T)
Definition Types.h:129
constexpr ScalarTy getFixedValue() const
Definition TypeSize.h:201
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition TypeSize.h:169
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition TypeSize.h:166
constexpr bool isZero() const
Definition TypeSize.h:154
RecordFlags
Definition Types.h:389
@ IsPolymorphic
Definition Types.h:395
@ IsCXXRecord
Definition Types.h:394
@ CanPassInRegisters
Definition Types.h:391
@ IsTransparent
Definition Types.h:393
@ LLVM_MARK_AS_BITMASK_ENUM
Definition Types.h:397
@ IsUnion
Definition Types.h:392
@ HasFlexibleArrayMember
Definition Types.h:396
VectorKind
Distinguishes the vector flavors that ABIs have to treat differently.
Definition Types.h:279
@ SVEPredicate
An AArch64 SVE predicate vector, such as svbool_t.
Definition Types.h:292
@ SVEData
An AArch64 SVE data vector, such as svint32_t.
Definition Types.h:285
@ Generic
A plain vector, such as a Neon vector or a GCC vector_size vector.
Definition Types.h:281
@ SVECount
The AArch64 __SVCount_t type.
Definition Types.h:297
StructPacking
Definition Types.h:387
This is an optimization pass for GlobalISel generic memory operations.
constexpr T alignToPowerOf2(U Value, V Align)
Will overflow only if result is not representable in T.
Definition MathExtras.h:488
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition Alignment.h:149
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr unsigned BitWidth
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:391
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
FieldInfo(const Type *FieldType, uint64_t OffsetInBits=0, bool IsBitField=false, uint64_t BitFieldWidth=0, bool IsUnnamedBitField=false, bool HasNoUniqueAddress=false)
Definition Types.h:376
bool HasNoUniqueAddress
Definition Types.h:374
const Type * FieldType
Definition Types.h:369
uint64_t BitFieldWidth
Definition Types.h:371
LLVM_ABI bool isEmpty() const
Definition Types.cpp:119
uint64_t OffsetInBits
Definition Types.h:370