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
44
45/// Represents the ABI-specific view of a type in LLVM.
46///
47/// This abstracts platform and language-specific ABI details from the
48/// frontend, providing a consistent interface for the ABI Library.
49class Type {
50private:
51 TypeSize getTypeStoreSize() const {
52 TypeSize StoreSizeInBits = getTypeStoreSizeInBits();
53 return {StoreSizeInBits.getKnownMinValue() / 8,
54 StoreSizeInBits.isScalable()};
55 }
56 TypeSize getTypeStoreSizeInBits() const {
57 TypeSize BaseSize = getSizeInBits();
58 uint64_t AlignedSizeInBits =
59 alignToPowerOf2(BaseSize.getKnownMinValue(), 8);
60 return {AlignedSizeInBits, BaseSize.isScalable()};
61 }
62
63protected:
68
70 : Type(K, SizeInBits, ABIAlign, ABIAlign) {}
71 Type(TypeKind K, TypeSize SizeInBits, Align ABIAlign, Align UnadjustedAlign)
72 : Kind(K), SizeInBits(SizeInBits), ABIAlignment(ABIAlign),
73 UnadjustedAlignment(UnadjustedAlign) {}
74
75public:
76 TypeKind getKind() const { return Kind; }
77 TypeSize getSizeInBits() const { return SizeInBits; }
78
79 /// Returns the size in bits if it is fixed, otherwise 0.
81 return SizeInBits.isFixed() ? SizeInBits.getFixedValue() : 0;
82 }
83
84 /// Returns the size in bits that the source language gives this type,
85 /// including any padding.
86 ///
87 /// An integer is rounded up to whole bytes. A _BitInt or a floating-point
88 /// type is rounded up further, to its alignment. That alignment must be the
89 /// one its size is padded to, not one an aligned attribute raised or lowered.
90 /// A complex type is twice the ABI size of its element type. A fixed-length
91 /// vector counts an integer element other than a _BitInt at its bit width and
92 /// every other element at its own ABI size, so a bool element takes one bit.
93 /// The total is rounded up to a power of two of at least 8 bits. Any other
94 /// type returns the size it was created with, and a scalable type returns 0.
96
97 Align getAlignment() const { return ABIAlignment; }
98
99 /// Alignment before record-level adjustments such as aligned attributes.
100 /// Equal to getAlignment() unless a distinct unadjusted alignment was
101 /// provided when the type was created.
103
105 return alignTo(getTypeStoreSize(), getAlignment().value());
106 }
107
108 bool isVoid() const { return Kind == TypeKind::Void; }
109 bool isAtomic() const { return Kind == TypeKind::Atomic; }
110 bool isInteger() const { return Kind == TypeKind::Integer; }
111 bool isFloat() const { return Kind == TypeKind::Float; }
112 bool isOpaqueFloat8() const { return Kind == TypeKind::OpaqueFloat8; }
113 bool isSveCount() const { return Kind == TypeKind::SveCount; }
114 bool isPointer() const { return Kind == TypeKind::Pointer; }
115 bool isArray() const { return Kind == TypeKind::Array; }
116 bool isVector() const { return Kind == TypeKind::Vector; }
117 bool isTuple() const { return Kind == TypeKind::Tuple; }
118 bool isRecord() const { return Kind == TypeKind::Record; }
119 bool isMemberPointer() const { return Kind == TypeKind::MemberPointer; }
120 bool isComplex() const { return Kind == TypeKind::Complex; }
121 bool isZeroSize() const { return getSizeInBits().isZero(); }
122
123 LLVM_ABI bool isSVESizelessType() const;
124
125 /// True if this type is a record that is empty for ABI purposes.
126 LLVM_ABI bool isEmptyRecord() const;
127};
128
129class VoidType : public Type {
130public:
131 VoidType() : Type(TypeKind::Void, TypeSize::getFixed(0), Align(1)) {}
132
133 static bool classof(const Type *T) { return T->getKind() == TypeKind::Void; }
134};
135
136class AtomicType : public Type {
137public:
138 AtomicType(const Type *ValueType, uint64_t SizeInBits, Align Alignment)
139 : Type(TypeKind::Atomic, TypeSize::getFixed(SizeInBits), Alignment),
140 ValueType(ValueType) {}
141
142 const Type *getValueType() const { return ValueType; }
143
144 static bool classof(const Type *T) {
145 return T->getKind() == TypeKind::Atomic;
146 }
147
148private:
149 const Type *ValueType;
150};
151
152class ComplexType : public Type {
153public:
154 ComplexType(const Type *ElementType, uint64_t SizeInBits, Align Alignment)
155 : Type(TypeKind::Complex, TypeSize::getFixed(SizeInBits), Alignment),
156 ElementType(ElementType) {}
157
158 const Type *getElementType() const { return ElementType; }
159
160 static bool classof(const Type *T) {
161 return T->getKind() == TypeKind::Complex;
162 }
163
164private:
165 const Type *ElementType;
166};
167
168class IntegerType : public Type {
169private:
170 bool IsSigned;
171 bool IsBitInt;
172
173public:
174 IntegerType(uint64_t BitWidth, Align ABIAlign, bool IsSigned,
175 bool IsBitInt = false)
176 : Type(TypeKind::Integer, TypeSize::getFixed(BitWidth), ABIAlign),
177 IsSigned(IsSigned), IsBitInt(IsBitInt) {}
178
179 bool isSigned() const { return IsSigned; }
180 bool isBitInt() const { return IsBitInt; }
181 bool isBool() const {
182 return getSizeInBits().getFixedValue() == 1 && !IsBitInt;
183 }
184
185 static bool classof(const Type *T) {
186 return T->getKind() == TypeKind::Integer;
187 }
188};
189
190class FloatType : public Type {
191private:
192 const fltSemantics *Semantics;
193
194public:
195 FloatType(const fltSemantics &FloatSemantics, Align ABIAlign)
197 TypeSize::getFixed(APFloat::getSizeInBits(FloatSemantics)),
198 ABIAlign),
199 Semantics(&FloatSemantics) {}
200
201 const fltSemantics *getSemantics() const { return Semantics; }
202 static bool classof(const Type *T) { return T->getKind() == TypeKind::Float; }
203};
204
205/// An 8-bit floating-point format with no numeric semantics. This corresponds
206/// to the AArch64 __mfp8 type. A vector of this format uses an 8-bit integer
207/// element, so this type is not a valid vector element. If a similar type is
208/// needed for other targets this should be generalized.
209class OpaqueFloat8Type : public Type {
210public:
211 explicit OpaqueFloat8Type(Align ABIAlign)
212 : Type(TypeKind::OpaqueFloat8, TypeSize::getFixed(8), ABIAlign) {}
213
214 static bool classof(const Type *T) {
215 return T->getKind() == TypeKind::OpaqueFloat8;
216 }
217};
218
219/// The AArch64 __SVCount_t (svcount_t) predicate-as-counter type. Such a value
220/// contains information about the number of active lanes, the element width,
221/// and a bit that indicates whether the generated mask should be inverted.
222class SveCountType : public Type {
223public:
224 explicit SveCountType(Align ABIAlign)
225 : Type(TypeKind::SveCount, TypeSize::getScalable(16), ABIAlign) {}
226
227 static bool classof(const Type *T) {
228 return T->getKind() == TypeKind::SveCount;
229 }
230};
231
232class PointerLikeType : public Type {
233protected:
234 unsigned AddrSpace;
236 : Type(K, SizeInBits, ABIAlign), AddrSpace(AS) {}
237
238public:
239 unsigned getAddrSpace() const { return AddrSpace; }
240 bool isMemberPointer() const { return getKind() == TypeKind::MemberPointer; }
241
242 static bool classof(const Type *T) {
243 return T->getKind() == TypeKind::Pointer ||
244 T->getKind() == TypeKind::MemberPointer;
245 }
246};
247
249 bool HasAddressSpaceQualifier;
250
251public:
252 PointerType(uint64_t Size, Align ABIAlign, unsigned AddressSpace = 0,
253 bool HasAddressSpaceQualifier = false)
254 : PointerLikeType(TypeKind::Pointer, TypeSize::getFixed(Size), ABIAlign,
256 HasAddressSpaceQualifier(HasAddressSpaceQualifier) {}
257
258 bool hasAddressSpaceQualifier() const { return HasAddressSpaceQualifier; }
259
260 static bool classof(const Type *T) {
261 return T->getKind() == TypeKind::Pointer;
262 }
263};
264
266private:
267 bool IsFunctionPointer;
268
269public:
270 MemberPointerType(bool IsFunctionPointer, uint64_t SizeInBits, Align ABIAlign,
271 unsigned AddressSpace = 0)
273 ABIAlign, AddressSpace),
274 IsFunctionPointer(IsFunctionPointer) {}
275 bool isFunctionPointer() const { return IsFunctionPointer; }
276
277 static bool classof(const Type *T) {
278 return T->getKind() == TypeKind::MemberPointer;
279 }
280};
281
282class ArrayType : public Type {
283private:
284 const Type *ElementType;
285 uint64_t NumElements;
286 bool IsMatrix;
287
288public:
289 ArrayType(const Type *ElementType, uint64_t NumElements, uint64_t SizeInBits,
290 bool IsMatrixType = false)
291 : Type(TypeKind::Array, TypeSize::getFixed(SizeInBits),
292 ElementType->getAlignment()),
293 ElementType(ElementType), NumElements(NumElements),
294 IsMatrix(IsMatrixType) {}
295
296 const Type *getElementType() const { return ElementType; }
297 uint64_t getNumElements() const { return NumElements; }
298 bool isMatrixType() const { return IsMatrix; }
299
300 static bool classof(const Type *T) { return T->getKind() == TypeKind::Array; }
301};
302
303/// Distinguishes the vector flavors that ABIs have to treat differently.
304/// Scalability is not part of the kind. It is tracked by the vector's
305/// ElementCount, because some flavors have both a scalable and a
306/// fixed-length spelling.
307enum class VectorKind {
308 /// A plain vector, such as a Neon vector or a GCC vector_size vector.
310
311 /// An AArch64 SVE data vector, such as svint32_t. Data vectors are
312 /// passed in Z registers. Tuples of these vectors use TupleType.
314
315 /// An AArch64 SVE predicate vector, such as svbool_t. These are passed
316 /// in P registers. Sizeless predicates have one-bit elements; the
317 /// fixed-length arm_sve_vector_bits form keeps unsigned char (i8)
318 /// elements, matching the Clang AST. Both use this kind. Tuples of
319 /// these vectors use TupleType.
321};
322
323class VectorType : public Type {
324private:
325 const Type *ElementType;
326 ElementCount NumElements;
327 VectorKind VecKind;
328
329 static TypeSize computeSizeInBits(const Type *ElementType,
330 ElementCount NumElements) {
331 return TypeSize(ElementType->getSizeInBits().getFixedValue() *
332 NumElements.getKnownMinValue(),
333 NumElements.isScalable());
334 }
335
336public:
337 VectorType(const Type *ElementType, ElementCount NumElements, Align ABIAlign,
339 : Type(TypeKind::Vector, computeSizeInBits(ElementType, NumElements),
340 ABIAlign),
341 ElementType(ElementType), NumElements(NumElements), VecKind(VecKind) {
342 assert(!ElementType->isOpaqueFloat8() &&
343 "opaque 8-bit float is not a valid vector element type");
344 }
345
346 const Type *getElementType() const { return ElementType; }
347 ElementCount getNumElements() const { return NumElements; }
348
349 VectorKind getVectorKind() const { return VecKind; }
350
351 bool isScalable() const { return NumElements.isScalable(); }
352 bool isFixedLength() const { return !NumElements.isScalable(); }
353
354 bool isSVEData() const { return VecKind == VectorKind::SVEData; }
355 bool isSVEPredicate() const { return VecKind == VectorKind::SVEPredicate; }
356
357 bool isFixedLengthSVEData() const { return isFixedLength() && isSVEData(); }
359 return isFixedLength() && isSVEPredicate();
360 }
361
362 /// Returns true for any of the AArch64 SVE flavors.
363 bool isSVEType() const { return VecKind != VectorKind::Generic; }
364
365 static bool classof(const Type *T) {
366 return T->getKind() == TypeKind::Vector;
367 }
368};
369
370/// A homogeneous tuple of 2, 3, or 4 identical vectors, such as the
371/// AArch64 SVE types svint32x3_t and svboolx2_t.
372///
373/// The contained vector describes one register-shaped member. Size and
374/// alignment of the tuple cover the whole group: size is NumVectors times
375/// the vector size, and alignment matches the contained vector.
376class TupleType : public Type {
377private:
378 const VectorType *Vec;
379 unsigned NumVectors;
380
381public:
382 TupleType(const VectorType *Vec, unsigned NumVectors)
383 : Type(TypeKind::Tuple, (Vec->getSizeInBits() * NumVectors),
384 Vec->getAlignment()),
385 Vec(Vec), NumVectors(NumVectors) {}
386
387 const VectorType *getVectorType() const { return Vec; }
388 unsigned getNumVectors() const { return NumVectors; }
389
390 static bool classof(const Type *T) { return T->getKind() == TypeKind::Tuple; }
391};
392
411
413
429
430class RecordType : public Type {
431private:
432 ArrayRef<FieldInfo> Fields;
433 ArrayRef<FieldInfo> BaseClasses;
434 ArrayRef<FieldInfo> VirtualBaseClasses;
435 StructPacking Packing;
436 RecordFlags Flags;
437
438public:
440 ArrayRef<FieldInfo> VBases, TypeSize Size, Align ABIAlign,
441 Align UnadjustedAlign, StructPacking Pack = StructPacking::Default,
443 : Type(TypeKind::Record, Size, ABIAlign, UnadjustedAlign),
444 Fields(StructFields), BaseClasses(Bases), VirtualBaseClasses(VBases),
445 Packing(Pack), Flags(RecFlags) {}
446 uint32_t getNumFields() const { return Fields.size(); }
447 StructPacking getPacking() const { return Packing; }
448
449 bool isUnion() const {
450 return static_cast<unsigned>(Flags & RecordFlags::IsUnion) != 0;
451 }
452 bool isCXXRecord() const {
453 return static_cast<unsigned>(Flags & RecordFlags::IsCXXRecord) != 0;
454 }
455 bool isPolymorphic() const {
456 return static_cast<unsigned>(Flags & RecordFlags::IsPolymorphic) != 0;
457 }
458 bool canPassInRegisters() const {
459 return static_cast<unsigned>(Flags & RecordFlags::CanPassInRegisters) != 0;
460 }
462 return static_cast<unsigned>(Flags & RecordFlags::HasFlexibleArrayMember) !=
463 0;
464 }
465 /// True for a C++ class that is empty in the sense of std::is_empty. This
466 /// differs from isEmpty(), which applies the ABI rules for ignoring empty
467 /// records.
468 bool isCXXEmpty() const {
469 return static_cast<unsigned>(Flags & RecordFlags::IsCXXEmpty) != 0;
470 }
472 return static_cast<unsigned>(Flags &
474 }
476 return static_cast<unsigned>(Flags &
478 }
480 return static_cast<unsigned>(
482 }
483 uint32_t getNumBaseClasses() const { return BaseClasses.size(); }
485 return VirtualBaseClasses.size();
486 }
487 bool isTransparentUnion() const {
488 return static_cast<unsigned>(Flags & RecordFlags::IsTransparent) != 0;
489 }
490 ArrayRef<FieldInfo> getFields() const { return Fields; }
491 ArrayRef<FieldInfo> getBaseClasses() const { return BaseClasses; }
493 return VirtualBaseClasses;
494 }
495
496 LLVM_ABI bool isEmpty() const;
497
498 /// Returns the field, base, or virtual base whose extent contains
499 /// \p OffsetInBits, or nullptr if no such element exists. Empty bases and
500 /// unnamed bitfields are skipped.
501 LLVM_ABI const FieldInfo *
502 getElementContainingOffset(unsigned OffsetInBits) const;
503
504 static bool classof(const Type *T) {
505 return T->getKind() == TypeKind::Record;
506 }
507};
508
509/// TypeBuilder manages the lifecycle of ABI types using bump pointer
510/// allocation. Types created by a TypeBuilder are valid for the lifetime of the
511/// allocator.
512///
513/// Example usage:
514/// \code
515/// BumpPtrAllocator Alloc;
516/// TypeBuilder Builder(Alloc);
517/// const auto *IntTy = Builder.getIntegerType(32, Align(4), true);
518/// \endcode
520private:
521 BumpPtrAllocator &Allocator;
522
523public:
524 explicit TypeBuilder(BumpPtrAllocator &Alloc) : Allocator(Alloc) {}
525
527 return new (Allocator.Allocate<VoidType>()) VoidType();
528 }
529
530 const AtomicType *getAtomicType(const Type *ValueType, uint64_t SizeInBits,
531 Align Align) {
532 return new (Allocator.Allocate<AtomicType>())
533 AtomicType(ValueType, SizeInBits, Align);
534 }
535
537 bool IsBitInt = false) {
538 return new (Allocator.Allocate<IntegerType>())
539 IntegerType(BitWidth, Align, Signed, IsBitInt);
540 }
541
542 const FloatType *getFloatType(const fltSemantics &Semantics, Align Align) {
543 return new (Allocator.Allocate<FloatType>()) FloatType(Semantics, Align);
544 }
545
547 return new (Allocator.Allocate<OpaqueFloat8Type>()) OpaqueFloat8Type(Align);
548 }
549
551 unsigned Addrspace = 0,
552 bool HasAddressSpaceQualifier = false) {
553 return new (Allocator.Allocate<PointerType>())
554 PointerType(Size, Align, Addrspace, HasAddressSpaceQualifier);
555 }
556
557 const ArrayType *getArrayType(const Type *ElementType, uint64_t NumElements,
558 uint64_t SizeInBits,
559 bool IsMatrixType = false) {
560 return new (Allocator.Allocate<ArrayType>())
561 ArrayType(ElementType, NumElements, SizeInBits, IsMatrixType);
562 }
563
564 const VectorType *getVectorType(const Type *ElementType,
565 ElementCount NumElements, Align Align,
567 return new (Allocator.Allocate<VectorType>())
568 VectorType(ElementType, NumElements, Align, VecKind);
569 }
570
571 /// Creates a homogeneous tuple of \p NumVectors copies of \p Vec.
572 /// \p NumVectors must be 2, 3, or 4.
573 const TupleType *getTupleType(const VectorType *Vec, unsigned NumVectors) {
574 assert(NumVectors >= 2 && NumVectors <= 4 &&
575 "tuple types hold 2, 3, or 4 vectors");
576 return new (Allocator.Allocate<TupleType>()) TupleType(Vec, NumVectors);
577 }
578
579 /// Creates a scalable SVE predicate vector: 16 one-bit elements per granule.
581 const Type *PredicateBit =
582 getIntegerType(1, Align(1), /*Signed=*/false, /*IsBitInt=*/false);
583 return getVectorType(PredicateBit, ElementCount::getScalable(16), ABIAlign,
585 }
586
588 return new (Allocator.Allocate<SveCountType>()) SveCountType(Align);
589 }
590
592 Align ABIAlign, Align UnadjustedAlign,
594 ArrayRef<FieldInfo> BaseClasses = {},
595 ArrayRef<FieldInfo> VirtualBaseClasses = {},
596 RecordFlags RecFlags = RecordFlags::None) {
597 FieldInfo *FieldArray = Allocator.Allocate<FieldInfo>(Fields.size());
598 std::copy(Fields.begin(), Fields.end(), FieldArray);
599
600 FieldInfo *BaseArray = nullptr;
601 if (!BaseClasses.empty()) {
602 BaseArray = Allocator.Allocate<FieldInfo>(BaseClasses.size());
603 std::copy(BaseClasses.begin(), BaseClasses.end(), BaseArray);
604 }
605
606 FieldInfo *VBaseArray = nullptr;
607 if (!VirtualBaseClasses.empty()) {
608 VBaseArray = Allocator.Allocate<FieldInfo>(VirtualBaseClasses.size());
609 std::copy(VirtualBaseClasses.begin(), VirtualBaseClasses.end(),
610 VBaseArray);
611 }
612
613 ArrayRef<FieldInfo> FieldsRef(FieldArray, Fields.size());
614 ArrayRef<FieldInfo> BasesRef(BaseArray, BaseClasses.size());
615 ArrayRef<FieldInfo> VBasesRef(VBaseArray, VirtualBaseClasses.size());
616
617 return new (Allocator.Allocate<RecordType>())
618 RecordType(FieldsRef, BasesRef, VBasesRef, Size, ABIAlign,
619 UnadjustedAlign, Pack, RecFlags);
620 }
621
623 Align ABIAlign, Align UnadjustedAlign,
625 RecordFlags RecFlags = RecordFlags::None) {
626 FieldInfo *FieldArray = Allocator.Allocate<FieldInfo>(Fields.size());
627
628 for (size_t I = 0, E = Fields.size(); I != E; ++I) {
629 FieldInfo Field = Fields[I];
630 Field.OffsetInBits = 0;
631 new (&FieldArray[I]) FieldInfo(Field);
632 }
633
634 ArrayRef<FieldInfo> FieldsRef(FieldArray, Fields.size());
635
636 return new (Allocator.Allocate<RecordType>()) RecordType(
637 FieldsRef, ArrayRef<FieldInfo>(), ArrayRef<FieldInfo>(), Size, ABIAlign,
638 UnadjustedAlign, Pack, RecFlags | RecordFlags::IsUnion);
639 }
640
641 const ComplexType *getComplexType(const Type *ElementType, Align Align) {
642 // Complex types have two elements (real and imaginary parts)
643 uint64_t ElementSizeInBits = ElementType->getSizeInBits().getFixedValue();
644 uint64_t ComplexSizeInBits = ElementSizeInBits * 2;
645
646 return new (Allocator.Allocate<ComplexType>())
647 ComplexType(ElementType, ComplexSizeInBits, Align);
648 }
649
650 const MemberPointerType *getMemberPointerType(bool IsFunctionPointer,
651 uint64_t SizeInBits,
652 Align Align) {
653 return new (Allocator.Allocate<MemberPointerType>())
654 MemberPointerType(IsFunctionPointer, SizeInBits, Align);
655 }
656};
657
658} // namespace abi
659} // namespace llvm
660
661#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:296
bool isMatrixType() const
Definition Types.h:298
static bool classof(const Type *T)
Definition Types.h:300
ArrayType(const Type *ElementType, uint64_t NumElements, uint64_t SizeInBits, bool IsMatrixType=false)
Definition Types.h:289
uint64_t getNumElements() const
Definition Types.h:297
const Type * getValueType() const
Definition Types.h:142
AtomicType(const Type *ValueType, uint64_t SizeInBits, Align Alignment)
Definition Types.h:138
static bool classof(const Type *T)
Definition Types.h:144
ComplexType(const Type *ElementType, uint64_t SizeInBits, Align Alignment)
Definition Types.h:154
const Type * getElementType() const
Definition Types.h:158
static bool classof(const Type *T)
Definition Types.h:160
FloatType(const fltSemantics &FloatSemantics, Align ABIAlign)
Definition Types.h:195
const fltSemantics * getSemantics() const
Definition Types.h:201
static bool classof(const Type *T)
Definition Types.h:202
static bool classof(const Type *T)
Definition Types.h:185
bool isBitInt() const
Definition Types.h:180
IntegerType(uint64_t BitWidth, Align ABIAlign, bool IsSigned, bool IsBitInt=false)
Definition Types.h:174
bool isBool() const
Definition Types.h:181
bool isSigned() const
Definition Types.h:179
bool isFunctionPointer() const
Definition Types.h:275
static bool classof(const Type *T)
Definition Types.h:277
MemberPointerType(bool IsFunctionPointer, uint64_t SizeInBits, Align ABIAlign, unsigned AddressSpace=0)
Definition Types.h:270
An 8-bit floating-point format with no numeric semantics.
Definition Types.h:209
static bool classof(const Type *T)
Definition Types.h:214
OpaqueFloat8Type(Align ABIAlign)
Definition Types.h:211
PointerLikeType(TypeKind K, TypeSize SizeInBits, Align ABIAlign, unsigned AS)
Definition Types.h:235
static bool classof(const Type *T)
Definition Types.h:242
bool isMemberPointer() const
Definition Types.h:240
unsigned getAddrSpace() const
Definition Types.h:239
bool hasAddressSpaceQualifier() const
Definition Types.h:258
static bool classof(const Type *T)
Definition Types.h:260
PointerType(uint64_t Size, Align ABIAlign, unsigned AddressSpace=0, bool HasAddressSpaceQualifier=false)
Definition Types.h:252
bool isPolymorphic() const
Definition Types.h:455
bool isUnion() const
Definition Types.h:449
bool canPassInRegisters() const
Definition Types.h:458
bool hasNonTrivialDefaultConstructor() const
Definition Types.h:479
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:98
ArrayRef< FieldInfo > getBaseClasses() const
Definition Types.h:491
uint32_t getNumBaseClasses() const
Definition Types.h:483
ArrayRef< FieldInfo > getFields() const
Definition Types.h:490
uint32_t getNumVirtualBaseClasses() const
Definition Types.h:484
bool hasFlexibleArrayMember() const
Definition Types.h:461
bool hasNonTrivialCopyAssignment() const
Definition Types.h:471
bool isCXXRecord() const
Definition Types.h:452
bool isTransparentUnion() const
Definition Types.h:487
static bool classof(const Type *T)
Definition Types.h:504
bool hasNonTrivialDestructor() const
Definition Types.h:475
LLVM_ABI bool isEmpty() const
Definition Types.cpp:73
uint32_t getNumFields() const
Definition Types.h:446
ArrayRef< FieldInfo > getVirtualBaseClasses() const
Definition Types.h:492
StructPacking getPacking() const
Definition Types.h:447
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:439
bool isCXXEmpty() const
True for a C++ class that is empty in the sense of std::is_empty.
Definition Types.h:468
The AArch64 __SVCount_t (svcount_t) predicate-as-counter type.
Definition Types.h:222
static bool classof(const Type *T)
Definition Types.h:227
SveCountType(Align ABIAlign)
Definition Types.h:224
A homogeneous tuple of 2, 3, or 4 identical vectors, such as the AArch64 SVE types svint32x3_t and sv...
Definition Types.h:376
const VectorType * getVectorType() const
Definition Types.h:387
unsigned getNumVectors() const
Definition Types.h:388
TupleType(const VectorType *Vec, unsigned NumVectors)
Definition Types.h:382
static bool classof(const Type *T)
Definition Types.h:390
const ComplexType * getComplexType(const Type *ElementType, Align Align)
Definition Types.h:641
const FloatType * getFloatType(const fltSemantics &Semantics, Align Align)
Definition Types.h:542
const PointerType * getPointerType(uint64_t Size, Align Align, unsigned Addrspace=0, bool HasAddressSpaceQualifier=false)
Definition Types.h:550
const SveCountType * getSveCountType(Align Align)
Definition Types.h:587
const IntegerType * getIntegerType(uint64_t BitWidth, Align Align, bool Signed, bool IsBitInt=false)
Definition Types.h:536
const AtomicType * getAtomicType(const Type *ValueType, uint64_t SizeInBits, Align Align)
Definition Types.h:530
const RecordType * getUnionType(ArrayRef< FieldInfo > Fields, TypeSize Size, Align ABIAlign, Align UnadjustedAlign, StructPacking Pack=StructPacking::Default, RecordFlags RecFlags=RecordFlags::None)
Definition Types.h:622
const MemberPointerType * getMemberPointerType(bool IsFunctionPointer, uint64_t SizeInBits, Align Align)
Definition Types.h:650
TypeBuilder(BumpPtrAllocator &Alloc)
Definition Types.h:524
const TupleType * getTupleType(const VectorType *Vec, unsigned NumVectors)
Creates a homogeneous tuple of NumVectors copies of Vec.
Definition Types.h:573
const VectorType * getVectorType(const Type *ElementType, ElementCount NumElements, Align Align, VectorKind VecKind=VectorKind::Generic)
Definition Types.h:564
const OpaqueFloat8Type * getOpaqueFloat8Type(Align Align)
Definition Types.h:546
const ArrayType * getArrayType(const Type *ElementType, uint64_t NumElements, uint64_t SizeInBits, bool IsMatrixType=false)
Definition Types.h:557
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:591
const VoidType * getVoidType()
Definition Types.h:526
const VectorType * getScalablePredicateVectorType(Align ABIAlign)
Creates a scalable SVE predicate vector: 16 one-bit elements per granule.
Definition Types.h:580
Represents the ABI-specific view of a type in LLVM.
Definition Types.h:49
TypeSize getTypeAllocSize() const
Definition Types.h:104
Align ABIAlignment
Definition Types.h:66
bool isMemberPointer() const
Definition Types.h:119
bool isVoid() const
Definition Types.h:108
Type(TypeKind K, TypeSize SizeInBits, Align ABIAlign, Align UnadjustedAlign)
Definition Types.h:71
LLVM_ABI bool isSVESizelessType() const
Definition Types.cpp:53
LLVM_ABI bool isEmptyRecord() const
True if this type is a record that is empty for ABI purposes.
Definition Types.cpp:68
bool isAtomic() const
Definition Types.h:109
TypeSize SizeInBits
Definition Types.h:65
TypeSize getSizeInBits() const
Definition Types.h:77
bool isInteger() const
Definition Types.h:110
bool isOpaqueFloat8() const
Definition Types.h:112
Type(TypeKind K, TypeSize SizeInBits, Align ABIAlign)
Definition Types.h:69
bool isTuple() const
Definition Types.h:117
bool isSveCount() const
Definition Types.h:113
TypeKind Kind
Definition Types.h:64
bool isRecord() const
Definition Types.h:118
bool isArray() const
Definition Types.h:115
bool isZeroSize() const
Definition Types.h:121
bool isVector() const
Definition Types.h:116
bool isFloat() const
Definition Types.h:111
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:97
Align UnadjustedAlignment
Definition Types.h:67
Align getUnadjustedAlignment() const
Alignment before record-level adjustments such as aligned attributes.
Definition Types.h:102
bool isComplex() const
Definition Types.h:120
uint64_t getFixedSizeInBitsOrZero() const
Returns the size in bits if it is fixed, otherwise 0.
Definition Types.h:80
TypeKind getKind() const
Definition Types.h:76
bool isPointer() const
Definition Types.h:114
ElementCount getNumElements() const
Definition Types.h:347
bool isFixedLengthSVEData() const
Definition Types.h:357
const Type * getElementType() const
Definition Types.h:346
VectorKind getVectorKind() const
Definition Types.h:349
static bool classof(const Type *T)
Definition Types.h:365
VectorType(const Type *ElementType, ElementCount NumElements, Align ABIAlign, VectorKind VecKind=VectorKind::Generic)
Definition Types.h:337
bool isSVEType() const
Returns true for any of the AArch64 SVE flavors.
Definition Types.h:363
bool isFixedLength() const
Definition Types.h:352
bool isScalable() const
Definition Types.h:351
bool isSVEData() const
Definition Types.h:354
bool isSVEPredicate() const
Definition Types.h:355
bool isFixedLengthSVEPredicate() const
Definition Types.h:358
static bool classof(const Type *T)
Definition Types.h:133
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:414
@ IsCXXEmpty
Definition Types.h:422
@ IsPolymorphic
Definition Types.h:420
@ IsCXXRecord
Definition Types.h:419
@ CanPassInRegisters
Definition Types.h:416
@ IsTransparent
Definition Types.h:418
@ LLVM_MARK_AS_BITMASK_ENUM
Definition Types.h:426
@ HasNonTrivialCopyAssignment
Definition Types.h:423
@ HasNonTrivialDefaultConstructor
Definition Types.h:425
@ IsUnion
Definition Types.h:417
@ HasNonTrivialDestructor
Definition Types.h:424
@ HasFlexibleArrayMember
Definition Types.h:421
VectorKind
Distinguishes the vector flavors that ABIs have to treat differently.
Definition Types.h:307
@ SVEPredicate
An AArch64 SVE predicate vector, such as svbool_t.
Definition Types.h:320
@ SVEData
An AArch64 SVE data vector, such as svint32_t.
Definition Types.h:313
@ Generic
A plain vector, such as a Neon vector or a GCC vector_size vector.
Definition Types.h:309
StructPacking
Definition Types.h:412
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:493
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:401
bool HasNoUniqueAddress
Definition Types.h:399
const Type * FieldType
Definition Types.h:394
uint64_t BitFieldWidth
Definition Types.h:396
LLVM_ABI bool isEmpty() const
Definition Types.cpp:123
uint64_t OffsetInBits
Definition Types.h:395