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