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