LLVM  9.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 /// 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  /// 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 /// 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;
96 
97  /// Initializer
98  static PointerAlignElem get(uint32_t AddressSpace, unsigned ABIAlign,
99  unsigned PrefAlign, uint32_t TypeByteWidth,
100  uint32_t IndexWidth);
101 
102  bool operator==(const PointerAlignElem &rhs) const;
103 };
104 
105 /// A parsed version of the target data layout string in and methods for
106 /// querying it.
107 ///
108 /// The target data layout string is specified *by the target* - a frontend
109 /// generating LLVM IR is required to generate the right target data for the
110 /// target being codegen'd to.
111 class DataLayout {
112 private:
113  /// Defaults to false.
114  bool BigEndian;
115 
116  unsigned AllocaAddrSpace;
117  unsigned StackNaturalAlign;
118  unsigned ProgramAddrSpace;
119 
120  enum ManglingModeT {
121  MM_None,
122  MM_ELF,
123  MM_MachO,
124  MM_WinCOFF,
125  MM_WinCOFFX86,
126  MM_Mips
127  };
128  ManglingModeT ManglingMode;
129 
130  SmallVector<unsigned char, 8> LegalIntWidths;
131 
132  /// Primitive type alignment data. This is sorted by type and bit
133  /// width during construction.
135  AlignmentsTy Alignments;
136 
138  findAlignmentLowerBound(AlignTypeEnum AlignType, uint32_t BitWidth) const {
139  return const_cast<DataLayout *>(this)->findAlignmentLowerBound(AlignType,
140  BitWidth);
141  }
142 
144  findAlignmentLowerBound(AlignTypeEnum AlignType, uint32_t BitWidth);
145 
146  /// The string representation used to create this DataLayout
147  std::string StringRepresentation;
148 
150  PointersTy Pointers;
151 
153  findPointerLowerBound(uint32_t AddressSpace) const {
154  return const_cast<DataLayout *>(this)->findPointerLowerBound(AddressSpace);
155  }
156 
157  PointersTy::iterator findPointerLowerBound(uint32_t AddressSpace);
158 
159  // The StructType -> StructLayout map.
160  mutable void *LayoutMap = nullptr;
161 
162  /// Pointers in these address spaces are non-integral, and don't have a
163  /// well-defined bitwise representation.
164  SmallVector<unsigned, 8> NonIntegralAddressSpaces;
165 
166  void setAlignment(AlignTypeEnum align_type, unsigned abi_align,
167  unsigned pref_align, uint32_t bit_width);
168  unsigned getAlignmentInfo(AlignTypeEnum align_type, uint32_t bit_width,
169  bool ABIAlign, Type *Ty) const;
170  void setPointerAlignment(uint32_t AddrSpace, unsigned ABIAlign,
171  unsigned PrefAlign, uint32_t TypeByteWidth,
172  uint32_t IndexWidth);
173 
174  /// Internal helper method that returns requested alignment for type.
175  unsigned getAlignment(Type *Ty, bool abi_or_pref) const;
176 
177  /// Parses a target data specification string. Assert if the string is
178  /// malformed.
179  void parseSpecifier(StringRef LayoutDescription);
180 
181  // Free all internal data structures.
182  void clear();
183 
184 public:
185  /// Constructs a DataLayout from a specification string. See reset().
186  explicit DataLayout(StringRef LayoutDescription) {
187  reset(LayoutDescription);
188  }
189 
190  /// Initialize target data from properties stored in the module.
191  explicit DataLayout(const Module *M);
192 
193  DataLayout(const DataLayout &DL) { *this = DL; }
194 
195  ~DataLayout(); // Not virtual, do not subclass this class
196 
198  clear();
199  StringRepresentation = DL.StringRepresentation;
200  BigEndian = DL.isBigEndian();
201  AllocaAddrSpace = DL.AllocaAddrSpace;
202  StackNaturalAlign = DL.StackNaturalAlign;
203  ProgramAddrSpace = DL.ProgramAddrSpace;
204  ManglingMode = DL.ManglingMode;
205  LegalIntWidths = DL.LegalIntWidths;
206  Alignments = DL.Alignments;
207  Pointers = DL.Pointers;
208  NonIntegralAddressSpaces = DL.NonIntegralAddressSpaces;
209  return *this;
210  }
211 
212  bool operator==(const DataLayout &Other) const;
213  bool operator!=(const DataLayout &Other) const { return !(*this == Other); }
214 
215  void init(const Module *M);
216 
217  /// Parse a data layout string (with fallback to default values).
218  void reset(StringRef LayoutDescription);
219 
220  /// Layout endianness...
221  bool isLittleEndian() const { return !BigEndian; }
222  bool isBigEndian() const { return BigEndian; }
223 
224  /// Returns the string representation of the DataLayout.
225  ///
226  /// This representation is in the same format accepted by the string
227  /// constructor above. This should not be used to compare two DataLayout as
228  /// different string can represent the same layout.
229  const std::string &getStringRepresentation() const {
230  return StringRepresentation;
231  }
232 
233  /// Test if the DataLayout was constructed from an empty string.
234  bool isDefault() const { return StringRepresentation.empty(); }
235 
236  /// Returns true if the specified type is known to be a native integer
237  /// type supported by the CPU.
238  ///
239  /// For example, i64 is not native on most 32-bit CPUs and i37 is not native
240  /// on any known one. This returns false if the integer width is not legal.
241  ///
242  /// The width is specified in bits.
243  bool isLegalInteger(uint64_t Width) const {
244  for (unsigned LegalIntWidth : LegalIntWidths)
245  if (LegalIntWidth == Width)
246  return true;
247  return false;
248  }
249 
250  bool isIllegalInteger(uint64_t Width) const { return !isLegalInteger(Width); }
251 
252  /// Returns true if the given alignment exceeds the natural stack alignment.
253  bool exceedsNaturalStackAlignment(unsigned Align) const {
254  return (StackNaturalAlign != 0) && (Align > StackNaturalAlign);
255  }
256 
257  unsigned getStackAlignment() const { return StackNaturalAlign; }
258  unsigned getAllocaAddrSpace() const { return AllocaAddrSpace; }
259 
260  unsigned getProgramAddressSpace() const { return ProgramAddrSpace; }
261 
263  return ManglingMode == MM_WinCOFFX86;
264  }
265 
266  /// Returns true if symbols with leading question marks should not receive IR
267  /// mangling. True for Windows mangling modes.
269  return ManglingMode == MM_WinCOFF || ManglingMode == MM_WinCOFFX86;
270  }
271 
272  bool hasLinkerPrivateGlobalPrefix() const { return ManglingMode == MM_MachO; }
273 
275  if (ManglingMode == MM_MachO)
276  return "l";
277  return "";
278  }
279 
280  char getGlobalPrefix() const {
281  switch (ManglingMode) {
282  case MM_None:
283  case MM_ELF:
284  case MM_Mips:
285  case MM_WinCOFF:
286  return '\0';
287  case MM_MachO:
288  case MM_WinCOFFX86:
289  return '_';
290  }
291  llvm_unreachable("invalid mangling mode");
292  }
293 
295  switch (ManglingMode) {
296  case MM_None:
297  return "";
298  case MM_ELF:
299  case MM_WinCOFF:
300  return ".L";
301  case MM_Mips:
302  return "$";
303  case MM_MachO:
304  case MM_WinCOFFX86:
305  return "L";
306  }
307  llvm_unreachable("invalid mangling mode");
308  }
309 
310  static const char *getManglingComponent(const Triple &T);
311 
312  /// Returns true if the specified type fits in a native integer type
313  /// supported by the CPU.
314  ///
315  /// For example, if the CPU only supports i32 as a native integer type, then
316  /// i27 fits in a legal integer type but i45 does not.
317  bool fitsInLegalInteger(unsigned Width) const {
318  for (unsigned LegalIntWidth : LegalIntWidths)
319  if (Width <= LegalIntWidth)
320  return true;
321  return false;
322  }
323 
324  /// Layout pointer alignment
325  unsigned getPointerABIAlignment(unsigned AS) const;
326 
327  /// Return target's alignment for stack-based pointers
328  /// FIXME: The defaults need to be removed once all of
329  /// the backends/clients are updated.
330  unsigned getPointerPrefAlignment(unsigned AS = 0) const;
331 
332  /// Layout pointer size
333  /// FIXME: The defaults need to be removed once all of
334  /// the backends/clients are updated.
335  unsigned getPointerSize(unsigned AS = 0) const;
336 
337  /// Returns the maximum pointer size over all address spaces.
338  unsigned getMaxPointerSize() const;
339 
340  // Index size used for address calculation.
341  unsigned getIndexSize(unsigned AS) const;
342 
343  /// Return the address spaces containing non-integral pointers. Pointers in
344  /// this address space don't have a well-defined bitwise representation.
346  return NonIntegralAddressSpaces;
347  }
348 
350  ArrayRef<unsigned> NonIntegralSpaces = getNonIntegralAddressSpaces();
351  return find(NonIntegralSpaces, PT->getAddressSpace()) !=
352  NonIntegralSpaces.end();
353  }
354 
355  bool isNonIntegralPointerType(Type *Ty) const {
356  auto *PTy = dyn_cast<PointerType>(Ty);
357  return PTy && isNonIntegralPointerType(PTy);
358  }
359 
360  /// Layout pointer size, in bits
361  /// FIXME: The defaults need to be removed once all of
362  /// the backends/clients are updated.
363  unsigned getPointerSizeInBits(unsigned AS = 0) const {
364  return getPointerSize(AS) * 8;
365  }
366 
367  /// Returns the maximum pointer size over all address spaces.
368  unsigned getMaxPointerSizeInBits() const {
369  return getMaxPointerSize() * 8;
370  }
371 
372  /// Size in bits of index used for address calculation in getelementptr.
373  unsigned getIndexSizeInBits(unsigned AS) const {
374  return getIndexSize(AS) * 8;
375  }
376 
377  /// Layout pointer size, in bits, based on the type. If this function is
378  /// called with a pointer type, then the type size of the pointer is returned.
379  /// If this function is called with a vector of pointers, then the type size
380  /// of the pointer is returned. This should only be called with a pointer or
381  /// vector of pointers.
382  unsigned getPointerTypeSizeInBits(Type *) const;
383 
384  /// Layout size of the index used in GEP calculation.
385  /// The function should be called with pointer or vector of pointers type.
386  unsigned getIndexTypeSizeInBits(Type *Ty) const;
387 
388  unsigned getPointerTypeSize(Type *Ty) const {
389  return getPointerTypeSizeInBits(Ty) / 8;
390  }
391 
392  /// Size examples:
393  ///
394  /// Type SizeInBits StoreSizeInBits AllocSizeInBits[*]
395  /// ---- ---------- --------------- ---------------
396  /// i1 1 8 8
397  /// i8 8 8 8
398  /// i19 19 24 32
399  /// i32 32 32 32
400  /// i100 100 104 128
401  /// i128 128 128 128
402  /// Float 32 32 32
403  /// Double 64 64 64
404  /// X86_FP80 80 80 96
405  ///
406  /// [*] The alloc size depends on the alignment, and thus on the target.
407  /// These values are for x86-32 linux.
408 
409  /// Returns the number of bits necessary to hold the specified type.
410  ///
411  /// For example, returns 36 for i36 and 80 for x86_fp80. The type passed must
412  /// have a size (Type::isSized() must return true).
413  uint64_t getTypeSizeInBits(Type *Ty) const;
414 
415  /// Returns the maximum number of bytes that may be overwritten by
416  /// storing the specified type.
417  ///
418  /// For example, returns 5 for i36 and 10 for x86_fp80.
419  uint64_t getTypeStoreSize(Type *Ty) const {
420  return (getTypeSizeInBits(Ty) + 7) / 8;
421  }
422 
423  /// Returns the maximum number of bits that may be overwritten by
424  /// storing the specified type; always a multiple of 8.
425  ///
426  /// For example, returns 40 for i36 and 80 for x86_fp80.
427  uint64_t getTypeStoreSizeInBits(Type *Ty) const {
428  return 8 * getTypeStoreSize(Ty);
429  }
430 
431  /// Returns the offset in bytes between successive objects of the
432  /// specified type, including alignment padding.
433  ///
434  /// This is the amount that alloca reserves for this type. For example,
435  /// returns 12 or 16 for x86_fp80, depending on alignment.
436  uint64_t getTypeAllocSize(Type *Ty) const {
437  // Round up to the next alignment boundary.
438  return alignTo(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
439  }
440 
441  /// Returns the offset in bits between successive objects of the
442  /// specified type, including alignment padding; always a multiple of 8.
443  ///
444  /// This is the amount that alloca reserves for this type. For example,
445  /// returns 96 or 128 for x86_fp80, depending on alignment.
446  uint64_t getTypeAllocSizeInBits(Type *Ty) const {
447  return 8 * getTypeAllocSize(Ty);
448  }
449 
450  /// Returns the minimum ABI-required alignment for the specified type.
451  unsigned getABITypeAlignment(Type *Ty) const;
452 
453  /// Returns the minimum ABI-required alignment for an integer type of
454  /// the specified bitwidth.
455  unsigned getABIIntegerTypeAlignment(unsigned BitWidth) const;
456 
457  /// Returns the preferred stack/global alignment for the specified
458  /// type.
459  ///
460  /// This is always at least as good as the ABI alignment.
461  unsigned getPrefTypeAlignment(Type *Ty) const;
462 
463  /// Returns the preferred alignment for the specified type, returned as
464  /// log2 of the value (a shift amount).
465  unsigned getPreferredTypeAlignmentShift(Type *Ty) const;
466 
467  /// Returns an integer type with size at least as big as that of a
468  /// pointer in the given address space.
469  IntegerType *getIntPtrType(LLVMContext &C, unsigned AddressSpace = 0) const;
470 
471  /// Returns an integer (vector of integer) type with size at least as
472  /// big as that of a pointer of the given pointer (vector of pointer) type.
473  Type *getIntPtrType(Type *) const;
474 
475  /// Returns the smallest integer type with size at least as big as
476  /// Width bits.
477  Type *getSmallestLegalIntType(LLVMContext &C, unsigned Width = 0) const;
478 
479  /// Returns the largest legal integer type, or null if none are set.
481  unsigned LargestSize = getLargestLegalIntTypeSizeInBits();
482  return (LargestSize == 0) ? nullptr : Type::getIntNTy(C, LargestSize);
483  }
484 
485  /// Returns the size of largest legal integer type size, or 0 if none
486  /// are set.
487  unsigned getLargestLegalIntTypeSizeInBits() const;
488 
489  /// Returns the type of a GEP index.
490  /// If it was not specified explicitly, it will be the integer type of the
491  /// pointer width - IntPtrType.
492  Type *getIndexType(Type *PtrTy) const;
493 
494  /// Returns the offset from the beginning of the type for the specified
495  /// indices.
496  ///
497  /// Note that this takes the element type, not the pointer type.
498  /// This is used to implement getelementptr.
499  int64_t getIndexedOffsetInType(Type *ElemTy, ArrayRef<Value *> Indices) const;
500 
501  /// Returns a StructLayout object, indicating the alignment of the
502  /// struct, its size, and the offsets of its fields.
503  ///
504  /// Note that this information is lazily cached.
505  const StructLayout *getStructLayout(StructType *Ty) const;
506 
507  /// Returns the preferred alignment of the specified global.
508  ///
509  /// This includes an explicitly requested alignment (if the global has one).
510  unsigned getPreferredAlignment(const GlobalVariable *GV) const;
511 
512  /// Returns the preferred alignment of the specified global, returned
513  /// in log form.
514  ///
515  /// This includes an explicitly requested alignment (if the global has one).
516  unsigned getPreferredAlignmentLog(const GlobalVariable *GV) const;
517 };
518 
520  return reinterpret_cast<DataLayout *>(P);
521 }
522 
524  return reinterpret_cast<LLVMTargetDataRef>(const_cast<DataLayout *>(P));
525 }
526 
527 /// Used to lazily calculate structure layout information for a target machine,
528 /// based on the DataLayout structure.
530  uint64_t StructSize;
531  unsigned StructAlignment;
532  unsigned IsPadded : 1;
533  unsigned NumElements : 31;
534  uint64_t MemberOffsets[1]; // variable sized array!
535 
536 public:
537  uint64_t getSizeInBytes() const { return StructSize; }
538 
539  uint64_t getSizeInBits() const { return 8 * StructSize; }
540 
541  unsigned getAlignment() const { return StructAlignment; }
542 
543  /// Returns whether the struct has padding or not between its fields.
544  /// NB: Padding in nested element is not taken into account.
545  bool hasPadding() const { return IsPadded; }
546 
547  /// Given a valid byte offset into the structure, returns the structure
548  /// index that contains it.
549  unsigned getElementContainingOffset(uint64_t Offset) const;
550 
551  uint64_t getElementOffset(unsigned Idx) const {
552  assert(Idx < NumElements && "Invalid element idx!");
553  return MemberOffsets[Idx];
554  }
555 
556  uint64_t getElementOffsetInBits(unsigned Idx) const {
557  return getElementOffset(Idx) * 8;
558  }
559 
560 private:
561  friend class DataLayout; // Only DataLayout can create this class
562 
563  StructLayout(StructType *ST, const DataLayout &DL);
564 };
565 
566 // The implementation of this method is provided inline as it is particularly
567 // well suited to constant folding when called on a specific Type subclass.
568 inline uint64_t DataLayout::getTypeSizeInBits(Type *Ty) const {
569  assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
570  switch (Ty->getTypeID()) {
571  case Type::LabelTyID:
572  return getPointerSizeInBits(0);
573  case Type::PointerTyID:
574  return getPointerSizeInBits(Ty->getPointerAddressSpace());
575  case Type::ArrayTyID: {
576  ArrayType *ATy = cast<ArrayType>(Ty);
577  return ATy->getNumElements() *
578  getTypeAllocSizeInBits(ATy->getElementType());
579  }
580  case Type::StructTyID:
581  // Get the layout annotation... which is lazily created on demand.
582  return getStructLayout(cast<StructType>(Ty))->getSizeInBits();
583  case Type::IntegerTyID:
584  return Ty->getIntegerBitWidth();
585  case Type::HalfTyID:
586  return 16;
587  case Type::FloatTyID:
588  return 32;
589  case Type::DoubleTyID:
590  case Type::X86_MMXTyID:
591  return 64;
592  case Type::PPC_FP128TyID:
593  case Type::FP128TyID:
594  return 128;
595  // In memory objects this is always aligned to a higher boundary, but
596  // only 80 bits contain information.
597  case Type::X86_FP80TyID:
598  return 80;
599  case Type::VectorTyID: {
600  VectorType *VTy = cast<VectorType>(Ty);
601  return VTy->getNumElements() * getTypeSizeInBits(VTy->getElementType());
602  }
603  default:
604  llvm_unreachable("DataLayout::getTypeSizeInBits(): Unsupported type");
605  }
606 }
607 
608 } // end namespace llvm
609 
610 #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:111
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:427
unsigned getIndexSizeInBits(unsigned AS) const
Size in bits of index used for address calculation in getelementptr.
Definition: DataLayout.h:373
typename SuperClass::const_iterator const_iterator
Definition: SmallVector.h:328
AlignTypeEnum
Enum used to categorize the alignment types stored by LayoutAlignElem.
Definition: DataLayout.h:51
This class represents lattice values for constants.
Definition: AllocatorList.h:24
StringRef getPrivateGlobalPrefix() const
Definition: DataLayout.h:294
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
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
bool exceedsNaturalStackAlignment(unsigned Align) const
Returns true if the given alignment exceeds the natural stack alignment.
Definition: DataLayout.h:253
bool operator!=(const DataLayout &Other) const
Definition: DataLayout.h:213
const std::string & getStringRepresentation() const
Returns the string representation of the DataLayout.
Definition: DataLayout.h:229
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:363
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:685
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition: DerivedTypes.h:503
char getGlobalPrefix() const
Definition: DataLayout.h:280
1: 16-bit floating point type
Definition: Type.h:58
15: Pointers
Definition: Type.h:75
StringRef getLinkerPrivateGlobalPrefix() const
Definition: DataLayout.h:274
unsigned getAllocaAddrSpace() const
Definition: DataLayout.h:258
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
Definition: DataLayout.h:529
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:388
Class to represent struct types.
Definition: DerivedTypes.h:201
uint64_t getElementOffsetInBits(unsigned Idx) const
Definition: DataLayout.h:556
DataLayout(const DataLayout &DL)
Definition: DataLayout.h:193
DataLayout & operator=(const DataLayout &DL)
Definition: DataLayout.h:197
uint64_t getNumElements() const
Definition: DerivedTypes.h:359
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:784
uint64_t getSizeInBits() const
Definition: DataLayout.h:539
Class to represent array types.
Definition: DerivedTypes.h:369
static uint64_t getPointerSize(const Value *V, const DataLayout &DL, const TargetLibraryInfo &TLI, const Function *F)
bool isLittleEndian() const
Layout endianness...
Definition: DataLayout.h:221
bool isNonIntegralPointerType(Type *Ty) const
Definition: DataLayout.h:355
unsigned getStackAlignment() const
Definition: DataLayout.h:257
Class to represent pointers.
Definition: DerivedTypes.h:467
Layout pointer alignment element.
Definition: DataLayout.h:90
unsigned getMaxPointerSizeInBits() const
Returns the maximum pointer size over all address spaces.
Definition: DataLayout.h:368
11: Arbitrary bit width integers
Definition: Type.h:71
#define P(N)
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:423
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:480
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:272
Class to represent integer types.
Definition: DerivedTypes.h:40
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1207
#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
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:243
uint64_t getSizeInBytes() const
Definition: DataLayout.h:537
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Definition: Type.cpp:180
bool hasMicrosoftFastStdCallMangling() const
Definition: DataLayout.h:262
unsigned getProgramAddressSpace() const
Definition: DataLayout.h:260
bool isDefault() const
Test if the DataLayout was constructed from an empty string.
Definition: DataLayout.h:234
Class to represent vector types.
Definition: DerivedTypes.h:393
typename SuperClass::iterator iterator
Definition: SmallVector.h:327
DataLayout(StringRef LayoutDescription)
Constructs a DataLayout from a specification string. See reset().
Definition: DataLayout.h:186
static void clear(coro::Shape &Shape)
Definition: Coroutines.cpp:212
bool isNonIntegralPointerType(PointerType *PT) const
Definition: DataLayout.h:349
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
Definition: DataLayout.h:568
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Definition: DataLayout.h:436
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:190
uint64_t getElementOffset(unsigned Idx) const
Definition: DataLayout.h:551
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:545
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:345
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:419
unsigned getAlignment() const
Definition: DataLayout.h:541
uint64_t getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
Definition: DataLayout.h:446
Type * getElementType() const
Definition: DerivedTypes.h:360
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
static unsigned getMaxPointerSize(const DataLayout &DL)
bool fitsInLegalInteger(unsigned Width) const
Returns true if the specified type fits in a native integer type supported by the CPU...
Definition: DataLayout.h:317
bool isIllegalInteger(uint64_t Width) const
Definition: DataLayout.h:250
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:222
bool doNotMangleLeadingQuestionMark() const
Returns true if symbols with leading question marks should not receive IR mangling.
Definition: DataLayout.h:268
5: 128-bit floating point type (112-bit mantissa)
Definition: Type.h:62