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