LLVM 23.0.0git
Type.h
Go to the documentation of this file.
1//===- llvm/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 file contains the declaration of the Type class. For more "Type"
10// stuff, look in DerivedTypes.h.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_TYPE_H
15#define LLVM_IR_TYPE_H
16
17#include "llvm/ADT/ArrayRef.h"
23#include <cassert>
24#include <cstdint>
25#include <iterator>
26
27namespace llvm {
28
29class ByteType;
30class IntegerType;
31struct fltSemantics;
32class LLVMContext;
33class PointerType;
34class raw_ostream;
35class StringRef;
36template <typename PtrType> class SmallPtrSetImpl;
37
38/// The instances of the Type class are immutable: once they are created,
39/// they are never changed. Also note that only one instance of a particular
40/// type is ever created. Thus seeing if two types are equal is a matter of
41/// doing a trivial pointer comparison. To enforce that no two equal instances
42/// are created, Type instances can only be created via static factory methods
43/// in class Type and in derived classes. Once allocated, Types are never
44/// free'd.
45///
46class Type {
47public:
48 //===--------------------------------------------------------------------===//
49 /// Definitions of all of the base types for the Type system. Based on this
50 /// value, you can cast to a class defined in DerivedTypes.h.
51 /// Note: If you add an element to this, you need to add an element to the
52 /// Type::getPrimitiveType function, or else things will break!
53 /// Also update LLVMTypeKind and LLVMGetTypeKind () in the C binding.
54 ///
55 enum TypeID {
56 // PrimitiveTypes
57 HalfTyID = 0, ///< 16-bit floating point type
58 BFloatTyID, ///< 16-bit floating point type (7-bit significand)
59 FloatTyID, ///< 32-bit floating point type
60 DoubleTyID, ///< 64-bit floating point type
61 X86_FP80TyID, ///< 80-bit floating point type (X87)
62 FP128TyID, ///< 128-bit floating point type (112-bit significand)
63 PPC_FP128TyID, ///< 128-bit floating point type (two 64-bits, PowerPC)
64 VoidTyID, ///< type with no size
65 LabelTyID, ///< Labels
66 MetadataTyID, ///< Metadata
67 X86_AMXTyID, ///< AMX vectors (8192 bits, X86 specific)
68 TokenTyID, ///< Tokens
69
70 // Derived types... see DerivedTypes.h file.
71 IntegerTyID, ///< Arbitrary bit width integers
72 ByteTyID, ///< Arbitrary bit width bytes
73 FunctionTyID, ///< Functions
74 PointerTyID, ///< Pointers
75 StructTyID, ///< Structures
76 ArrayTyID, ///< Arrays
77 FixedVectorTyID, ///< Fixed width SIMD vector type
78 ScalableVectorTyID, ///< Scalable SIMD vector type
79 TypedPointerTyID, ///< Typed pointer used by some GPU targets
80 TargetExtTyID, ///< Target extension type
81 };
82
83private:
84 /// This refers to the LLVMContext in which this type was uniqued.
85 LLVMContext &Context;
86
87 TypeID ID : 8; // The current base type of this type.
88 unsigned SubclassData : 24; // Space for subclasses to store data.
89 // Note that this should be synchronized with
90 // MAX_INT_BITS value in IntegerType class.
91
92protected:
93 friend class LLVMContextImpl;
94
95 explicit Type(LLVMContext &C, TypeID tid)
96 : Context(C), ID(tid), SubclassData(0) {}
97 ~Type() = default;
98
99 unsigned getSubclassData() const { return SubclassData; }
100
101 void setSubclassData(unsigned val) {
102 SubclassData = val;
103 // Ensure we don't have any accidental truncation.
104 assert(getSubclassData() == val && "Subclass data too large for field");
105 }
106
107 /// Keeps track of how many Type*'s there are in the ContainedTys list.
108 unsigned NumContainedTys = 0;
109
110 /// A pointer to the array of Types contained by this Type. For example, this
111 /// includes the arguments of a function type, the elements of a structure,
112 /// the pointee of a pointer, the element type of an array, etc. This pointer
113 /// may be 0 for types that don't contain other types (Integer, Double,
114 /// Float).
115 Type * const *ContainedTys = nullptr;
116
117public:
118 /// Print the current type.
119 /// Omit the type details if \p NoDetails == true.
120 /// E.g., let %st = type { i32, i16 }
121 /// When \p NoDetails is true, we only print %st.
122 /// Put differently, \p NoDetails prints the type as if
123 /// inlined with the operands when printing an instruction.
124 LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false,
125 bool NoDetails = false) const;
126
127 LLVM_ABI void dump() const;
128
129 /// Return the LLVMContext in which this type was uniqued.
130 LLVMContext &getContext() const { return Context; }
131
132 //===--------------------------------------------------------------------===//
133 // Accessors for working with types.
134 //
135
136 /// Return the type id for the type. This will return one of the TypeID enum
137 /// elements defined above.
138 TypeID getTypeID() const { return ID; }
139
140 /// Return true if this is 'void'.
141 bool isVoidTy() const { return getTypeID() == VoidTyID; }
142
143 /// Return true if this is 'half', a 16-bit IEEE fp type.
144 bool isHalfTy() const { return getTypeID() == HalfTyID; }
145
146 /// Return true if this is 'bfloat', a 16-bit bfloat type.
147 bool isBFloatTy() const { return getTypeID() == BFloatTyID; }
148
149 /// Return true if this is a 16-bit float type.
150 bool is16bitFPTy() const {
151 return getTypeID() == BFloatTyID || getTypeID() == HalfTyID;
152 }
153
154 /// Return true if this is 'float', a 32-bit IEEE fp type.
155 bool isFloatTy() const { return getTypeID() == FloatTyID; }
156
157 /// Return true if this is 'double', a 64-bit IEEE fp type.
158 bool isDoubleTy() const { return getTypeID() == DoubleTyID; }
159
160 /// Return true if this is x86 long double.
161 bool isX86_FP80Ty() const { return getTypeID() == X86_FP80TyID; }
162
163 /// Return true if this is 'fp128'.
164 bool isFP128Ty() const { return getTypeID() == FP128TyID; }
165
166 /// Return true if this is powerpc long double.
167 bool isPPC_FP128Ty() const { return getTypeID() == PPC_FP128TyID; }
168
169 /// Return true if this is a well-behaved IEEE-like type, which has a IEEE
170 /// compatible layout, and does not have non-IEEE values, such as x86_fp80's
171 /// unnormal values.
172 bool isIEEELikeFPTy() const {
173 switch (getTypeID()) {
174 case DoubleTyID:
175 case FloatTyID:
176 case HalfTyID:
177 case BFloatTyID:
178 case FP128TyID:
179 return true;
180 default:
181 return false;
182 }
183 }
184
185 /// Return true if this is one of the floating-point types
186 bool isFloatingPointTy() const {
187 return isIEEELikeFPTy() || getTypeID() == X86_FP80TyID ||
189 }
190
191 /// Returns true if this is a floating-point type that is an unevaluated sum
192 /// of multiple floating-point units.
193 /// An example of such a type is ppc_fp128, also known as double-double, which
194 /// consists of two IEEE 754 doubles.
195 bool isMultiUnitFPType() const {
196 return getTypeID() == PPC_FP128TyID;
197 }
198
200
201 /// Return true if this is X86 AMX.
202 bool isX86_AMXTy() const { return getTypeID() == X86_AMXTyID; }
203
204 /// Return true if this is a target extension type.
205 bool isTargetExtTy() const { return getTypeID() == TargetExtTyID; }
206
207 /// Return true if this is a target extension type with a scalable layout.
208 LLVM_ABI bool isScalableTargetExtTy() const;
209
210 /// Return true if this is a type whose size is a known multiple of vscale.
212 LLVM_ABI bool isScalableTy() const;
213
214 /// Return true if this type is or contains a target extension type that
215 /// disallows being used as a global.
216 LLVM_ABI bool
219
220 /// Return true if this type is or contains a target extension type that
221 /// disallows being used as a local.
222 LLVM_ABI bool
225
226 /// Return true if this is a FP type or a vector of FP.
228
229 /// Return true if this is 'label'.
230 bool isLabelTy() const { return getTypeID() == LabelTyID; }
231
232 /// Return true if this is 'metadata'.
233 bool isMetadataTy() const { return getTypeID() == MetadataTyID; }
234
235 /// Return true if this is 'token'.
236 bool isTokenTy() const { return getTypeID() == TokenTyID; }
237
238 /// Returns true if this is 'token' or a token-like target type.s
239 LLVM_ABI bool isTokenLikeTy() const;
240
241 /// True if this is an instance of ByteType.
242 bool isByteTy() const { return getTypeID() == ByteTyID; }
243
244 /// Return true if this is a ByteType of the given width.
245 LLVM_ABI bool isByteTy(unsigned BitWidth) const;
246
247 /// Return true if this is a byte type or a vector of byte types.
248 bool isByteOrByteVectorTy() const { return getScalarType()->isByteTy(); }
249
250 /// Return true if this is a byte type or a vector of byte types of
251 /// the given width.
252 bool isByteOrByteVectorTy(unsigned BitWidth) const {
254 }
255
256 /// True if this is an instance of IntegerType.
257 bool isIntegerTy() const { return getTypeID() == IntegerTyID; }
258
259 /// Return true if this is an IntegerType of the given width.
260 LLVM_ABI bool isIntegerTy(unsigned Bitwidth) const;
261
262 /// Return true if this is an integer type or a vector of integer types.
263 bool isIntOrIntVectorTy() const { return getScalarType()->isIntegerTy(); }
264
265 /// Return true if this is an integer type or a vector of integer types of
266 /// the given width.
267 bool isIntOrIntVectorTy(unsigned BitWidth) const {
269 }
270
271 /// Return true if this is an integer type or a pointer type.
272 bool isIntOrPtrTy() const { return isIntegerTy() || isPointerTy(); }
273
274 /// True if this is an instance of FunctionType.
275 bool isFunctionTy() const { return getTypeID() == FunctionTyID; }
276
277 /// True if this is an instance of StructType.
278 bool isStructTy() const { return getTypeID() == StructTyID; }
279
280 /// True if this is an instance of ArrayType.
281 bool isArrayTy() const { return getTypeID() == ArrayTyID; }
282
283 /// True if this is an instance of PointerType.
284 bool isPointerTy() const { return getTypeID() == PointerTyID; }
285
286 /// Return true if this is a pointer type or a vector of pointer types.
287 bool isPtrOrPtrVectorTy() const { return getScalarType()->isPointerTy(); }
288
289 /// True if this is an instance of VectorType.
290 inline bool isVectorTy() const {
292 }
293
294 // True if this is an instance of TargetExtType of RISC-V vector tuple.
295 LLVM_ABI bool isRISCVVectorTupleTy() const;
296
297 /// Return true if this type could be converted with a lossless BitCast to
298 /// type 'Ty'. For example, i8* to i32*. BitCasts are valid for types of the
299 /// same size only where no re-interpretation of the bits is done.
300 /// Determine if this type could be losslessly bitcast to Ty
301 LLVM_ABI bool canLosslesslyBitCastTo(Type *Ty) const;
302
303 /// Return true if this type is empty, that is, it has no elements or all of
304 /// its elements are empty.
305 LLVM_ABI bool isEmptyTy() const;
306
307 /// Return true if the type is "first class", meaning it is a valid type for a
308 /// Value.
309 LLVM_ABI bool isFirstClassType() const;
310
311 /// Return true if the type is a valid type for a register in codegen. This
312 /// includes all first-class types except struct and array types.
313 bool isSingleValueType() const {
314 return isFloatingPointTy() || isIntegerTy() || isPointerTy() ||
316 }
317
318 /// Return true if the type is an aggregate type. This means it is valid as
319 /// the first operand of an insertvalue or extractvalue instruction. This
320 /// includes struct and array types, but does not include vector types.
321 bool isAggregateType() const {
322 return getTypeID() == StructTyID || getTypeID() == ArrayTyID;
323 }
324
325 /// Return true if it makes sense to take the size of this type. To get the
326 /// actual size for a particular target, it is reasonable to use the
327 /// DataLayout subsystem to do this.
328 bool isSized(SmallPtrSetImpl<Type*> *Visited = nullptr) const {
329 // If it's a primitive, it is always sized.
332 getTypeID() == ByteTyID)
333 return true;
334 // If it is not something that can have a size (e.g. a function or label),
335 // it doesn't have a size.
336 if (getTypeID() != StructTyID && getTypeID() != ArrayTyID &&
338 return false;
339 // Otherwise we have to try harder to decide.
340 return isSizedDerivedType(Visited);
341 }
342
343 /// Return the basic size of this type if it is a primitive type. These are
344 /// fixed by LLVM and are not target-dependent.
345 /// This will return zero if the type does not have a size or is not a
346 /// primitive type.
347 ///
348 /// If this is a scalable vector type, the scalable property will be set and
349 /// the runtime size will be a positive integer multiple of the base size.
350 ///
351 /// Note that this may not reflect the size of memory allocated for an
352 /// instance of the type or the number of bytes that are written when an
353 /// instance of the type is stored to memory. The DataLayout class provides
354 /// additional query functions to provide this information.
355 ///
357
358 /// If this is a vector type, return the getPrimitiveSizeInBits value for the
359 /// element type. Otherwise return the getPrimitiveSizeInBits value for this
360 /// type.
362
363 /// Return the width of the mantissa of this type. This is only valid on
364 /// floating-point types. If the FP type does not have a stable mantissa (e.g.
365 /// ppc long double), this method returns -1.
367
368 /// If this is a vector type, return the element type, otherwise return
369 /// 'this'.
371 if (isVectorTy())
372 return getContainedType(0);
373 return const_cast<Type *>(this);
374 }
375
376 //===--------------------------------------------------------------------===//
377 // Type Iteration support.
378 //
379 using subtype_iterator = Type * const *;
380
385 }
386
387 using subtype_reverse_iterator = std::reverse_iterator<subtype_iterator>;
388
395
396 /// This method is used to implement the type iterator (defined at the end of
397 /// the file). For derived types, this returns the types 'contained' in the
398 /// derived type.
399 Type *getContainedType(unsigned i) const {
400 assert(i < NumContainedTys && "Index out of range!");
401 return ContainedTys[i];
402 }
403
404 /// Return the number of types in the derived type.
405 unsigned getNumContainedTypes() const { return NumContainedTys; }
406
407 //===--------------------------------------------------------------------===//
408 // Helper methods corresponding to subclass methods. This forces a cast to
409 // the specified subclass and calls its accessor. "getArrayNumElements" (for
410 // example) is shorthand for cast<ArrayType>(Ty)->getNumElements(). This is
411 // only intended to cover the core methods that are frequently used, helper
412 // methods should not be added here.
413
414 LLVM_ABI inline unsigned getIntegerBitWidth() const;
415 LLVM_ABI inline unsigned getByteBitWidth() const;
416
417 LLVM_ABI inline Type *getFunctionParamType(unsigned i) const;
418 LLVM_ABI inline unsigned getFunctionNumParams() const;
419 LLVM_ABI inline bool isFunctionVarArg() const;
420
421 LLVM_ABI inline StringRef getStructName() const;
422 LLVM_ABI inline unsigned getStructNumElements() const;
423 LLVM_ABI inline Type *getStructElementType(unsigned N) const;
424
426
429 return ContainedTys[0];
430 }
431
432 LLVM_ABI inline StringRef getTargetExtName() const;
433
434 /// Given vector type, change the element type,
435 /// whilst keeping the old number of elements.
436 /// For non-vectors simply returns \p EltTy.
437 LLVM_ABI inline Type *getWithNewType(Type *EltTy) const;
438
439 /// Given an integer or vector type, change the lane bitwidth to NewBitwidth,
440 /// whilst keeping the old number of lanes.
441 LLVM_ABI inline Type *getWithNewBitWidth(unsigned NewBitWidth) const;
442
443 /// Given scalar/vector integer type, returns a type with elements twice as
444 /// wide as in the original type. For vectors, preserves element count.
445 LLVM_ABI inline Type *getExtendedType() const;
446
447 /// Get the address space of this pointer or pointer vector type.
448 LLVM_ABI inline unsigned getPointerAddressSpace() const;
449
450 //===--------------------------------------------------------------------===//
451 // Static members exported by the Type class itself. Useful for getting
452 // instances of Type.
453 //
454
455 /// Return a type based on an identifier.
456 LLVM_ABI static Type *getPrimitiveType(LLVMContext &C, TypeID IDNumber);
457
458 //===--------------------------------------------------------------------===//
459 // These are the builtin types that are always available.
460 //
473 LLVM_ABI static ByteType *getByteNTy(LLVMContext &C, unsigned N);
480 LLVM_ABI static IntegerType *getIntNTy(LLVMContext &C, unsigned N);
487 template <typename ScalarTy> static Type *getScalarTy(LLVMContext &C) {
488 int noOfBits = sizeof(ScalarTy) * CHAR_BIT;
489 if (std::is_integral<ScalarTy>::value) {
490 return (Type*) Type::getIntNTy(C, noOfBits);
491 } else if (std::is_floating_point<ScalarTy>::value) {
492 switch (noOfBits) {
493 case 32:
494 return Type::getFloatTy(C);
495 case 64:
496 return Type::getDoubleTy(C);
497 }
498 }
499 llvm_unreachable("Unsupported type in Type::getScalarTy");
500 }
502 const fltSemantics &S);
503
504 //===--------------------------------------------------------------------===//
505 // Convenience methods for getting byte/integer types.
506 //
507 /// Returns an integer (vector of integer) type with the same size of a byte
508 /// of the given byte (vector of byte) type.
510
511 /// Returns a byte (vector of byte) type with the same size of an integer of
512 /// the given integer (vector of integer) type.
514
515 //===--------------------------------------------------------------------===//
516 // Convenience methods for getting pointer types.
517 //
520
521 /// Return a pointer to the current type. This is equivalent to
522 /// PointerType::get(Ctx, AddrSpace).
523 /// TODO: Remove this after opaque pointer transition is complete.
524 LLVM_ABI LLVM_DEPRECATED("Use PointerType::get instead", "PointerType::get")
525 PointerType *getPointerTo(unsigned AddrSpace = 0) const;
526
527private:
528 /// Derived types like structures and arrays are sized iff all of the members
529 /// of the type are sized as well. Since asking for their size is relatively
530 /// uncommon, move this operation out-of-line.
531 LLVM_ABI bool
532 isSizedDerivedType(SmallPtrSetImpl<Type *> *Visited = nullptr) const;
533};
534
535// Printing of types.
537 T.print(OS);
538 return OS;
539}
540
541// allow isa<PointerType>(x) to work without DerivedTypes.h included.
542template <> struct isa_impl<PointerType, Type> {
543 static inline bool doit(const Type &Ty) {
544 return Ty.getTypeID() == Type::PointerTyID;
545 }
546};
547
548// Create wrappers for C Binding types (see CBindingWrapping.h).
550
551/* Specialized opaque type conversions.
552 */
554 return reinterpret_cast<Type**>(Tys);
555}
556
557inline LLVMTypeRef *wrap(Type **Tys) {
558 return reinterpret_cast<LLVMTypeRef *>(Tys);
559}
560
561} // end namespace llvm
562
563#endif // LLVM_IR_TYPE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
aarch64 promote const
always inline
#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref)
#define LLVM_ABI
Definition Compiler.h:213
#define LLVM_READONLY
Definition Compiler.h:322
Type::TypeID TypeID
#define T
static unsigned getScalarSizeInBits(Type *Ty)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Class to represent byte types.
Class to represent integer types.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Class to represent pointers.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI ByteType * getByte16Ty(LLVMContext &C)
Definition Type.cpp:301
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:314
static LLVM_ABI Type * getX86_AMXTy(LLVMContext &C)
Definition Type.cpp:297
~Type()=default
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:267
LLVM_ABI 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.cpp:184
LLVM_ABI unsigned getIntegerBitWidth() const
LLVM_ABI Type * getStructElementType(unsigned N) const
bool isByteTy() const
True if this is an instance of ByteType.
Definition Type.h:242
static LLVM_ABI Type * getWasm_ExternrefTy(LLVMContext &C)
Definition Type.cpp:340
bool isVectorTy() const
True if this is an instance of VectorType.
Definition Type.h:290
bool isX86_FP80Ty() const
Return true if this is x86 long double.
Definition Type.h:161
static LLVM_ABI Type * getMetadataTy(LLVMContext &C)
Definition Type.cpp:292
bool isArrayTy() const
True if this is an instance of ArrayType.
Definition Type.h:281
static LLVM_ABI Type * getTokenTy(LLVMContext &C)
Definition Type.cpp:293
static LLVM_ABI IntegerType * getInt128Ty(LLVMContext &C)
Definition Type.cpp:315
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:313
bool isLabelTy() const
Return true if this is 'label'.
Definition Type.h:230
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition Type.h:263
bool isPointerTy() const
True if this is an instance of PointerType.
Definition Type.h:284
Type * getArrayElementType() const
Definition Type.h:427
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition Type.h:155
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
Definition Type.h:147
static LLVM_ABI Type * getPPC_FP128Ty(LLVMContext &C)
Definition Type.cpp:296
static LLVM_ABI Type * getFP128Ty(LLVMContext &C)
Definition Type.cpp:295
static LLVM_ABI Type * getLabelTy(LLVMContext &C)
Definition Type.cpp:287
LLVM_ABI StringRef getStructName() const
LLVM_ABI bool isTokenLikeTy() const
Returns true if this is 'token' or a token-like target type.s.
Definition Type.cpp:1136
Type *const * subtype_iterator
Definition Type.h:379
static LLVM_ABI Type * getByteFromIntType(Type *)
Returns a byte (vector of byte) type with the same size of an integer of the given integer (vector of...
Definition Type.cpp:330
LLVM_ABI unsigned getStructNumElements() const
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
LLVM_ABI uint64_t getArrayNumElements() const
TypeID
Definitions of all of the base types for the Type system.
Definition Type.h:55
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
Definition Type.h:67
@ FunctionTyID
Functions.
Definition Type.h:73
@ ArrayTyID
Arrays.
Definition Type.h:76
@ TypedPointerTyID
Typed pointer used by some GPU targets.
Definition Type.h:79
@ HalfTyID
16-bit floating point type
Definition Type.h:57
@ TargetExtTyID
Target extension type.
Definition Type.h:80
@ VoidTyID
type with no size
Definition Type.h:64
@ ScalableVectorTyID
Scalable SIMD vector type.
Definition Type.h:78
@ LabelTyID
Labels.
Definition Type.h:65
@ FloatTyID
32-bit floating point type
Definition Type.h:59
@ StructTyID
Structures.
Definition Type.h:75
@ IntegerTyID
Arbitrary bit width integers.
Definition Type.h:71
@ FixedVectorTyID
Fixed width SIMD vector type.
Definition Type.h:77
@ BFloatTyID
16-bit floating point type (7-bit significand)
Definition Type.h:58
@ DoubleTyID
64-bit floating point type
Definition Type.h:60
@ X86_FP80TyID
80-bit floating point type (X87)
Definition Type.h:61
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
Definition Type.h:63
@ MetadataTyID
Metadata.
Definition Type.h:66
@ TokenTyID
Tokens.
Definition Type.h:68
@ ByteTyID
Arbitrary bit width bytes.
Definition Type.h:72
@ PointerTyID
Pointers.
Definition Type.h:74
@ FP128TyID
128-bit floating point type (112-bit significand)
Definition Type.h:62
ArrayRef< Type * > subtypes() const
Definition Type.h:383
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
Definition Type.h:313
static LLVM_ABI ByteType * getByte32Ty(LLVMContext &C)
Definition Type.cpp:302
LLVM_ABI bool canLosslesslyBitCastTo(Type *Ty) const
Return true if this type could be converted with a lossless BitCast to type 'Ty'.
Definition Type.cpp:157
unsigned getNumContainedTypes() const
Return the number of types in the derived type.
Definition Type.h:405
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
Definition Type.h:167
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
Definition Type.h:108
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Definition Type.cpp:286
bool isFP128Ty() const
Return true if this is 'fp128'.
Definition Type.h:164
LLVM_ABI LLVM_DEPRECATED("Use PointerType::get instead", "PointerType::get") PointerType *getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
bool is16bitFPTy() const
Return true if this is a 16-bit float type.
Definition Type.h:150
LLVM_ABI bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
Definition Type.cpp:255
LLVM_ABI StringRef getTargetExtName() const
static LLVM_ABI Type * getFloatingPointTy(LLVMContext &C, const fltSemantics &S)
Definition Type.cpp:129
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:311
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition Type.h:370
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:195
Type(LLVMContext &C, TypeID tid)
Definition Type.h:95
bool isStructTy() const
True if this is an instance of StructType.
Definition Type.h:278
LLVM_ABI bool isRISCVVectorTupleTy() const
Definition Type.cpp:150
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Definition Type.cpp:201
LLVM_ABI Type * getWithNewBitWidth(unsigned NewBitWidth) const
Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old numb...
bool isByteOrByteVectorTy() const
Return true if this is a byte type or a vector of byte types.
Definition Type.h:248
bool isTargetExtTy() const
Return true if this is a target extension type.
Definition Type.h:205
static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)
Definition Type.cpp:312
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Definition Type.h:328
static LLVM_ABI Type * getPrimitiveType(LLVMContext &C, TypeID IDNumber)
Return a type based on an identifier.
Definition Type.cpp:38
bool isAggregateType() const
Return true if the type is an aggregate type.
Definition Type.h:321
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition Type.h:144
LLVM_ABI Type * getWithNewType(Type *EltTy) const
Given vector type, change the element type, whilst keeping the old number of elements.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition Type.h:130
LLVM_ABI void dump() const
LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
Definition Type.h:115
unsigned getSubclassData() const
Definition Type.h:99
std::reverse_iterator< subtype_iterator > subtype_reverse_iterator
Definition Type.h:387
LLVM_ABI bool isFunctionVarArg() const
static LLVM_ABI Type * getIntFromByteType(Type *)
Returns an integer (vector of integer) type with the same size of a byte of the given byte (vector of...
Definition Type.cpp:321
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition Type.h:158
static LLVM_ABI ByteType * getByte8Ty(LLVMContext &C)
Definition Type.cpp:300
void setSubclassData(unsigned val)
Definition Type.h:101
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Definition Type.cpp:310
friend class LLVMContextImpl
Definition Type.h:93
static LLVM_ABI ByteType * getByte128Ty(LLVMContext &C)
Definition Type.cpp:304
static LLVM_ABI ByteType * getByte1Ty(LLVMContext &C)
Definition Type.cpp:299
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
Definition Type.h:186
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Definition Type.h:287
subtype_iterator subtype_begin() const
Definition Type.h:381
bool isX86_AMXTy() const
Return true if this is X86 AMX.
Definition Type.h:202
static Type * getScalarTy(LLVMContext &C)
Definition Type.h:487
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition Type.h:275
LLVM_ABI unsigned getByteBitWidth() const
LLVM_ABI bool isScalableTy() const
Definition Type.cpp:73
bool isIntOrPtrTy() const
Return true if this is an integer type or a pointer type.
Definition Type.h:272
LLVM_ABI Type * getExtendedType() const
Given scalar/vector integer type, returns a type with elements twice as wide as in the original type.
bool isByteOrByteVectorTy(unsigned BitWidth) const
Return true if this is a byte type or a vector of byte types of the given width.
Definition Type.h:252
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition Type.h:257
TypeID getTypeID() const
Return the type id for the type.
Definition Type.h:138
bool isTokenTy() const
Return true if this is 'token'.
Definition Type.h:236
LLVM_ABI Type * getFunctionParamType(unsigned i) const
subtype_reverse_iterator subtype_rend() const
Definition Type.h:392
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Definition Type.cpp:317
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
Definition Type.cpp:291
static LLVM_ABI Type * getX86_FP80Ty(LLVMContext &C)
Definition Type.cpp:294
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Definition Type.h:227
subtype_reverse_iterator subtype_rbegin() const
Definition Type.h:389
Type * getContainedType(unsigned i) const
This method is used to implement the type iterator (defined at the end of the file).
Definition Type.h:399
subtype_iterator subtype_end() const
Definition Type.h:382
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:290
bool isIEEELikeFPTy() const
Return true if this is a well-behaved IEEE-like type, which has a IEEE compatible layout,...
Definition Type.h:172
LLVM_ABI int getFPMantissaWidth() const
Return the width of the mantissa of this type.
Definition Type.cpp:241
static LLVM_ABI ByteType * getByteNTy(LLVMContext &C, unsigned N)
Definition Type.cpp:306
LLVM_ABI const fltSemantics & getFltSemantics() const
Definition Type.cpp:110
static LLVM_ABI Type * getWasm_FuncrefTy(LLVMContext &C)
Definition Type.cpp:345
static LLVM_ABI ByteType * getByte64Ty(LLVMContext &C)
Definition Type.cpp:303
static LLVM_ABI Type * getBFloatTy(LLVMContext &C)
Definition Type.cpp:289
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
Definition Type.cpp:288
LLVM_ABI unsigned getFunctionNumParams() const
LLVM_ABI bool containsNonLocalTargetExtType() const
Definition Type.cpp:105
LLVM_ABI bool containsNonGlobalTargetExtType() const
Definition Type.cpp:89
bool isVoidTy() const
Return true if this is 'void'.
Definition Type.h:141
LLVM_ABI bool isScalableTargetExtTy() const
Return true if this is a target extension type with a scalable layout.
Definition Type.cpp:123
bool isMetadataTy() const
Return true if this is 'metadata'.
Definition Type.h:233
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
struct LLVMOpaqueType * LLVMTypeRef
Each value in the LLVM IR has a type, an LLVMTypeRef.
Definition Types.h:68
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
Attribute unwrap(LLVMAttributeRef Attr)
Definition Attributes.h:397
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr unsigned BitWidth
LLVMAttributeRef wrap(Attribute Attr)
Definition Attributes.h:392
#define N
static bool doit(const Type &Ty)
Definition Type.h:543