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