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