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