LLVM  6.0.0svn
DataLayout.h
Go to the documentation of this file.
1 //===- llvm/DataLayout.h - Data size & alignment info -----------*- 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 defines layout properties related to datatype size/offset/alignment
11 // information. It uses lazy annotations to cache information about how
12 // structure types are laid out and used.
13 //
14 // This structure should be created once, filled in if the defaults are not
15 // correct and then passed around by const&. None of the members functions
16 // require modification to the object.
17 //
18 //===----------------------------------------------------------------------===//
19 
20 #ifndef LLVM_IR_DATALAYOUT_H
21 #define LLVM_IR_DATALAYOUT_H
22 
23 #include "llvm/ADT/ArrayRef.h"
24 #include "llvm/ADT/STLExtras.h"
25 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/StringRef.h"
27 #include "llvm/IR/DerivedTypes.h"
28 #include "llvm/IR/Type.h"
29 #include "llvm/Pass.h"
30 #include "llvm/Support/Casting.h"
33 #include <cassert>
34 #include <cstdint>
35 #include <string>
36 
37 // This needs to be outside of the namespace, to avoid conflict with llvm-c
38 // decl.
39 using LLVMTargetDataRef = struct LLVMOpaqueTargetData *;
40 
41 namespace llvm {
42 
43 class GlobalVariable;
44 class LLVMContext;
45 class Module;
46 class StructLayout;
47 class Triple;
48 class Value;
49 
50 /// Enum used to categorize the alignment types stored by LayoutAlignElem
54  VECTOR_ALIGN = 'v',
55  FLOAT_ALIGN = 'f',
57 };
58 
59 // FIXME: Currently the DataLayout string carries a "preferred alignment"
60 // for types. As the DataLayout is module/global, this should likely be
61 // sunk down to an FTTI element that is queried rather than a global
62 // preference.
63 
64 /// \brief Layout alignment element.
65 ///
66 /// Stores the alignment data associated with a given alignment type (integer,
67 /// vector, float) and type bit width.
68 ///
69 /// \note The unusual order of elements in the structure attempts to reduce
70 /// padding and make the structure slightly more cache friendly.
72  /// \brief Alignment type from \c AlignTypeEnum
73  unsigned AlignType : 8;
74  unsigned TypeBitWidth : 24;
75  unsigned ABIAlign : 16;
76  unsigned PrefAlign : 16;
77 
78  static LayoutAlignElem get(AlignTypeEnum align_type, unsigned abi_align,
79  unsigned pref_align, uint32_t bit_width);
80 
81  bool operator==(const LayoutAlignElem &rhs) const;
82 };
83 
84 /// \brief Layout pointer alignment element.
85 ///
86 /// Stores the alignment data associated with a given pointer and address space.
87 ///
88 /// \note The unusual order of elements in the structure attempts to reduce
89 /// padding and make the structure slightly more cache friendly.
91  unsigned ABIAlign;
92  unsigned PrefAlign;
95 
96  /// Initializer
97  static PointerAlignElem get(uint32_t AddressSpace, unsigned ABIAlign,
98  unsigned PrefAlign, uint32_t TypeByteWidth);
99 
100  bool operator==(const PointerAlignElem &rhs) const;
101 };
102 
103 /// \brief A parsed version of the target data layout string in and methods for
104 /// querying it.
105 ///
106 /// The target data layout string is specified *by the target* - a frontend
107 /// generating LLVM IR is required to generate the right target data for the
108 /// target being codegen'd to.
109 class DataLayout {
110 private:
111  /// Defaults to false.
112  bool BigEndian;
113 
114  unsigned AllocaAddrSpace;
115  unsigned StackNaturalAlign;
116 
117  enum ManglingModeT {
118  MM_None,
119  MM_ELF,
120  MM_MachO,
121  MM_WinCOFF,
122  MM_WinCOFFX86,
123  MM_Mips
124  };
125  ManglingModeT ManglingMode;
126 
127  SmallVector<unsigned char, 8> LegalIntWidths;
128 
129  /// \brief Primitive type alignment data. This is sorted by type and bit
130  /// width during construction.
132  AlignmentsTy Alignments;
133 
135  findAlignmentLowerBound(AlignTypeEnum AlignType, uint32_t BitWidth) const {
136  return const_cast<DataLayout *>(this)->findAlignmentLowerBound(AlignType,
137  BitWidth);
138  }
139 
141  findAlignmentLowerBound(AlignTypeEnum AlignType, uint32_t BitWidth);
142 
143  /// \brief The string representation used to create this DataLayout
144  std::string StringRepresentation;
145 
147  PointersTy Pointers;
148 
150  findPointerLowerBound(uint32_t AddressSpace) const {
151  return const_cast<DataLayout *>(this)->findPointerLowerBound(AddressSpace);
152  }
153 
154  PointersTy::iterator findPointerLowerBound(uint32_t AddressSpace);
155 
156  // The StructType -> StructLayout map.
157  mutable void *LayoutMap = nullptr;
158 
159  /// Pointers in these address spaces are non-integral, and don't have a
160  /// well-defined bitwise representation.
161  SmallVector<unsigned, 8> NonIntegralAddressSpaces;
162 
163  void setAlignment(AlignTypeEnum align_type, unsigned abi_align,
164  unsigned pref_align, uint32_t bit_width);
165  unsigned getAlignmentInfo(AlignTypeEnum align_type, uint32_t bit_width,
166  bool ABIAlign, Type *Ty) const;
167  void setPointerAlignment(uint32_t AddrSpace, unsigned ABIAlign,
168  unsigned PrefAlign, uint32_t TypeByteWidth);
169 
170  /// Internal helper method that returns requested alignment for type.
171  unsigned getAlignment(Type *Ty, bool abi_or_pref) const;
172 
173  /// Parses a target data specification string. Assert if the string is
174  /// malformed.
175  void parseSpecifier(StringRef LayoutDescription);
176 
177  // Free all internal data structures.
178  void clear();
179 
180 public:
181  /// Constructs a DataLayout from a specification string. See reset().
182  explicit DataLayout(StringRef LayoutDescription) {
183  reset(LayoutDescription);
184  }
185 
186  /// Initialize target data from properties stored in the module.
187  explicit DataLayout(const Module *M);
188 
189  DataLayout(const DataLayout &DL) { *this = DL; }
190 
191  ~DataLayout(); // Not virtual, do not subclass this class
192 
194  clear();
195  StringRepresentation = DL.StringRepresentation;
196  BigEndian = DL.isBigEndian();
197  AllocaAddrSpace = DL.AllocaAddrSpace;
198  StackNaturalAlign = DL.StackNaturalAlign;
199  ManglingMode = DL.ManglingMode;
200  LegalIntWidths = DL.LegalIntWidths;
201  Alignments = DL.Alignments;
202  Pointers = DL.Pointers;
203  NonIntegralAddressSpaces = DL.NonIntegralAddressSpaces;
204  return *this;
205  }
206 
207  bool operator==(const DataLayout &Other) const;
208  bool operator!=(const DataLayout &Other) const { return !(*this == Other); }
209 
210  void init(const Module *M);
211 
212  /// Parse a data layout string (with fallback to default values).
213  void reset(StringRef LayoutDescription);
214 
215  /// Layout endianness...
216  bool isLittleEndian() const { return !BigEndian; }
217  bool isBigEndian() const { return BigEndian; }
218 
219  /// \brief Returns the string representation of the DataLayout.
220  ///
221  /// This representation is in the same format accepted by the string
222  /// constructor above. This should not be used to compare two DataLayout as
223  /// different string can represent the same layout.
224  const std::string &getStringRepresentation() const {
225  return StringRepresentation;
226  }
227 
228  /// \brief Test if the DataLayout was constructed from an empty string.
229  bool isDefault() const { return StringRepresentation.empty(); }
230 
231  /// \brief Returns true if the specified type is known to be a native integer
232  /// type supported by the CPU.
233  ///
234  /// For example, i64 is not native on most 32-bit CPUs and i37 is not native
235  /// on any known one. This returns false if the integer width is not legal.
236  ///
237  /// The width is specified in bits.
238  bool isLegalInteger(uint64_t Width) const {
239  for (unsigned LegalIntWidth : LegalIntWidths)
240  if (LegalIntWidth == Width)
241  return true;
242  return false;
243  }
244 
245  bool isIllegalInteger(uint64_t Width) const { return !isLegalInteger(Width); }
246 
247  /// Returns true if the given alignment exceeds the natural stack alignment.
248  bool exceedsNaturalStackAlignment(unsigned Align) const {
249  return (StackNaturalAlign != 0) && (Align > StackNaturalAlign);
250  }
251 
252  unsigned getStackAlignment() const { return StackNaturalAlign; }
253  unsigned getAllocaAddrSpace() const { return AllocaAddrSpace; }
254 
256  return ManglingMode == MM_WinCOFFX86;
257  }
258 
259  bool hasLinkerPrivateGlobalPrefix() const { return ManglingMode == MM_MachO; }
260 
262  if (ManglingMode == MM_MachO)
263  return "l";
264  return "";
265  }
266 
267  char getGlobalPrefix() const {
268  switch (ManglingMode) {
269  case MM_None:
270  case MM_ELF:
271  case MM_Mips:
272  case MM_WinCOFF:
273  return '\0';
274  case MM_MachO:
275  case MM_WinCOFFX86:
276  return '_';
277  }
278  llvm_unreachable("invalid mangling mode");
279  }
280 
282  switch (ManglingMode) {
283  case MM_None:
284  return "";
285  case MM_ELF:
286  case MM_WinCOFF:
287  return ".L";
288  case MM_Mips:
289  return "$";
290  case MM_MachO:
291  case MM_WinCOFFX86:
292  return "L";
293  }
294  llvm_unreachable("invalid mangling mode");
295  }
296 
297  static const char *getManglingComponent(const Triple &T);
298 
299  /// \brief Returns true if the specified type fits in a native integer type
300  /// supported by the CPU.
301  ///
302  /// For example, if the CPU only supports i32 as a native integer type, then
303  /// i27 fits in a legal integer type but i45 does not.
304  bool fitsInLegalInteger(unsigned Width) const {
305  for (unsigned LegalIntWidth : LegalIntWidths)
306  if (Width <= LegalIntWidth)
307  return true;
308  return false;
309  }
310 
311  /// Layout pointer alignment
312  unsigned getPointerABIAlignment(unsigned AS) const;
313 
314  /// Return target's alignment for stack-based pointers
315  /// FIXME: The defaults need to be removed once all of
316  /// the backends/clients are updated.
317  unsigned getPointerPrefAlignment(unsigned AS = 0) const;
318 
319  /// Layout pointer size
320  /// FIXME: The defaults need to be removed once all of
321  /// the backends/clients are updated.
322  unsigned getPointerSize(unsigned AS = 0) const;
323 
324  /// Return the address spaces containing non-integral pointers. Pointers in
325  /// this address space don't have a well-defined bitwise representation.
327  return NonIntegralAddressSpaces;
328  }
329 
331  ArrayRef<unsigned> NonIntegralSpaces = getNonIntegralAddressSpaces();
332  return find(NonIntegralSpaces, PT->getAddressSpace()) !=
333  NonIntegralSpaces.end();
334  }
335 
336  bool isNonIntegralPointerType(Type *Ty) const {
337  auto *PTy = dyn_cast<PointerType>(Ty);
338  return PTy && isNonIntegralPointerType(PTy);
339  }
340 
341  /// Layout pointer size, in bits
342  /// FIXME: The defaults need to be removed once all of
343  /// the backends/clients are updated.
344  unsigned getPointerSizeInBits(unsigned AS = 0) const {
345  return getPointerSize(AS) * 8;
346  }
347 
348  /// Layout pointer size, in bits, based on the type. If this function is
349  /// called with a pointer type, then the type size of the pointer is returned.
350  /// If this function is called with a vector of pointers, then the type size
351  /// of the pointer is returned. This should only be called with a pointer or
352  /// vector of pointers.
353  unsigned getPointerTypeSizeInBits(Type *) const;
354 
355  unsigned getPointerTypeSize(Type *Ty) const {
356  return getPointerTypeSizeInBits(Ty) / 8;
357  }
358 
359  /// Size examples:
360  ///
361  /// Type SizeInBits StoreSizeInBits AllocSizeInBits[*]
362  /// ---- ---------- --------------- ---------------
363  /// i1 1 8 8
364  /// i8 8 8 8
365  /// i19 19 24 32
366  /// i32 32 32 32
367  /// i100 100 104 128
368  /// i128 128 128 128
369  /// Float 32 32 32
370  /// Double 64 64 64
371  /// X86_FP80 80 80 96
372  ///
373  /// [*] The alloc size depends on the alignment, and thus on the target.
374  /// These values are for x86-32 linux.
375 
376  /// \brief Returns the number of bits necessary to hold the specified type.
377  ///
378  /// For example, returns 36 for i36 and 80 for x86_fp80. The type passed must
379  /// have a size (Type::isSized() must return true).
380  uint64_t getTypeSizeInBits(Type *Ty) const;
381 
382  /// \brief Returns the maximum number of bytes that may be overwritten by
383  /// storing the specified type.
384  ///
385  /// For example, returns 5 for i36 and 10 for x86_fp80.
386  uint64_t getTypeStoreSize(Type *Ty) const {
387  return (getTypeSizeInBits(Ty) + 7) / 8;
388  }
389 
390  /// \brief Returns the maximum number of bits that may be overwritten by
391  /// storing the specified type; always a multiple of 8.
392  ///
393  /// For example, returns 40 for i36 and 80 for x86_fp80.
394  uint64_t getTypeStoreSizeInBits(Type *Ty) const {
395  return 8 * getTypeStoreSize(Ty);
396  }
397 
398  /// \brief Returns the offset in bytes between successive objects of the
399  /// specified type, including alignment padding.
400  ///
401  /// This is the amount that alloca reserves for this type. For example,
402  /// returns 12 or 16 for x86_fp80, depending on alignment.
403  uint64_t getTypeAllocSize(Type *Ty) const {
404  // Round up to the next alignment boundary.
405  return alignTo(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
406  }
407 
408  /// \brief Returns the offset in bits between successive objects of the
409  /// specified type, including alignment padding; always a multiple of 8.
410  ///
411  /// This is the amount that alloca reserves for this type. For example,
412  /// returns 96 or 128 for x86_fp80, depending on alignment.
413  uint64_t getTypeAllocSizeInBits(Type *Ty) const {
414  return 8 * getTypeAllocSize(Ty);
415  }
416 
417  /// \brief Returns the minimum ABI-required alignment for the specified type.
418  unsigned getABITypeAlignment(Type *Ty) const;
419 
420  /// \brief Returns the minimum ABI-required alignment for an integer type of
421  /// the specified bitwidth.
422  unsigned getABIIntegerTypeAlignment(unsigned BitWidth) const;
423 
424  /// \brief Returns the preferred stack/global alignment for the specified
425  /// type.
426  ///
427  /// This is always at least as good as the ABI alignment.
428  unsigned getPrefTypeAlignment(Type *Ty) const;
429 
430  /// \brief Returns the preferred alignment for the specified type, returned as
431  /// log2 of the value (a shift amount).
432  unsigned getPreferredTypeAlignmentShift(Type *Ty) const;
433 
434  /// \brief Returns an integer type with size at least as big as that of a
435  /// pointer in the given address space.
436  IntegerType *getIntPtrType(LLVMContext &C, unsigned AddressSpace = 0) const;
437 
438  /// \brief Returns an integer (vector of integer) type with size at least as
439  /// big as that of a pointer of the given pointer (vector of pointer) type.
440  Type *getIntPtrType(Type *) const;
441 
442  /// \brief Returns the smallest integer type with size at least as big as
443  /// Width bits.
444  Type *getSmallestLegalIntType(LLVMContext &C, unsigned Width = 0) const;
445 
446  /// \brief Returns the largest legal integer type, or null if none are set.
448  unsigned LargestSize = getLargestLegalIntTypeSizeInBits();
449  return (LargestSize == 0) ? nullptr : Type::getIntNTy(C, LargestSize);
450  }
451 
452  /// \brief Returns the size of largest legal integer type size, or 0 if none
453  /// are set.
454  unsigned getLargestLegalIntTypeSizeInBits() const;
455 
456  /// \brief Returns the offset from the beginning of the type for the specified
457  /// indices.
458  ///
459  /// Note that this takes the element type, not the pointer type.
460  /// This is used to implement getelementptr.
461  int64_t getIndexedOffsetInType(Type *ElemTy, ArrayRef<Value *> Indices) const;
462 
463  /// \brief Returns a StructLayout object, indicating the alignment of the
464  /// struct, its size, and the offsets of its fields.
465  ///
466  /// Note that this information is lazily cached.
467  const StructLayout *getStructLayout(StructType *Ty) const;
468 
469  /// \brief Returns the preferred alignment of the specified global.
470  ///
471  /// This includes an explicitly requested alignment (if the global has one).
472  unsigned getPreferredAlignment(const GlobalVariable *GV) const;
473 
474  /// \brief Returns the preferred alignment of the specified global, returned
475  /// in log form.
476  ///
477  /// This includes an explicitly requested alignment (if the global has one).
478  unsigned getPreferredAlignmentLog(const GlobalVariable *GV) const;
479 };
480 
482  return reinterpret_cast<DataLayout *>(P);
483 }
484 
486  return reinterpret_cast<LLVMTargetDataRef>(const_cast<DataLayout *>(P));
487 }
488 
489 /// Used to lazily calculate structure layout information for a target machine,
490 /// based on the DataLayout structure.
492  uint64_t StructSize;
493  unsigned StructAlignment;
494  unsigned IsPadded : 1;
495  unsigned NumElements : 31;
496  uint64_t MemberOffsets[1]; // variable sized array!
497 
498 public:
499  uint64_t getSizeInBytes() const { return StructSize; }
500 
501  uint64_t getSizeInBits() const { return 8 * StructSize; }
502 
503  unsigned getAlignment() const { return StructAlignment; }
504 
505  /// Returns whether the struct has padding or not between its fields.
506  /// NB: Padding in nested element is not taken into account.
507  bool hasPadding() const { return IsPadded; }
508 
509  /// \brief Given a valid byte offset into the structure, returns the structure
510  /// index that contains it.
511  unsigned getElementContainingOffset(uint64_t Offset) const;
512 
513  uint64_t getElementOffset(unsigned Idx) const {
514  assert(Idx < NumElements && "Invalid element idx!");
515  return MemberOffsets[Idx];
516  }
517 
518  uint64_t getElementOffsetInBits(unsigned Idx) const {
519  return getElementOffset(Idx) * 8;
520  }
521 
522 private:
523  friend class DataLayout; // Only DataLayout can create this class
524 
525  StructLayout(StructType *ST, const DataLayout &DL);
526 };
527 
528 // The implementation of this method is provided inline as it is particularly
529 // well suited to constant folding when called on a specific Type subclass.
530 inline uint64_t DataLayout::getTypeSizeInBits(Type *Ty) const {
531  assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
532  switch (Ty->getTypeID()) {
533  case Type::LabelTyID:
534  return getPointerSizeInBits(0);
535  case Type::PointerTyID:
536  return getPointerSizeInBits(Ty->getPointerAddressSpace());
537  case Type::ArrayTyID: {
538  ArrayType *ATy = cast<ArrayType>(Ty);
539  return ATy->getNumElements() *
540  getTypeAllocSizeInBits(ATy->getElementType());
541  }
542  case Type::StructTyID:
543  // Get the layout annotation... which is lazily created on demand.
544  return getStructLayout(cast<StructType>(Ty))->getSizeInBits();
545  case Type::IntegerTyID:
546  return Ty->getIntegerBitWidth();
547  case Type::HalfTyID:
548  return 16;
549  case Type::FloatTyID:
550  return 32;
551  case Type::DoubleTyID:
552  case Type::X86_MMXTyID:
553  return 64;
554  case Type::PPC_FP128TyID:
555  case Type::FP128TyID:
556  return 128;
557  // In memory objects this is always aligned to a higher boundary, but
558  // only 80 bits contain information.
559  case Type::X86_FP80TyID:
560  return 80;
561  case Type::VectorTyID: {
562  VectorType *VTy = cast<VectorType>(Ty);
563  return VTy->getNumElements() * getTypeSizeInBits(VTy->getElementType());
564  }
565  default:
566  llvm_unreachable("DataLayout::getTypeSizeInBits(): Unsupported type");
567  }
568 }
569 
570 } // end namespace llvm
571 
572 #endif // LLVM_IR_DATALAYOUT_H
uint64_t CallInst * C
7: Labels
Definition: Type.h:64
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:109
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
uint64_t getTypeStoreSizeInBits(Type *Ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
Definition: DataLayout.h:394
typename SuperClass::const_iterator const_iterator
Definition: SmallVector.h:329
AlignTypeEnum
Enum used to categorize the alignment types stored by LayoutAlignElem.
Definition: DataLayout.h:51
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
StringRef getPrivateGlobalPrefix() const
Definition: DataLayout.h:281
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Definition: Type.h:262
2: 32-bit floating point type
Definition: Type.h:59
bool exceedsNaturalStackAlignment(unsigned Align) const
Returns true if the given alignment exceeds the natural stack alignment.
Definition: DataLayout.h:248
bool operator!=(const DataLayout &Other) const
Definition: DataLayout.h:208
const std::string & getStringRepresentation() const
Returns the string representation of the DataLayout.
Definition: DataLayout.h:224
13: Structures
Definition: Type.h:73
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
Definition: DataLayout.h:344
4: 80-bit floating point type (X87)
Definition: Type.h:61
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Definition: MathExtras.h:677
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition: DerivedTypes.h:503
char getGlobalPrefix() const
Definition: DataLayout.h:267
1: 16-bit floating point type
Definition: Type.h:58
15: Pointers
Definition: Type.h:75
StringRef getLinkerPrivateGlobalPrefix() const
Definition: DataLayout.h:261
unsigned getAllocaAddrSpace() const
Definition: DataLayout.h:253
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
Definition: DataLayout.h:491
static uint32_t getAlignment(const MCSectionCOFF &Sec)
struct LLVMOpaqueTargetData * LLVMTargetDataRef
Definition: DataLayout.h:39
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:195
TypeID getTypeID() const
Return the type id for the type.
Definition: Type.h:138
unsigned getPointerTypeSize(Type *Ty) const
Definition: DataLayout.h:355
Class to represent struct types.
Definition: DerivedTypes.h:201
uint64_t getElementOffsetInBits(unsigned Idx) const
Definition: DataLayout.h:518
DataLayout(const DataLayout &DL)
Definition: DataLayout.h:189
DataLayout & operator=(const DataLayout &DL)
Definition: DataLayout.h:193
uint64_t getNumElements() const
Definition: DerivedTypes.h:359
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:736
uint64_t getSizeInBits() const
Definition: DataLayout.h:501
Class to represent array types.
Definition: DerivedTypes.h:369
bool isLittleEndian() const
Layout endianness...
Definition: DataLayout.h:216
bool isNonIntegralPointerType(Type *Ty) const
Definition: DataLayout.h:336
unsigned getStackAlignment() const
Definition: DataLayout.h:252
Class to represent pointers.
Definition: DerivedTypes.h:467
Layout pointer alignment element.
Definition: DataLayout.h:90
11: Arbitrary bit width integers
Definition: Type.h:71
#define P(N)
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:406
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:69
Type * getLargestLegalIntType(LLVMContext &C) const
Returns the largest legal integer type, or null if none are set.
Definition: DataLayout.h:447
6: 128-bit floating point type (two 64-bits, PowerPC)
Definition: Type.h:63
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:495
bool hasLinkerPrivateGlobalPrefix() const
Definition: DataLayout.h:259
Class to represent integer types.
Definition: DerivedTypes.h:40
const AMDGPUAS & AS
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
14: Arrays
Definition: Type.h:74
auto find(R &&Range, const T &Val) -> decltype(std::begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:788
16: SIMD &#39;packed&#39; format, or other vector type
Definition: Type.h:76
AddressSpace
Definition: NVPTXBaseInfo.h:22
iterator end() const
Definition: ArrayRef.h:138
bool isLegalInteger(uint64_t Width) const
Returns true if the specified type is known to be a native integer type supported by the CPU...
Definition: DataLayout.h:238
uint64_t getSizeInBytes() const
Definition: DataLayout.h:499
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Definition: Type.cpp:180
bool hasMicrosoftFastStdCallMangling() const
Definition: DataLayout.h:255
bool isDefault() const
Test if the DataLayout was constructed from an empty string.
Definition: DataLayout.h:229
Class to represent vector types.
Definition: DerivedTypes.h:393
typename SuperClass::iterator iterator
Definition: SmallVector.h:328
DataLayout(StringRef LayoutDescription)
Constructs a DataLayout from a specification string. See reset().
Definition: DataLayout.h:182
static void clear(coro::Shape &Shape)
Definition: Coroutines.cpp:210
bool isNonIntegralPointerType(PointerType *PT) const
Definition: DataLayout.h:330
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
Definition: DataLayout.h:530
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Definition: DataLayout.h:403
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:190
uint64_t getElementOffset(unsigned Idx) const
Definition: DataLayout.h:513
unsigned getIntegerBitWidth() const
Definition: DerivedTypes.h:97
Layout alignment element.
Definition: DataLayout.h:71
bool hasPadding() const
Returns whether the struct has padding or not between its fields.
Definition: DataLayout.h:507
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
ArrayRef< unsigned > getNonIntegralAddressSpaces() const
Return the address spaces containing non-integral pointers.
Definition: DataLayout.h:326
unsigned AlignType
Alignment type from AlignTypeEnum.
Definition: DataLayout.h:73
3: 64-bit floating point type
Definition: Type.h:60
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
Definition: DataLayout.h:386
unsigned getAlignment() const
Definition: DataLayout.h:503
uint64_t getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
Definition: DataLayout.h:413
Type * getElementType() const
Definition: DerivedTypes.h:360
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
bool fitsInLegalInteger(unsigned Width) const
Returns true if the specified type fits in a native integer type supported by the CPU...
Definition: DataLayout.h:304
bool isIllegalInteger(uint64_t Width) const
Definition: DataLayout.h:245
bool operator==(const LayoutAlignElem &rhs) const
Definition: DataLayout.cpp:119
9: MMX vectors (64 bits, X86 specific)
Definition: Type.h:66
bool isBigEndian() const
Definition: DataLayout.h:217
static uint64_t getPointerSize(const Value *V, const DataLayout &DL, const TargetLibraryInfo &TLI)
5: 128-bit floating point type (112-bit mantissa)
Definition: Type.h:62