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
218public:
219 PointerType(uint64_t Size, Align ABIAlign, unsigned AddressSpace = 0)
220 : PointerLikeType(TypeKind::Pointer, TypeSize::getFixed(Size), ABIAlign,
221 AddressSpace) {}
222
223 static bool classof(const Type *T) {
224 return T->getKind() == TypeKind::Pointer;
225 }
226};
227
229private:
230 bool IsFunctionPointer;
231
232public:
233 MemberPointerType(bool IsFunctionPointer, uint64_t SizeInBits, Align ABIAlign,
234 unsigned AddressSpace = 0)
236 ABIAlign, AddressSpace),
237 IsFunctionPointer(IsFunctionPointer) {}
238 bool isFunctionPointer() const { return IsFunctionPointer; }
239
240 static bool classof(const Type *T) {
241 return T->getKind() == TypeKind::MemberPointer;
242 }
243};
244
245class ArrayType : public Type {
246private:
247 const Type *ElementType;
248 uint64_t NumElements;
249 bool IsMatrix;
250
251public:
252 ArrayType(const Type *ElementType, uint64_t NumElements, uint64_t SizeInBits,
253 bool IsMatrixType = false)
254 : Type(TypeKind::Array, TypeSize::getFixed(SizeInBits),
255 ElementType->getAlignment()),
256 ElementType(ElementType), NumElements(NumElements),
257 IsMatrix(IsMatrixType) {}
258
259 const Type *getElementType() const { return ElementType; }
260 uint64_t getNumElements() const { return NumElements; }
261 bool isMatrixType() const { return IsMatrix; }
262
263 static bool classof(const Type *T) { return T->getKind() == TypeKind::Array; }
264};
265
266/// Distinguishes the vector flavors that ABIs have to treat differently.
267/// Scalability is not part of the kind. It is tracked by the vector's
268/// ElementCount, because some flavors have both a scalable and a
269/// fixed-length spelling.
270enum class VectorKind {
271 /// A plain vector, such as a Neon vector or a GCC vector_size vector.
273
274 /// An AArch64 SVE data vector, such as svint32_t. Data vectors are
275 /// passed in Z registers. Tuples of these vectors use TupleType.
277
278 /// An AArch64 SVE predicate vector, such as svbool_t. These are passed
279 /// in P registers. Sizeless predicates have one-bit elements; the
280 /// fixed-length arm_sve_vector_bits form keeps unsigned char (i8)
281 /// elements, matching the Clang AST. Both use this kind. Tuples of
282 /// these vectors use TupleType.
284
285 /// The AArch64 __SVCount_t type. It is opaque rather than a real vector,
286 /// but it occupies a predicate register, so it is given the same shape as
287 /// svbool_t.
289};
290
291class VectorType : public Type {
292private:
293 const Type *ElementType;
294 ElementCount NumElements;
295 VectorKind VecKind;
296
297 static TypeSize computeSizeInBits(const Type *ElementType,
298 ElementCount NumElements) {
299 return TypeSize(ElementType->getSizeInBits().getFixedValue() *
300 NumElements.getKnownMinValue(),
301 NumElements.isScalable());
302 }
303
304public:
305 VectorType(const Type *ElementType, ElementCount NumElements, Align ABIAlign,
307 : Type(TypeKind::Vector, computeSizeInBits(ElementType, NumElements),
308 ABIAlign),
309 ElementType(ElementType), NumElements(NumElements), VecKind(VecKind) {}
310
311 const Type *getElementType() const { return ElementType; }
312 ElementCount getNumElements() const { return NumElements; }
313
314 VectorKind getVectorKind() const { return VecKind; }
315
316 bool isScalable() const { return NumElements.isScalable(); }
317 bool isFixedLength() const { return !NumElements.isScalable(); }
318
319 bool isSVEData() const { return VecKind == VectorKind::SVEData; }
320 bool isSVEPredicate() const { return VecKind == VectorKind::SVEPredicate; }
321 bool isSVECount() const { return VecKind == VectorKind::SVECount; }
322
323 bool isFixedLengthSVEData() const { return isFixedLength() && isSVEData(); }
325 return isFixedLength() && isSVEPredicate();
326 }
327
328 /// Returns true for any of the AArch64 SVE flavors.
329 bool isSVEType() const { return VecKind != VectorKind::Generic; }
330
331 static bool classof(const Type *T) {
332 return T->getKind() == TypeKind::Vector;
333 }
334};
335
336/// A homogeneous tuple of 2, 3, or 4 identical vectors, such as the
337/// AArch64 SVE types svint32x3_t and svboolx2_t.
338///
339/// The contained vector describes one register-shaped member. Size and
340/// alignment of the tuple cover the whole group: size is NumVectors times
341/// the vector size, and alignment matches the contained vector.
342class TupleType : public Type {
343private:
344 const VectorType *Vec;
345 unsigned NumVectors;
346
347public:
348 TupleType(const VectorType *Vec, unsigned NumVectors)
349 : Type(TypeKind::Tuple, (Vec->getSizeInBits() * NumVectors),
350 Vec->getAlignment()),
351 Vec(Vec), NumVectors(NumVectors) {}
352
353 const VectorType *getVectorType() const { return Vec; }
354 unsigned getNumVectors() const { return NumVectors; }
355
356 static bool classof(const Type *T) { return T->getKind() == TypeKind::Tuple; }
357};
358
377
379
380enum RecordFlags : unsigned {
381 None = 0,
383 IsUnion = 1 << 1,
385 IsCXXRecord = 1 << 3,
389};
390
391class RecordType : public Type {
392private:
393 ArrayRef<FieldInfo> Fields;
394 ArrayRef<FieldInfo> BaseClasses;
395 ArrayRef<FieldInfo> VirtualBaseClasses;
396 StructPacking Packing;
397 RecordFlags Flags;
398
399public:
401 ArrayRef<FieldInfo> VBases, TypeSize Size, Align ABIAlign,
402 Align UnadjustedAlign, StructPacking Pack = StructPacking::Default,
404 : Type(TypeKind::Record, Size, ABIAlign, UnadjustedAlign),
405 Fields(StructFields), BaseClasses(Bases), VirtualBaseClasses(VBases),
406 Packing(Pack), Flags(RecFlags) {}
407 uint32_t getNumFields() const { return Fields.size(); }
408 StructPacking getPacking() const { return Packing; }
409
410 bool isUnion() const {
411 return static_cast<unsigned>(Flags & RecordFlags::IsUnion) != 0;
412 }
413 bool isCXXRecord() const {
414 return static_cast<unsigned>(Flags & RecordFlags::IsCXXRecord) != 0;
415 }
416 bool isPolymorphic() const {
417 return static_cast<unsigned>(Flags & RecordFlags::IsPolymorphic) != 0;
418 }
419 bool canPassInRegisters() const {
420 return static_cast<unsigned>(Flags & RecordFlags::CanPassInRegisters) != 0;
421 }
423 return static_cast<unsigned>(Flags & RecordFlags::HasFlexibleArrayMember) !=
424 0;
425 }
426 uint32_t getNumBaseClasses() const { return BaseClasses.size(); }
428 return VirtualBaseClasses.size();
429 }
430 bool isTransparentUnion() const {
431 return static_cast<unsigned>(Flags & RecordFlags::IsTransparent) != 0;
432 }
433 ArrayRef<FieldInfo> getFields() const { return Fields; }
434 ArrayRef<FieldInfo> getBaseClasses() const { return BaseClasses; }
436 return VirtualBaseClasses;
437 }
438
439 LLVM_ABI bool isEmpty() const;
440
441 /// Returns the field, base, or virtual base whose extent contains
442 /// \p OffsetInBits, or nullptr if no such element exists. Empty bases and
443 /// unnamed bitfields are skipped.
444 LLVM_ABI const FieldInfo *
445 getElementContainingOffset(unsigned OffsetInBits) const;
446
447 static bool classof(const Type *T) {
448 return T->getKind() == TypeKind::Record;
449 }
450};
451
452/// TypeBuilder manages the lifecycle of ABI types using bump pointer
453/// allocation. Types created by a TypeBuilder are valid for the lifetime of the
454/// allocator.
455///
456/// Example usage:
457/// \code
458/// BumpPtrAllocator Alloc;
459/// TypeBuilder Builder(Alloc);
460/// const auto *IntTy = Builder.getIntegerType(32, Align(4), true);
461/// \endcode
463private:
464 BumpPtrAllocator &Allocator;
465
466public:
467 explicit TypeBuilder(BumpPtrAllocator &Alloc) : Allocator(Alloc) {}
468
470 return new (Allocator.Allocate<VoidType>()) VoidType();
471 }
472
473 const AtomicType *getAtomicType(const Type *ValueType, uint64_t SizeInBits,
474 Align Align) {
475 return new (Allocator.Allocate<AtomicType>())
476 AtomicType(ValueType, SizeInBits, Align);
477 }
478
480 bool IsBitInt = false) {
481 return new (Allocator.Allocate<IntegerType>())
482 IntegerType(BitWidth, Align, Signed, IsBitInt);
483 }
484
485 const FloatType *getFloatType(const fltSemantics &Semantics, Align Align) {
486 return new (Allocator.Allocate<FloatType>()) FloatType(Semantics, Align);
487 }
488
490 unsigned Addrspace = 0) {
491 return new (Allocator.Allocate<PointerType>())
492 PointerType(Size, Align, Addrspace);
493 }
494
495 const ArrayType *getArrayType(const Type *ElementType, uint64_t NumElements,
496 uint64_t SizeInBits,
497 bool IsMatrixType = false) {
498 return new (Allocator.Allocate<ArrayType>())
499 ArrayType(ElementType, NumElements, SizeInBits, IsMatrixType);
500 }
501
502 const VectorType *getVectorType(const Type *ElementType,
503 ElementCount NumElements, Align Align,
505 return new (Allocator.Allocate<VectorType>())
506 VectorType(ElementType, NumElements, Align, VecKind);
507 }
508
509 /// Creates a homogeneous tuple of \p NumVectors copies of \p Vec.
510 /// \p NumVectors must be 2, 3, or 4.
511 const TupleType *getTupleType(const VectorType *Vec, unsigned NumVectors) {
512 assert(NumVectors >= 2 && NumVectors <= 4 &&
513 "tuple types hold 2, 3, or 4 vectors");
514 return new (Allocator.Allocate<TupleType>()) TupleType(Vec, NumVectors);
515 }
516
517 /// Creates a scalable predicate or count vector.
518 /// Note: The AArch64 __SVCount_t type is opaque, so it is modeled with the
519 /// shape of svbool_t: a scalable vector of 16 one-bit elements.
521 VectorKind Kind) {
523 "expected predicate or count vector kind");
524 const Type *PredicateBit =
525 getIntegerType(1, Align(1), /*Signed=*/false, /*IsBitInt=*/false);
526 return getVectorType(PredicateBit, ElementCount::getScalable(16), ABIAlign,
527 Kind);
528 }
529
531 Align ABIAlign, Align UnadjustedAlign,
533 ArrayRef<FieldInfo> BaseClasses = {},
534 ArrayRef<FieldInfo> VirtualBaseClasses = {},
535 RecordFlags RecFlags = RecordFlags::None) {
536 FieldInfo *FieldArray = Allocator.Allocate<FieldInfo>(Fields.size());
537 std::copy(Fields.begin(), Fields.end(), FieldArray);
538
539 FieldInfo *BaseArray = nullptr;
540 if (!BaseClasses.empty()) {
541 BaseArray = Allocator.Allocate<FieldInfo>(BaseClasses.size());
542 std::copy(BaseClasses.begin(), BaseClasses.end(), BaseArray);
543 }
544
545 FieldInfo *VBaseArray = nullptr;
546 if (!VirtualBaseClasses.empty()) {
547 VBaseArray = Allocator.Allocate<FieldInfo>(VirtualBaseClasses.size());
548 std::copy(VirtualBaseClasses.begin(), VirtualBaseClasses.end(),
549 VBaseArray);
550 }
551
552 ArrayRef<FieldInfo> FieldsRef(FieldArray, Fields.size());
553 ArrayRef<FieldInfo> BasesRef(BaseArray, BaseClasses.size());
554 ArrayRef<FieldInfo> VBasesRef(VBaseArray, VirtualBaseClasses.size());
555
556 return new (Allocator.Allocate<RecordType>())
557 RecordType(FieldsRef, BasesRef, VBasesRef, Size, ABIAlign,
558 UnadjustedAlign, Pack, RecFlags);
559 }
560
562 Align ABIAlign, Align UnadjustedAlign,
564 RecordFlags RecFlags = RecordFlags::None) {
565 FieldInfo *FieldArray = Allocator.Allocate<FieldInfo>(Fields.size());
566
567 for (size_t I = 0, E = Fields.size(); I != E; ++I) {
568 FieldInfo Field = Fields[I];
569 Field.OffsetInBits = 0;
570 new (&FieldArray[I]) FieldInfo(Field);
571 }
572
573 ArrayRef<FieldInfo> FieldsRef(FieldArray, Fields.size());
574
575 return new (Allocator.Allocate<RecordType>()) RecordType(
576 FieldsRef, ArrayRef<FieldInfo>(), ArrayRef<FieldInfo>(), Size, ABIAlign,
577 UnadjustedAlign, Pack, RecFlags | RecordFlags::IsUnion);
578 }
579
580 const ComplexType *getComplexType(const Type *ElementType, Align Align) {
581 // Complex types have two elements (real and imaginary parts)
582 uint64_t ElementSizeInBits = ElementType->getSizeInBits().getFixedValue();
583 uint64_t ComplexSizeInBits = ElementSizeInBits * 2;
584
585 return new (Allocator.Allocate<ComplexType>())
586 ComplexType(ElementType, ComplexSizeInBits, Align);
587 }
588
589 const MemberPointerType *getMemberPointerType(bool IsFunctionPointer,
590 uint64_t SizeInBits,
591 Align Align) {
592 return new (Allocator.Allocate<MemberPointerType>())
593 MemberPointerType(IsFunctionPointer, SizeInBits, Align);
594 }
595};
596
597} // namespace abi
598} // namespace llvm
599
600#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...
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
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:259
bool isMatrixType() const
Definition Types.h:261
static bool classof(const Type *T)
Definition Types.h:263
ArrayType(const Type *ElementType, uint64_t NumElements, uint64_t SizeInBits, bool IsMatrixType=false)
Definition Types.h:252
uint64_t getNumElements() const
Definition Types.h:260
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:238
static bool classof(const Type *T)
Definition Types.h:240
MemberPointerType(bool IsFunctionPointer, uint64_t SizeInBits, Align ABIAlign, unsigned AddressSpace=0)
Definition Types.h:233
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
PointerType(uint64_t Size, Align ABIAlign, unsigned AddressSpace=0)
Definition Types.h:219
static bool classof(const Type *T)
Definition Types.h:223
bool isPolymorphic() const
Definition Types.h:416
bool isUnion() const
Definition Types.h:410
bool canPassInRegisters() const
Definition Types.h:419
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:434
uint32_t getNumBaseClasses() const
Definition Types.h:426
ArrayRef< FieldInfo > getFields() const
Definition Types.h:433
uint32_t getNumVirtualBaseClasses() const
Definition Types.h:427
bool hasFlexibleArrayMember() const
Definition Types.h:422
bool isCXXRecord() const
Definition Types.h:413
bool isTransparentUnion() const
Definition Types.h:430
static bool classof(const Type *T)
Definition Types.h:447
LLVM_ABI bool isEmpty() const
Definition Types.cpp:69
uint32_t getNumFields() const
Definition Types.h:407
ArrayRef< FieldInfo > getVirtualBaseClasses() const
Definition Types.h:435
StructPacking getPacking() const
Definition Types.h:408
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:400
A homogeneous tuple of 2, 3, or 4 identical vectors, such as the AArch64 SVE types svint32x3_t and sv...
Definition Types.h:342
const VectorType * getVectorType() const
Definition Types.h:353
unsigned getNumVectors() const
Definition Types.h:354
TupleType(const VectorType *Vec, unsigned NumVectors)
Definition Types.h:348
static bool classof(const Type *T)
Definition Types.h:356
const ComplexType * getComplexType(const Type *ElementType, Align Align)
Definition Types.h:580
const FloatType * getFloatType(const fltSemantics &Semantics, Align Align)
Definition Types.h:485
const IntegerType * getIntegerType(uint64_t BitWidth, Align Align, bool Signed, bool IsBitInt=false)
Definition Types.h:479
const VectorType * getScalablePredicateOrCountVectorType(Align ABIAlign, VectorKind Kind)
Creates a scalable predicate or count vector.
Definition Types.h:520
const AtomicType * getAtomicType(const Type *ValueType, uint64_t SizeInBits, Align Align)
Definition Types.h:473
const RecordType * getUnionType(ArrayRef< FieldInfo > Fields, TypeSize Size, Align ABIAlign, Align UnadjustedAlign, StructPacking Pack=StructPacking::Default, RecordFlags RecFlags=RecordFlags::None)
Definition Types.h:561
const MemberPointerType * getMemberPointerType(bool IsFunctionPointer, uint64_t SizeInBits, Align Align)
Definition Types.h:589
TypeBuilder(BumpPtrAllocator &Alloc)
Definition Types.h:467
const TupleType * getTupleType(const VectorType *Vec, unsigned NumVectors)
Creates a homogeneous tuple of NumVectors copies of Vec.
Definition Types.h:511
const VectorType * getVectorType(const Type *ElementType, ElementCount NumElements, Align Align, VectorKind VecKind=VectorKind::Generic)
Definition Types.h:502
const ArrayType * getArrayType(const Type *ElementType, uint64_t NumElements, uint64_t SizeInBits, bool IsMatrixType=false)
Definition Types.h:495
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:530
const PointerType * getPointerType(uint64_t Size, Align Align, unsigned Addrspace=0)
Definition Types.h:489
const VoidType * getVoidType()
Definition Types.h:469
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:312
bool isFixedLengthSVEData() const
Definition Types.h:323
const Type * getElementType() const
Definition Types.h:311
VectorKind getVectorKind() const
Definition Types.h:314
static bool classof(const Type *T)
Definition Types.h:331
VectorType(const Type *ElementType, ElementCount NumElements, Align ABIAlign, VectorKind VecKind=VectorKind::Generic)
Definition Types.h:305
bool isSVEType() const
Returns true for any of the AArch64 SVE flavors.
Definition Types.h:329
bool isFixedLength() const
Definition Types.h:317
bool isSVECount() const
Definition Types.h:321
bool isScalable() const
Definition Types.h:316
bool isSVEData() const
Definition Types.h:319
bool isSVEPredicate() const
Definition Types.h:320
bool isFixedLengthSVEPredicate() const
Definition Types.h:324
static bool classof(const Type *T)
Definition Types.h:129
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:380
@ IsPolymorphic
Definition Types.h:386
@ IsCXXRecord
Definition Types.h:385
@ CanPassInRegisters
Definition Types.h:382
@ IsTransparent
Definition Types.h:384
@ LLVM_MARK_AS_BITMASK_ENUM
Definition Types.h:388
@ IsUnion
Definition Types.h:383
@ HasFlexibleArrayMember
Definition Types.h:387
VectorKind
Distinguishes the vector flavors that ABIs have to treat differently.
Definition Types.h:270
@ SVEPredicate
An AArch64 SVE predicate vector, such as svbool_t.
Definition Types.h:283
@ SVEData
An AArch64 SVE data vector, such as svint32_t.
Definition Types.h:276
@ Generic
A plain vector, such as a Neon vector or a GCC vector_size vector.
Definition Types.h:272
@ SVECount
The AArch64 __SVCount_t type.
Definition Types.h:288
StructPacking
Definition Types.h:378
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:367
bool HasNoUniqueAddress
Definition Types.h:365
const Type * FieldType
Definition Types.h:360
uint64_t BitFieldWidth
Definition Types.h:362
LLVM_ABI bool isEmpty() const
Definition Types.cpp:119
uint64_t OffsetInBits
Definition Types.h:361