LLVM  9.0.0svn
DerivedTypes.h
Go to the documentation of this file.
1 //===- llvm/DerivedTypes.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 declarations of classes that represent "derived
10 // types". These are things like "arrays of x" or "structure of x, y, z" or
11 // "function returning x taking (y,z) as parameters", etc...
12 //
13 // The implementations of these classes live in the Type.cpp file.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_IR_DERIVEDTYPES_H
18 #define LLVM_IR_DERIVEDTYPES_H
19 
20 #include "llvm/ADT/ArrayRef.h"
21 #include "llvm/ADT/STLExtras.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/IR/Type.h"
24 #include "llvm/Support/Casting.h"
25 #include "llvm/Support/Compiler.h"
26 #include <cassert>
27 #include <cstdint>
28 
29 namespace llvm {
30 
31 class Value;
32 class APInt;
33 class LLVMContext;
34 
35 /// Class to represent integer types. Note that this class is also used to
36 /// represent the built-in integer types: Int1Ty, Int8Ty, Int16Ty, Int32Ty and
37 /// Int64Ty.
38 /// Integer representation type
39 class IntegerType : public Type {
40  friend class LLVMContextImpl;
41 
42 protected:
43  explicit IntegerType(LLVMContext &C, unsigned NumBits) : Type(C, IntegerTyID){
44  setSubclassData(NumBits);
45  }
46 
47 public:
48  /// This enum is just used to hold constants we need for IntegerType.
49  enum {
50  MIN_INT_BITS = 1, ///< Minimum number of bits that can be specified
51  MAX_INT_BITS = (1<<24)-1 ///< Maximum number of bits that can be specified
52  ///< Note that bit width is stored in the Type classes SubclassData field
53  ///< which has 24 bits. This yields a maximum bit width of 16,777,215
54  ///< bits.
55  };
56 
57  /// This static method is the primary way of constructing an IntegerType.
58  /// If an IntegerType with the same NumBits value was previously instantiated,
59  /// that instance will be returned. Otherwise a new one will be created. Only
60  /// one instance with a given NumBits value is ever created.
61  /// Get or create an IntegerType instance.
62  static IntegerType *get(LLVMContext &C, unsigned NumBits);
63 
64  /// Get the number of bits in this IntegerType
65  unsigned getBitWidth() const { return getSubclassData(); }
66 
67  /// Return a bitmask with ones set for all of the bits that can be set by an
68  /// unsigned version of this type. This is 0xFF for i8, 0xFFFF for i16, etc.
69  uint64_t getBitMask() const {
70  return ~uint64_t(0UL) >> (64-getBitWidth());
71  }
72 
73  /// Return a uint64_t with just the most significant bit set (the sign bit, if
74  /// the value is treated as a signed number).
75  uint64_t getSignBit() const {
76  return 1ULL << (getBitWidth()-1);
77  }
78 
79  /// For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
80  /// @returns a bit mask with ones set for all the bits of this type.
81  /// Get a bit mask for this type.
82  APInt getMask() const;
83 
84  /// This method determines if the width of this IntegerType is a power-of-2
85  /// in terms of 8 bit bytes.
86  /// @returns true if this is a power-of-2 byte width.
87  /// Is this a power-of-2 byte-width IntegerType ?
88  bool isPowerOf2ByteWidth() const;
89 
90  /// Methods for support type inquiry through isa, cast, and dyn_cast.
91  static bool classof(const Type *T) {
92  return T->getTypeID() == IntegerTyID;
93  }
94 };
95 
96 unsigned Type::getIntegerBitWidth() const {
97  return cast<IntegerType>(this)->getBitWidth();
98 }
99 
100 /// Class to represent function types
101 ///
102 class FunctionType : public Type {
103  FunctionType(Type *Result, ArrayRef<Type*> Params, bool IsVarArgs);
104 
105 public:
106  FunctionType(const FunctionType &) = delete;
107  FunctionType &operator=(const FunctionType &) = delete;
108 
109  /// This static method is the primary way of constructing a FunctionType.
110  static FunctionType *get(Type *Result,
111  ArrayRef<Type*> Params, bool isVarArg);
112 
113  /// Create a FunctionType taking no parameters.
114  static FunctionType *get(Type *Result, bool isVarArg);
115 
116  /// Return true if the specified type is valid as a return type.
117  static bool isValidReturnType(Type *RetTy);
118 
119  /// Return true if the specified type is valid as an argument type.
120  static bool isValidArgumentType(Type *ArgTy);
121 
122  bool isVarArg() const { return getSubclassData()!=0; }
123  Type *getReturnType() const { return ContainedTys[0]; }
124 
126 
127  param_iterator param_begin() const { return ContainedTys + 1; }
130  return makeArrayRef(param_begin(), param_end());
131  }
132 
133  /// Parameter type accessors.
134  Type *getParamType(unsigned i) const { return ContainedTys[i+1]; }
135 
136  /// Return the number of fixed parameters this function type requires.
137  /// This does not consider varargs.
138  unsigned getNumParams() const { return NumContainedTys - 1; }
139 
140  /// Methods for support type inquiry through isa, cast, and dyn_cast.
141  static bool classof(const Type *T) {
142  return T->getTypeID() == FunctionTyID;
143  }
144 };
145 static_assert(alignof(FunctionType) >= alignof(Type *),
146  "Alignment sufficient for objects appended to FunctionType");
147 
149  return cast<FunctionType>(this)->isVarArg();
150 }
151 
152 Type *Type::getFunctionParamType(unsigned i) const {
153  return cast<FunctionType>(this)->getParamType(i);
154 }
155 
156 unsigned Type::getFunctionNumParams() const {
157  return cast<FunctionType>(this)->getNumParams();
158 }
159 
160 /// A handy container for a FunctionType+Callee-pointer pair, which can be
161 /// passed around as a single entity. This assists in replacing the use of
162 /// PointerType::getElementType() to access the function's type, since that's
163 /// slated for removal as part of the [opaque pointer types] project.
165 public:
166  // Allow implicit conversion from types which have a getFunctionType member
167  // (e.g. Function and InlineAsm).
168  template <typename T, typename U = decltype(&T::getFunctionType)>
170  : FnTy(Fn ? Fn->getFunctionType() : nullptr), Callee(Fn) {}
171 
173  : FnTy(FnTy), Callee(Callee) {
174  assert((FnTy == nullptr) == (Callee == nullptr));
175  }
176 
177  FunctionCallee(std::nullptr_t) {}
178 
179  FunctionCallee() = default;
180 
181  FunctionType *getFunctionType() { return FnTy; }
182 
183  Value *getCallee() { return Callee; }
184 
185  explicit operator bool() { return Callee; }
186 
187 private:
188  FunctionType *FnTy = nullptr;
189  Value *Callee = nullptr;
190 };
191 
192 /// Common super class of ArrayType, StructType and VectorType.
193 class CompositeType : public Type {
194 protected:
195  explicit CompositeType(LLVMContext &C, TypeID tid) : Type(C, tid) {}
196 
197 public:
198  /// Given an index value into the type, return the type of the element.
199  Type *getTypeAtIndex(const Value *V) const;
200  Type *getTypeAtIndex(unsigned Idx) const;
201  bool indexValid(const Value *V) const;
202  bool indexValid(unsigned Idx) const;
203 
204  /// Methods for support type inquiry through isa, cast, and dyn_cast.
205  static bool classof(const Type *T) {
206  return T->getTypeID() == ArrayTyID ||
207  T->getTypeID() == StructTyID ||
208  T->getTypeID() == VectorTyID;
209  }
210 };
211 
212 /// Class to represent struct types. There are two different kinds of struct
213 /// types: Literal structs and Identified structs.
214 ///
215 /// Literal struct types (e.g. { i32, i32 }) are uniqued structurally, and must
216 /// always have a body when created. You can get one of these by using one of
217 /// the StructType::get() forms.
218 ///
219 /// Identified structs (e.g. %foo or %42) may optionally have a name and are not
220 /// uniqued. The names for identified structs are managed at the LLVMContext
221 /// level, so there can only be a single identified struct with a given name in
222 /// a particular LLVMContext. Identified structs may also optionally be opaque
223 /// (have no body specified). You get one of these by using one of the
224 /// StructType::create() forms.
225 ///
226 /// Independent of what kind of struct you have, the body of a struct type are
227 /// laid out in memory consecutively with the elements directly one after the
228 /// other (if the struct is packed) or (if not packed) with padding between the
229 /// elements as defined by DataLayout (which is required to match what the code
230 /// generator for a target expects).
231 ///
232 class StructType : public CompositeType {
234 
235  enum {
236  /// This is the contents of the SubClassData field.
237  SCDB_HasBody = 1,
238  SCDB_Packed = 2,
239  SCDB_IsLiteral = 4,
240  SCDB_IsSized = 8
241  };
242 
243  /// For a named struct that actually has a name, this is a pointer to the
244  /// symbol table entry (maintained by LLVMContext) for the struct.
245  /// This is null if the type is an literal struct or if it is a identified
246  /// type that has an empty name.
247  void *SymbolTableEntry = nullptr;
248 
249 public:
250  StructType(const StructType &) = delete;
251  StructType &operator=(const StructType &) = delete;
252 
253  /// This creates an identified struct.
254  static StructType *create(LLVMContext &Context, StringRef Name);
255  static StructType *create(LLVMContext &Context);
256 
257  static StructType *create(ArrayRef<Type *> Elements, StringRef Name,
258  bool isPacked = false);
259  static StructType *create(ArrayRef<Type *> Elements);
260  static StructType *create(LLVMContext &Context, ArrayRef<Type *> Elements,
261  StringRef Name, bool isPacked = false);
262  static StructType *create(LLVMContext &Context, ArrayRef<Type *> Elements);
263  template <class... Tys>
264  static typename std::enable_if<are_base_of<Type, Tys...>::value,
266  create(StringRef Name, Type *elt1, Tys *... elts) {
267  assert(elt1 && "Cannot create a struct type with no elements with this");
268  SmallVector<llvm::Type *, 8> StructFields({elt1, elts...});
269  return create(StructFields, Name);
270  }
271 
272  /// This static method is the primary way to create a literal StructType.
273  static StructType *get(LLVMContext &Context, ArrayRef<Type*> Elements,
274  bool isPacked = false);
275 
276  /// Create an empty structure type.
277  static StructType *get(LLVMContext &Context, bool isPacked = false);
278 
279  /// This static method is a convenience method for creating structure types by
280  /// specifying the elements as arguments. Note that this method always returns
281  /// a non-packed struct, and requires at least one element type.
282  template <class... Tys>
283  static typename std::enable_if<are_base_of<Type, Tys...>::value,
285  get(Type *elt1, Tys *... elts) {
286  assert(elt1 && "Cannot create a struct type with no elements with this");
287  LLVMContext &Ctx = elt1->getContext();
288  SmallVector<llvm::Type *, 8> StructFields({elt1, elts...});
289  return llvm::StructType::get(Ctx, StructFields);
290  }
291 
292  bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; }
293 
294  /// Return true if this type is uniqued by structural equivalence, false if it
295  /// is a struct definition.
296  bool isLiteral() const { return (getSubclassData() & SCDB_IsLiteral) != 0; }
297 
298  /// Return true if this is a type with an identity that has no body specified
299  /// yet. These prints as 'opaque' in .ll files.
300  bool isOpaque() const { return (getSubclassData() & SCDB_HasBody) == 0; }
301 
302  /// isSized - Return true if this is a sized type.
303  bool isSized(SmallPtrSetImpl<Type *> *Visited = nullptr) const;
304 
305  /// Return true if this is a named struct that has a non-empty name.
306  bool hasName() const { return SymbolTableEntry != nullptr; }
307 
308  /// Return the name for this struct type if it has an identity.
309  /// This may return an empty string for an unnamed struct type. Do not call
310  /// this on an literal type.
311  StringRef getName() const;
312 
313  /// Change the name of this type to the specified name, or to a name with a
314  /// suffix if there is a collision. Do not call this on an literal type.
315  void setName(StringRef Name);
316 
317  /// Specify a body for an opaque identified type.
318  void setBody(ArrayRef<Type*> Elements, bool isPacked = false);
319 
320  template <typename... Tys>
321  typename std::enable_if<are_base_of<Type, Tys...>::value, void>::type
322  setBody(Type *elt1, Tys *... elts) {
323  assert(elt1 && "Cannot create a struct type with no elements with this");
324  SmallVector<llvm::Type *, 8> StructFields({elt1, elts...});
325  setBody(StructFields);
326  }
327 
328  /// Return true if the specified type is valid as a element type.
329  static bool isValidElementType(Type *ElemTy);
330 
331  // Iterator access to the elements.
333 
336  ArrayRef<Type *> const elements() const {
337  return makeArrayRef(element_begin(), element_end());
338  }
339 
340  /// Return true if this is layout identical to the specified struct.
341  bool isLayoutIdentical(StructType *Other) const;
342 
343  /// Random access to the elements
344  unsigned getNumElements() const { return NumContainedTys; }
345  Type *getElementType(unsigned N) const {
346  assert(N < NumContainedTys && "Element number out of range!");
347  return ContainedTys[N];
348  }
349 
350  /// Methods for support type inquiry through isa, cast, and dyn_cast.
351  static bool classof(const Type *T) {
352  return T->getTypeID() == StructTyID;
353  }
354 };
355 
357  return cast<StructType>(this)->getName();
358 }
359 
360 unsigned Type::getStructNumElements() const {
361  return cast<StructType>(this)->getNumElements();
362 }
363 
365  return cast<StructType>(this)->getElementType(N);
366 }
367 
368 /// This is the superclass of the array and vector type classes. Both of these
369 /// represent "arrays" in memory. The array type represents a specifically sized
370 /// array, and the vector type represents a specifically sized array that allows
371 /// for use of SIMD instructions. SequentialType holds the common features of
372 /// both, which stem from the fact that both lay their components out in memory
373 /// identically.
375  Type *ContainedType; ///< Storage for the single contained type.
376  uint64_t NumElements;
377 
378 protected:
379  SequentialType(TypeID TID, Type *ElType, uint64_t NumElements)
380  : CompositeType(ElType->getContext(), TID), ContainedType(ElType),
381  NumElements(NumElements) {
382  ContainedTys = &ContainedType;
383  NumContainedTys = 1;
384  }
385 
386 public:
387  SequentialType(const SequentialType &) = delete;
388  SequentialType &operator=(const SequentialType &) = delete;
389 
390  uint64_t getNumElements() const { return NumElements; }
391  Type *getElementType() const { return ContainedType; }
392 
393  /// Methods for support type inquiry through isa, cast, and dyn_cast.
394  static bool classof(const Type *T) {
395  return T->getTypeID() == ArrayTyID || T->getTypeID() == VectorTyID;
396  }
397 };
398 
399 /// Class to represent array types.
400 class ArrayType : public SequentialType {
401  ArrayType(Type *ElType, uint64_t NumEl);
402 
403 public:
404  ArrayType(const ArrayType &) = delete;
405  ArrayType &operator=(const ArrayType &) = delete;
406 
407  /// This static method is the primary way to construct an ArrayType
408  static ArrayType *get(Type *ElementType, uint64_t NumElements);
409 
410  /// Return true if the specified type is valid as a element type.
411  static bool isValidElementType(Type *ElemTy);
412 
413  /// Methods for support type inquiry through isa, cast, and dyn_cast.
414  static bool classof(const Type *T) {
415  return T->getTypeID() == ArrayTyID;
416  }
417 };
418 
419 uint64_t Type::getArrayNumElements() const {
420  return cast<ArrayType>(this)->getNumElements();
421 }
422 
423 /// Class to represent vector types.
424 class VectorType : public SequentialType {
425  VectorType(Type *ElType, unsigned NumEl);
426 
427 public:
428  VectorType(const VectorType &) = delete;
429  VectorType &operator=(const VectorType &) = delete;
430 
431  /// This static method is the primary way to construct an VectorType.
432  static VectorType *get(Type *ElementType, unsigned NumElements);
433 
434  /// This static method gets a VectorType with the same number of elements as
435  /// the input type, and the element type is an integer type of the same width
436  /// as the input element type.
438  unsigned EltBits = VTy->getElementType()->getPrimitiveSizeInBits();
439  assert(EltBits && "Element size must be of a non-zero size");
440  Type *EltTy = IntegerType::get(VTy->getContext(), EltBits);
441  return VectorType::get(EltTy, VTy->getNumElements());
442  }
443 
444  /// This static method is like getInteger except that the element types are
445  /// twice as wide as the elements in the input type.
447  unsigned EltBits = VTy->getElementType()->getPrimitiveSizeInBits();
448  Type *EltTy = IntegerType::get(VTy->getContext(), EltBits * 2);
449  return VectorType::get(EltTy, VTy->getNumElements());
450  }
451 
452  /// This static method is like getInteger except that the element types are
453  /// half as wide as the elements in the input type.
455  unsigned EltBits = VTy->getElementType()->getPrimitiveSizeInBits();
456  assert((EltBits & 1) == 0 &&
457  "Cannot truncate vector element with odd bit-width");
458  Type *EltTy = IntegerType::get(VTy->getContext(), EltBits / 2);
459  return VectorType::get(EltTy, VTy->getNumElements());
460  }
461 
462  /// This static method returns a VectorType with half as many elements as the
463  /// input type and the same element type.
465  unsigned NumElts = VTy->getNumElements();
466  assert ((NumElts & 1) == 0 &&
467  "Cannot halve vector with odd number of elements.");
468  return VectorType::get(VTy->getElementType(), NumElts/2);
469  }
470 
471  /// This static method returns a VectorType with twice as many elements as the
472  /// input type and the same element type.
474  unsigned NumElts = VTy->getNumElements();
475  return VectorType::get(VTy->getElementType(), NumElts*2);
476  }
477 
478  /// Return true if the specified type is valid as a element type.
479  static bool isValidElementType(Type *ElemTy);
480 
481  /// Return the number of bits in the Vector type.
482  /// Returns zero when the vector is a vector of pointers.
483  unsigned getBitWidth() const {
484  return getNumElements() * getElementType()->getPrimitiveSizeInBits();
485  }
486 
487  /// Methods for support type inquiry through isa, cast, and dyn_cast.
488  static bool classof(const Type *T) {
489  return T->getTypeID() == VectorTyID;
490  }
491 };
492 
493 unsigned Type::getVectorNumElements() const {
494  return cast<VectorType>(this)->getNumElements();
495 }
496 
497 /// Class to represent pointers.
498 class PointerType : public Type {
499  explicit PointerType(Type *ElType, unsigned AddrSpace);
500 
501  Type *PointeeTy;
502 
503 public:
504  PointerType(const PointerType &) = delete;
505  PointerType &operator=(const PointerType &) = delete;
506 
507  /// This constructs a pointer to an object of the specified type in a numbered
508  /// address space.
509  static PointerType *get(Type *ElementType, unsigned AddressSpace);
510 
511  /// This constructs a pointer to an object of the specified type in the
512  /// generic address space (address space zero).
513  static PointerType *getUnqual(Type *ElementType) {
514  return PointerType::get(ElementType, 0);
515  }
516 
517  Type *getElementType() const { return PointeeTy; }
518 
519  /// Return true if the specified type is valid as a element type.
520  static bool isValidElementType(Type *ElemTy);
521 
522  /// Return true if we can load or store from a pointer to this type.
523  static bool isLoadableOrStorableType(Type *ElemTy);
524 
525  /// Return the address space of the Pointer type.
526  inline unsigned getAddressSpace() const { return getSubclassData(); }
527 
528  /// Implement support type inquiry through isa, cast, and dyn_cast.
529  static bool classof(const Type *T) {
530  return T->getTypeID() == PointerTyID;
531  }
532 };
533 
535  return cast<PointerType>(getScalarType())->getAddressSpace();
536 }
537 
538 } // end namespace llvm
539 
540 #endif // LLVM_IR_DERIVEDTYPES_H
uint64_t CallInst * C
FunctionCallee(std::nullptr_t)
Definition: DerivedTypes.h:177
CompositeType(LLVMContext &C, TypeID tid)
Definition: DerivedTypes.h:195
LLVMContext & Context
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Type * getParamType(unsigned i) const
Parameter type accessors.
Definition: DerivedTypes.h:134
Type * getElementType(unsigned N) const
Definition: DerivedTypes.h:345
unsigned getFunctionNumParams() const
Definition: DerivedTypes.h:156
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Definition: Type.h:264
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
ArrayRef< Type * > const elements() const
Definition: DerivedTypes.h:336
Maximum number of bits that can be specified.
Definition: DerivedTypes.h:51
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition: DerivedTypes.h:164
unsigned getNumElements() const
Random access to the elements.
Definition: DerivedTypes.h:344
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition: DerivedTypes.h:414
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
Definition: Type.cpp:629
13: Structures
Definition: Type.h:72
Type * getStructElementType(unsigned N) const
Definition: DerivedTypes.h:364
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition: DerivedTypes.h:534
param_iterator param_end() const
Definition: DerivedTypes.h:128
bool isOpaque() const
Return true if this is a type with an identity that has no body specified yet.
Definition: DerivedTypes.h:300
SequentialType(TypeID TID, Type *ElType, uint64_t NumElements)
Definition: DerivedTypes.h:379
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition: DerivedTypes.h:141
15: Pointers
Definition: Type.h:74
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are half as wide as the elements ...
Definition: DerivedTypes.h:454
12: Functions
Definition: Type.h:71
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
Definition: Type.h:110
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:129
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:343
unsigned getBitWidth() const
Return the number of bits in the Vector type.
Definition: DerivedTypes.h:483
APInt getMask() const
For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
Definition: Type.cpp:268
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:450
TypeID getTypeID() const
Return the type id for the type.
Definition: Type.h:137
uint64_t getArrayNumElements() const
Definition: DerivedTypes.h:419
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition: DerivedTypes.h:488
Class to represent struct types.
Definition: DerivedTypes.h:232
static StringRef getName(Value *V)
TypeID
Definitions of all of the base types for the Type system.
Definition: Type.h:54
Type * getFunctionParamType(unsigned i) const
Definition: DerivedTypes.h:152
uint64_t getNumElements() const
Definition: DerivedTypes.h:390
static StructType * get(LLVMContext &Context, ArrayRef< Type *> Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Definition: Type.cpp:341
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:838
Class to represent function types.
Definition: DerivedTypes.h:102
Class to represent array types.
Definition: DerivedTypes.h:400
bool isVarArg() const
Definition: DerivedTypes.h:122
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
uint64_t getBitMask() const
Return a bitmask with ones set for all of the bits that can be set by an unsigned version of this typ...
Definition: DerivedTypes.h:69
Type(LLVMContext &C, TypeID tid)
Definition: Type.h:90
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Definition: DerivedTypes.h:65
Type *const * subtype_iterator
Definition: Type.h:312
Type::subtype_iterator element_iterator
Definition: DerivedTypes.h:332
Class to represent pointers.
Definition: DerivedTypes.h:498
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return &#39;this&#39;.
Definition: Type.h:303
11: Arbitrary bit width integers
Definition: Type.h:70
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
Definition: DerivedTypes.h:464
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:64
static std::enable_if< are_base_of< Type, Tys... >::value, StructType * >::type create(StringRef Name, Type *elt1, Tys *... elts)
Definition: DerivedTypes.h:266
FunctionCallee(FunctionType *FnTy, Value *Callee)
Definition: DerivedTypes.h:172
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Definition: DerivedTypes.h:138
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition: DerivedTypes.h:205
element_iterator element_end() const
Definition: DerivedTypes.h:335
ArrayRef< Type * > params() const
Definition: DerivedTypes.h:129
param_iterator param_begin() const
Definition: DerivedTypes.h:127
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type...
Definition: DerivedTypes.h:437
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition: DerivedTypes.h:394
unsigned getStructNumElements() const
Definition: DerivedTypes.h:360
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:526
Class to represent integer types.
Definition: DerivedTypes.h:39
static VectorType * getDoubleElementsVectorType(VectorType *VTy)
This static method returns a VectorType with twice as many elements as the input type and the same el...
Definition: DerivedTypes.h:473
bool isFunctionVarArg() const
Definition: DerivedTypes.h:148
14: Arrays
Definition: Type.h:73
This is the superclass of the array and vector type classes.
Definition: DerivedTypes.h:374
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:239
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
Definition: DerivedTypes.h:513
16: SIMD &#39;packed&#39; format, or other vector type
Definition: Type.h:75
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:841
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition: DerivedTypes.h:351
Type::subtype_iterator param_iterator
Definition: DerivedTypes.h:125
AddressSpace
Definition: NVPTXBaseInfo.h:21
Type * getReturnType() const
Definition: DerivedTypes.h:123
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
Definition: DerivedTypes.h:446
unsigned getVectorNumElements() const
Definition: DerivedTypes.h:493
Symbol info for RuntimeDyld.
bool isLiteral() const
Return true if this type is uniqued by structural equivalence, false if it is a struct definition...
Definition: DerivedTypes.h:296
Class to represent vector types.
Definition: DerivedTypes.h:424
Class for arbitrary precision integers.
Definition: APInt.h:69
amdgpu Simplify well known AMD library false FunctionCallee Callee
element_iterator element_begin() const
Definition: DerivedTypes.h:334
Common super class of ArrayType, StructType and VectorType.
Definition: DerivedTypes.h:193
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition: DerivedTypes.h:91
std::enable_if< are_base_of< Type, Tys... >::value, void >::type setBody(Type *elt1, Tys *... elts)
Definition: DerivedTypes.h:322
unsigned getSubclassData() const
Definition: Type.h:94
bool isPowerOf2ByteWidth() const
This method determines if the width of this IntegerType is a power-of-2 in terms of 8 bit bytes...
Definition: Type.cpp:263
bool isPacked() const
Definition: DerivedTypes.h:292
unsigned getIntegerBitWidth() const
Definition: DerivedTypes.h:96
#define N
static bool isValidElementType(Type *Ty)
Predicate for the element types that the SLP vectorizer supports.
Minimum number of bits that can be specified.
Definition: DerivedTypes.h:50
FunctionType * getFunctionType()
Definition: DerivedTypes.h:181
uint64_t getSignBit() const
Return a uint64_t with just the most significant bit set (the sign bit, if the value is treated as a ...
Definition: DerivedTypes.h:75
static bool classof(const Type *T)
Implement support type inquiry through isa, cast, and dyn_cast.
Definition: DerivedTypes.h:529
IntegerType(LLVMContext &C, unsigned NumBits)
Definition: DerivedTypes.h:43
void setSubclassData(unsigned val)
Definition: Type.h:96
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
traits class for checking whether type T is a base class for all the given types in the variadic list...
Definition: STLExtras.h:1027
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Definition: Type.cpp:114
LLVM Value Representation.
Definition: Value.h:72
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:605
Type * getElementType() const
Definition: DerivedTypes.h:391
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
bool hasName() const
Return true if this is a named struct that has a non-empty name.
Definition: DerivedTypes.h:306
Type * getElementType() const
Definition: DerivedTypes.h:517
unsigned NumContainedTys
Keeps track of how many Type*&#39;s there are in the ContainedTys list.
Definition: Type.h:103
StringRef getStructName() const
Definition: DerivedTypes.h:356