LLVM  4.0.0
Type.h
Go to the documentation of this file.
1 //===-- llvm/Type.h - Classes for handling data types -----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the declaration of the Type class. For more "Type"
11 // stuff, look in DerivedTypes.h.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_IR_TYPE_H
16 #define LLVM_IR_TYPE_H
17 
18 #include "llvm/ADT/APFloat.h"
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/SmallPtrSet.h"
22 #include "llvm/Support/Casting.h"
23 #include "llvm/Support/DataTypes.h"
25 
26 namespace llvm {
27 
28 class PointerType;
29 class IntegerType;
30 class raw_ostream;
31 class Module;
32 class LLVMContext;
33 class LLVMContextImpl;
34 class StringRef;
35 template<class GraphType> struct GraphTraits;
36 
37 /// The instances of the Type class are immutable: once they are created,
38 /// they are never changed. Also note that only one instance of a particular
39 /// type is ever created. Thus seeing if two types are equal is a matter of
40 /// doing a trivial pointer comparison. To enforce that no two equal instances
41 /// are created, Type instances can only be created via static factory methods
42 /// in class Type and in derived classes. Once allocated, Types are never
43 /// free'd.
44 ///
45 class Type {
46 public:
47  //===--------------------------------------------------------------------===//
48  /// Definitions of all of the base types for the Type system. Based on this
49  /// value, you can cast to a class defined in DerivedTypes.h.
50  /// Note: If you add an element to this, you need to add an element to the
51  /// Type::getPrimitiveType function, or else things will break!
52  /// Also update LLVMTypeKind and LLVMGetTypeKind () in the C binding.
53  ///
54  enum TypeID {
55  // PrimitiveTypes - make sure LastPrimitiveTyID stays up to date.
56  VoidTyID = 0, ///< 0: type with no size
57  HalfTyID, ///< 1: 16-bit floating point type
58  FloatTyID, ///< 2: 32-bit floating point type
59  DoubleTyID, ///< 3: 64-bit floating point type
60  X86_FP80TyID, ///< 4: 80-bit floating point type (X87)
61  FP128TyID, ///< 5: 128-bit floating point type (112-bit mantissa)
62  PPC_FP128TyID, ///< 6: 128-bit floating point type (two 64-bits, PowerPC)
63  LabelTyID, ///< 7: Labels
64  MetadataTyID, ///< 8: Metadata
65  X86_MMXTyID, ///< 9: MMX vectors (64 bits, X86 specific)
66  TokenTyID, ///< 10: Tokens
67 
68  // Derived types... see DerivedTypes.h file.
69  // Make sure FirstDerivedTyID stays up to date!
70  IntegerTyID, ///< 11: Arbitrary bit width integers
71  FunctionTyID, ///< 12: Functions
72  StructTyID, ///< 13: Structures
73  ArrayTyID, ///< 14: Arrays
74  PointerTyID, ///< 15: Pointers
75  VectorTyID ///< 16: SIMD 'packed' format, or other vector type
76  };
77 
78 private:
79  /// This refers to the LLVMContext in which this type was uniqued.
80  LLVMContext &Context;
81 
82  TypeID ID : 8; // The current base type of this type.
83  unsigned SubclassData : 24; // Space for subclasses to store data.
84  // Note that this should be synchronized with
85  // MAX_INT_BITS value in IntegerType class.
86 
87 protected:
88  friend class LLVMContextImpl;
89  explicit Type(LLVMContext &C, TypeID tid)
90  : Context(C), ID(tid), SubclassData(0),
91  NumContainedTys(0), ContainedTys(nullptr) {}
92  ~Type() = default;
93 
94  unsigned getSubclassData() const { return SubclassData; }
95 
96  void setSubclassData(unsigned val) {
97  SubclassData = val;
98  // Ensure we don't have any accidental truncation.
99  assert(getSubclassData() == val && "Subclass data too large for field");
100  }
101 
102  /// Keeps track of how many Type*'s there are in the ContainedTys list.
103  unsigned NumContainedTys;
104 
105  /// A pointer to the array of Types contained by this Type. For example, this
106  /// includes the arguments of a function type, the elements of a structure,
107  /// the pointee of a pointer, the element type of an array, etc. This pointer
108  /// may be 0 for types that don't contain other types (Integer, Double,
109  /// Float).
110  Type * const *ContainedTys;
111 
112  static bool isSequentialType(TypeID TyID) {
113  return TyID == ArrayTyID || TyID == VectorTyID;
114  }
115 
116 public:
117  /// Print the current type.
118  /// Omit the type details if \p NoDetails == true.
119  /// E.g., let %st = type { i32, i16 }
120  /// When \p NoDetails is true, we only print %st.
121  /// Put differently, \p NoDetails prints the type as if
122  /// inlined with the operands when printing an instruction.
123  void print(raw_ostream &O, bool IsForDebug = false,
124  bool NoDetails = false) const;
125  void dump() const;
126 
127  /// Return the LLVMContext in which this type was uniqued.
128  LLVMContext &getContext() const { return Context; }
129 
130  //===--------------------------------------------------------------------===//
131  // Accessors for working with types.
132  //
133 
134  /// Return the type id for the type. This will return one of the TypeID enum
135  /// elements defined above.
136  TypeID getTypeID() const { return ID; }
137 
138  /// Return true if this is 'void'.
139  bool isVoidTy() const { return getTypeID() == VoidTyID; }
140 
141  /// Return true if this is 'half', a 16-bit IEEE fp type.
142  bool isHalfTy() const { return getTypeID() == HalfTyID; }
143 
144  /// Return true if this is 'float', a 32-bit IEEE fp type.
145  bool isFloatTy() const { return getTypeID() == FloatTyID; }
146 
147  /// Return true if this is 'double', a 64-bit IEEE fp type.
148  bool isDoubleTy() const { return getTypeID() == DoubleTyID; }
149 
150  /// Return true if this is x86 long double.
151  bool isX86_FP80Ty() const { return getTypeID() == X86_FP80TyID; }
152 
153  /// Return true if this is 'fp128'.
154  bool isFP128Ty() const { return getTypeID() == FP128TyID; }
155 
156  /// Return true if this is powerpc long double.
157  bool isPPC_FP128Ty() const { return getTypeID() == PPC_FP128TyID; }
158 
159  /// Return true if this is one of the six floating-point types
160  bool isFloatingPointTy() const {
161  return getTypeID() == HalfTyID || getTypeID() == FloatTyID ||
162  getTypeID() == DoubleTyID ||
163  getTypeID() == X86_FP80TyID || getTypeID() == FP128TyID ||
165  }
166 
167  const fltSemantics &getFltSemantics() const {
168  switch (getTypeID()) {
169  case HalfTyID: return APFloat::IEEEhalf();
170  case FloatTyID: return APFloat::IEEEsingle();
171  case DoubleTyID: return APFloat::IEEEdouble();
173  case FP128TyID: return APFloat::IEEEquad();
175  default: llvm_unreachable("Invalid floating type");
176  }
177  }
178 
179  /// Return true if this is X86 MMX.
180  bool isX86_MMXTy() const { return getTypeID() == X86_MMXTyID; }
181 
182  /// Return true if this is a FP type or a vector of FP.
183  bool isFPOrFPVectorTy() const { return getScalarType()->isFloatingPointTy(); }
184 
185  /// Return true if this is 'label'.
186  bool isLabelTy() const { return getTypeID() == LabelTyID; }
187 
188  /// Return true if this is 'metadata'.
189  bool isMetadataTy() const { return getTypeID() == MetadataTyID; }
190 
191  /// Return true if this is 'token'.
192  bool isTokenTy() const { return getTypeID() == TokenTyID; }
193 
194  /// True if this is an instance of IntegerType.
195  bool isIntegerTy() const { return getTypeID() == IntegerTyID; }
196 
197  /// Return true if this is an IntegerType of the given width.
198  bool isIntegerTy(unsigned Bitwidth) const;
199 
200  /// Return true if this is an integer type or a vector of integer types.
201  bool isIntOrIntVectorTy() const { return getScalarType()->isIntegerTy(); }
202 
203  /// True if this is an instance of FunctionType.
204  bool isFunctionTy() const { return getTypeID() == FunctionTyID; }
205 
206  /// True if this is an instance of StructType.
207  bool isStructTy() const { return getTypeID() == StructTyID; }
208 
209  /// True if this is an instance of ArrayType.
210  bool isArrayTy() const { return getTypeID() == ArrayTyID; }
211 
212  /// True if this is an instance of PointerType.
213  bool isPointerTy() const { return getTypeID() == PointerTyID; }
214 
215  /// Return true if this is a pointer type or a vector of pointer types.
216  bool isPtrOrPtrVectorTy() const { return getScalarType()->isPointerTy(); }
217 
218  /// True if this is an instance of VectorType.
219  bool isVectorTy() const { return getTypeID() == VectorTyID; }
220 
221  /// Return true if this type could be converted with a lossless BitCast to
222  /// type 'Ty'. For example, i8* to i32*. BitCasts are valid for types of the
223  /// same size only where no re-interpretation of the bits is done.
224  /// @brief Determine if this type could be losslessly bitcast to Ty
225  bool canLosslesslyBitCastTo(Type *Ty) const;
226 
227  /// Return true if this type is empty, that is, it has no elements or all of
228  /// its elements are empty.
229  bool isEmptyTy() const;
230 
231  /// Return true if the type is "first class", meaning it is a valid type for a
232  /// Value.
233  bool isFirstClassType() const {
234  return getTypeID() != FunctionTyID && getTypeID() != VoidTyID;
235  }
236 
237  /// Return true if the type is a valid type for a register in codegen. This
238  /// includes all first-class types except struct and array types.
239  bool isSingleValueType() const {
240  return isFloatingPointTy() || isX86_MMXTy() || isIntegerTy() ||
241  isPointerTy() || isVectorTy();
242  }
243 
244  /// Return true if the type is an aggregate type. This means it is valid as
245  /// the first operand of an insertvalue or extractvalue instruction. This
246  /// includes struct and array types, but does not include vector types.
247  bool isAggregateType() const {
248  return getTypeID() == StructTyID || getTypeID() == ArrayTyID;
249  }
250 
251  /// Return true if it makes sense to take the size of this type. To get the
252  /// actual size for a particular target, it is reasonable to use the
253  /// DataLayout subsystem to do this.
254  bool isSized(SmallPtrSetImpl<Type*> *Visited = nullptr) const {
255  // If it's a primitive, it is always sized.
256  if (getTypeID() == IntegerTyID || isFloatingPointTy() ||
257  getTypeID() == PointerTyID ||
258  getTypeID() == X86_MMXTyID)
259  return true;
260  // If it is not something that can have a size (e.g. a function or label),
261  // it doesn't have a size.
262  if (getTypeID() != StructTyID && getTypeID() != ArrayTyID &&
263  getTypeID() != VectorTyID)
264  return false;
265  // Otherwise we have to try harder to decide.
266  return isSizedDerivedType(Visited);
267  }
268 
269  /// Return the basic size of this type if it is a primitive type. These are
270  /// fixed by LLVM and are not target-dependent.
271  /// This will return zero if the type does not have a size or is not a
272  /// primitive type.
273  ///
274  /// Note that this may not reflect the size of memory allocated for an
275  /// instance of the type or the number of bytes that are written when an
276  /// instance of the type is stored to memory. The DataLayout class provides
277  /// additional query functions to provide this information.
278  ///
280 
281  /// If this is a vector type, return the getPrimitiveSizeInBits value for the
282  /// element type. Otherwise return the getPrimitiveSizeInBits value for this
283  /// type.
285 
286  /// Return the width of the mantissa of this type. This is only valid on
287  /// floating-point types. If the FP type does not have a stable mantissa (e.g.
288  /// ppc long double), this method returns -1.
290 
291  /// If this is a vector type, return the element type, otherwise return
292  /// 'this'.
293  Type *getScalarType() const LLVM_READONLY;
294 
295  //===--------------------------------------------------------------------===//
296  // Type Iteration support.
297  //
298  typedef Type * const *subtype_iterator;
299  subtype_iterator subtype_begin() const { return ContainedTys; }
303  }
304 
305  typedef std::reverse_iterator<subtype_iterator> subtype_reverse_iterator;
308  }
311  }
312 
313  /// This method is used to implement the type iterator (defined at the end of
314  /// the file). For derived types, this returns the types 'contained' in the
315  /// derived type.
316  Type *getContainedType(unsigned i) const {
317  assert(i < NumContainedTys && "Index out of range!");
318  return ContainedTys[i];
319  }
320 
321  /// Return the number of types in the derived type.
322  unsigned getNumContainedTypes() const { return NumContainedTys; }
323 
324  //===--------------------------------------------------------------------===//
325  // Helper methods corresponding to subclass methods. This forces a cast to
326  // the specified subclass and calls its accessor. "getVectorNumElements" (for
327  // example) is shorthand for cast<VectorType>(Ty)->getNumElements(). This is
328  // only intended to cover the core methods that are frequently used, helper
329  // methods should not be added here.
330 
331  inline unsigned getIntegerBitWidth() const;
332 
333  inline Type *getFunctionParamType(unsigned i) const;
334  inline unsigned getFunctionNumParams() const;
335  inline bool isFunctionVarArg() const;
336 
337  inline StringRef getStructName() const;
338  inline unsigned getStructNumElements() const;
339  inline Type *getStructElementType(unsigned N) const;
340 
341  inline Type *getSequentialElementType() const {
342  assert(isSequentialType(getTypeID()) && "Not a sequential type!");
343  return ContainedTys[0];
344  }
345 
346  inline uint64_t getArrayNumElements() const;
348  assert(getTypeID() == ArrayTyID);
349  return ContainedTys[0];
350  }
351 
352  inline unsigned getVectorNumElements() const;
355  return ContainedTys[0];
356  }
357 
360  return ContainedTys[0];
361  }
362 
363  /// Get the address space of this pointer or pointer vector type.
364  inline unsigned getPointerAddressSpace() const;
365 
366  //===--------------------------------------------------------------------===//
367  // Static members exported by the Type class itself. Useful for getting
368  // instances of Type.
369  //
370 
371  /// Return a type based on an identifier.
372  static Type *getPrimitiveType(LLVMContext &C, TypeID IDNumber);
373 
374  //===--------------------------------------------------------------------===//
375  // These are the builtin types that are always available.
376  //
377  static Type *getVoidTy(LLVMContext &C);
378  static Type *getLabelTy(LLVMContext &C);
379  static Type *getHalfTy(LLVMContext &C);
380  static Type *getFloatTy(LLVMContext &C);
381  static Type *getDoubleTy(LLVMContext &C);
382  static Type *getMetadataTy(LLVMContext &C);
383  static Type *getX86_FP80Ty(LLVMContext &C);
384  static Type *getFP128Ty(LLVMContext &C);
385  static Type *getPPC_FP128Ty(LLVMContext &C);
386  static Type *getX86_MMXTy(LLVMContext &C);
387  static Type *getTokenTy(LLVMContext &C);
388  static IntegerType *getIntNTy(LLVMContext &C, unsigned N);
395 
396  //===--------------------------------------------------------------------===//
397  // Convenience methods for getting pointer types with one of the above builtin
398  // types as pointee.
399  //
400  static PointerType *getHalfPtrTy(LLVMContext &C, unsigned AS = 0);
401  static PointerType *getFloatPtrTy(LLVMContext &C, unsigned AS = 0);
402  static PointerType *getDoublePtrTy(LLVMContext &C, unsigned AS = 0);
403  static PointerType *getX86_FP80PtrTy(LLVMContext &C, unsigned AS = 0);
404  static PointerType *getFP128PtrTy(LLVMContext &C, unsigned AS = 0);
405  static PointerType *getPPC_FP128PtrTy(LLVMContext &C, unsigned AS = 0);
406  static PointerType *getX86_MMXPtrTy(LLVMContext &C, unsigned AS = 0);
407  static PointerType *getIntNPtrTy(LLVMContext &C, unsigned N, unsigned AS = 0);
408  static PointerType *getInt1PtrTy(LLVMContext &C, unsigned AS = 0);
409  static PointerType *getInt8PtrTy(LLVMContext &C, unsigned AS = 0);
410  static PointerType *getInt16PtrTy(LLVMContext &C, unsigned AS = 0);
411  static PointerType *getInt32PtrTy(LLVMContext &C, unsigned AS = 0);
412  static PointerType *getInt64PtrTy(LLVMContext &C, unsigned AS = 0);
413 
414  /// Return a pointer to the current type. This is equivalent to
415  /// PointerType::get(Foo, AddrSpace).
416  PointerType *getPointerTo(unsigned AddrSpace = 0) const;
417 
418 private:
419  /// Derived types like structures and arrays are sized iff all of the members
420  /// of the type are sized as well. Since asking for their size is relatively
421  /// uncommon, move this operation out-of-line.
422  bool isSizedDerivedType(SmallPtrSetImpl<Type*> *Visited = nullptr) const;
423 };
424 
425 // Printing of types.
426 static inline raw_ostream &operator<<(raw_ostream &OS, Type &T) {
427  T.print(OS);
428  return OS;
429 }
430 
431 // allow isa<PointerType>(x) to work without DerivedTypes.h included.
432 template <> struct isa_impl<PointerType, Type> {
433  static inline bool doit(const Type &Ty) {
434  return Ty.getTypeID() == Type::PointerTyID;
435  }
436 };
437 
438 //===----------------------------------------------------------------------===//
439 // Provide specializations of GraphTraits to be able to treat a type as a
440 // graph of sub types.
441 
442 template <> struct GraphTraits<Type *> {
443  typedef Type *NodeRef;
445 
446  static NodeRef getEntryNode(Type *T) { return T; }
447  static ChildIteratorType child_begin(NodeRef N) { return N->subtype_begin(); }
448  static ChildIteratorType child_end(NodeRef N) { return N->subtype_end(); }
449 };
450 
451 template <> struct GraphTraits<const Type*> {
452  typedef const Type *NodeRef;
454 
455  static NodeRef getEntryNode(NodeRef T) { return T; }
456  static ChildIteratorType child_begin(NodeRef N) { return N->subtype_begin(); }
457  static ChildIteratorType child_end(NodeRef N) { return N->subtype_end(); }
458 };
459 
460 // Create wrappers for C Binding types (see CBindingWrapping.h).
462 
463 /* Specialized opaque type conversions.
464  */
466  return reinterpret_cast<Type**>(Tys);
467 }
468 
469 inline LLVMTypeRef *wrap(Type **Tys) {
470  return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
471 }
472 
473 } // End llvm namespace
474 
475 #endif
7: Labels
Definition: Type.h:63
static Type * getDoubleTy(LLVMContext &C)
Definition: Type.cpp:158
static IntegerType * getInt1Ty(LLVMContext &C)
Definition: Type.cpp:166
LLVMContext & Context
size_t i
unsigned getStructNumElements() const
Definition: DerivedTypes.h:305
2: 32-bit floating point type
Definition: Type.h:58
Type * getSequentialElementType() const
Definition: Type.h:341
Type::TypeID TypeID
static PointerType * getInt32PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:221
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition: Type.h:148
bool isTokenTy() const
Return true if this is 'token'.
Definition: Type.h:192
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Definition: Type.h:216
int getFPMantissaWidth() const
Return the width of the mantissa of this type.
Definition: Type.cpp:127
13: Structures
Definition: Type.h:72
4: 80-bit floating point type (X87)
Definition: Type.h:60
subtype_reverse_iterator subtype_rend() const
Definition: Type.h:309
1: 16-bit floating point type
Definition: Type.h:57
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:170
static Type * getMetadataTy(LLVMContext &C)
Definition: Type.cpp:159
15: Pointers
Definition: Type.h:74
static IntegerType * getInt16Ty(LLVMContext &C)
Definition: Type.cpp:168
static Type * getX86_MMXTy(LLVMContext &C)
Definition: Type.cpp:164
static PointerType * getX86_MMXPtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:201
12: Functions
Definition: Type.h:71
subtype_iterator subtype_end() const
Definition: Type.h:300
Type * getFunctionParamType(unsigned i) const
Definition: DerivedTypes.h:151
static PointerType * getInt64PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:225
static Type * getX86_FP80Ty(LLVMContext &C)
Definition: Type.cpp:161
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
Definition: Type.h:110
Type * getPointerElementType() const
Definition: Type.h:358
uint64_t getArrayNumElements() const
Definition: DerivedTypes.h:364
static bool isSequentialType(TypeID TyID)
Definition: Type.h:112
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:345
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
Definition: Type.h:239
static Type * getTokenTy(LLVMContext &C)
Definition: Type.cpp:160
static const fltSemantics & x87DoubleExtended()
Definition: APFloat.cpp:109
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:191
static Type * getFloatTy(LLVMContext &C)
Definition: Type.cpp:157
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:440
Type * getArrayElementType() const
Definition: Type.h:347
bool canLosslesslyBitCastTo(Type *Ty) const
Return true if this type could be converted with a lossless BitCast to type 'Ty'. ...
Definition: Type.cpp:54
TypeID
Definitions of all of the base types for the Type system.
Definition: Type.h:54
static PointerType * getInt16PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:217
Type * getVectorElementType() const
Definition: Type.h:353
static Type * getPPC_FP128Ty(LLVMContext &C)
Definition: Type.cpp:163
#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref)
struct LLVMOpaqueType * LLVMTypeRef
Each value in the LLVM IR has a type, an LLVMTypeRef.
Definition: c/Types.h:69
static Type * getLabelTy(LLVMContext &C)
Definition: Type.cpp:155
Type * getStructElementType(unsigned N) const
Definition: DerivedTypes.h:309
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition: Type.h:142
#define T
static bool doit(const Type &Ty)
Definition: Type.h:433
~Type()=default
static PointerType * getDoublePtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:185
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value. ...
Definition: Type.h:233
void dump() const
Definition: AsmWriter.cpp:3544
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
TypeID getTypeID() const
Return the type id for the type.
Definition: Type.h:136
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
Definition: Type.h:160
bool isArrayTy() const
True if this is an instance of ArrayType.
Definition: Type.h:210
unsigned getSubclassData() const
Definition: Type.h:94
Type(LLVMContext &C, TypeID tid)
Definition: Type.h:89
Type * getScalarType() const LLVM_READONLY
If this is a vector type, return the element type, otherwise return 'this'.
Definition: Type.cpp:44
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
Definition: Type.h:157
Class to represent pointers.
Definition: DerivedTypes.h:443
static const fltSemantics & IEEEsingle()
Definition: APFloat.cpp:100
11: Arbitrary bit width integers
Definition: Type.h:70
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Definition: Type.h:254
static ChildIteratorType child_end(NodeRef N)
Definition: Type.h:457
static ChildIteratorType child_begin(NodeRef N)
Definition: Type.h:456
0: type with no size
Definition: Type.h:56
bool isX86_MMXTy() const
Return true if this is X86 MMX.
Definition: Type.h:180
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition: Type.h:201
static IntegerType * getInt128Ty(LLVMContext &C)
Definition: Type.cpp:171
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:48
bool isVectorTy() const
True if this is an instance of VectorType.
Definition: Type.h:219
Type * getContainedType(unsigned i) const
This method is used to implement the type iterator (defined at the end of the file).
Definition: Type.h:316
static NodeRef getEntryNode(Type *T)
Definition: Type.h:446
10: Tokens
Definition: Type.h:66
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition: Type.h:145
static const fltSemantics & IEEEhalf()
Definition: APFloat.cpp:97
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:154
void print(raw_ostream &O, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
Definition: AsmWriter.cpp:3368
6: 128-bit floating point type (two 64-bits, PowerPC)
Definition: Type.h:62
bool isFunctionVarArg() const
Definition: DerivedTypes.h:147
unsigned getIntegerBitWidth() const
Definition: DerivedTypes.h:96
Class to represent integer types.
Definition: DerivedTypes.h:39
Type::subtype_iterator ChildIteratorType
Definition: Type.h:444
static PointerType * getPPC_FP128PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:197
Type::subtype_iterator ChildIteratorType
Definition: Type.h:453
unsigned getNumContainedTypes() const
Return the number of types in the derived type.
Definition: Type.h:322
bool isFP128Ty() const
Return true if this is 'fp128'.
Definition: Type.h:154
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:213
static const fltSemantics & IEEEquad()
Definition: APFloat.cpp:106
static PointerType * getFloatPtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:181
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Definition: Type.h:183
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:213
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static Type * getFP128Ty(LLVMContext &C)
Definition: Type.cpp:162
static PointerType * getX86_FP80PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:189
14: Arrays
Definition: Type.h:73
static Type * getHalfTy(LLVMContext &C)
Definition: Type.cpp:156
static PointerType * getInt1PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:209
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:204
static ChildIteratorType child_end(NodeRef N)
Definition: Type.h:448
16: SIMD 'packed' format, or other vector type
Definition: Type.h:75
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
Definition: Type.cpp:123
Type *const * subtype_iterator
Definition: Type.h:298
always inline
StringRef getStructName() const
Definition: DerivedTypes.h:301
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Definition: Type.cpp:173
static PointerType * getHalfPtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:177
static Type * getPrimitiveType(LLVMContext &C, TypeID IDNumber)
Return a type based on an identifier.
Definition: Type.cpp:26
const fltSemantics & getFltSemantics() const
Definition: Type.h:167
static PointerType * getFP128PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:193
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
8: Metadata
Definition: Type.h:64
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:195
unsigned getVectorNumElements() const
Definition: DerivedTypes.h:438
static const fltSemantics & IEEEdouble()
Definition: APFloat.cpp:103
bool isStructTy() const
True if this is an instance of StructType.
Definition: Type.h:207
unsigned getFunctionNumParams() const
Definition: DerivedTypes.h:155
bool isX86_FP80Ty() const
Return true if this is x86 long double.
Definition: Type.h:151
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:186
bool isAggregateType() const
Return true if the type is an aggregate type.
Definition: Type.h:247
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:169
static ChildIteratorType child_begin(NodeRef N)
Definition: Type.h:447
#define N
static const fltSemantics & PPCDoubleDouble()
Definition: APFloat.cpp:115
#define LLVM_READONLY
Definition: Compiler.h:174
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:1726
static PointerType * getIntNPtrTy(LLVMContext &C, unsigned N, unsigned AS=0)
Definition: Type.cpp:205
3: 64-bit floating point type
Definition: Type.h:59
void setSubclassData(unsigned val)
Definition: Type.h:96
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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:91
aarch64 promote const
static NodeRef getEntryNode(NodeRef T)
Definition: Type.h:455
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Definition: Type.cpp:108
bool isLabelTy() const
Return true if this is 'label'.
Definition: Type.h:186
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
std::reverse_iterator< subtype_iterator > subtype_reverse_iterator
Definition: Type.h:305
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
Definition: Type.cpp:678
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
9: MMX vectors (64 bits, X86 specific)
Definition: Type.h:65
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition: DerivedTypes.h:479
subtype_reverse_iterator subtype_rbegin() const
Definition: Type.h:306
static IntegerType * getInt8Ty(LLVMContext &C)
Definition: Type.cpp:167
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
Definition: Type.h:103
subtype_iterator subtype_begin() const
Definition: Type.h:299
ArrayRef< Type * > subtypes() const
Definition: Type.h:301
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:139
5: 128-bit floating point type (112-bit mantissa)
Definition: Type.h:61
bool isMetadataTy() const
Return true if this is 'metadata'.
Definition: Type.h:189