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