LLVM  16.0.0git
Attributes.h
Go to the documentation of this file.
1 //===- llvm/Attributes.h - Container for Attributes -------------*- 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 /// \file
10 /// This file contains the simple types necessary to represent the
11 /// attributes associated with functions and their calls.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_IR_ATTRIBUTES_H
16 #define LLVM_IR_ATTRIBUTES_H
17 
18 #include "llvm-c/Types.h"
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/BitmaskEnum.h"
21 #include "llvm/ADT/Optional.h"
22 #include "llvm/ADT/SmallString.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/Config/llvm-config.h"
25 #include "llvm/Support/Alignment.h"
26 #include "llvm/Support/CodeGen.h"
28 #include <bitset>
29 #include <cassert>
30 #include <cstdint>
31 #include <set>
32 #include <string>
33 #include <utility>
34 
35 namespace llvm {
36 
37 class AttrBuilder;
38 class AttributeMask;
39 class AttributeImpl;
40 class AttributeListImpl;
41 class AttributeSetNode;
42 class FoldingSetNodeID;
43 class Function;
44 class LLVMContext;
45 class Type;
46 
47 enum class AllocFnKind : uint64_t {
48  Unknown = 0,
49  Alloc = 1 << 0, // Allocator function returns a new allocation
50  Realloc = 1 << 1, // Allocator function resizes the `allocptr` argument
51  Free = 1 << 2, // Allocator function frees the `allocptr` argument
52  Uninitialized = 1 << 3, // Allocator function returns uninitialized memory
53  Zeroed = 1 << 4, // Allocator function returns zeroed memory
54  Aligned = 1 << 5, // Allocator function aligns allocations per the
55  // `allocalign` argument
56  LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ Aligned)
57 };
58 
59 //===----------------------------------------------------------------------===//
60 /// \class
61 /// Functions, function parameters, and return types can have attributes
62 /// to indicate how they should be treated by optimizations and code
63 /// generation. This class represents one of those attributes. It's light-weight
64 /// and should be passed around by-value.
65 class Attribute {
66 public:
67  /// This enumeration lists the attributes that can be associated with
68  /// parameters, function results, or the function itself.
69  ///
70  /// Note: The `uwtable' attribute is about the ABI or the user mandating an
71  /// entry in the unwind table. The `nounwind' attribute is about an exception
72  /// passing by the function.
73  ///
74  /// In a theoretical system that uses tables for profiling and SjLj for
75  /// exceptions, they would be fully independent. In a normal system that uses
76  /// tables for both, the semantics are:
77  ///
78  /// nil = Needs an entry because an exception might pass by.
79  /// nounwind = No need for an entry
80  /// uwtable = Needs an entry because the ABI says so and because
81  /// an exception might pass by.
82  /// uwtable + nounwind = Needs an entry because the ABI says so.
83 
84  enum AttrKind {
85  // IR-Level Attributes
86  None, ///< No attributes have been set
87  #define GET_ATTR_ENUM
88  #include "llvm/IR/Attributes.inc"
89  EndAttrKinds, ///< Sentinal value useful for loops
90  EmptyKey, ///< Use as Empty key for DenseMap of AttrKind
91  TombstoneKey, ///< Use as Tombstone key for DenseMap of AttrKind
92  };
93 
94  static const unsigned NumIntAttrKinds = LastIntAttr - FirstIntAttr + 1;
95  static const unsigned NumTypeAttrKinds = LastTypeAttr - FirstTypeAttr + 1;
96 
97  static bool isEnumAttrKind(AttrKind Kind) {
98  return Kind >= FirstEnumAttr && Kind <= LastEnumAttr;
99  }
100  static bool isIntAttrKind(AttrKind Kind) {
101  return Kind >= FirstIntAttr && Kind <= LastIntAttr;
102  }
103  static bool isTypeAttrKind(AttrKind Kind) {
104  return Kind >= FirstTypeAttr && Kind <= LastTypeAttr;
105  }
106 
107  static bool canUseAsFnAttr(AttrKind Kind);
108  static bool canUseAsParamAttr(AttrKind Kind);
109  static bool canUseAsRetAttr(AttrKind Kind);
110 
111 private:
112  AttributeImpl *pImpl = nullptr;
113 
114  Attribute(AttributeImpl *A) : pImpl(A) {}
115 
116 public:
117  Attribute() = default;
118 
119  //===--------------------------------------------------------------------===//
120  // Attribute Construction
121  //===--------------------------------------------------------------------===//
122 
123  /// Return a uniquified Attribute object.
124  static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val = 0);
125  static Attribute get(LLVMContext &Context, StringRef Kind,
126  StringRef Val = StringRef());
127  static Attribute get(LLVMContext &Context, AttrKind Kind, Type *Ty);
128 
129  /// Return a uniquified Attribute object that has the specific
130  /// alignment set.
131  static Attribute getWithAlignment(LLVMContext &Context, Align Alignment);
132  static Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment);
133  static Attribute getWithDereferenceableBytes(LLVMContext &Context,
134  uint64_t Bytes);
136  uint64_t Bytes);
137  static Attribute getWithAllocSizeArgs(LLVMContext &Context,
138  unsigned ElemSizeArg,
139  const Optional<unsigned> &NumElemsArg);
140  static Attribute getWithVScaleRangeArgs(LLVMContext &Context,
141  unsigned MinValue, unsigned MaxValue);
142  static Attribute getWithByValType(LLVMContext &Context, Type *Ty);
143  static Attribute getWithStructRetType(LLVMContext &Context, Type *Ty);
144  static Attribute getWithByRefType(LLVMContext &Context, Type *Ty);
145  static Attribute getWithPreallocatedType(LLVMContext &Context, Type *Ty);
146  static Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty);
147  static Attribute getWithUWTableKind(LLVMContext &Context, UWTableKind Kind);
148 
149  /// For a typed attribute, return the equivalent attribute with the type
150  /// changed to \p ReplacementTy.
152  assert(isTypeAttribute() && "this requires a typed attribute");
153  return get(Context, getKindAsEnum(), ReplacementTy);
154  }
155 
157 
159 
160  /// Return true if the provided string matches the IR name of an attribute.
161  /// example: "noalias" return true but not "NoAlias"
162  static bool isExistingAttribute(StringRef Name);
163 
164  //===--------------------------------------------------------------------===//
165  // Attribute Accessors
166  //===--------------------------------------------------------------------===//
167 
168  /// Return true if the attribute is an Attribute::AttrKind type.
169  bool isEnumAttribute() const;
170 
171  /// Return true if the attribute is an integer attribute.
172  bool isIntAttribute() const;
173 
174  /// Return true if the attribute is a string (target-dependent)
175  /// attribute.
176  bool isStringAttribute() const;
177 
178  /// Return true if the attribute is a type attribute.
179  bool isTypeAttribute() const;
180 
181  /// Return true if the attribute is any kind of attribute.
182  bool isValid() const { return pImpl; }
183 
184  /// Return true if the attribute is present.
185  bool hasAttribute(AttrKind Val) const;
186 
187  /// Return true if the target-dependent attribute is present.
188  bool hasAttribute(StringRef Val) const;
189 
190  /// Return the attribute's kind as an enum (Attribute::AttrKind). This
191  /// requires the attribute to be an enum, integer, or type attribute.
193 
194  /// Return the attribute's value as an integer. This requires that the
195  /// attribute be an integer attribute.
196  uint64_t getValueAsInt() const;
197 
198  /// Return the attribute's value as a boolean. This requires that the
199  /// attribute be a string attribute.
200  bool getValueAsBool() const;
201 
202  /// Return the attribute's kind as a string. This requires the
203  /// attribute to be a string attribute.
204  StringRef getKindAsString() const;
205 
206  /// Return the attribute's value as a string. This requires the
207  /// attribute to be a string attribute.
208  StringRef getValueAsString() const;
209 
210  /// Return the attribute's value as a Type. This requires the attribute to be
211  /// a type attribute.
212  Type *getValueAsType() const;
213 
214  /// Returns the alignment field of an attribute as a byte alignment
215  /// value.
216  MaybeAlign getAlignment() const;
217 
218  /// Returns the stack alignment field of an attribute as a byte
219  /// alignment value.
221 
222  /// Returns the number of dereferenceable bytes from the
223  /// dereferenceable attribute.
225 
226  /// Returns the number of dereferenceable_or_null bytes from the
227  /// dereferenceable_or_null attribute.
229 
230  /// Returns the argument numbers for the allocsize attribute (or pair(0, 0)
231  /// if not known).
232  std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const;
233 
234  /// Returns the minimum value for the vscale_range attribute.
235  unsigned getVScaleRangeMin() const;
236 
237  /// Returns the maximum value for the vscale_range attribute or None when
238  /// unknown.
240 
241  // Returns the unwind table kind.
242  UWTableKind getUWTableKind() const;
243 
244  // Returns the allocator function kind.
245  AllocFnKind getAllocKind() const;
246 
247  /// The Attribute is converted to a string of equivalent mnemonic. This
248  /// is, presumably, for writing out the mnemonics for the assembly writer.
249  std::string getAsString(bool InAttrGrp = false) const;
250 
251  /// Return true if this attribute belongs to the LLVMContext.
252  bool hasParentContext(LLVMContext &C) const;
253 
254  /// Equality and non-equality operators.
255  bool operator==(Attribute A) const { return pImpl == A.pImpl; }
256  bool operator!=(Attribute A) const { return pImpl != A.pImpl; }
257 
258  /// Less-than operator. Useful for sorting the attributes list.
259  bool operator<(Attribute A) const;
260 
261  void Profile(FoldingSetNodeID &ID) const;
262 
263  /// Return a raw pointer that uniquely identifies this attribute.
264  void *getRawPointer() const {
265  return pImpl;
266  }
267 
268  /// Get an attribute from a raw pointer created by getRawPointer.
269  static Attribute fromRawPointer(void *RawPtr) {
270  return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
271  }
272 };
273 
274 // Specialized opaque value conversions.
276  return reinterpret_cast<LLVMAttributeRef>(Attr.getRawPointer());
277 }
278 
279 // Specialized opaque value conversions.
281  return Attribute::fromRawPointer(Attr);
282 }
283 
284 //===----------------------------------------------------------------------===//
285 /// \class
286 /// This class holds the attributes for a particular argument, parameter,
287 /// function, or return value. It is an immutable value type that is cheap to
288 /// copy. Adding and removing enum attributes is intended to be fast, but adding
289 /// and removing string or integer attributes involves a FoldingSet lookup.
291  friend AttributeListImpl;
292  template <typename Ty, typename Enable> friend struct DenseMapInfo;
293 
294  // TODO: Extract AvailableAttrs from AttributeSetNode and store them here.
295  // This will allow an efficient implementation of addAttribute and
296  // removeAttribute for enum attrs.
297 
298  /// Private implementation pointer.
299  AttributeSetNode *SetNode = nullptr;
300 
301 private:
302  explicit AttributeSet(AttributeSetNode *ASN) : SetNode(ASN) {}
303 
304 public:
305  /// AttributeSet is a trivially copyable value type.
306  AttributeSet() = default;
307  AttributeSet(const AttributeSet &) = default;
308  ~AttributeSet() = default;
309 
310  static AttributeSet get(LLVMContext &C, const AttrBuilder &B);
312 
313  bool operator==(const AttributeSet &O) const { return SetNode == O.SetNode; }
314  bool operator!=(const AttributeSet &O) const { return !(*this == O); }
315 
316  /// Add an argument attribute. Returns a new set because attribute sets are
317  /// immutable.
318  [[nodiscard]] AttributeSet addAttribute(LLVMContext &C,
319  Attribute::AttrKind Kind) const;
320 
321  /// Add a target-dependent attribute. Returns a new set because attribute sets
322  /// are immutable.
324  StringRef Value = StringRef()) const;
325 
326  /// Add attributes to the attribute set. Returns a new set because attribute
327  /// sets are immutable.
328  [[nodiscard]] AttributeSet addAttributes(LLVMContext &C,
329  AttributeSet AS) const;
330 
331  /// Remove the specified attribute from this set. Returns a new set because
332  /// attribute sets are immutable.
333  [[nodiscard]] AttributeSet removeAttribute(LLVMContext &C,
334  Attribute::AttrKind Kind) const;
335 
336  /// Remove the specified attribute from this set. Returns a new set because
337  /// attribute sets are immutable.
338  [[nodiscard]] AttributeSet removeAttribute(LLVMContext &C,
339  StringRef Kind) const;
340 
341  /// Remove the specified attributes from this set. Returns a new set because
342  /// attribute sets are immutable.
343  [[nodiscard]] AttributeSet
344  removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const;
345 
346  /// Return the number of attributes in this set.
347  unsigned getNumAttributes() const;
348 
349  /// Return true if attributes exists in this set.
350  bool hasAttributes() const { return SetNode != nullptr; }
351 
352  /// Return true if the attribute exists in this set.
354 
355  /// Return true if the attribute exists in this set.
356  bool hasAttribute(StringRef Kind) const;
357 
358  /// Return the attribute object.
360 
361  /// Return the target-dependent attribute object.
363 
364  MaybeAlign getAlignment() const;
368  Type *getByValType() const;
369  Type *getStructRetType() const;
370  Type *getByRefType() const;
371  Type *getPreallocatedType() const;
372  Type *getInAllocaType() const;
373  Type *getElementType() const;
374  std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const;
375  unsigned getVScaleRangeMin() const;
377  UWTableKind getUWTableKind() const;
378  AllocFnKind getAllocKind() const;
379  std::string getAsString(bool InAttrGrp = false) const;
380 
381  /// Return true if this attribute set belongs to the LLVMContext.
382  bool hasParentContext(LLVMContext &C) const;
383 
384  using iterator = const Attribute *;
385 
386  iterator begin() const;
387  iterator end() const;
388 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
389  void dump() const;
390 #endif
391 };
392 
393 //===----------------------------------------------------------------------===//
394 /// \class
395 /// Provide DenseMapInfo for AttributeSet.
396 template <> struct DenseMapInfo<AttributeSet, void> {
398  auto Val = static_cast<uintptr_t>(-1);
399  Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
400  return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
401  }
402 
404  auto Val = static_cast<uintptr_t>(-2);
405  Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
406  return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
407  }
408 
409  static unsigned getHashValue(AttributeSet AS) {
410  return (unsigned((uintptr_t)AS.SetNode) >> 4) ^
411  (unsigned((uintptr_t)AS.SetNode) >> 9);
412  }
413 
414  static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
415 };
416 
417 //===----------------------------------------------------------------------===//
418 /// \class
419 /// This class holds the attributes for a function, its return value, and
420 /// its parameters. You access the attributes for each of them via an index into
421 /// the AttributeList object. The function attributes are at index
422 /// `AttributeList::FunctionIndex', the return value is at index
423 /// `AttributeList::ReturnIndex', and the attributes for the parameters start at
424 /// index `AttributeList::FirstArgIndex'.
426 public:
427  enum AttrIndex : unsigned {
431  };
432 
433 private:
434  friend class AttrBuilder;
435  friend class AttributeListImpl;
436  friend class AttributeSet;
437  friend class AttributeSetNode;
438  template <typename Ty, typename Enable> friend struct DenseMapInfo;
439 
440  /// The attributes that we are managing. This can be null to represent
441  /// the empty attributes list.
442  AttributeListImpl *pImpl = nullptr;
443 
444 public:
445  /// Create an AttributeList with the specified parameters in it.
446  static AttributeList get(LLVMContext &C,
447  ArrayRef<std::pair<unsigned, Attribute>> Attrs);
448  static AttributeList get(LLVMContext &C,
449  ArrayRef<std::pair<unsigned, AttributeSet>> Attrs);
450 
451  /// Create an AttributeList from attribute sets for a function, its
452  /// return value, and all of its arguments.
453  static AttributeList get(LLVMContext &C, AttributeSet FnAttrs,
454  AttributeSet RetAttrs,
455  ArrayRef<AttributeSet> ArgAttrs);
456 
457 private:
458  explicit AttributeList(AttributeListImpl *LI) : pImpl(LI) {}
459 
461 
462  AttributeList setAttributesAtIndex(LLVMContext &C, unsigned Index,
463  AttributeSet Attrs) const;
464 
465 public:
466  AttributeList() = default;
467 
468  //===--------------------------------------------------------------------===//
469  // AttributeList Construction and Mutation
470  //===--------------------------------------------------------------------===//
471 
472  /// Return an AttributeList with the specified parameters in it.
474  static AttributeList get(LLVMContext &C, unsigned Index,
476  static AttributeList get(LLVMContext &C, unsigned Index,
478  ArrayRef<uint64_t> Values);
479  static AttributeList get(LLVMContext &C, unsigned Index,
481  static AttributeList get(LLVMContext &C, unsigned Index,
483  static AttributeList get(LLVMContext &C, unsigned Index,
484  const AttrBuilder &B);
485 
486  // TODO: remove non-AtIndex versions of these methods.
487  /// Add an attribute to the attribute set at the given index.
488  /// Returns a new list because attribute lists are immutable.
489  [[nodiscard]] AttributeList
491  Attribute::AttrKind Kind) const;
492 
493  /// Add an attribute to the attribute set at the given index.
494  /// Returns a new list because attribute lists are immutable.
495  [[nodiscard]] AttributeList
497  StringRef Value = StringRef()) const;
498 
499  /// Add an attribute to the attribute set at the given index.
500  /// Returns a new list because attribute lists are immutable.
501  [[nodiscard]] AttributeList
502  addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute A) const;
503 
504  /// Add attributes to the attribute set at the given index.
505  /// Returns a new list because attribute lists are immutable.
507  unsigned Index,
508  const AttrBuilder &B) const;
509 
510  /// Add a function attribute to the list. Returns a new list because
511  /// attribute lists are immutable.
513  Attribute::AttrKind Kind) const {
515  }
516 
517  /// Add a function attribute to the list. Returns a new list because
518  /// attribute lists are immutable.
520  Attribute Attr) const {
521  return addAttributeAtIndex(C, FunctionIndex, Attr);
522  }
523 
524  /// Add a function attribute to the list. Returns a new list because
525  /// attribute lists are immutable.
526  [[nodiscard]] AttributeList
528  StringRef Value = StringRef()) const {
530  }
531 
532  /// Add function attribute to the list. Returns a new list because
533  /// attribute lists are immutable.
535  const AttrBuilder &B) const {
537  }
538 
539  /// Add a return value attribute to the list. Returns a new list because
540  /// attribute lists are immutable.
542  Attribute::AttrKind Kind) const {
544  }
545 
546  /// Add a return value attribute to the list. Returns a new list because
547  /// attribute lists are immutable.
549  Attribute Attr) const {
550  return addAttributeAtIndex(C, ReturnIndex, Attr);
551  }
552 
553  /// Add a return value attribute to the list. Returns a new list because
554  /// attribute lists are immutable.
556  const AttrBuilder &B) const {
558  }
559 
560  /// Add an argument attribute to the list. Returns a new list because
561  /// attribute lists are immutable.
562  [[nodiscard]] AttributeList
563  addParamAttribute(LLVMContext &C, unsigned ArgNo,
564  Attribute::AttrKind Kind) const {
565  return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
566  }
567 
568  /// Add an argument attribute to the list. Returns a new list because
569  /// attribute lists are immutable.
570  [[nodiscard]] AttributeList
572  StringRef Value = StringRef()) const {
573  return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind, Value);
574  }
575 
576  /// Add an attribute to the attribute list at the given arg indices. Returns a
577  /// new list because attribute lists are immutable.
579  ArrayRef<unsigned> ArgNos,
580  Attribute A) const;
581 
582  /// Add an argument attribute to the list. Returns a new list because
583  /// attribute lists are immutable.
584  [[nodiscard]] AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo,
585  const AttrBuilder &B) const {
586  return addAttributesAtIndex(C, ArgNo + FirstArgIndex, B);
587  }
588 
589  /// Remove the specified attribute at the specified index from this
590  /// attribute list. Returns a new list because attribute lists are immutable.
591  [[nodiscard]] AttributeList
593  Attribute::AttrKind Kind) const;
594 
595  /// Remove the specified attribute at the specified index from this
596  /// attribute list. Returns a new list because attribute lists are immutable.
597  [[nodiscard]] AttributeList
599  [[nodiscard]] AttributeList removeAttribute(LLVMContext &C, unsigned Index,
600  StringRef Kind) const {
602  }
603 
604  /// Remove the specified attributes at the specified index from this
605  /// attribute list. Returns a new list because attribute lists are immutable.
606  [[nodiscard]] AttributeList
608  const AttributeMask &AttrsToRemove) const;
609 
610  /// Remove all attributes at the specified index from this
611  /// attribute list. Returns a new list because attribute lists are immutable.
613  unsigned Index) const;
614 
615  /// Remove the specified attribute at the function index from this
616  /// attribute list. Returns a new list because attribute lists are immutable.
617  [[nodiscard]] AttributeList
620  }
621 
622  /// Remove the specified attribute at the function index from this
623  /// attribute list. Returns a new list because attribute lists are immutable.
625  StringRef Kind) const {
627  }
628 
629  /// Remove the specified attribute at the function index from this
630  /// attribute list. Returns a new list because attribute lists are immutable.
631  [[nodiscard]] AttributeList
632  removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const {
633  return removeAttributesAtIndex(C, FunctionIndex, AttrsToRemove);
634  }
635 
636  /// Remove the attributes at the function index from this
637  /// attribute list. Returns a new list because attribute lists are immutable.
640  }
641 
642  /// Remove the specified attribute at the return value index from this
643  /// attribute list. Returns a new list because attribute lists are immutable.
644  [[nodiscard]] AttributeList
647  }
648 
649  /// Remove the specified attribute at the return value index from this
650  /// attribute list. Returns a new list because attribute lists are immutable.
652  StringRef Kind) const {
654  }
655 
656  /// Remove the specified attribute at the return value index from this
657  /// attribute list. Returns a new list because attribute lists are immutable.
658  [[nodiscard]] AttributeList
660  const AttributeMask &AttrsToRemove) const {
661  return removeAttributesAtIndex(C, ReturnIndex, AttrsToRemove);
662  }
663 
664  /// Remove the specified attribute at the specified arg index from this
665  /// attribute list. Returns a new list because attribute lists are immutable.
666  [[nodiscard]] AttributeList
668  Attribute::AttrKind Kind) const {
669  return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
670  }
671 
672  /// Remove the specified attribute at the specified arg index from this
673  /// attribute list. Returns a new list because attribute lists are immutable.
674  [[nodiscard]] AttributeList
675  removeParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind) const {
676  return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
677  }
678 
679  /// Remove the specified attribute at the specified arg index from this
680  /// attribute list. Returns a new list because attribute lists are immutable.
681  [[nodiscard]] AttributeList
683  const AttributeMask &AttrsToRemove) const {
684  return removeAttributesAtIndex(C, ArgNo + FirstArgIndex, AttrsToRemove);
685  }
686 
687  /// Remove all attributes at the specified arg index from this
688  /// attribute list. Returns a new list because attribute lists are immutable.
690  unsigned ArgNo) const {
691  return removeAttributesAtIndex(C, ArgNo + FirstArgIndex);
692  }
693 
694  /// Replace the type contained by attribute \p AttrKind at index \p ArgNo wih
695  /// \p ReplacementTy, preserving all other attributes.
696  [[nodiscard]] AttributeList
699  Type *ReplacementTy) const {
700  Attribute Attr = getAttributeAtIndex(ArgNo, Kind);
701  auto Attrs = removeAttributeAtIndex(C, ArgNo, Kind);
702  return Attrs.addAttributeAtIndex(C, ArgNo,
703  Attr.getWithNewType(C, ReplacementTy));
704  }
705 
706  /// \brief Add the dereferenceable attribute to the attribute set at the given
707  /// index. Returns a new list because attribute lists are immutable.
709  uint64_t Bytes) const;
710 
711  /// \brief Add the dereferenceable attribute to the attribute set at the given
712  /// arg index. Returns a new list because attribute lists are immutable.
714  unsigned ArgNo,
715  uint64_t Bytes) const;
716 
717  /// Add the dereferenceable_or_null attribute to the attribute set at
718  /// the given arg index. Returns a new list because attribute lists are
719  /// immutable.
720  [[nodiscard]] AttributeList
722  uint64_t Bytes) const;
723 
724  /// Add the allocsize attribute to the attribute set at the given arg index.
725  /// Returns a new list because attribute lists are immutable.
726  [[nodiscard]] AttributeList
727  addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg,
728  const Optional<unsigned> &NumElemsArg);
729 
730  //===--------------------------------------------------------------------===//
731  // AttributeList Accessors
732  //===--------------------------------------------------------------------===//
733 
734  /// The attributes for the specified index are returned.
735  AttributeSet getAttributes(unsigned Index) const;
736 
737  /// The attributes for the argument or parameter at the given index are
738  /// returned.
739  AttributeSet getParamAttrs(unsigned ArgNo) const;
740 
741  /// The attributes for the ret value are returned.
742  AttributeSet getRetAttrs() const;
743 
744  /// The function attributes are returned.
745  AttributeSet getFnAttrs() const;
746 
747  /// Return true if the attribute exists at the given index.
748  bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const;
749 
750  /// Return true if the attribute exists at the given index.
751  bool hasAttributeAtIndex(unsigned Index, StringRef Kind) const;
752 
753  /// Return true if attribute exists at the given index.
754  bool hasAttributesAtIndex(unsigned Index) const;
755 
756  /// Return true if the attribute exists for the given argument
757  bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
758  return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
759  }
760 
761  /// Return true if the attribute exists for the given argument
762  bool hasParamAttr(unsigned ArgNo, StringRef Kind) const {
763  return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
764  }
765 
766  /// Return true if attributes exists for the given argument
767  bool hasParamAttrs(unsigned ArgNo) const {
768  return hasAttributesAtIndex(ArgNo + FirstArgIndex);
769  }
770 
771  /// Return true if the attribute exists for the return value.
774  }
775 
776  /// Return true if the attribute exists for the return value.
777  bool hasRetAttr(StringRef Kind) const {
779  }
780 
781  /// Return true if attributes exist for the return value.
782  bool hasRetAttrs() const { return hasAttributesAtIndex(ReturnIndex); }
783 
784  /// Return true if the attribute exists for the function.
785  bool hasFnAttr(Attribute::AttrKind Kind) const;
786 
787  /// Return true if the attribute exists for the function.
788  bool hasFnAttr(StringRef Kind) const;
789 
790  /// Return true the attributes exist for the function.
792 
793  /// Return true if the specified attribute is set for at least one
794  /// parameter or for the return value. If Index is not nullptr, the index
795  /// of a parameter with the specified attribute is provided.
797  unsigned *Index = nullptr) const;
798 
799  /// Return the attribute object that exists at the given index.
801 
802  /// Return the attribute object that exists at the given index.
804 
805  /// Return the attribute object that exists at the arg index.
807  return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
808  }
809 
810  /// Return the attribute object that exists at the given index.
811  Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const {
812  return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
813  }
814 
815  /// Return the attribute object that exists for the function.
818  }
819 
820  /// Return the attribute object that exists for the function.
823  }
824 
825  /// Return the alignment of the return value.
826  MaybeAlign getRetAlignment() const;
827 
828  /// Return the alignment for the specified function parameter.
829  MaybeAlign getParamAlignment(unsigned ArgNo) const;
830 
831  /// Return the stack alignment for the specified function parameter.
832  MaybeAlign getParamStackAlignment(unsigned ArgNo) const;
833 
834  /// Return the byval type for the specified function parameter.
835  Type *getParamByValType(unsigned ArgNo) const;
836 
837  /// Return the sret type for the specified function parameter.
838  Type *getParamStructRetType(unsigned ArgNo) const;
839 
840  /// Return the byref type for the specified function parameter.
841  Type *getParamByRefType(unsigned ArgNo) const;
842 
843  /// Return the preallocated type for the specified function parameter.
844  Type *getParamPreallocatedType(unsigned ArgNo) const;
845 
846  /// Return the inalloca type for the specified function parameter.
847  Type *getParamInAllocaType(unsigned ArgNo) const;
848 
849  /// Return the elementtype type for the specified function parameter.
850  Type *getParamElementType(unsigned ArgNo) const;
851 
852  /// Get the stack alignment of the function.
854 
855  /// Get the stack alignment of the return value.
857 
858  /// Get the number of dereferenceable bytes (or zero if unknown) of the return
859  /// value.
861 
862  /// Get the number of dereferenceable bytes (or zero if unknown) of an arg.
864 
865  /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of
866  /// the return value.
868 
869  /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of an
870  /// arg.
871  uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const;
872 
873  /// Get the unwind table kind requested for the function.
874  UWTableKind getUWTableKind() const;
875 
876  AllocFnKind getAllocKind() const;
877 
878  /// Return the attributes at the index as a string.
879  std::string getAsString(unsigned Index, bool InAttrGrp = false) const;
880 
881  /// Return true if this attribute list belongs to the LLVMContext.
882  bool hasParentContext(LLVMContext &C) const;
883 
884  //===--------------------------------------------------------------------===//
885  // AttributeList Introspection
886  //===--------------------------------------------------------------------===//
887 
888  using iterator = const AttributeSet *;
889 
890  iterator begin() const;
891  iterator end() const;
892 
893  unsigned getNumAttrSets() const;
894 
895  // Implementation of indexes(). Produces iterators that wrap an index. Mostly
896  // to hide the awkwardness of unsigned wrapping when iterating over valid
897  // indexes.
898  struct index_iterator {
899  unsigned NumAttrSets;
901  struct int_wrapper {
902  int_wrapper(unsigned i) : i(i) {}
903  unsigned i;
904  unsigned operator*() { return i; }
905  bool operator!=(const int_wrapper &Other) { return i != Other.i; }
907  // This is expected to undergo unsigned wrapping since FunctionIndex is
908  // ~0 and that's where we start.
909  ++i;
910  return *this;
911  }
912  };
913 
915 
917  };
918 
919  /// Use this to iterate over the valid attribute indexes.
921 
922  /// operator==/!= - Provide equality predicates.
923  bool operator==(const AttributeList &RHS) const { return pImpl == RHS.pImpl; }
924  bool operator!=(const AttributeList &RHS) const { return pImpl != RHS.pImpl; }
925 
926  /// Return a raw pointer that uniquely identifies this attribute list.
927  void *getRawPointer() const {
928  return pImpl;
929  }
930 
931  /// Return true if there are no attributes.
932  bool isEmpty() const { return pImpl == nullptr; }
933 
934  void print(raw_ostream &O) const;
935 
936  void dump() const;
937 };
938 
939 //===----------------------------------------------------------------------===//
940 /// \class
941 /// Provide DenseMapInfo for AttributeList.
942 template <> struct DenseMapInfo<AttributeList, void> {
944  auto Val = static_cast<uintptr_t>(-1);
945  Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
946  return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
947  }
948 
950  auto Val = static_cast<uintptr_t>(-2);
951  Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
952  return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
953  }
954 
955  static unsigned getHashValue(AttributeList AS) {
956  return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
957  (unsigned((uintptr_t)AS.pImpl) >> 9);
958  }
959 
961  return LHS == RHS;
962  }
963 };
964 
965 //===----------------------------------------------------------------------===//
966 /// \class
967 /// This class stores enough information to efficiently remove some attributes
968 /// from an existing AttrBuilder, AttributeSet or AttributeList.
970  std::bitset<Attribute::EndAttrKinds> Attrs;
971  std::set<SmallString<32>, std::less<>> TargetDepAttrs;
972 
973 public:
974  AttributeMask() = default;
975  AttributeMask(const AttributeMask &) = delete;
976  AttributeMask(AttributeMask &&) = default;
977 
979  for (Attribute A : AS)
980  addAttribute(A);
981  }
982 
983  /// Add an attribute to the mask.
985  assert((unsigned)Val < Attribute::EndAttrKinds &&
986  "Attribute out of range!");
987  Attrs[Val] = true;
988  return *this;
989  }
990 
991  /// Add the Attribute object to the builder.
993  if (A.isStringAttribute())
994  addAttribute(A.getKindAsString());
995  else
996  addAttribute(A.getKindAsEnum());
997  return *this;
998  }
999 
1000  /// Add the target-dependent attribute to the builder.
1002  TargetDepAttrs.insert(A);
1003  return *this;
1004  }
1005 
1006  /// Return true if the builder has the specified attribute.
1008  assert((unsigned)A < Attribute::EndAttrKinds && "Attribute out of range!");
1009  return Attrs[A];
1010  }
1011 
1012  /// Return true if the builder has the specified target-dependent
1013  /// attribute.
1014  bool contains(StringRef A) const { return TargetDepAttrs.count(A); }
1015 
1016  /// Return true if the mask contains the specified attribute.
1017  bool contains(Attribute A) const {
1018  if (A.isStringAttribute())
1019  return contains(A.getKindAsString());
1020  return contains(A.getKindAsEnum());
1021  }
1022 };
1023 
1024 //===----------------------------------------------------------------------===//
1025 /// \class
1026 /// This class is used in conjunction with the Attribute::get method to
1027 /// create an Attribute object. The object itself is uniquified. The Builder's
1028 /// value, however, is not. So this can be used as a quick way to test for
1029 /// equality, presence of attributes, etc.
1031  LLVMContext &Ctx;
1033 
1034 public:
1035  AttrBuilder(LLVMContext &Ctx) : Ctx(Ctx) {}
1036  AttrBuilder(const AttrBuilder &) = delete;
1037  AttrBuilder(AttrBuilder &&) = default;
1038 
1039  AttrBuilder(LLVMContext &Ctx, const Attribute &A) : Ctx(Ctx) {
1040  addAttribute(A);
1041  }
1042 
1044 
1045  void clear();
1046 
1047  /// Add an attribute to the builder.
1049 
1050  /// Add the Attribute object to the builder.
1052 
1053  /// Add the target-dependent attribute to the builder.
1055 
1056  /// Remove an attribute from the builder.
1058 
1059  /// Remove the target-dependent attribute from the builder.
1061 
1062  /// Remove the target-dependent attribute from the builder.
1064  if (A.isStringAttribute())
1065  return removeAttribute(A.getKindAsString());
1066  else
1067  return removeAttribute(A.getKindAsEnum());
1068  }
1069 
1070  /// Add the attributes from the builder. Attributes in the passed builder
1071  /// overwrite attributes in this builder if they have the same key.
1072  AttrBuilder &merge(const AttrBuilder &B);
1073 
1074  /// Remove the attributes from the builder.
1075  AttrBuilder &remove(const AttributeMask &AM);
1076 
1077  /// Return true if the builder has any attribute that's in the
1078  /// specified builder.
1079  bool overlaps(const AttributeMask &AM) const;
1080 
1081  /// Return true if the builder has the specified attribute.
1082  bool contains(Attribute::AttrKind A) const;
1083 
1084  /// Return true if the builder has the specified target-dependent
1085  /// attribute.
1086  bool contains(StringRef A) const;
1087 
1088  /// Return true if the builder has IR-level attributes.
1089  bool hasAttributes() const { return !Attrs.empty(); }
1090 
1091  /// Return true if the builder has an alignment attribute.
1092  bool hasAlignmentAttr() const;
1093 
1094  /// Return Attribute with the given Kind. The returned attribute will be
1095  /// invalid if the Kind is not present in the builder.
1097 
1098  /// Return Attribute with the given Kind. The returned attribute will be
1099  /// invalid if the Kind is not present in the builder.
1101 
1102  /// Return raw (possibly packed/encoded) value of integer attribute or 0 if
1103  /// not set.
1105 
1106  /// Retrieve the alignment attribute, if it exists.
1108  return MaybeAlign(getRawIntAttr(Attribute::Alignment));
1109  }
1110 
1111  /// Retrieve the stack alignment attribute, if it exists.
1113  return MaybeAlign(getRawIntAttr(Attribute::StackAlignment));
1114  }
1115 
1116  /// Retrieve the number of dereferenceable bytes, if the
1117  /// dereferenceable attribute exists (zero is returned otherwise).
1119  return getRawIntAttr(Attribute::Dereferenceable);
1120  }
1121 
1122  /// Retrieve the number of dereferenceable_or_null bytes, if the
1123  /// dereferenceable_or_null attribute exists (zero is returned otherwise).
1125  return getRawIntAttr(Attribute::DereferenceableOrNull);
1126  }
1127 
1128  /// Retrieve type for the given type attribute.
1130 
1131  /// Retrieve the byval type.
1132  Type *getByValType() const { return getTypeAttr(Attribute::ByVal); }
1133 
1134  /// Retrieve the sret type.
1135  Type *getStructRetType() const { return getTypeAttr(Attribute::StructRet); }
1136 
1137  /// Retrieve the byref type.
1138  Type *getByRefType() const { return getTypeAttr(Attribute::ByRef); }
1139 
1140  /// Retrieve the preallocated type.
1142  return getTypeAttr(Attribute::Preallocated);
1143  }
1144 
1145  /// Retrieve the inalloca type.
1146  Type *getInAllocaType() const { return getTypeAttr(Attribute::InAlloca); }
1147 
1148  /// Retrieve the allocsize args, if the allocsize attribute exists. If it
1149  /// doesn't exist, pair(0, 0) is returned.
1150  std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const;
1151 
1152  /// Retrieve the minimum value of 'vscale_range'.
1153  unsigned getVScaleRangeMin() const;
1154 
1155  /// Retrieve the maximum value of 'vscale_range' or None when unknown.
1157 
1158  /// Add integer attribute with raw value (packed/encoded if necessary).
1160 
1161  /// This turns an alignment into the form used internally in Attribute.
1162  /// This call has no effect if Align is not set.
1164 
1165  /// This turns an int alignment (which must be a power of 2) into the
1166  /// form used internally in Attribute.
1167  /// This call has no effect if Align is 0.
1168  /// Deprecated, use the version using a MaybeAlign.
1169  inline AttrBuilder &addAlignmentAttr(unsigned Align) {
1171  }
1172 
1173  /// This turns a stack alignment into the form used internally in Attribute.
1174  /// This call has no effect if Align is not set.
1176 
1177  /// This turns an int stack alignment (which must be a power of 2) into
1178  /// the form used internally in Attribute.
1179  /// This call has no effect if Align is 0.
1180  /// Deprecated, use the version using a MaybeAlign.
1183  }
1184 
1185  /// This turns the number of dereferenceable bytes into the form used
1186  /// internally in Attribute.
1188 
1189  /// This turns the number of dereferenceable_or_null bytes into the
1190  /// form used internally in Attribute.
1192 
1193  /// This turns one (or two) ints into the form used internally in Attribute.
1194  AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg,
1195  const Optional<unsigned> &NumElemsArg);
1196 
1197  /// This turns two ints into the form used internally in Attribute.
1198  AttrBuilder &addVScaleRangeAttr(unsigned MinValue,
1199  Optional<unsigned> MaxValue);
1200 
1201  /// Add a type attribute with the given type.
1203 
1204  /// This turns a byval type into the form used internally in Attribute.
1206 
1207  /// This turns a sret type into the form used internally in Attribute.
1209 
1210  /// This turns a byref type into the form used internally in Attribute.
1212 
1213  /// This turns a preallocated type into the form used internally in Attribute.
1215 
1216  /// This turns an inalloca type into the form used internally in Attribute.
1218 
1219  /// Add an allocsize attribute, using the representation returned by
1220  /// Attribute.getIntValue().
1222 
1223  /// Add a vscale_range attribute, using the representation returned by
1224  /// Attribute.getIntValue().
1225  AttrBuilder &addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr);
1226 
1227  /// This turns the unwind table kind into the form used internally in
1228  /// Attribute.
1230 
1231  // This turns the allocator kind into the form used internally in Attribute.
1233 
1234  ArrayRef<Attribute> attrs() const { return Attrs; }
1235 
1236  bool operator==(const AttrBuilder &B) const;
1237  bool operator!=(const AttrBuilder &B) const { return !(*this == B); }
1238 };
1239 
1240 namespace AttributeFuncs {
1241 
1242 enum AttributeSafetyKind : uint8_t {
1246 };
1247 
1248 /// Which attributes cannot be applied to a type. The argument \p ASK indicates,
1249 /// if only attributes that are known to be safely droppable are contained in
1250 /// the mask; only attributes that might be unsafe to drop (e.g., ABI-related
1251 /// attributes) are in the mask; or both.
1253 
1254 /// Get param/return attributes which imply immediate undefined behavior if an
1255 /// invalid value is passed. For example, this includes noundef (where undef
1256 /// implies UB), but not nonnull (where null implies poison). It also does not
1257 /// include attributes like nocapture, which constrain the function
1258 /// implementation rather than the passed value.
1260 
1261 /// \returns Return true if the two functions have compatible target-independent
1262 /// attributes for inlining purposes.
1263 bool areInlineCompatible(const Function &Caller, const Function &Callee);
1264 
1265 
1266 /// Checks if there are any incompatible function attributes between
1267 /// \p A and \p B.
1268 ///
1269 /// \param [in] A - The first function to be compared with.
1270 /// \param [in] B - The second function to be compared with.
1271 /// \returns true if the functions have compatible attributes.
1272 bool areOutlineCompatible(const Function &A, const Function &B);
1273 
1274 /// Merge caller's and callee's attributes.
1275 void mergeAttributesForInlining(Function &Caller, const Function &Callee);
1276 
1277 /// Merges the functions attributes from \p ToMerge into function \p Base.
1278 ///
1279 /// \param [in,out] Base - The function being merged into.
1280 /// \param [in] ToMerge - The function to merge attributes from.
1281 void mergeAttributesForOutlining(Function &Base, const Function &ToMerge);
1282 
1283 /// Update min-legal-vector-width if it is in Attribute and less than Width.
1285 
1286 } // end namespace AttributeFuncs
1287 
1288 } // end namespace llvm
1289 
1290 #endif // LLVM_IR_ATTRIBUTES_H
llvm::AttributeList::removeAttributeAtIndex
AttributeList removeAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
Definition: Attributes.cpp:1292
llvm::AttrBuilder::addDereferenceableOrNullAttr
AttrBuilder & addDereferenceableOrNullAttr(uint64_t Bytes)
This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute.
Definition: Attributes.cpp:1687
llvm::AttributeList::getRetDereferenceableOrNullBytes
uint64_t getRetDereferenceableOrNullBytes() const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of the return value.
Definition: Attributes.cpp:1480
llvm::AttributeList::getParamInAllocaType
Type * getParamInAllocaType(unsigned ArgNo) const
Return the inalloca type for the specified function parameter.
Definition: Attributes.cpp:1456
llvm::AttributeList::print
void print(raw_ostream &O) const
Definition: Attributes.cpp:1532
llvm::Attribute::getWithPreallocatedType
static Attribute getWithPreallocatedType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:198
llvm::AttributeList::removeAttributesAtIndex
AttributeList removeAttributesAtIndex(LLVMContext &C, unsigned Index, const AttributeMask &AttrsToRemove) const
Remove the specified attributes at the specified index from this attribute list.
Definition: Attributes.cpp:1321
llvm::Attribute::EndAttrKinds
@ EndAttrKinds
Sentinal value useful for loops.
Definition: Attributes.h:89
llvm::AttributeImpl
Definition: AttributeImpl.h:39
llvm::AttributeSet::AttributeSet
AttributeSet()=default
AttributeSet is a trivially copyable value type.
Attrs
Function Attrs
Definition: README_ALTIVEC.txt:215
llvm::AttrBuilder::getAttribute
Attribute getAttribute(Attribute::AttrKind Kind) const
Return Attribute with the given Kind.
Definition: Attributes.cpp:1775
llvm::AttributeMask::addAttribute
AttributeMask & addAttribute(StringRef A)
Add the target-dependent attribute to the builder.
Definition: Attributes.h:1001
llvm::AttributeFuncs::mergeAttributesForOutlining
void mergeAttributesForOutlining(Function &Base, const Function &ToMerge)
Merges the functions attributes from ToMerge into function Base.
Definition: Attributes.cpp:2055
llvm::AttrBuilder::getStackAlignment
MaybeAlign getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
Definition: Attributes.h:1112
llvm::AttrBuilder::getByValType
Type * getByValType() const
Retrieve the byval type.
Definition: Attributes.h:1132
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::Attribute::isEnumAttribute
bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
Definition: Attributes.cpp:260
llvm::Attribute::isValid
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition: Attributes.h:182
llvm::AttributeList::addDereferenceableParamAttr
AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
Definition: Attributes.cpp:1351
llvm::AttrBuilder::AttrBuilder
AttrBuilder(LLVMContext &Ctx)
Definition: Attributes.h:1035
llvm::AttributeSet::hasAttributes
bool hasAttributes() const
Return true if attributes exists in this set.
Definition: Attributes.h:350
llvm::AttrBuilder::addUWTableAttr
AttrBuilder & addUWTableAttr(UWTableKind Kind)
This turns the unwind table kind into the form used internally in Attribute.
Definition: Attributes.cpp:1718
llvm::AttributeList::hasAttributesAtIndex
bool hasAttributesAtIndex(unsigned Index) const
Return true if attribute exists at the given index.
Definition: Attributes.cpp:1401
Optional.h
llvm::AttributeSet::getAllocKind
AllocFnKind getAllocKind() const
Definition: Attributes.cpp:763
llvm::AttrBuilder::hasAlignmentAttr
bool hasAlignmentAttr() const
Return true if the builder has an alignment attribute.
Definition: Attributes.cpp:1798
llvm::Attribute::getStackAlignment
MaybeAlign getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
Definition: Attributes.cpp:334
llvm::Attribute::getWithAllocSizeArgs
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
Definition: Attributes.cpp:212
llvm::AttributeList::hasAttrSomewhere
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value.
Definition: Attributes.cpp:1413
llvm::AttrBuilder::addTypeAttr
AttrBuilder & addTypeAttr(Attribute::AttrKind Kind, Type *Ty)
Add a type attribute with the given type.
Definition: Attributes.cpp:1734
llvm::AttributeSet::getDereferenceableOrNullBytes
uint64_t getDereferenceableOrNullBytes() const
Definition: Attributes.cpp:718
llvm::Attribute::hasAttribute
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
Definition: Attributes.cpp:319
llvm::AttributeList::AttributeList
AttributeList()=default
llvm::Function
Definition: Function.h:60
llvm::AttrBuilder::getDereferenceableBytes
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
Definition: Attributes.h:1118
llvm::Attribute
Definition: Attributes.h:65
LLVM_MARK_AS_BITMASK_ENUM
#define LLVM_MARK_AS_BITMASK_ENUM(LargestValue)
LLVM_MARK_AS_BITMASK_ENUM lets you opt in an individual enum type so you can perform bitwise operatio...
Definition: BitmaskEnum.h:41
StringRef.h
llvm::AttributeFuncs::ASK_UNSAFE_TO_DROP
@ ASK_UNSAFE_TO_DROP
Definition: Attributes.h:1244
llvm::AttributeList::index_iterator::index_iterator
index_iterator(int NumAttrSets)
Definition: Attributes.h:900
llvm::AttributeList::index_iterator::int_wrapper
Definition: Attributes.h:901
llvm::AttributeList::getParamPreallocatedType
Type * getParamPreallocatedType(unsigned ArgNo) const
Return the preallocated type for the specified function parameter.
Definition: Attributes.cpp:1452
llvm::AttributeMask::contains
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
Definition: Attributes.h:1007
llvm::Attribute::TombstoneKey
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
Definition: Attributes.h:91
llvm::DenseMapInfo< AttributeSet, void >::getTombstoneKey
static AttributeSet getTombstoneKey()
Definition: Attributes.h:403
llvm::Attribute::getAttrKindFromName
static Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
Definition: Attributes.cpp:225
llvm::Attribute::get
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Definition: Attributes.cpp:90
llvm::AttributeList::addFnAttributes
AttributeList addFnAttributes(LLVMContext &C, const AttrBuilder &B) const
Add function attribute to the list.
Definition: Attributes.h:534
llvm::Attribute::isTypeAttribute
bool isTypeAttribute() const
Return true if the attribute is a type attribute.
Definition: Attributes.cpp:272
llvm::Attribute::isIntAttrKind
static bool isIntAttrKind(AttrKind Kind)
Definition: Attributes.h:100
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1181
Types.h
getImpl
static LazyValueInfoImpl & getImpl(void *&PImpl, AssumptionCache *AC, const Module *M)
This lazily constructs the LazyValueInfoImpl.
Definition: LazyValueInfo.cpp:1515
llvm::AttributeList::getUWTableKind
UWTableKind getUWTableKind() const
Get the unwind table kind requested for the function.
Definition: Attributes.cpp:1489
llvm::AttributeSet::addAttributes
AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
Definition: Attributes.cpp:646
llvm::AttributeFuncs::getUBImplyingAttributes
AttributeMask getUBImplyingAttributes()
Get param/return attributes which imply immediate undefined behavior if an invalid value is passed.
Definition: Attributes.cpp:1860
llvm::AttributeList::end
iterator end() const
Definition: Attributes.cpp:1520
llvm::AttributeList::get
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute >> Attrs)
Create an AttributeList with the specified parameters in it.
Definition: Attributes.cpp:1050
llvm::Attribute::EmptyKey
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
Definition: Attributes.h:90
llvm::Attribute::getWithStackAlignment
static Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment)
Definition: Attributes.cpp:169
llvm::AttrBuilder::getAlignment
MaybeAlign getAlignment() const
Retrieve the alignment attribute, if it exists.
Definition: Attributes.h:1107
llvm::AttributeList::getParamByValType
Type * getParamByValType(unsigned ArgNo) const
Return the byval type for the specified function parameter.
Definition: Attributes.cpp:1440
llvm::AttrBuilder::addAllocSizeAttr
AttrBuilder & addAllocSizeAttr(unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
This turns one (or two) ints into the form used internally in Attribute.
Definition: Attributes.cpp:1694
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Attribute::getWithVScaleRangeArgs
static Attribute getWithVScaleRangeArgs(LLVMContext &Context, unsigned MinValue, unsigned MaxValue)
Definition: Attributes.cpp:219
llvm::AttributeList::removeParamAttributes
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:682
llvm::AttributeList
Definition: Attributes.h:425
llvm::AttributeMask
Definition: Attributes.h:969
llvm::AttributeList::addDereferenceableRetAttr
AttributeList addDereferenceableRetAttr(LLVMContext &C, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
Definition: Attributes.cpp:1344
llvm::Attribute::isTypeAttrKind
static bool isTypeAttrKind(AttrKind Kind)
Definition: Attributes.h:103
llvm::Attribute::operator==
bool operator==(Attribute A) const
Equality and non-equality operators.
Definition: Attributes.h:255
llvm::AttrBuilder::getVScaleRangeMin
unsigned getVScaleRangeMin() const
Retrieve the minimum value of 'vscale_range'.
Definition: Attributes.cpp:1656
llvm::AttrBuilder::addAllocKindAttr
AttrBuilder & addAllocKindAttr(AllocFnKind Kind)
Definition: Attributes.cpp:1724
llvm::AttributeList::getFnAttrs
AttributeSet getFnAttrs() const
The function attributes are returned.
Definition: Attributes.cpp:1388
llvm::AllocFnKind::Alloc
@ Alloc
llvm::Optional< unsigned >
llvm::AttributeSet::getVScaleRangeMin
unsigned getVScaleRangeMin() const
Definition: Attributes.cpp:751
llvm::AttrBuilder::addPreallocatedAttr
AttrBuilder & addPreallocatedAttr(Type *Ty)
This turns a preallocated type into the form used internally in Attribute.
Definition: Attributes.cpp:1750
llvm::AttributeList::removeParamAttribute
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:675
llvm::AttributeSet::operator==
bool operator==(const AttributeSet &O) const
Definition: Attributes.h:313
llvm::AttributeList::getRawPointer
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute list.
Definition: Attributes.h:927
llvm::Attribute::getAlignment
MaybeAlign getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
Definition: Attributes.cpp:328
llvm::AttrBuilder::addAlignmentAttr
AttrBuilder & addAlignmentAttr(unsigned Align)
This turns an int alignment (which must be a power of 2) into the form used internally in Attribute.
Definition: Attributes.h:1169
llvm::AttrBuilder::addRawIntAttr
AttrBuilder & addRawIntAttr(Attribute::AttrKind Kind, uint64_t Value)
Add integer attribute with raw value (packed/encoded if necessary).
Definition: Attributes.cpp:1647
llvm::AttributeList::index_iterator::int_wrapper::int_wrapper
int_wrapper(unsigned i)
Definition: Attributes.h:902
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::AttributeList::addFnAttribute
AttributeList addFnAttribute(LLVMContext &C, Attribute Attr) const
Add a function attribute to the list.
Definition: Attributes.h:519
llvm::AllocFnKind::Unknown
@ Unknown
llvm::DenseMapInfo< AttributeList, void >::getTombstoneKey
static AttributeList getTombstoneKey()
Definition: Attributes.h:949
llvm::AttrBuilder::merge
AttrBuilder & merge(const AttrBuilder &B)
Add the attributes from the builder.
Definition: Attributes.cpp:1758
llvm::Attribute::getValueAsBool
bool getValueAsBool() const
Return the attribute's value as a boolean.
Definition: Attributes.cpp:290
llvm::AttrBuilder::removeAttribute
AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
Definition: Attributes.cpp:1626
llvm::AttributeList::removeFnAttributes
AttributeList removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:632
llvm::Attribute::NumIntAttrKinds
static const unsigned NumIntAttrKinds
Definition: Attributes.h:94
llvm::AttributeList::replaceAttributeTypeAtIndex
AttributeList replaceAttributeTypeAtIndex(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind, Type *ReplacementTy) const
Replace the type contained by attribute AttrKind at index ArgNo wih ReplacementTy,...
Definition: Attributes.h:697
llvm::AttributeList::getParamDereferenceableBytes
uint64_t getParamDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
Definition: Attributes.cpp:1476
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::AttrBuilder::remove
AttrBuilder & remove(const AttributeMask &AM)
Remove the attributes from the builder.
Definition: Attributes.cpp:1766
llvm::Attribute::getAllocKind
AllocFnKind getAllocKind() const
Definition: Attributes.cpp:378
llvm::AttributeList::getParamStackAlignment
MaybeAlign getParamStackAlignment(unsigned ArgNo) const
Return the stack alignment for the specified function parameter.
Definition: Attributes.cpp:1436
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::Attribute::getValueAsInt
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
Definition: Attributes.cpp:283
llvm::AttributeSet::addAttribute
AttributeSet addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add an argument attribute.
Definition: Attributes.cpp:631
llvm::AttributeList::hasAttributeAtIndex
bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
Definition: Attributes.cpp:1392
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: APInt.h:34
llvm::UWTableKind
UWTableKind
Definition: CodeGen.h:100
llvm::AttributeList::index_iterator
Definition: Attributes.h:898
llvm::AttributeList::hasRetAttrs
bool hasRetAttrs() const
Return true if attributes exist for the return value.
Definition: Attributes.h:782
llvm::Attribute::getWithInAllocaType
static Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:202
llvm::AttributeSet::operator!=
bool operator!=(const AttributeSet &O) const
Definition: Attributes.h:314
llvm::AttrBuilder::getRawIntAttr
uint64_t getRawIntAttr(Attribute::AttrKind Kind) const
Return raw (possibly packed/encoded) value of integer attribute or 0 if not set.
Definition: Attributes.cpp:1641
llvm::AttrBuilder::getTypeAttr
Type * getTypeAttr(Attribute::AttrKind Kind) const
Retrieve type for the given type attribute.
Definition: Attributes.cpp:1728
llvm::AttributeList::addParamAttributes
AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
Definition: Attributes.h:584
llvm::AttributeList::hasParentContext
bool hasParentContext(LLVMContext &C) const
Return true if this attribute list belongs to the LLVMContext.
Definition: Attributes.cpp:1508
llvm::AttributeListImpl
Definition: AttributeImpl.h:282
llvm::AttrBuilder::addByValAttr
AttrBuilder & addByValAttr(Type *Ty)
This turns a byval type into the form used internally in Attribute.
Definition: Attributes.cpp:1738
SmallString.h
llvm::AttributeList::removeFnAttribute
AttributeList removeFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:618
llvm::AttributeSet::getAsString
std::string getAsString(bool InAttrGrp=false) const
Definition: Attributes.cpp:767
llvm::AttributeList::begin
iterator begin() const
Definition: Attributes.cpp:1516
llvm::AttributeList::index_iterator::int_wrapper::operator!=
bool operator!=(const int_wrapper &Other)
Definition: Attributes.h:905
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::AttributeList::getParamDereferenceableOrNullBytes
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
Definition: Attributes.cpp:1485
llvm::AttributeSet::hasAttribute
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
Definition: Attributes.cpp:690
llvm::AttrBuilder::operator==
bool operator==(const AttrBuilder &B) const
Definition: Attributes.cpp:1802
llvm::AttributeList::removeFnAttribute
AttributeList removeFnAttribute(LLVMContext &C, StringRef Kind) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:624
llvm::AttributeList::index_iterator::int_wrapper::operator++
int_wrapper & operator++()
Definition: Attributes.h:906
llvm::AttributeSet::getDereferenceableBytes
uint64_t getDereferenceableBytes() const
Definition: Attributes.cpp:714
llvm::AttributeFuncs::areOutlineCompatible
bool areOutlineCompatible(const Function &A, const Function &B)
Checks if there are any incompatible function attributes between A and B.
Definition: Attributes.cpp:2045
llvm::AttrBuilder::AttrBuilder
AttrBuilder(LLVMContext &Ctx, const Attribute &A)
Definition: Attributes.h:1039
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::Attribute::getVScaleRangeMin
unsigned getVScaleRangeMin() const
Returns the minimum value for the vscale_range attribute.
Definition: Attributes.cpp:360
llvm::AttributeFuncs::ASK_ALL
@ ASK_ALL
Definition: Attributes.h:1245
llvm::AttributeList::hasFnAttr
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
Definition: Attributes.cpp:1405
llvm::AttributeMask::AttributeMask
AttributeMask()=default
llvm::AttributeList::getAttributes
AttributeSet getAttributes(unsigned Index) const
The attributes for the specified index are returned.
Definition: Attributes.cpp:1501
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:280
llvm::AttributeList::getRetAlignment
MaybeAlign getRetAlignment() const
Return the alignment of the return value.
Definition: Attributes.cpp:1428
llvm::AttributeMask::contains
bool contains(Attribute A) const
Return true if the mask contains the specified attribute.
Definition: Attributes.h:1017
PointerLikeTypeTraits.h
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
llvm::AttributeSet::getInAllocaType
Type * getInAllocaType() const
Definition: Attributes.cpp:738
llvm::AttributeList::addFnAttribute
AttributeList addFnAttribute(LLVMContext &C, StringRef Kind, StringRef Value=StringRef()) const
Add a function attribute to the list.
Definition: Attributes.h:527
llvm::Attribute::getKindAsString
StringRef getKindAsString() const
Return the attribute's kind as a string.
Definition: Attributes.cpp:297
llvm::Attribute::isStringAttribute
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
Definition: Attributes.cpp:268
llvm::AttributeList::getParamElementType
Type * getParamElementType(unsigned ArgNo) const
Return the elementtype type for the specified function parameter.
Definition: Attributes.cpp:1460
llvm::AttributeList::addDereferenceableOrNullParamAttr
AttributeList addDereferenceableOrNullParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given arg index.
Definition: Attributes.cpp:1360
Align
uint64_t Align
Definition: ELFObjHandler.cpp:81
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::Attribute::getWithStructRetType
static Attribute getWithStructRetType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:190
llvm::AttrBuilder::getByRefType
Type * getByRefType() const
Retrieve the byref type.
Definition: Attributes.h:1138
llvm::AttributeMask::AttributeMask
AttributeMask(AttributeSet AS)
Definition: Attributes.h:978
llvm::AttributeList::addRetAttribute
AttributeList addRetAttribute(LLVMContext &C, Attribute Attr) const
Add a return value attribute to the list.
Definition: Attributes.h:548
llvm::AttrBuilder::clear
void clear()
Definition: Attributes.cpp:1568
llvm::Attribute::isEnumAttrKind
static bool isEnumAttrKind(AttrKind Kind)
Definition: Attributes.h:97
llvm::Attribute::getValueAsString
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:304
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::AttributeList::addParamAttribute
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
Definition: Attributes.h:563
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::AttrBuilder::addAlignmentAttr
AttrBuilder & addAlignmentAttr(MaybeAlign Align)
This turns an alignment into the form used internally in Attribute.
Definition: Attributes.cpp:1664
llvm::AttrBuilder::getStructRetType
Type * getStructRetType() const
Retrieve the sret type.
Definition: Attributes.h:1135
llvm::AttributeFuncs::AttributeSafetyKind
AttributeSafetyKind
Definition: Attributes.h:1242
llvm::DenseMapInfo< AttributeList, void >::isEqual
static bool isEqual(AttributeList LHS, AttributeList RHS)
Definition: Attributes.h:960
llvm::AttributeList::removeFnAttributes
AttributeList removeFnAttributes(LLVMContext &C) const
Remove the attributes at the function index from this attribute list.
Definition: Attributes.h:638
llvm::AttributeList::removeRetAttributes
AttributeList removeRetAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:659
llvm::AttributeList::hasRetAttr
bool hasRetAttr(StringRef Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:777
llvm::AttributeSet::end
iterator end() const
Definition: Attributes.cpp:783
llvm::AttrBuilder::addAttribute
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
Definition: Attributes.cpp:1616
llvm::AttributeList::index_iterator::end
int_wrapper end()
Definition: Attributes.h:916
llvm::AttributeSet::getUWTableKind
UWTableKind getUWTableKind() const
Definition: Attributes.cpp:759
llvm::AttributeList::index_iterator::int_wrapper::i
unsigned i
Definition: Attributes.h:903
llvm::AllocFnKind::Realloc
@ Realloc
llvm::AllocFnKind::Free
@ Free
llvm::AttributeList::ReturnIndex
@ ReturnIndex
Definition: Attributes.h:428
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:264
llvm::AttributeList::getRetAttrs
AttributeSet getRetAttrs() const
The attributes for the ret value are returned.
Definition: Attributes.cpp:1384
llvm::AttrBuilder::addStackAlignmentAttr
AttrBuilder & addStackAlignmentAttr(MaybeAlign Align)
This turns a stack alignment into the form used internally in Attribute.
Definition: Attributes.cpp:1672
llvm::Attribute::canUseAsFnAttr
static bool canUseAsFnAttr(AttrKind Kind)
Definition: Attributes.cpp:538
llvm::Attribute::getVScaleRangeMax
Optional< unsigned > getVScaleRangeMax() const
Returns the maximum value for the vscale_range attribute or None when unknown.
Definition: Attributes.cpp:366
llvm::AttributeList::index_iterator::begin
int_wrapper begin()
Definition: Attributes.h:914
uint64_t
llvm::AttrBuilder::getVScaleRangeMax
Optional< unsigned > getVScaleRangeMax() const
Retrieve the maximum value of 'vscale_range' or None when unknown.
Definition: Attributes.cpp:1660
llvm::Attribute::operator!=
bool operator!=(Attribute A) const
Definition: Attributes.h:256
llvm::Attribute::getRawPointer
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute.
Definition: Attributes.h:264
llvm::Attribute::None
@ None
No attributes have been set.
Definition: Attributes.h:86
llvm::AttributeList::getRetDereferenceableBytes
uint64_t getRetDereferenceableBytes() const
Get the number of dereferenceable bytes (or zero if unknown) of the return value.
Definition: Attributes.cpp:1472
llvm::AttrBuilder::addVScaleRangeAttrFromRawRepr
AttrBuilder & addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr)
Add a vscale_range attribute, using the representation returned by Attribute.getIntValue().
Definition: Attributes.cpp:1710
llvm::Attribute::getWithNewType
Attribute getWithNewType(LLVMContext &Context, Type *ReplacementTy)
For a typed attribute, return the equivalent attribute with the type changed to ReplacementTy.
Definition: Attributes.h:151
llvm::AttributeList::addRetAttribute
AttributeList addRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a return value attribute to the list.
Definition: Attributes.h:541
llvm::AttributeSet::get
static AttributeSet get(LLVMContext &C, const AttrBuilder &B)
Definition: Attributes.cpp:623
llvm::AttrBuilder::addInAllocaAttr
AttrBuilder & addInAllocaAttr(Type *Ty)
This turns an inalloca type into the form used internally in Attribute.
Definition: Attributes.cpp:1754
llvm::AttributeFuncs::ASK_SAFE_TO_DROP
@ ASK_SAFE_TO_DROP
Definition: Attributes.h:1243
llvm::Attribute::getWithUWTableKind
static Attribute getWithUWTableKind(LLVMContext &Context, UWTableKind Kind)
Definition: Attributes.cpp:206
llvm::AttrBuilder::getDereferenceableOrNullBytes
uint64_t getDereferenceableOrNullBytes() const
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists...
Definition: Attributes.h:1124
llvm::AttrBuilder::operator!=
bool operator!=(const AttrBuilder &B) const
Definition: Attributes.h:1237
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
llvm::AttributeList::getAsString
std::string getAsString(unsigned Index, bool InAttrGrp=false) const
Return the attributes at the index as a string.
Definition: Attributes.cpp:1497
llvm::AttributeList::dump
void dump() const
Definition: Attributes.cpp:1556
llvm::Attribute::getKindAsEnum
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
Definition: Attributes.cpp:276
llvm::AttrBuilder
Definition: Attributes.h:1030
llvm::Attribute::AttrKind
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:84
llvm::Attribute::getWithDereferenceableBytes
static Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
Definition: Attributes.cpp:174
llvm::AttributeList::getParamAlignment
MaybeAlign getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
Definition: Attributes.cpp:1432
llvm::AttributeList::removeRetAttribute
AttributeList removeRetAttribute(LLVMContext &C, StringRef Kind) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:651
ArrayRef.h
llvm::AttrBuilder::attrs
ArrayRef< Attribute > attrs() const
Definition: Attributes.h:1234
llvm::AttributeSet::getVScaleRangeMax
Optional< unsigned > getVScaleRangeMax() const
Definition: Attributes.cpp:755
TemplateParamKind::Type
@ Type
llvm::Attribute::canUseAsParamAttr
static bool canUseAsParamAttr(AttrKind Kind)
Definition: Attributes.cpp:542
llvm::AttributeList::index_iterator::NumAttrSets
unsigned NumAttrSets
Definition: Attributes.h:899
llvm::AttributeSet::removeAttributes
AttributeSet removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attributes from this set.
Definition: Attributes.cpp:675
llvm::AllocFnKind::Aligned
@ Aligned
llvm::AttributeSet::hasParentContext
bool hasParentContext(LLVMContext &C) const
Return true if this attribute set belongs to the LLVMContext.
Definition: Attributes.cpp:771
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::AttrBuilder::addByRefAttr
AttrBuilder & addByRefAttr(Type *Ty)
This turns a byref type into the form used internally in Attribute.
Definition: Attributes.cpp:1746
llvm::Attribute::getAsString
std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
Definition: Attributes.cpp:384
llvm::AttributeSet::removeAttribute
AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
Definition: Attributes.cpp:659
llvm::AttrBuilder::contains
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
Definition: Attributes.cpp:1790
llvm::AttrBuilder::getPreallocatedType
Type * getPreallocatedType() const
Retrieve the preallocated type.
Definition: Attributes.h:1141
llvm::AttributeSet::getNumAttributes
unsigned getNumAttributes() const
Return the number of attributes in this set.
Definition: Attributes.cpp:686
llvm::AttributeMask::addAttribute
AttributeMask & addAttribute(Attribute A)
Add the Attribute object to the builder.
Definition: Attributes.h:992
llvm::AttributeList::operator==
bool operator==(const AttributeList &RHS) const
operator==/!= - Provide equality predicates.
Definition: Attributes.h:923
llvm::AttributeList::AttrIndex
AttrIndex
Definition: Attributes.h:427
llvm::wrap
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:275
llvm::AttrBuilder::addStackAlignmentAttr
AttrBuilder & addStackAlignmentAttr(unsigned Align)
This turns an int stack alignment (which must be a power of 2) into the form used internally in Attri...
Definition: Attributes.h:1181
llvm::AttributeList::removeAttribute
AttributeList removeAttribute(LLVMContext &C, unsigned Index, StringRef Kind) const
Definition: Attributes.h:599
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::AttributeSet::~AttributeSet
~AttributeSet()=default
llvm::AttributeSet::dump
void dump() const
Definition: Attributes.cpp:788
BitmaskEnum.h
A
* A
Definition: README_ALTIVEC.txt:89
llvm::Attribute::getDereferenceableOrNullBytes
uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute.
Definition: Attributes.cpp:347
llvm::AttributeList::getParamByRefType
Type * getParamByRefType(unsigned ArgNo) const
Return the byref type for the specified function parameter.
Definition: Attributes.cpp:1448
llvm::FoldingSetNodeID
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition: FoldingSet.h:318
llvm::AttributeFuncs::updateMinLegalVectorWidthAttr
void updateMinLegalVectorWidthAttr(Function &Fn, uint64_t Width)
Update min-legal-vector-width if it is in Attribute and less than Width.
Definition: Attributes.cpp:2068
llvm::Attribute::getUWTableKind
UWTableKind getUWTableKind() const
Definition: Attributes.cpp:372
llvm::AttributeSetNode
Definition: AttributeImpl.h:212
llvm::AttrBuilder::addAllocSizeAttrFromRawRepr
AttrBuilder & addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr)
Add an allocsize attribute, using the representation returned by Attribute.getIntValue().
Definition: Attributes.cpp:1699
llvm::AttributeSet::getAllocSizeArgs
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Definition: Attributes.cpp:746
llvm::Attribute::getWithDereferenceableOrNullBytes
static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
Definition: Attributes.cpp:180
llvm::AttributeList::getRetStackAlignment
MaybeAlign getRetStackAlignment() const
Get the stack alignment of the return value.
Definition: Attributes.cpp:1468
LLVMAttributeRef
struct LLVMOpaqueAttributeRef * LLVMAttributeRef
Used to represent an attributes.
Definition: Types.h:143
llvm::AttrBuilder::addStructRetAttr
AttrBuilder & addStructRetAttr(Type *Ty)
This turns a sret type into the form used internally in Attribute.
Definition: Attributes.cpp:1742
llvm::AttributeList::addAttributesAtIndex
AttributeList addAttributesAtIndex(LLVMContext &C, unsigned Index, const AttrBuilder &B) const
Add attributes to the attribute set at the given index.
Definition: Attributes.cpp:1257
llvm::Attribute::getWithAlignment
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
Definition: Attributes.cpp:164
llvm::DenseMapInfo< AttributeSet, void >::getHashValue
static unsigned getHashValue(AttributeSet AS)
Definition: Attributes.h:409
llvm::DenseMapInfo< AttributeSet, void >::getEmptyKey
static AttributeSet getEmptyKey()
Definition: Attributes.h:397
llvm::Attribute::getDereferenceableBytes
uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
Definition: Attributes.cpp:340
llvm::Attribute::hasParentContext
bool hasParentContext(LLVMContext &C) const
Return true if this attribute belongs to the LLVMContext.
Definition: Attributes.cpp:502
Alignment.h
llvm::AttributeSet::getPreallocatedType
Type * getPreallocatedType() const
Definition: Attributes.cpp:734
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
llvm::AttributeList::addFnAttribute
AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
Definition: Attributes.h:512
llvm::AttributeSet::getByRefType
Type * getByRefType() const
Definition: Attributes.cpp:722
llvm::Attribute::isExistingAttribute
static bool isExistingAttribute(StringRef Name)
Return true if the provided string matches the IR name of an attribute.
Definition: Attributes.cpp:248
llvm::AttributeList::getFnAttr
Attribute getFnAttr(StringRef Kind) const
Return the attribute object that exists for the function.
Definition: Attributes.h:821
llvm::Attribute::Attribute
Attribute()=default
llvm::AttributeSet::getByValType
Type * getByValType() const
Definition: Attributes.cpp:726
llvm::AttributeList::getAllocKind
AllocFnKind getAllocKind() const
Definition: Attributes.cpp:1493
llvm::AttributeList::hasParamAttr
bool hasParamAttr(unsigned ArgNo, StringRef Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:762
llvm::AttributeList::getParamStructRetType
Type * getParamStructRetType(unsigned ArgNo) const
Return the sret type for the specified function parameter.
Definition: Attributes.cpp:1444
llvm::AllocFnKind::Uninitialized
@ Uninitialized
llvm::Attribute::getValueAsType
Type * getValueAsType() const
Return the attribute's value as a Type.
Definition: Attributes.cpp:311
llvm::AttributeList::getNumAttrSets
unsigned getNumAttrSets() const
Definition: Attributes.cpp:1528
llvm::AttributeFuncs::typeIncompatible
AttributeMask typeIncompatible(Type *Ty, AttributeSafetyKind ASK=ASK_ALL)
Which attributes cannot be applied to a type.
Definition: Attributes.cpp:1811
llvm::AttributeSet::begin
iterator begin() const
Definition: Attributes.cpp:779
llvm::AttributeList::getAttributeAtIndex
Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
Definition: Attributes.cpp:1418
llvm::AttributeSet::getElementType
Type * getElementType() const
Definition: Attributes.cpp:742
llvm::AttributeList::addAllocSizeParamAttr
AttributeList addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
Add the allocsize attribute to the attribute set at the given arg index.
Definition: Attributes.cpp:1368
llvm::DenseMapInfo< AttributeSet, void >::isEqual
static bool isEqual(AttributeSet LHS, AttributeSet RHS)
Definition: Attributes.h:414
llvm::AttributeList::removeRetAttribute
AttributeList removeRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:645
llvm::AMDGPU::Hwreg::Width
Width
Definition: SIDefines.h:439
llvm::Attribute::NumTypeAttrKinds
static const unsigned NumTypeAttrKinds
Definition: Attributes.h:95
llvm::AttrBuilder::addDereferenceableAttr
AttrBuilder & addDereferenceableAttr(uint64_t Bytes)
This turns the number of dereferenceable bytes into the form used internally in Attribute.
Definition: Attributes.cpp:1681
CodeGen.h
llvm::AttributeList::removeParamAttributes
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo) const
Remove all attributes at the specified arg index from this attribute list.
Definition: Attributes.h:689
llvm::Attribute::getWithByRefType
static Attribute getWithByRefType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:194
llvm::AttributeList::FunctionIndex
@ FunctionIndex
Definition: Attributes.h:429
llvm::AttributeList::addParamAttribute
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind, StringRef Value=StringRef()) const
Add an argument attribute to the list.
Definition: Attributes.h:571
llvm::Attribute::getNameFromAttrKind
static StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind)
Definition: Attributes.cpp:234
llvm::AttributeFuncs::areInlineCompatible
bool areInlineCompatible(const Function &Caller, const Function &Callee)
Definition: Attributes.cpp:2040
llvm::AttributeList::index_iterator::int_wrapper::operator*
unsigned operator*()
Definition: Attributes.h:904
llvm::AttributeSet
Definition: Attributes.h:290
llvm::AttributeList::hasFnAttrs
bool hasFnAttrs() const
Return true the attributes exist for the function.
Definition: Attributes.h:791
llvm::AttrBuilder::hasAttributes
bool hasAttributes() const
Return true if the builder has IR-level attributes.
Definition: Attributes.h:1089
llvm::AttributeSet::getAttribute
Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
Definition: Attributes.cpp:698
llvm::AttributeList::operator!=
bool operator!=(const AttributeList &RHS) const
Definition: Attributes.h:924
llvm::AttributeList::hasRetAttr
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:772
llvm::AttributeList::addRetAttributes
AttributeList addRetAttributes(LLVMContext &C, const AttrBuilder &B) const
Add a return value attribute to the list.
Definition: Attributes.h:555
llvm::AllocFnKind
AllocFnKind
Definition: Attributes.h:47
llvm::AttributeList::hasParamAttrs
bool hasParamAttrs(unsigned ArgNo) const
Return true if attributes exists for the given argument.
Definition: Attributes.h:767
llvm::AttributeList::indexes
index_iterator indexes() const
Use this to iterate over the valid attribute indexes.
Definition: Attributes.h:920
llvm::AttributeList::addAttributeAtIndex
AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
Definition: Attributes.cpp:1220
llvm::Attribute::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Attributes.cpp:517
llvm::AttributeSet::getStackAlignment
MaybeAlign getStackAlignment() const
Definition: Attributes.cpp:710
llvm::Attribute::isIntAttribute
bool isIntAttribute() const
Return true if the attribute is an integer attribute.
Definition: Attributes.cpp:264
llvm::AttributeSet::getStructRetType
Type * getStructRetType() const
Definition: Attributes.cpp:730
llvm::AttributeMask::contains
bool contains(StringRef A) const
Return true if the builder has the specified target-dependent attribute.
Definition: Attributes.h:1014
llvm::DenseMapInfo< AttributeList, void >::getEmptyKey
static AttributeList getEmptyKey()
Definition: Attributes.h:943
llvm::AttrBuilder::addVScaleRangeAttr
AttrBuilder & addVScaleRangeAttr(unsigned MinValue, Optional< unsigned > MaxValue)
This turns two ints into the form used internally in Attribute.
Definition: Attributes.cpp:1705
llvm::DenseMapInfo< AttributeList, void >::getHashValue
static unsigned getHashValue(AttributeList AS)
Definition: Attributes.h:955
llvm::AttributeFuncs::mergeAttributesForInlining
void mergeAttributesForInlining(Function &Caller, const Function &Callee)
Merge caller's and callee's attributes.
Definition: Attributes.cpp:2050
llvm::AttributeMask::addAttribute
AttributeMask & addAttribute(Attribute::AttrKind Val)
Add an attribute to the mask.
Definition: Attributes.h:984
llvm::AttributeSet::getAlignment
MaybeAlign getAlignment() const
Definition: Attributes.cpp:706
llvm::AttributeList::hasParamAttr
bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:757
llvm::Attribute::getWithByValType
static Attribute getWithByValType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:186
llvm::AttributeList::getParamAttrs
AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
Definition: Attributes.cpp:1380
llvm::AttrBuilder::getInAllocaType
Type * getInAllocaType() const
Retrieve the inalloca type.
Definition: Attributes.h:1146
llvm::AttrBuilder::getAllocSizeArgs
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Retrieve the allocsize args, if the allocsize attribute exists.
Definition: Attributes.cpp:1652
llvm::AttributeList::getFnAttr
Attribute getFnAttr(Attribute::AttrKind Kind) const
Return the attribute object that exists for the function.
Definition: Attributes.h:816
llvm::AttrBuilder::overlaps
bool overlaps(const AttributeMask &AM) const
Return true if the builder has any attribute that's in the specified builder.
Definition: Attributes.cpp:1771
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::AttributeList::FirstArgIndex
@ FirstArgIndex
Definition: Attributes.h:430
llvm::AttributeList::getParamAttr
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
Definition: Attributes.h:806
llvm::AllocFnKind::Zeroed
@ Zeroed
llvm::Attribute::operator<
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
Definition: Attributes.cpp:510
llvm::AttributeList::isEmpty
bool isEmpty() const
Return true if there are no attributes.
Definition: Attributes.h:932
llvm::AttributeList::getParamAttr
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const
Return the attribute object that exists at the given index.
Definition: Attributes.h:811
llvm::Attribute::fromRawPointer
static Attribute fromRawPointer(void *RawPtr)
Get an attribute from a raw pointer created by getRawPointer.
Definition: Attributes.h:269
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::Attribute::canUseAsRetAttr
static bool canUseAsRetAttr(AttrKind Kind)
Definition: Attributes.cpp:546
llvm::sampleprof::Base
@ Base
Definition: Discriminator.h:58
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1247
llvm::Attribute::getAllocSizeArgs
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Returns the argument numbers for the allocsize attribute (or pair(0, 0) if not known).
Definition: Attributes.cpp:354
llvm::AttributeList::getFnStackAlignment
MaybeAlign getFnStackAlignment() const
Get the stack alignment of the function.
Definition: Attributes.cpp:1464
llvm::AttributeList::removeParamAttribute
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:667
llvm::AttrBuilder::removeAttribute
AttrBuilder & removeAttribute(Attribute A)
Remove the target-dependent attribute from the builder.
Definition: Attributes.h:1063