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