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