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