LLVM  3.7.0
Attributes.h
Go to the documentation of this file.
1 //===-- llvm/Attributes.h - Container for Attributes ------------*- 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 /// \file
11 /// \brief This file contains the simple types necessary to represent the
12 /// attributes associated with functions and their calls.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_IR_ATTRIBUTES_H
17 #define LLVM_IR_ATTRIBUTES_H
18 
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/FoldingSet.h"
21 #include "llvm/Support/Compiler.h"
23 #include <bitset>
24 #include <cassert>
25 #include <map>
26 #include <string>
27 
28 namespace llvm {
29 
30 class AttrBuilder;
31 class AttributeImpl;
32 class AttributeSetImpl;
33 class AttributeSetNode;
34 class Constant;
35 template<typename T> struct DenseMapInfo;
36 class LLVMContext;
37 class Type;
38 
39 //===----------------------------------------------------------------------===//
40 /// \class
41 /// \brief Functions, function parameters, and return types can have attributes
42 /// to indicate how they should be treated by optimizations and code
43 /// generation. This class represents one of those attributes. It's light-weight
44 /// and should be passed around by-value.
45 class Attribute {
46 public:
47  /// This enumeration lists the attributes that can be associated with
48  /// parameters, function results, or the function itself.
49  ///
50  /// Note: The `uwtable' attribute is about the ABI or the user mandating an
51  /// entry in the unwind table. The `nounwind' attribute is about an exception
52  /// passing by the function.
53  ///
54  /// In a theoretical system that uses tables for profiling and SjLj for
55  /// exceptions, they would be fully independent. In a normal system that uses
56  /// tables for both, the semantics are:
57  ///
58  /// nil = Needs an entry because an exception might pass by.
59  /// nounwind = No need for an entry
60  /// uwtable = Needs an entry because the ABI says so and because
61  /// an exception might pass by.
62  /// uwtable + nounwind = Needs an entry because the ABI says so.
63 
64  enum AttrKind {
65  // IR-Level Attributes
66  None, ///< No attributes have been set
67  Alignment, ///< Alignment of parameter (5 bits)
68  ///< stored as log2 of alignment with +1 bias
69  ///< 0 means unaligned (different from align(1))
70  AlwaysInline, ///< inline=always
71  Builtin, ///< Callee is recognized as a builtin, despite
72  ///< nobuiltin attribute on its declaration.
73  ByVal, ///< Pass structure by value
74  InAlloca, ///< Pass structure in an alloca
75  Cold, ///< Marks function as being in a cold path.
76  Convergent, ///< Can only be moved to control-equivalent blocks
77  InlineHint, ///< Source said inlining was desirable
78  InReg, ///< Force argument to be passed in register
79  JumpTable, ///< Build jump-instruction tables and replace refs.
80  MinSize, ///< Function must be optimized for size first
81  Naked, ///< Naked function
82  Nest, ///< Nested function static chain
83  NoAlias, ///< Considered to not alias after call
84  NoBuiltin, ///< Callee isn't recognized as a builtin
85  NoCapture, ///< Function creates no aliases of pointer
86  NoDuplicate, ///< Call cannot be duplicated
87  NoImplicitFloat, ///< Disable implicit floating point insts
88  NoInline, ///< inline=never
89  NonLazyBind, ///< Function is called early and/or
90  ///< often, so lazy binding isn't worthwhile
91  NonNull, ///< Pointer is known to be not null
92  Dereferenceable, ///< Pointer is known to be dereferenceable
93  DereferenceableOrNull, ///< Pointer is either null or dereferenceable
94  NoRedZone, ///< Disable redzone
95  NoReturn, ///< Mark the function as not returning
96  NoUnwind, ///< Function doesn't unwind stack
97  OptimizeForSize, ///< opt_size
98  OptimizeNone, ///< Function must not be optimized.
99  ReadNone, ///< Function does not access memory
100  ReadOnly, ///< Function only reads from memory
101  ArgMemOnly, ///< Funciton can access memory only using pointers
102  ///< based on its arguments.
103  Returned, ///< Return value is always equal to this argument
104  ReturnsTwice, ///< Function can return twice
105  SExt, ///< Sign extended before/after call
106  StackAlignment, ///< Alignment of stack for function (3 bits)
107  ///< stored as log2 of alignment with +1 bias 0
108  ///< means unaligned (different from
109  ///< alignstack=(1))
110  StackProtect, ///< Stack protection.
111  StackProtectReq, ///< Stack protection required.
112  StackProtectStrong, ///< Strong Stack protection.
113  SafeStack, ///< Safe Stack protection.
114  StructRet, ///< Hidden pointer to structure to return
115  SanitizeAddress, ///< AddressSanitizer is on.
116  SanitizeThread, ///< ThreadSanitizer is on.
117  SanitizeMemory, ///< MemorySanitizer is on.
118  UWTable, ///< Function must be in a unwind table
119  ZExt, ///< Zero extended before/after call
120 
121  EndAttrKinds ///< Sentinal value useful for loops
122  };
123 private:
124  AttributeImpl *pImpl;
125  Attribute(AttributeImpl *A) : pImpl(A) {}
126 public:
127  Attribute() : pImpl(nullptr) {}
128 
129  //===--------------------------------------------------------------------===//
130  // Attribute Construction
131  //===--------------------------------------------------------------------===//
132 
133  /// \brief Return a uniquified Attribute object.
134  static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val = 0);
135  static Attribute get(LLVMContext &Context, StringRef Kind,
136  StringRef Val = StringRef());
137 
138  /// \brief Return a uniquified Attribute object that has the specific
139  /// alignment set.
140  static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align);
141  static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align);
143  uint64_t Bytes);
145  uint64_t Bytes);
146 
147  //===--------------------------------------------------------------------===//
148  // Attribute Accessors
149  //===--------------------------------------------------------------------===//
150 
151  /// \brief Return true if the attribute is an Attribute::AttrKind type.
152  bool isEnumAttribute() const;
153 
154  /// \brief Return true if the attribute is an integer attribute.
155  bool isIntAttribute() const;
156 
157  /// \brief Return true if the attribute is a string (target-dependent)
158  /// attribute.
159  bool isStringAttribute() const;
160 
161  /// \brief Return true if the attribute is present.
162  bool hasAttribute(AttrKind Val) const;
163 
164  /// \brief Return true if the target-dependent attribute is present.
165  bool hasAttribute(StringRef Val) const;
166 
167  /// \brief Return the attribute's kind as an enum (Attribute::AttrKind). This
168  /// requires the attribute to be an enum or alignment attribute.
170 
171  /// \brief Return the attribute's value as an integer. This requires that the
172  /// attribute be an alignment attribute.
173  uint64_t getValueAsInt() const;
174 
175  /// \brief Return the attribute's kind as a string. This requires the
176  /// attribute to be a string attribute.
177  StringRef getKindAsString() const;
178 
179  /// \brief Return the attribute's value as a string. This requires the
180  /// attribute to be a string attribute.
181  StringRef getValueAsString() const;
182 
183  /// \brief Returns the alignment field of an attribute as a byte alignment
184  /// value.
185  unsigned getAlignment() const;
186 
187  /// \brief Returns the stack alignment field of an attribute as a byte
188  /// alignment value.
189  unsigned getStackAlignment() const;
190 
191  /// \brief Returns the number of dereferenceable bytes from the
192  /// dereferenceable attribute (or zero if unknown).
193  uint64_t getDereferenceableBytes() const;
194 
195  /// \brief Returns the number of dereferenceable_or_null bytes from the
196  /// dereferenceable_or_null attribute (or zero if unknown).
197  uint64_t getDereferenceableOrNullBytes() const;
198 
199  /// \brief The Attribute is converted to a string of equivalent mnemonic. This
200  /// is, presumably, for writing out the mnemonics for the assembly writer.
201  std::string getAsString(bool InAttrGrp = false) const;
202 
203  /// \brief Equality and non-equality operators.
204  bool operator==(Attribute A) const { return pImpl == A.pImpl; }
205  bool operator!=(Attribute A) const { return pImpl != A.pImpl; }
206 
207  /// \brief Less-than operator. Useful for sorting the attributes list.
208  bool operator<(Attribute A) const;
209 
210  void Profile(FoldingSetNodeID &ID) const {
211  ID.AddPointer(pImpl);
212  }
213 };
214 
215 //===----------------------------------------------------------------------===//
216 /// \class
217 /// \brief This class holds the attributes for a function, its return value, and
218 /// its parameters. You access the attributes for each of them via an index into
219 /// the AttributeSet object. The function attributes are at index
220 /// `AttributeSet::FunctionIndex', the return value is at index
221 /// `AttributeSet::ReturnIndex', and the attributes for the parameters start at
222 /// index `1'.
224 public:
225  enum AttrIndex : unsigned {
228  };
229 private:
230  friend class AttrBuilder;
231  friend class AttributeSetImpl;
232  template <typename Ty> friend struct DenseMapInfo;
233 
234  /// \brief The attributes that we are managing. This can be null to represent
235  /// the empty attributes list.
236  AttributeSetImpl *pImpl;
237 
238  /// \brief The attributes for the specified index are returned.
239  AttributeSetNode *getAttributes(unsigned Index) const;
240 
241  /// \brief Create an AttributeSet with the specified parameters in it.
242  static AttributeSet get(LLVMContext &C,
244  static AttributeSet get(LLVMContext &C,
245  ArrayRef<std::pair<unsigned,
246  AttributeSetNode*> > Attrs);
247 
248  static AttributeSet getImpl(LLVMContext &C,
249  ArrayRef<std::pair<unsigned,
250  AttributeSetNode*> > Attrs);
251 
252 
253  explicit AttributeSet(AttributeSetImpl *LI) : pImpl(LI) {}
254 public:
255  AttributeSet() : pImpl(nullptr) {}
256 
257  //===--------------------------------------------------------------------===//
258  // AttributeSet Construction and Mutation
259  //===--------------------------------------------------------------------===//
260 
261  /// \brief Return an AttributeSet with the specified parameters in it.
262  static AttributeSet get(LLVMContext &C, ArrayRef<AttributeSet> Attrs);
263  static AttributeSet get(LLVMContext &C, unsigned Index,
265  static AttributeSet get(LLVMContext &C, unsigned Index, const AttrBuilder &B);
266 
267  /// \brief Add an attribute to the attribute set at the given index. Because
268  /// attribute sets are immutable, this returns a new set.
269  AttributeSet addAttribute(LLVMContext &C, unsigned Index,
270  Attribute::AttrKind Attr) const;
271 
272  /// \brief Add an attribute to the attribute set at the given index. Because
273  /// attribute sets are immutable, this returns a new set.
274  AttributeSet addAttribute(LLVMContext &C, unsigned Index,
275  StringRef Kind) const;
276  AttributeSet addAttribute(LLVMContext &C, unsigned Index,
277  StringRef Kind, StringRef Value) const;
278 
279  /// \brief Add attributes to the attribute set at the given index. Because
280  /// attribute sets are immutable, this returns a new set.
281  AttributeSet addAttributes(LLVMContext &C, unsigned Index,
282  AttributeSet Attrs) const;
283 
284  /// \brief Remove the specified attribute at the specified index from this
285  /// attribute list. Because attribute lists are immutable, this returns the
286  /// new list.
287  AttributeSet removeAttribute(LLVMContext &C, unsigned Index,
288  Attribute::AttrKind Attr) const;
289 
290  /// \brief Remove the specified attributes at the specified index from this
291  /// attribute list. Because attribute lists are immutable, this returns the
292  /// new list.
293  AttributeSet removeAttributes(LLVMContext &C, unsigned Index,
294  AttributeSet Attrs) const;
295 
296  /// \brief Remove the specified attributes at the specified index from this
297  /// attribute list. Because attribute lists are immutable, this returns the
298  /// new list.
299  AttributeSet removeAttributes(LLVMContext &C, unsigned Index,
300  const AttrBuilder &Attrs) const;
301 
302  /// \brief Add the dereferenceable attribute to the attribute set at the given
303  /// index. Because attribute sets are immutable, this returns a new set.
305  uint64_t Bytes) const;
306 
307  /// \brief Add the dereferenceable_or_null attribute to the attribute set at
308  /// the given index. Because attribute sets are immutable, this returns a new
309  /// set.
311  uint64_t Bytes) const;
312 
313  //===--------------------------------------------------------------------===//
314  // AttributeSet Accessors
315  //===--------------------------------------------------------------------===//
316 
317  /// \brief Retrieve the LLVM context.
318  LLVMContext &getContext() const;
319 
320  /// \brief The attributes for the specified index are returned.
321  AttributeSet getParamAttributes(unsigned Index) const;
322 
323  /// \brief The attributes for the ret value are returned.
325 
326  /// \brief The function attributes are returned.
328 
329  /// \brief Return true if the attribute exists at the given index.
330  bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const;
331 
332  /// \brief Return true if the attribute exists at the given index.
333  bool hasAttribute(unsigned Index, StringRef Kind) const;
334 
335  /// \brief Return true if attribute exists at the given index.
336  bool hasAttributes(unsigned Index) const;
337 
338  /// \brief Return true if the specified attribute is set for at least one
339  /// parameter or for the return value.
340  bool hasAttrSomewhere(Attribute::AttrKind Attr) const;
341 
342  /// \brief Return the attribute object that exists at the given index.
343  Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const;
344 
345  /// \brief Return the attribute object that exists at the given index.
346  Attribute getAttribute(unsigned Index, StringRef Kind) const;
347 
348  /// \brief Return the alignment for the specified function parameter.
349  unsigned getParamAlignment(unsigned Index) const;
350 
351  /// \brief Get the stack alignment.
352  unsigned getStackAlignment(unsigned Index) const;
353 
354  /// \brief Get the number of dereferenceable bytes (or zero if unknown).
355  uint64_t getDereferenceableBytes(unsigned Index) const;
356 
357  /// \brief Get the number of dereferenceable_or_null bytes (or zero if
358  /// unknown).
359  uint64_t getDereferenceableOrNullBytes(unsigned Index) const;
360 
361  /// \brief Return the attributes at the index as a string.
362  std::string getAsString(unsigned Index, bool InAttrGrp = false) const;
363 
365 
366  iterator begin(unsigned Slot) const;
367  iterator end(unsigned Slot) const;
368 
369  /// operator==/!= - Provide equality predicates.
370  bool operator==(const AttributeSet &RHS) const {
371  return pImpl == RHS.pImpl;
372  }
373  bool operator!=(const AttributeSet &RHS) const {
374  return pImpl != RHS.pImpl;
375  }
376 
377  //===--------------------------------------------------------------------===//
378  // AttributeSet Introspection
379  //===--------------------------------------------------------------------===//
380 
381  // FIXME: Remove this.
382  uint64_t Raw(unsigned Index) const;
383 
384  /// \brief Return a raw pointer that uniquely identifies this attribute list.
385  void *getRawPointer() const {
386  return pImpl;
387  }
388 
389  /// \brief Return true if there are no attributes.
390  bool isEmpty() const {
391  return getNumSlots() == 0;
392  }
393 
394  /// \brief Return the number of slots used in this attribute list. This is
395  /// the number of arguments that have an attribute set on them (including the
396  /// function itself).
397  unsigned getNumSlots() const;
398 
399  /// \brief Return the index for the given slot.
400  unsigned getSlotIndex(unsigned Slot) const;
401 
402  /// \brief Return the attributes at the given slot.
403  AttributeSet getSlotAttributes(unsigned Slot) const;
404 
405  void dump() const;
406 };
407 
408 //===----------------------------------------------------------------------===//
409 /// \class
410 /// \brief Provide DenseMapInfo for AttributeSet.
411 template<> struct DenseMapInfo<AttributeSet> {
412  static inline AttributeSet getEmptyKey() {
413  uintptr_t Val = static_cast<uintptr_t>(-1);
414  Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
415  return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
416  }
417  static inline AttributeSet getTombstoneKey() {
418  uintptr_t Val = static_cast<uintptr_t>(-2);
419  Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
420  return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
421  }
422  static unsigned getHashValue(AttributeSet AS) {
423  return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
424  (unsigned((uintptr_t)AS.pImpl) >> 9);
425  }
426  static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
427 };
428 
429 //===----------------------------------------------------------------------===//
430 /// \class
431 /// \brief This class is used in conjunction with the Attribute::get method to
432 /// create an Attribute object. The object itself is uniquified. The Builder's
433 /// value, however, is not. So this can be used as a quick way to test for
434 /// equality, presence of attributes, etc.
435 class AttrBuilder {
436  std::bitset<Attribute::EndAttrKinds> Attrs;
437  std::map<std::string, std::string> TargetDepAttrs;
438  uint64_t Alignment;
439  uint64_t StackAlignment;
440  uint64_t DerefBytes;
441  uint64_t DerefOrNullBytes;
442 public:
444  : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
445  DerefOrNullBytes(0) {}
446  explicit AttrBuilder(uint64_t Val)
447  : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
448  DerefOrNullBytes(0) {
449  addRawValue(Val);
450  }
452  : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
453  DerefOrNullBytes(0) {
454  addAttribute(A);
455  }
456  AttrBuilder(AttributeSet AS, unsigned Idx);
457 
458  void clear();
459 
460  /// \brief Add an attribute to the builder.
462 
463  /// \brief Add the Attribute object to the builder.
465 
466  /// \brief Add the target-dependent attribute to the builder.
468 
469  /// \brief Remove an attribute from the builder.
471 
472  /// \brief Remove the attributes from the builder.
473  AttrBuilder &removeAttributes(AttributeSet A, uint64_t Index);
474 
475  /// \brief Remove the target-dependent attribute to the builder.
477 
478  /// \brief Add the attributes from the builder.
479  AttrBuilder &merge(const AttrBuilder &B);
480 
481  /// \brief Remove the attributes from the builder.
482  AttrBuilder &remove(const AttrBuilder &B);
483 
484  /// \brief Return true if the builder has any attribute that's in the
485  /// specified builder.
486  bool overlaps(const AttrBuilder &B) const;
487 
488  /// \brief Return true if the builder has the specified attribute.
490  assert((unsigned)A < Attribute::EndAttrKinds && "Attribute out of range!");
491  return Attrs[A];
492  }
493 
494  /// \brief Return true if the builder has the specified target-dependent
495  /// attribute.
496  bool contains(StringRef A) const;
497 
498  /// \brief Return true if the builder has IR-level attributes.
499  bool hasAttributes() const;
500 
501  /// \brief Return true if the builder has any attribute that's in the
502  /// specified attribute.
503  bool hasAttributes(AttributeSet A, uint64_t Index) const;
504 
505  /// \brief Return true if the builder has an alignment attribute.
506  bool hasAlignmentAttr() const;
507 
508  /// \brief Retrieve the alignment attribute, if it exists.
509  uint64_t getAlignment() const { return Alignment; }
510 
511  /// \brief Retrieve the stack alignment attribute, if it exists.
512  uint64_t getStackAlignment() const { return StackAlignment; }
513 
514  /// \brief Retrieve the number of dereferenceable bytes, if the dereferenceable
515  /// attribute exists (zero is returned otherwise).
516  uint64_t getDereferenceableBytes() const { return DerefBytes; }
517 
518  /// \brief Retrieve the number of dereferenceable_or_null bytes, if the
519  /// dereferenceable_or_null attribute exists (zero is returned otherwise).
520  uint64_t getDereferenceableOrNullBytes() const { return DerefOrNullBytes; }
521 
522  /// \brief This turns an int alignment (which must be a power of 2) into the
523  /// form used internally in Attribute.
525 
526  /// \brief This turns an int stack alignment (which must be a power of 2) into
527  /// the form used internally in Attribute.
529 
530  /// \brief This turns the number of dereferenceable bytes into the form used
531  /// internally in Attribute.
532  AttrBuilder &addDereferenceableAttr(uint64_t Bytes);
533 
534  /// \brief This turns the number of dereferenceable_or_null bytes into the
535  /// form used internally in Attribute.
536  AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes);
537 
538  /// \brief Return true if the builder contains no target-independent
539  /// attributes.
540  bool empty() const { return Attrs.none(); }
541 
542  // Iterators for target-dependent attributes.
543  typedef std::pair<std::string, std::string> td_type;
544  typedef std::map<std::string, std::string>::iterator td_iterator;
545  typedef std::map<std::string, std::string>::const_iterator td_const_iterator;
548 
549  td_iterator td_begin() { return TargetDepAttrs.begin(); }
550  td_iterator td_end() { return TargetDepAttrs.end(); }
551 
552  td_const_iterator td_begin() const { return TargetDepAttrs.begin(); }
553  td_const_iterator td_end() const { return TargetDepAttrs.end(); }
554 
557  return td_const_range(td_begin(), td_end());
558  }
559 
560  bool td_empty() const { return TargetDepAttrs.empty(); }
561 
562  bool operator==(const AttrBuilder &B);
563  bool operator!=(const AttrBuilder &B) {
564  return !(*this == B);
565  }
566 
567  // FIXME: Remove this in 4.0.
568 
569  /// \brief Add the raw value to the internal representation.
570  AttrBuilder &addRawValue(uint64_t Val);
571 };
572 
573 namespace AttributeFuncs {
574 
575 /// \brief Which attributes cannot be applied to a type.
577 
578 } // end AttributeFuncs namespace
579 
580 } // end llvm namespace
581 
582 #endif
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
Definition: FoldingSet.cpp:52
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute list.
Definition: Attributes.h:385
static AttributeSet getEmptyKey()
Definition: Attributes.h:412
Alignment of stack for function (3 bits) stored as log2 of alignment with +1 bias 0 means unaligned (...
Definition: Attributes.h:106
AttributeSet getParamAttributes(unsigned Index) const
The attributes for the specified index are returned.
Definition: Attributes.cpp:930
unsigned getStackAlignment(unsigned Index) const
Get the stack alignment.
Sign extended before/after call.
Definition: Attributes.h:105
std::string getAsString(unsigned Index, bool InAttrGrp=false) const
Return the attributes at the index as a string.
static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align)
Return a uniquified Attribute object that has the specific alignment set.
Definition: Attributes.cpp:78
Force argument to be passed in register.
Definition: Attributes.h:78
Function is called early and/or often, so lazy binding isn't worthwhile.
Definition: Attributes.h:89
static Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
Definition: Attributes.cpp:91
Nested function static chain.
Definition: Attributes.h:82
static unsigned getHashValue(AttributeSet AS)
Definition: Attributes.h:422
td_iterator td_end()
Definition: Attributes.h:550
uint64_t getAlignment() const
Retrieve the alignment attribute, if it exists.
Definition: Attributes.h:509
uint64_t getDereferenceableOrNullBytes() const
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists...
Definition: Attributes.h:520
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
Definition: Attributes.cpp:126
Source said inlining was desirable.
Definition: Attributes.h:77
iterator begin(unsigned Slot) const
AttrBuilder & addDereferenceableAttr(uint64_t Bytes)
This turns the number of dereferenceable bytes into the form used internally in Attribute.
unsigned getParamAlignment(unsigned Index) const
Return the alignment for the specified function parameter.
Definition: Attributes.cpp:997
unsigned getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
Definition: Attributes.cpp:157
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
Definition: Attributes.cpp:956
bool hasAlignmentAttr() const
Return true if the builder has an alignment attribute.
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
Definition: Attributes.h:489
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
Definition: Attributes.cpp:147
Naked function.
Definition: Attributes.h:81
AttrBuilder & addRawValue(uint64_t Val)
Add the raw value to the internal representation.
AttributeSet getRetAttributes() const
The attributes for the ret value are returned.
Definition: Attributes.cpp:938
bool td_empty() const
Definition: Attributes.h:560
StringRef getKindAsString() const
Return the attribute's kind as a string.
Definition: Attributes.cpp:133
AttributeSet removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Attr) const
Remove the specified attribute at the specified index from this attribute list.
Definition: Attributes.cpp:822
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
Definition: Attributes.cpp:186
AttrBuilder & addDereferenceableOrNullAttr(uint64_t Bytes)
This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute...
static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
Definition: Attributes.cpp:97
No attributes have been set.
Definition: Attributes.h:66
AttributeSet addDereferenceableAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
Definition: Attributes.cpp:907
Function must be in a unwind table.
Definition: Attributes.h:118
td_const_range td_attrs() const
Definition: Attributes.h:556
Function does not access memory.
Definition: Attributes.h:99
Hidden pointer to structure to return.
Definition: Attributes.h:114
Function creates no aliases of pointer.
Definition: Attributes.h:85
td_const_iterator td_begin() const
Definition: Attributes.h:552
std::map< std::string, std::string >::iterator td_iterator
Definition: Attributes.h:544
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
Definition: Attributes.h:516
Safe Stack protection.
Definition: Attributes.h:113
static AttributeSet getTombstoneKey()
Definition: Attributes.h:417
llvm::iterator_range< td_const_iterator > td_const_range
Definition: Attributes.h:547
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:31
unsigned getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
Definition: Attributes.cpp:165
Pass structure by value.
Definition: Attributes.h:73
Stack protection.
Definition: Attributes.h:110
Considered to not alias after call.
Definition: Attributes.h:83
static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align)
Definition: Attributes.cpp:84
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition: FoldingSet.h:297
std::pair< std::string, std::string > td_type
Definition: Attributes.h:543
uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute (or zero if unknown)...
Definition: Attributes.cpp:172
unsigned getNumSlots() const
Return the number of slots used in this attribute list.
bool operator==(const AttrBuilder &B)
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
AttributeSet getSlotAttributes(unsigned Slot) const
Return the attributes at the given slot.
bool operator!=(const AttrBuilder &B)
Definition: Attributes.h:563
Return value is always equal to this argument.
Definition: Attributes.h:103
Pass structure in an alloca.
Definition: Attributes.h:74
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
td_iterator td_begin()
Definition: Attributes.h:549
Zero extended before/after call.
Definition: Attributes.h:119
bool overlaps(const AttrBuilder &B) const
Return true if the builder has any attribute that's in the specified builder.
Function doesn't unwind stack.
Definition: Attributes.h:96
bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
Definition: Attributes.cpp:107
bool operator==(Attribute A) const
Equality and non-equality operators.
Definition: Attributes.h:204
Marks function as being in a cold path.
Definition: Attributes.h:75
Sentinal value useful for loops.
Definition: Attributes.h:121
Mark the function as not returning.
Definition: Attributes.h:95
uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute (or ze...
Definition: Attributes.cpp:179
void dump() const
Call cannot be duplicated.
Definition: Attributes.h:86
Pointer is known to be not null.
Definition: Attributes.h:91
LLVMContext & getContext() const
Retrieve the LLVM context.
Definition: Attributes.cpp:926
AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
Callee is recognized as a builtin, despite nobuiltin attribute on its declaration.
Definition: Attributes.h:71
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
Definition: Attributes.cpp:119
iterator end(unsigned Slot) const
void Profile(FoldingSetNodeID &ID) const
Definition: Attributes.h:210
bool isIntAttribute() const
Return true if the attribute is an integer attribute.
Definition: Attributes.cpp:111
bool empty() const
Return true if the builder contains no target-independent attributes.
Definition: Attributes.h:540
AttrBuilder(const Attribute &A)
Definition: Attributes.h:451
llvm::iterator_range< td_iterator > td_range
Definition: Attributes.h:546
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))
Alignment of parameter (5 bits) stored as log2 of alignment with +1 bias 0 means unaligned (different...
Definition: Attributes.h:67
AttributeSet removeAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Remove the specified attributes at the specified index from this attribute list.
Definition: Attributes.cpp:828
A range adaptor for a pair of iterators.
Function must not be optimized.
Definition: Attributes.h:98
Function only reads from memory.
Definition: Attributes.h:100
std::map< std::string, std::string >::const_iterator td_const_iterator
Definition: Attributes.h:545
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
Definition: Attributes.cpp:327
bool operator==(const AttributeSet &RHS) const
operator==/!= - Provide equality predicates.
Definition: Attributes.h:370
Disable redzone.
Definition: Attributes.h:94
ThreadSanitizer is on.
Definition: Attributes.h:116
AttributeSet addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Attr) const
Add an attribute to the attribute set at the given index.
Definition: Attributes.cpp:753
unsigned getSlotIndex(unsigned Slot) const
Return the index for the given slot.
bool hasAttrSomewhere(Attribute::AttrKind Attr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
Definition: Attributes.cpp:973
AttributeSet addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given index.
Definition: Attributes.cpp:914
bool hasAttributes(unsigned Index) const
Return true if attribute exists at the given index.
Definition: Attributes.cpp:966
AttrBuilder typeIncompatible(const Type *Ty)
Which attributes cannot be applied to a type.
Callee isn't recognized as a builtin.
Definition: Attributes.h:84
AttrBuilder(uint64_t Val)
Definition: Attributes.h:446
ArrayRef< Attribute >::iterator iterator
Definition: Attributes.h:364
AddressSanitizer is on.
Definition: Attributes.h:115
Strong Stack protection.
Definition: Attributes.h:112
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
Definition: Attributes.cpp:115
td_range td_attrs()
Definition: Attributes.h:555
AttributeSet getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
Funciton can access memory only using pointers based on its arguments.
Definition: Attributes.h:101
AttrBuilder & removeAttributes(AttributeSet A, uint64_t Index)
Remove the attributes from the builder.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
Definition: Attributes.cpp:985
AttrBuilder & merge(const AttrBuilder &B)
Add the attributes from the builder.
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:140
Function can return twice.
Definition: Attributes.h:104
const ARM::ArchExtKind Kind
Pointer is known to be dereferenceable.
Definition: Attributes.h:92
LLVM Value Representation.
Definition: Value.h:69
uint64_t Raw(unsigned Index) const
bool hasAttributes() const
Return true if the builder has IR-level attributes.
Disable implicit floating point insts.
Definition: Attributes.h:87
AttrBuilder & addStackAlignmentAttr(unsigned Align)
This turns an int stack alignment (which must be a power of 2) into the form used internally in Attri...
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
AttrBuilder & addAlignmentAttr(unsigned Align)
This turns an int alignment (which must be a power of 2) into the form used internally in Attribute...
bool operator!=(Attribute A) const
Definition: Attributes.h:205
static bool isEqual(AttributeSet LHS, AttributeSet RHS)
Definition: Attributes.h:426
AttributeSet addAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Add attributes to the attribute set at the given index.
Definition: Attributes.cpp:773
Can only be moved to control-equivalent blocks.
Definition: Attributes.h:76
Stack protection required.
Definition: Attributes.h:111
td_const_iterator td_end() const
Definition: Attributes.h:553
MemorySanitizer is on.
Definition: Attributes.h:117
bool isEmpty() const
Return true if there are no attributes.
Definition: Attributes.h:390
Build jump-instruction tables and replace refs.
Definition: Attributes.h:79
Pointer is either null or dereferenceable.
Definition: Attributes.h:93
uint64_t getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
Definition: Attributes.h:512
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
Definition: Attributes.h:64
AttributeSet getFnAttributes() const
The function attributes are returned.
Definition: Attributes.cpp:947
bool operator!=(const AttributeSet &RHS) const
Definition: Attributes.h:373
Function must be optimized for size first.
Definition: Attributes.h:80