LLVM 20.0.0git
Type.h
Go to the documentation of this file.
1//===- llvm/SandboxIR/Type.h - Classes for handling data types --*- 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// This is a thin wrapper over llvm::Type.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_SANDBOXIR_TYPE_H
14#define LLVM_SANDBOXIR_TYPE_H
15
18#include "llvm/IR/Type.h"
19#include "llvm/Support/Debug.h"
21
22namespace llvm::sandboxir {
23
24class Context;
25// Forward declare friend classes for MSVC.
26class PointerType;
27class VectorType;
28class FixedVectorType;
29class ScalableVectorType;
30class IntegerType;
31class FunctionType;
32class ArrayType;
33class StructType;
34class TargetExtType;
35class Module;
36class FPMathOperator;
37#define DEF_INSTR(ID, OPCODE, CLASS) class CLASS;
38#define DEF_CONST(ID, CLASS) class CLASS;
39#include "llvm/SandboxIR/Values.def"
40
41/// Just like llvm::Type these are immutable, unique, never get freed and
42/// can only be created via static factory methods.
43class Type {
44protected:
46 friend class ArrayType; // For LLVMTy.
47 friend class StructType; // For LLVMTy.
48 friend class VectorType; // For LLVMTy.
49 friend class FixedVectorType; // For LLVMTy.
50 friend class ScalableVectorType; // For LLVMTy.
51 friend class PointerType; // For LLVMTy.
52 friend class FunctionType; // For LLVMTy.
53 friend class IntegerType; // For LLVMTy.
54 friend class Function; // For LLVMTy.
55 friend class CallBase; // For LLVMTy.
56 friend class ConstantInt; // For LLVMTy.
57 friend class ConstantArray; // For LLVMTy.
58 friend class ConstantStruct; // For LLVMTy.
59 friend class ConstantVector; // For LLVMTy.
60 friend class CmpInst; // For LLVMTy. TODO: Cleanup after
61 // sandboxir::VectorType is more complete.
62 friend class Utils; // for LLVMTy
63 friend class TargetExtType; // For LLVMTy.
64 friend class Module; // For LLVMTy.
65 friend class FPMathOperator; // For LLVMTy.
66
67 // Friend all instruction classes because `create()` functions use LLVMTy.
68#define DEF_INSTR(ID, OPCODE, CLASS) friend class CLASS;
69#define DEF_CONST(ID, CLASS) friend class CLASS;
70#include "llvm/SandboxIR/Values.def"
72
74 friend class Context; // For constructor and ~Type().
75 ~Type() = default;
76
77public:
78 /// Print the current type.
79 /// Omit the type details if \p NoDetails == true.
80 /// E.g., let %st = type { i32, i16 }
81 /// When \p NoDetails is true, we only print %st.
82 /// Put differently, \p NoDetails prints the type as if
83 /// inlined with the operands when printing an instruction.
84 void print(raw_ostream &OS, bool IsForDebug = false,
85 bool NoDetails = false) const {
86 LLVMTy->print(OS, IsForDebug, NoDetails);
87 }
88
89 Context &getContext() const { return Ctx; }
90
91 /// Return true if this is 'void'.
92 bool isVoidTy() const { return LLVMTy->isVoidTy(); }
93
94 /// Return true if this is 'half', a 16-bit IEEE fp type.
95 bool isHalfTy() const { return LLVMTy->isHalfTy(); }
96
97 /// Return true if this is 'bfloat', a 16-bit bfloat type.
98 bool isBFloatTy() const { return LLVMTy->isBFloatTy(); }
99
100 /// Return true if this is a 16-bit float type.
101 bool is16bitFPTy() const { return LLVMTy->is16bitFPTy(); }
102
103 /// Return true if this is 'float', a 32-bit IEEE fp type.
104 bool isFloatTy() const { return LLVMTy->isFloatTy(); }
105
106 /// Return true if this is 'double', a 64-bit IEEE fp type.
107 bool isDoubleTy() const { return LLVMTy->isDoubleTy(); }
108
109 /// Return true if this is x86 long double.
110 bool isX86_FP80Ty() const { return LLVMTy->isX86_FP80Ty(); }
111
112 /// Return true if this is 'fp128'.
113 bool isFP128Ty() const { return LLVMTy->isFP128Ty(); }
114
115 /// Return true if this is powerpc long double.
116 bool isPPC_FP128Ty() const { return LLVMTy->isPPC_FP128Ty(); }
117
118 /// Return true if this is a well-behaved IEEE-like type, which has a IEEE
119 /// compatible layout as defined by APFloat::isIEEE(), and does not have
120 /// non-IEEE values, such as x86_fp80's unnormal values.
121 bool isIEEELikeFPTy() const { return LLVMTy->isIEEELikeFPTy(); }
122
123 /// Return true if this is one of the floating-point types
124 bool isFloatingPointTy() const { return LLVMTy->isFloatingPointTy(); }
125
126 /// Returns true if this is a floating-point type that is an unevaluated sum
127 /// of multiple floating-point units.
128 /// An example of such a type is ppc_fp128, also known as double-double, which
129 /// consists of two IEEE 754 doubles.
130 bool isMultiUnitFPType() const { return LLVMTy->isMultiUnitFPType(); }
131
133 return LLVMTy->getFltSemantics();
134 }
135
136 /// Return true if this is X86 AMX.
137 bool isX86_AMXTy() const { return LLVMTy->isX86_AMXTy(); }
138
139 /// Return true if this is a target extension type.
140 bool isTargetExtTy() const { return LLVMTy->isTargetExtTy(); }
141
142 /// Return true if this is a target extension type with a scalable layout.
144
145 /// Return true if this is a type whose size is a known multiple of vscale.
146 bool isScalableTy() const { return LLVMTy->isScalableTy(); }
147
148 /// Return true if this is a FP type or a vector of FP.
149 bool isFPOrFPVectorTy() const { return LLVMTy->isFPOrFPVectorTy(); }
150
151 /// Return true if this is 'label'.
152 bool isLabelTy() const { return LLVMTy->isLabelTy(); }
153
154 /// Return true if this is 'metadata'.
155 bool isMetadataTy() const { return LLVMTy->isMetadataTy(); }
156
157 /// Return true if this is 'token'.
158 bool isTokenTy() const { return LLVMTy->isTokenTy(); }
159
160 /// True if this is an instance of IntegerType.
161 bool isIntegerTy() const { return LLVMTy->isIntegerTy(); }
162
163 /// Return true if this is an IntegerType of the given width.
164 bool isIntegerTy(unsigned Bitwidth) const {
165 return LLVMTy->isIntegerTy(Bitwidth);
166 }
167
168 /// Return true if this is an integer type or a vector of integer types.
169 bool isIntOrIntVectorTy() const { return LLVMTy->isIntOrIntVectorTy(); }
170
171 /// Return true if this is an integer type or a vector of integer types of
172 /// the given width.
173 bool isIntOrIntVectorTy(unsigned BitWidth) const {
175 }
176
177 /// Return true if this is an integer type or a pointer type.
178 bool isIntOrPtrTy() const { return LLVMTy->isIntOrPtrTy(); }
179
180 /// True if this is an instance of FunctionType.
181 bool isFunctionTy() const { return LLVMTy->isFunctionTy(); }
182
183 /// True if this is an instance of StructType.
184 bool isStructTy() const { return LLVMTy->isStructTy(); }
185
186 /// True if this is an instance of ArrayType.
187 bool isArrayTy() const { return LLVMTy->isArrayTy(); }
188
189 /// True if this is an instance of PointerType.
190 bool isPointerTy() const { return LLVMTy->isPointerTy(); }
191
192 /// Return true if this is a pointer type or a vector of pointer types.
193 bool isPtrOrPtrVectorTy() const { return LLVMTy->isPtrOrPtrVectorTy(); }
194
195 /// True if this is an instance of VectorType.
196 inline bool isVectorTy() const { return LLVMTy->isVectorTy(); }
197
198 /// Return true if this type could be converted with a lossless BitCast to
199 /// type 'Ty'. For example, i8* to i32*. BitCasts are valid for types of the
200 /// same size only where no re-interpretation of the bits is done.
201 /// Determine if this type could be losslessly bitcast to Ty
202 bool canLosslesslyBitCastTo(Type *Ty) const {
204 }
205
206 /// Return true if this type is empty, that is, it has no elements or all of
207 /// its elements are empty.
208 bool isEmptyTy() const { return LLVMTy->isEmptyTy(); }
209
210 /// Return true if the type is "first class", meaning it is a valid type for a
211 /// Value.
212 bool isFirstClassType() const { return LLVMTy->isFirstClassType(); }
213
214 /// Return true if the type is a valid type for a register in codegen. This
215 /// includes all first-class types except struct and array types.
216 bool isSingleValueType() const { return LLVMTy->isSingleValueType(); }
217
218 /// Return true if the type is an aggregate type. This means it is valid as
219 /// the first operand of an insertvalue or extractvalue instruction. This
220 /// includes struct and array types, but does not include vector types.
221 bool isAggregateType() const { return LLVMTy->isAggregateType(); }
222
223 /// Return true if it makes sense to take the size of this type. To get the
224 /// actual size for a particular target, it is reasonable to use the
225 /// DataLayout subsystem to do this.
226 bool isSized(SmallPtrSetImpl<Type *> *Visited = nullptr) const {
228 LLVMVisited.reserve(Visited->size());
229 for (Type *Ty : *Visited)
230 LLVMVisited.insert(Ty->LLVMTy);
231 return LLVMTy->isSized(&LLVMVisited);
232 }
233
234 /// Return the basic size of this type if it is a primitive type. These are
235 /// fixed by LLVM and are not target-dependent.
236 /// This will return zero if the type does not have a size or is not a
237 /// primitive type.
238 ///
239 /// If this is a scalable vector type, the scalable property will be set and
240 /// the runtime size will be a positive integer multiple of the base size.
241 ///
242 /// Note that this may not reflect the size of memory allocated for an
243 /// instance of the type or the number of bytes that are written when an
244 /// instance of the type is stored to memory. The DataLayout class provides
245 /// additional query functions to provide this information.
246 ///
249 }
250
251 /// If this is a vector type, return the getPrimitiveSizeInBits value for the
252 /// element type. Otherwise return the getPrimitiveSizeInBits value for this
253 /// type.
254 unsigned getScalarSizeInBits() const { return LLVMTy->getScalarSizeInBits(); }
255
256 /// Return the width of the mantissa of this type. This is only valid on
257 /// floating-point types. If the FP type does not have a stable mantissa (e.g.
258 /// ppc long double), this method returns -1.
260
261 /// Return whether the type is IEEE compatible, as defined by the eponymous
262 /// method in APFloat.
263 bool isIEEE() const { return LLVMTy->isIEEE(); }
264
265 /// If this is a vector type, return the element type, otherwise return
266 /// 'this'.
268
269 // TODO: ADD MISSING
270
278 // TODO: missing get*
279
280 /// Get the address space of this pointer or pointer vector type.
281 inline unsigned getPointerAddressSpace() const {
283 }
284
285#ifndef NDEBUG
288#endif // NDEBUG
289};
290
291class PointerType : public Type {
292public:
293 // TODO: add missing functions
294 static PointerType *get(Type *ElementType, unsigned AddressSpace);
295 static PointerType *get(Context &Ctx, unsigned AddressSpace);
296
297 static bool classof(const Type *From) {
298 return isa<llvm::PointerType>(From->LLVMTy);
299 }
300};
301
302class ArrayType : public Type {
303public:
304 static ArrayType *get(Type *ElementType, uint64_t NumElements);
305 // TODO: add missing functions
306 static bool classof(const Type *From) {
307 return isa<llvm::ArrayType>(From->LLVMTy);
308 }
309};
310
311class StructType : public Type {
312public:
313 /// This static method is the primary way to create a literal StructType.
314 static StructType *get(Context &Ctx, ArrayRef<Type *> Elements,
315 bool IsPacked = false);
316
317 bool isPacked() const { return cast<llvm::StructType>(LLVMTy)->isPacked(); }
318
319 // TODO: add missing functions
320 static bool classof(const Type *From) {
321 return isa<llvm::StructType>(From->LLVMTy);
322 }
323};
324
325class VectorType : public Type {
326public:
327 static VectorType *get(Type *ElementType, ElementCount EC);
328 static VectorType *get(Type *ElementType, unsigned NumElements,
329 bool Scalable) {
330 return VectorType::get(ElementType,
331 ElementCount::get(NumElements, Scalable));
332 }
333 Type *getElementType() const;
334
335 static VectorType *get(Type *ElementType, const VectorType *Other) {
336 return VectorType::get(ElementType, Other->getElementCount());
337 }
338
340 return cast<llvm::VectorType>(LLVMTy)->getElementCount();
341 }
342 static VectorType *getInteger(VectorType *VTy);
345 static VectorType *getSubdividedVectorType(VectorType *VTy, int NumSubdivs);
348 static bool isValidElementType(Type *ElemTy);
349
350 static bool classof(const Type *From) {
351 return isa<llvm::VectorType>(From->LLVMTy);
352 }
353};
354
356public:
357 static FixedVectorType *get(Type *ElementType, unsigned NumElts);
358
359 static FixedVectorType *get(Type *ElementType, const FixedVectorType *FVTy) {
360 return get(ElementType, FVTy->getNumElements());
361 }
362
364 return cast<FixedVectorType>(VectorType::getInteger(VTy));
365 }
366
368 return cast<FixedVectorType>(VectorType::getExtendedElementVectorType(VTy));
369 }
370
372 return cast<FixedVectorType>(
374 }
375
377 int NumSubdivs) {
378 return cast<FixedVectorType>(
379 VectorType::getSubdividedVectorType(VTy, NumSubdivs));
380 }
381
383 return cast<FixedVectorType>(VectorType::getHalfElementsVectorType(VTy));
384 }
385
387 return cast<FixedVectorType>(VectorType::getDoubleElementsVectorType(VTy));
388 }
389
390 static bool classof(const Type *T) {
391 return isa<llvm::FixedVectorType>(T->LLVMTy);
392 }
393
394 unsigned getNumElements() const {
395 return cast<llvm::FixedVectorType>(LLVMTy)->getNumElements();
396 }
397};
398
400public:
401 static ScalableVectorType *get(Type *ElementType, unsigned MinNumElts);
402
403 static ScalableVectorType *get(Type *ElementType,
404 const ScalableVectorType *SVTy) {
405 return get(ElementType, SVTy->getMinNumElements());
406 }
407
409 return cast<ScalableVectorType>(VectorType::getInteger(VTy));
410 }
411
412 static ScalableVectorType *
414 return cast<ScalableVectorType>(
416 }
417
418 static ScalableVectorType *
420 return cast<ScalableVectorType>(
422 }
423
425 int NumSubdivs) {
426 return cast<ScalableVectorType>(
427 VectorType::getSubdividedVectorType(VTy, NumSubdivs));
428 }
429
430 static ScalableVectorType *
432 return cast<ScalableVectorType>(VectorType::getHalfElementsVectorType(VTy));
433 }
434
435 static ScalableVectorType *
437 return cast<ScalableVectorType>(
439 }
440
441 unsigned getMinNumElements() const {
442 return cast<llvm::ScalableVectorType>(LLVMTy)->getMinNumElements();
443 }
444
445 static bool classof(const Type *T) {
446 return isa<llvm::ScalableVectorType>(T->LLVMTy);
447 }
448};
449
450class FunctionType : public Type {
451public:
452 // TODO: add missing functions
453 static bool classof(const Type *From) {
454 return isa<llvm::FunctionType>(From->LLVMTy);
455 }
456};
457
458/// Class to represent integer types. Note that this class is also used to
459/// represent the built-in integer types: Int1Ty, Int8Ty, Int16Ty, Int32Ty and
460/// Int64Ty.
461/// Integer representation type
462class IntegerType : public Type {
463public:
464 static IntegerType *get(Context &C, unsigned NumBits);
465 // TODO: add missing functions
466 static bool classof(const Type *From) {
467 return isa<llvm::IntegerType>(From->LLVMTy);
468 }
469 operator llvm::IntegerType &() const {
470 return *cast<llvm::IntegerType>(LLVMTy);
471 }
472};
473
474} // namespace llvm::sandboxir
475
476#endif // LLVM_SANDBOXIR_TYPE_H
BlockVerifier::State From
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:622
Machine Check Debug Module
raw_pwrite_stream & OS
This file defines the SmallPtrSet class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Definition: TypeSize.h:317
Class to represent integer types.
Definition: DerivedTypes.h:42
void reserve(size_type NumEntries)
Definition: SmallPtrSet.h:112
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:363
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:384
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:519
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition: DerivedTypes.h:744
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
const fltSemantics & getFltSemantics() const
bool isVectorTy() const
True if this is an instance of VectorType.
Definition: Type.h:270
bool isX86_FP80Ty() const
Return true if this is x86 long double.
Definition: Type.h:159
bool isArrayTy() const
True if this is an instance of ArrayType.
Definition: Type.h:261
bool isLabelTy() const
Return true if this is 'label'.
Definition: Type.h:228
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition: Type.h:243
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:264
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition: Type.h:153
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty.
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
Definition: Type.h:145
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
Definition: Type.h:295
void print(raw_ostream &O, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
Definition: Type.h:165
bool isFP128Ty() const
Return true if this is 'fp128'.
Definition: Type.h:162
bool is16bitFPTy() const
Return true if this is a 16-bit float type.
Definition: Type.h:148
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isScalableTargetExtTy() const
Return true if this is a target extension type with a scalable layout.
bool isMultiUnitFPType() const
Returns true if this is a floating-point type that is an unevaluated sum of multiple floating-point u...
Definition: Type.h:193
bool isStructTy() const
True if this is an instance of StructType.
Definition: Type.h:258
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
Definition: Type.h:289
bool isTargetExtTy() const
Return true if this is a target extension type.
Definition: Type.h:203
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Definition: Type.h:310
bool isAggregateType() const
Return true if the type is an aggregate type.
Definition: Type.h:303
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition: Type.h:142
bool isScalableTy(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this is a type whose size is a known multiple of vscale.
int getFPMantissaWidth() const
Return the width of the mantissa of this type.
bool isIEEE() const
Return whether the type is IEEE compatible, as defined by the eponymous method in APFloat.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition: Type.h:156
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
Definition: Type.h:184
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Definition: Type.h:267
bool isX86_AMXTy() const
Return true if this is X86 AMX.
Definition: Type.h:200
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:255
bool canLosslesslyBitCastTo(Type *Ty) const
Return true if this type could be converted with a lossless BitCast to type 'Ty'.
bool isIntOrPtrTy() const
Return true if this is an integer type or a pointer type.
Definition: Type.h:252
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:237
bool isTokenTy() const
Return true if this is 'token'.
Definition: Type.h:234
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Definition: Type.h:225
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
bool isIEEELikeFPTy() const
Return true if this is a well-behaved IEEE-like type, which has a IEEE compatible layout as defined b...
Definition: Type.h:170
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:139
bool isMetadataTy() const
Return true if this is 'metadata'.
Definition: Type.h:231
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
static bool classof(const Type *From)
Definition: Type.h:306
static ArrayType * get(Type *ElementType, uint64_t NumElements)
Definition: Type.cpp:746
static FixedVectorType * getExtendedElementVectorType(FixedVectorType *VTy)
Definition: Type.h:367
unsigned getNumElements() const
Definition: Type.h:394
static bool classof(const Type *T)
Definition: Type.h:390
static FixedVectorType * getDoubleElementsVectorType(FixedVectorType *VTy)
Definition: Type.h:386
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
static FixedVectorType * get(Type *ElementType, const FixedVectorType *FVTy)
Definition: Type.h:359
static FixedVectorType * getHalfElementsVectorType(FixedVectorType *VTy)
Definition: Type.h:382
static FixedVectorType * getSubdividedVectorType(FixedVectorType *VTy, int NumSubdivs)
Definition: Type.h:376
static FixedVectorType * getTruncatedElementVectorType(FixedVectorType *VTy)
Definition: Type.h:371
static FixedVectorType * getInteger(FixedVectorType *VTy)
Definition: Type.h:363
static bool classof(const Type *From)
Definition: Type.h:453
Class to represent integer types.
Definition: Type.h:462
static bool classof(const Type *From)
Definition: Type.h:466
static IntegerType * get(Context &C, unsigned NumBits)
In SandboxIR the Module is mainly used to access the list of global objects.
Definition: Module.h:31
static PointerType * get(Type *ElementType, unsigned AddressSpace)
Definition: Type.cpp:48
static bool classof(const Type *From)
Definition: Type.h:297
static ScalableVectorType * getExtendedElementVectorType(ScalableVectorType *VTy)
Definition: Type.h:413
static bool classof(const Type *T)
Definition: Type.h:445
static ScalableVectorType * getInteger(ScalableVectorType *VTy)
Definition: Type.h:408
static ScalableVectorType * getHalfElementsVectorType(ScalableVectorType *VTy)
Definition: Type.h:431
unsigned getMinNumElements() const
Definition: Type.h:441
static ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
static ScalableVectorType * getDoubleElementsVectorType(ScalableVectorType *VTy)
Definition: Type.h:436
static ScalableVectorType * get(Type *ElementType, const ScalableVectorType *SVTy)
Definition: Type.h:403
static ScalableVectorType * getSubdividedVectorType(ScalableVectorType *VTy, int NumSubdivs)
Definition: Type.h:424
static ScalableVectorType * getTruncatedElementVectorType(ScalableVectorType *VTy)
Definition: Type.h:419
static bool classof(const Type *From)
Definition: Type.h:320
bool isPacked() const
Definition: Type.h:317
static StructType * get(Context &Ctx, ArrayRef< Type * > Elements, bool IsPacked=false)
This static method is the primary way to create a literal StructType.
Definition: Type.cpp:63
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Definition: Type.h:43
bool isX86_FP80Ty() const
Return true if this is x86 long double.
Definition: Type.h:110
bool isScalableTy() const
Return true if this is a type whose size is a known multiple of vscale.
Definition: Type.h:146
bool isFP128Ty() const
Return true if this is 'fp128'.
Definition: Type.h:113
bool isIEEE() const
Return whether the type is IEEE compatible, as defined by the eponymous method in APFloat.
Definition: Type.h:263
const fltSemantics & getFltSemantics() const
Definition: Type.h:132
bool isIntOrPtrTy() const
Return true if this is an integer type or a pointer type.
Definition: Type.h:178
bool isTargetExtTy() const
Return true if this is a target extension type.
Definition: Type.h:140
llvm::Type * LLVMTy
Definition: Type.h:45
bool isIEEELikeFPTy() const
Return true if this is a well-behaved IEEE-like type, which has a IEEE compatible layout as defined b...
Definition: Type.h:121
Type(llvm::Type *LLVMTy, Context &Ctx)
Definition: Type.h:73
static Type * getFloatTy(Context &Ctx)
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
Definition: Type.h:124
bool canLosslesslyBitCastTo(Type *Ty) const
Return true if this type could be converted with a lossless BitCast to type 'Ty'.
Definition: Type.h:202
static Type * getDoubleTy(Context &Ctx)
bool isMetadataTy() const
Return true if this is 'metadata'.
Definition: Type.h:155
TypeSize getPrimitiveSizeInBits() const
Return the basic size of this type if it is a primitive type.
Definition: Type.h:247
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:161
void print(raw_ostream &OS, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
Definition: Type.h:84
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition: Type.h:169
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Definition: Type.h:149
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition: Type.h:281
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition: Type.h:95
bool isStructTy() const
True if this is an instance of StructType.
Definition: Type.h:184
bool isX86_AMXTy() const
Return true if this is X86 AMX.
Definition: Type.h:137
void dumpOS(raw_ostream &OS)
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition: Type.h:107
unsigned getScalarSizeInBits() const
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Definition: Type.h:254
bool is16bitFPTy() const
Return true if this is a 16-bit float type.
Definition: Type.h:101
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Definition: Type.h:226
static Type * getInt16Ty(Context &Ctx)
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Definition: Type.h:193
bool isArrayTy() const
True if this is an instance of ArrayType.
Definition: Type.h:187
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
Definition: Type.h:116
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
Definition: Type.h:216
static Type * getInt1Ty(Context &Ctx)
static Type * getInt32Ty(Context &Ctx)
bool isTokenTy() const
Return true if this is 'token'.
Definition: Type.h:158
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:92
int getFPMantissaWidth() const
Return the width of the mantissa of this type.
Definition: Type.h:259
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:181
bool isScalableTargetExtTy() const
Return true if this is a target extension type with a scalable layout.
Definition: Type.h:143
bool isVectorTy() const
True if this is an instance of VectorType.
Definition: Type.h:196
static Type * getInt64Ty(Context &Ctx)
bool isMultiUnitFPType() const
Returns true if this is a floating-point type that is an unevaluated sum of multiple floating-point u...
Definition: Type.h:130
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty.
Definition: Type.h:208
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:190
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition: Type.h:104
bool isIntegerTy(unsigned Bitwidth) const
Return true if this is an IntegerType of the given width.
Definition: Type.h:164
bool isAggregateType() const
Return true if the type is an aggregate type.
Definition: Type.h:221
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
Definition: Type.h:212
Context & Ctx
Definition: Type.h:71
Context & getContext() const
Definition: Type.h:89
LLVM_DUMP_METHOD void dump()
bool isLabelTy() const
Return true if this is 'label'.
Definition: Type.h:152
static Type * getInt8Ty(Context &Ctx)
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
Definition: Type.h:98
bool isIntOrIntVectorTy(unsigned BitWidth) const
Return true if this is an integer type or a vector of integer types of the given width.
Definition: Type.h:173
static bool isValidElementType(Type *ElemTy)
Definition: Type.cpp:782
ElementCount getElementCount() const
Definition: Type.h:339
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
Definition: Type.cpp:95
static VectorType * get(Type *ElementType, const VectorType *Other)
Definition: Type.h:335
static bool classof(const Type *From)
Definition: Type.h:350
static VectorType * get(Type *ElementType, unsigned NumElements, bool Scalable)
Definition: Type.h:328
static VectorType * getInteger(VectorType *VTy)
Definition: Type.cpp:81
static VectorType * get(Type *ElementType, ElementCount EC)
Definition: Type.cpp:775
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
Definition: Type.cpp:90
static VectorType * getDoubleElementsVectorType(VectorType *VTy)
Definition: Type.cpp:106
static VectorType * getHalfElementsVectorType(VectorType *VTy)
Definition: Type.cpp:101
static VectorType * getExtendedElementVectorType(VectorType *VTy)
Definition: Type.cpp:85
Type * getElementType() const
Definition: Type.cpp:78
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
@ Other
Any other memory.
constexpr unsigned BitWidth
Definition: BitmaskEnum.h:217