LLVM  14.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/Optional.h"
21 #include "llvm/ADT/SmallString.h"
22 #include "llvm/ADT/StringRef.h"
24 #include "llvm/Config/llvm-config.h"
25 #include "llvm/Support/Alignment.h"
27 #include <bitset>
28 #include <cassert>
29 #include <cstdint>
30 #include <map>
31 #include <string>
32 #include <utility>
33 
34 namespace llvm {
35 
36 class AttrBuilder;
37 class AttributeImpl;
38 class AttributeListImpl;
39 class AttributeSetNode;
40 class FoldingSetNodeID;
41 class Function;
42 class LLVMContext;
43 class Type;
44 
45 //===----------------------------------------------------------------------===//
46 /// \class
47 /// Functions, function parameters, and return types can have attributes
48 /// to indicate how they should be treated by optimizations and code
49 /// generation. This class represents one of those attributes. It's light-weight
50 /// and should be passed around by-value.
51 class Attribute {
52 public:
53  /// This enumeration lists the attributes that can be associated with
54  /// parameters, function results, or the function itself.
55  ///
56  /// Note: The `uwtable' attribute is about the ABI or the user mandating an
57  /// entry in the unwind table. The `nounwind' attribute is about an exception
58  /// passing by the function.
59  ///
60  /// In a theoretical system that uses tables for profiling and SjLj for
61  /// exceptions, they would be fully independent. In a normal system that uses
62  /// tables for both, the semantics are:
63  ///
64  /// nil = Needs an entry because an exception might pass by.
65  /// nounwind = No need for an entry
66  /// uwtable = Needs an entry because the ABI says so and because
67  /// an exception might pass by.
68  /// uwtable + nounwind = Needs an entry because the ABI says so.
69 
70  enum AttrKind {
71  // IR-Level Attributes
72  None, ///< No attributes have been set
73  #define GET_ATTR_ENUM
74  #include "llvm/IR/Attributes.inc"
75  EndAttrKinds, ///< Sentinal value useful for loops
76  EmptyKey, ///< Use as Empty key for DenseMap of AttrKind
77  TombstoneKey, ///< Use as Tombstone key for DenseMap of AttrKind
78  };
79 
80  static const unsigned NumIntAttrKinds = LastIntAttr - FirstIntAttr + 1;
81  static const unsigned NumTypeAttrKinds = LastTypeAttr - FirstTypeAttr + 1;
82 
83  static bool isEnumAttrKind(AttrKind Kind) {
84  return Kind >= FirstEnumAttr && Kind <= LastEnumAttr;
85  }
86  static bool isIntAttrKind(AttrKind Kind) {
87  return Kind >= FirstIntAttr && Kind <= LastIntAttr;
88  }
89  static bool isTypeAttrKind(AttrKind Kind) {
90  return Kind >= FirstTypeAttr && Kind <= LastTypeAttr;
91  }
92 
93  static bool canUseAsFnAttr(AttrKind Kind);
94  static bool canUseAsParamAttr(AttrKind Kind);
95  static bool canUseAsRetAttr(AttrKind Kind);
96 
97 private:
98  AttributeImpl *pImpl = nullptr;
99 
100  Attribute(AttributeImpl *A) : pImpl(A) {}
101 
102 public:
103  Attribute() = default;
104 
105  //===--------------------------------------------------------------------===//
106  // Attribute Construction
107  //===--------------------------------------------------------------------===//
108 
109  /// Return a uniquified Attribute object.
110  static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val = 0);
111  static Attribute get(LLVMContext &Context, StringRef Kind,
112  StringRef Val = StringRef());
113  static Attribute get(LLVMContext &Context, AttrKind Kind, Type *Ty);
114 
115  /// Return a uniquified Attribute object that has the specific
116  /// alignment set.
117  static Attribute getWithAlignment(LLVMContext &Context, Align Alignment);
118  static Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment);
119  static Attribute getWithDereferenceableBytes(LLVMContext &Context,
120  uint64_t Bytes);
122  uint64_t Bytes);
123  static Attribute getWithAllocSizeArgs(LLVMContext &Context,
124  unsigned ElemSizeArg,
125  const Optional<unsigned> &NumElemsArg);
126  static Attribute getWithVScaleRangeArgs(LLVMContext &Context,
127  unsigned MinValue, unsigned MaxValue);
128  static Attribute getWithByValType(LLVMContext &Context, Type *Ty);
129  static Attribute getWithStructRetType(LLVMContext &Context, Type *Ty);
130  static Attribute getWithByRefType(LLVMContext &Context, Type *Ty);
131  static Attribute getWithPreallocatedType(LLVMContext &Context, Type *Ty);
132  static Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty);
133 
134  /// For a typed attribute, return the equivalent attribute with the type
135  /// changed to \p ReplacementTy.
137  assert(isTypeAttribute() && "this requires a typed attribute");
138  return get(Context, getKindAsEnum(), ReplacementTy);
139  }
140 
142 
144 
145  /// Return true if the provided string matches the IR name of an attribute.
146  /// example: "noalias" return true but not "NoAlias"
147  static bool isExistingAttribute(StringRef Name);
148 
149  //===--------------------------------------------------------------------===//
150  // Attribute Accessors
151  //===--------------------------------------------------------------------===//
152 
153  /// Return true if the attribute is an Attribute::AttrKind type.
154  bool isEnumAttribute() const;
155 
156  /// Return true if the attribute is an integer attribute.
157  bool isIntAttribute() const;
158 
159  /// Return true if the attribute is a string (target-dependent)
160  /// attribute.
161  bool isStringAttribute() const;
162 
163  /// Return true if the attribute is a type attribute.
164  bool isTypeAttribute() const;
165 
166  /// Return true if the attribute is any kind of attribute.
167  bool isValid() const { return pImpl; }
168 
169  /// Return true if the attribute is present.
170  bool hasAttribute(AttrKind Val) const;
171 
172  /// Return true if the target-dependent attribute is present.
173  bool hasAttribute(StringRef Val) const;
174 
175  /// Return the attribute's kind as an enum (Attribute::AttrKind). This
176  /// requires the attribute to be an enum, integer, or type attribute.
178 
179  /// Return the attribute's value as an integer. This requires that the
180  /// attribute be an integer attribute.
181  uint64_t getValueAsInt() const;
182 
183  /// Return the attribute's value as a boolean. This requires that the
184  /// attribute be a string attribute.
185  bool getValueAsBool() const;
186 
187  /// Return the attribute's kind as a string. This requires the
188  /// attribute to be a string attribute.
189  StringRef getKindAsString() const;
190 
191  /// Return the attribute's value as a string. This requires the
192  /// attribute to be a string attribute.
193  StringRef getValueAsString() const;
194 
195  /// Return the attribute's value as a Type. This requires the attribute to be
196  /// a type attribute.
197  Type *getValueAsType() const;
198 
199  /// Returns the alignment field of an attribute as a byte alignment
200  /// value.
201  MaybeAlign getAlignment() const;
202 
203  /// Returns the stack alignment field of an attribute as a byte
204  /// alignment value.
206 
207  /// Returns the number of dereferenceable bytes from the
208  /// dereferenceable attribute.
210 
211  /// Returns the number of dereferenceable_or_null bytes from the
212  /// dereferenceable_or_null attribute.
214 
215  /// Returns the argument numbers for the allocsize attribute (or pair(0, 0)
216  /// if not known).
217  std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const;
218 
219  /// Returns the argument numbers for the vscale_range attribute (or pair(0, 0)
220  /// if not known).
221  std::pair<unsigned, unsigned> getVScaleRangeArgs() const;
222 
223  /// The Attribute is converted to a string of equivalent mnemonic. This
224  /// is, presumably, for writing out the mnemonics for the assembly writer.
225  std::string getAsString(bool InAttrGrp = false) const;
226 
227  /// Return true if this attribute belongs to the LLVMContext.
228  bool hasParentContext(LLVMContext &C) const;
229 
230  /// Equality and non-equality operators.
231  bool operator==(Attribute A) const { return pImpl == A.pImpl; }
232  bool operator!=(Attribute A) const { return pImpl != A.pImpl; }
233 
234  /// Less-than operator. Useful for sorting the attributes list.
235  bool operator<(Attribute A) const;
236 
237  void Profile(FoldingSetNodeID &ID) const;
238 
239  /// Return a raw pointer that uniquely identifies this attribute.
240  void *getRawPointer() const {
241  return pImpl;
242  }
243 
244  /// Get an attribute from a raw pointer created by getRawPointer.
245  static Attribute fromRawPointer(void *RawPtr) {
246  return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
247  }
248 };
249 
250 // Specialized opaque value conversions.
252  return reinterpret_cast<LLVMAttributeRef>(Attr.getRawPointer());
253 }
254 
255 // Specialized opaque value conversions.
257  return Attribute::fromRawPointer(Attr);
258 }
259 
260 //===----------------------------------------------------------------------===//
261 /// \class
262 /// This class holds the attributes for a particular argument, parameter,
263 /// function, or return value. It is an immutable value type that is cheap to
264 /// copy. Adding and removing enum attributes is intended to be fast, but adding
265 /// and removing string or integer attributes involves a FoldingSet lookup.
267  friend AttributeListImpl;
268  template <typename Ty, typename Enable> friend struct DenseMapInfo;
269 
270  // TODO: Extract AvailableAttrs from AttributeSetNode and store them here.
271  // This will allow an efficient implementation of addAttribute and
272  // removeAttribute for enum attrs.
273 
274  /// Private implementation pointer.
275  AttributeSetNode *SetNode = nullptr;
276 
277 private:
278  explicit AttributeSet(AttributeSetNode *ASN) : SetNode(ASN) {}
279 
280 public:
281  /// AttributeSet is a trivially copyable value type.
282  AttributeSet() = default;
283  AttributeSet(const AttributeSet &) = default;
284  ~AttributeSet() = default;
285 
286  static AttributeSet get(LLVMContext &C, const AttrBuilder &B);
288 
289  bool operator==(const AttributeSet &O) const { return SetNode == O.SetNode; }
290  bool operator!=(const AttributeSet &O) const { return !(*this == O); }
291 
292  /// Add an argument attribute. Returns a new set because attribute sets are
293  /// immutable.
295  Attribute::AttrKind Kind) const;
296 
297  /// Add a target-dependent attribute. Returns a new set because attribute sets
298  /// are immutable.
300  StringRef Value = StringRef()) const;
301 
302  /// Add attributes to the attribute set. Returns a new set because attribute
303  /// sets are immutable.
305  AttributeSet AS) const;
306 
307  /// Remove the specified attribute from this set. Returns a new set because
308  /// attribute sets are immutable.
310  Attribute::AttrKind Kind) const;
311 
312  /// Remove the specified attribute from this set. Returns a new set because
313  /// attribute sets are immutable.
315  StringRef Kind) const;
316 
317  /// Remove the specified attributes from this set. Returns a new set because
318  /// attribute sets are immutable.
320  removeAttributes(LLVMContext &C, const AttrBuilder &AttrsToRemove) const;
321 
322  /// Return the number of attributes in this set.
323  unsigned getNumAttributes() const;
324 
325  /// Return true if attributes exists in this set.
326  bool hasAttributes() const { return SetNode != nullptr; }
327 
328  /// Return true if the attribute exists in this set.
330 
331  /// Return true if the attribute exists in this set.
332  bool hasAttribute(StringRef Kind) const;
333 
334  /// Return the attribute object.
336 
337  /// Return the target-dependent attribute object.
339 
340  MaybeAlign getAlignment() const;
344  Type *getByValType() const;
345  Type *getStructRetType() const;
346  Type *getByRefType() const;
347  Type *getPreallocatedType() const;
348  Type *getInAllocaType() const;
349  Type *getElementType() const;
350  std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const;
351  std::pair<unsigned, unsigned> getVScaleRangeArgs() const;
352  std::string getAsString(bool InAttrGrp = false) const;
353 
354  /// Return true if this attribute set belongs to the LLVMContext.
355  bool hasParentContext(LLVMContext &C) const;
356 
357  using iterator = const Attribute *;
358 
359  iterator begin() const;
360  iterator end() const;
361 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
362  void dump() const;
363 #endif
364 };
365 
366 //===----------------------------------------------------------------------===//
367 /// \class
368 /// Provide DenseMapInfo for AttributeSet.
369 template <> struct DenseMapInfo<AttributeSet, void> {
371  auto Val = static_cast<uintptr_t>(-1);
372  Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
373  return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
374  }
375 
377  auto Val = static_cast<uintptr_t>(-2);
378  Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
379  return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
380  }
381 
382  static unsigned getHashValue(AttributeSet AS) {
383  return (unsigned((uintptr_t)AS.SetNode) >> 4) ^
384  (unsigned((uintptr_t)AS.SetNode) >> 9);
385  }
386 
387  static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
388 };
389 
390 //===----------------------------------------------------------------------===//
391 /// \class
392 /// This class holds the attributes for a function, its return value, and
393 /// its parameters. You access the attributes for each of them via an index into
394 /// the AttributeList object. The function attributes are at index
395 /// `AttributeList::FunctionIndex', the return value is at index
396 /// `AttributeList::ReturnIndex', and the attributes for the parameters start at
397 /// index `AttributeList::FirstArgIndex'.
399 public:
400  enum AttrIndex : unsigned {
404  };
405 
406 private:
407  friend class AttrBuilder;
408  friend class AttributeListImpl;
409  friend class AttributeSet;
410  friend class AttributeSetNode;
411  template <typename Ty, typename Enable> friend struct DenseMapInfo;
412 
413  /// The attributes that we are managing. This can be null to represent
414  /// the empty attributes list.
415  AttributeListImpl *pImpl = nullptr;
416 
417 public:
418  /// Create an AttributeList with the specified parameters in it.
419  static AttributeList get(LLVMContext &C,
420  ArrayRef<std::pair<unsigned, Attribute>> Attrs);
421  static AttributeList get(LLVMContext &C,
422  ArrayRef<std::pair<unsigned, AttributeSet>> Attrs);
423 
424  /// Create an AttributeList from attribute sets for a function, its
425  /// return value, and all of its arguments.
426  static AttributeList get(LLVMContext &C, AttributeSet FnAttrs,
427  AttributeSet RetAttrs,
428  ArrayRef<AttributeSet> ArgAttrs);
429 
430 private:
431  explicit AttributeList(AttributeListImpl *LI) : pImpl(LI) {}
432 
434 
435  AttributeList setAttributesAtIndex(LLVMContext &C, unsigned Index,
436  AttributeSet Attrs) const;
437 
438 public:
439  AttributeList() = default;
440 
441  //===--------------------------------------------------------------------===//
442  // AttributeList Construction and Mutation
443  //===--------------------------------------------------------------------===//
444 
445  /// Return an AttributeList with the specified parameters in it.
447  static AttributeList get(LLVMContext &C, unsigned Index,
449  static AttributeList get(LLVMContext &C, unsigned Index,
451  ArrayRef<uint64_t> Values);
452  static AttributeList get(LLVMContext &C, unsigned Index,
454  static AttributeList get(LLVMContext &C, unsigned Index,
455  const AttrBuilder &B);
456 
457  // TODO: remove non-AtIndex versions of these methods.
458  /// Add an attribute to the attribute set at the given index.
459  /// Returns a new list because attribute lists are immutable.
461  LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const;
462 
463  /// Add an attribute to the attribute set at the given index.
464  /// Returns a new list because attribute lists are immutable.
467  StringRef Value = StringRef()) const;
468 
469  /// Add an attribute to the attribute set at the given index.
470  /// Returns a new list because attribute lists are immutable.
472  unsigned Index,
473  Attribute A) const;
474 
475  /// Add attributes to the attribute set at the given index.
476  /// Returns a new list because attribute lists are immutable.
478  unsigned Index,
479  const AttrBuilder &B) const;
480 
481  /// Add a function attribute to the list. Returns a new list because
482  /// attribute lists are immutable.
484  Attribute::AttrKind Kind) const {
486  }
487 
488  /// Add a function attribute to the list. Returns a new list because
489  /// attribute lists are immutable.
491  Attribute Attr) const {
492  return addAttributeAtIndex(C, FunctionIndex, Attr);
493  }
494 
495  /// Add a function attribute to the list. Returns a new list because
496  /// attribute lists are immutable.
500  }
501 
502  /// Add function attribute to the list. Returns a new list because
503  /// attribute lists are immutable.
505  const AttrBuilder &B) const {
507  }
508 
509  /// Add a return value attribute to the list. Returns a new list because
510  /// attribute lists are immutable.
512  Attribute::AttrKind Kind) const {
514  }
515 
516  /// Add a return value attribute to the list. Returns a new list because
517  /// attribute lists are immutable.
519  Attribute Attr) const {
520  return addAttributeAtIndex(C, ReturnIndex, Attr);
521  }
522 
523  /// Add a return value attribute to the list. Returns a new list because
524  /// attribute lists are immutable.
526  const AttrBuilder &B) const {
528  }
529 
530  /// Add an argument attribute to the list. Returns a new list because
531  /// attribute lists are immutable.
533  LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const {
534  return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
535  }
536 
537  /// Add an argument attribute to the list. Returns a new list because
538  /// attribute lists are immutable.
541  StringRef Value = StringRef()) const {
542  return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind, Value);
543  }
544 
545  /// Add an attribute to the attribute list at the given arg indices. Returns a
546  /// new list because attribute lists are immutable.
548  ArrayRef<unsigned> ArgNos,
549  Attribute A) const;
550 
551  /// Add an argument attribute to the list. Returns a new list because
552  /// attribute lists are immutable.
554  unsigned ArgNo,
555  const AttrBuilder &B) const {
556  return addAttributesAtIndex(C, ArgNo + FirstArgIndex, B);
557  }
558 
559  /// Remove the specified attribute at the specified index from this
560  /// attribute list. Returns a new list because attribute lists are immutable.
562  LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const;
563 
564  /// Remove the specified attribute at the specified index from this
565  /// attribute list. Returns a new list because attribute lists are immutable.
567  unsigned Index,
568  StringRef Kind) const;
570  StringRef Kind) const {
572  }
573 
574  /// Remove the specified attributes at the specified index from this
575  /// attribute list. Returns a new list because attribute lists are immutable.
577  LLVMContext &C, unsigned Index, const AttrBuilder &AttrsToRemove) const;
578 
579  /// Remove all attributes at the specified index from this
580  /// attribute list. Returns a new list because attribute lists are immutable.
582  unsigned Index) const;
583 
584  /// Remove the specified attribute at the function index from this
585  /// attribute list. Returns a new list because attribute lists are immutable.
589  }
590 
591  /// Remove the specified attribute at the function index from this
592  /// attribute list. Returns a new list because attribute lists are immutable.
594  StringRef Kind) const {
596  }
597 
598  /// Remove the specified attribute at the function index from this
599  /// attribute list. Returns a new list because attribute lists are immutable.
601  removeFnAttributes(LLVMContext &C, const AttrBuilder &AttrsToRemove) const {
602  return removeAttributesAtIndex(C, FunctionIndex, AttrsToRemove);
603  }
604 
605  /// Remove the attributes at the function index from this
606  /// attribute list. Returns a new list because attribute lists are immutable.
609  }
610 
611  /// Remove the specified attribute at the return value index from this
612  /// attribute list. Returns a new list because attribute lists are immutable.
616  }
617 
618  /// Remove the specified attribute at the return value index from this
619  /// attribute list. Returns a new list because attribute lists are immutable.
621  StringRef Kind) const {
623  }
624 
625  /// Remove the specified attribute at the return value index from this
626  /// attribute list. Returns a new list because attribute lists are immutable.
628  removeRetAttributes(LLVMContext &C, const AttrBuilder &AttrsToRemove) const {
629  return removeAttributesAtIndex(C, ReturnIndex, AttrsToRemove);
630  }
631 
632  /// Remove the specified attribute at the specified arg index from this
633  /// attribute list. Returns a new list because attribute lists are immutable.
635  LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const {
636  return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
637  }
638 
639  /// Remove the specified attribute at the specified arg index from this
640  /// attribute list. Returns a new list because attribute lists are immutable.
642  unsigned ArgNo,
643  StringRef Kind) const {
644  return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
645  }
646 
647  /// Remove the specified attribute at the specified arg index from this
648  /// attribute list. Returns a new list because attribute lists are immutable.
650  LLVMContext &C, unsigned ArgNo, const AttrBuilder &AttrsToRemove) const {
651  return removeAttributesAtIndex(C, ArgNo + FirstArgIndex, AttrsToRemove);
652  }
653 
654  /// Remove all attributes at the specified arg index from this
655  /// attribute list. Returns a new list because attribute lists are immutable.
657  unsigned ArgNo) const {
658  return removeAttributesAtIndex(C, ArgNo + FirstArgIndex);
659  }
660 
661  /// Replace the type contained by attribute \p AttrKind at index \p ArgNo wih
662  /// \p ReplacementTy, preserving all other attributes.
664  LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind,
665  Type *ReplacementTy) const {
666  Attribute Attr = getAttributeAtIndex(ArgNo, Kind);
667  auto Attrs = removeAttributeAtIndex(C, ArgNo, Kind);
668  return Attrs.addAttributeAtIndex(C, ArgNo,
669  Attr.getWithNewType(C, ReplacementTy));
670  }
671 
672  /// \brief Add the dereferenceable attribute to the attribute set at the given
673  /// index. Returns a new list because attribute lists are immutable.
675  uint64_t Bytes) const;
676 
677  /// \brief Add the dereferenceable attribute to the attribute set at the given
678  /// arg index. Returns a new list because attribute lists are immutable.
680  LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const;
681 
682  /// Add the dereferenceable_or_null attribute to the attribute set at
683  /// the given arg index. Returns a new list because attribute lists are
684  /// immutable.
686  LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const;
687 
688  /// Add the allocsize attribute to the attribute set at the given arg index.
689  /// Returns a new list because attribute lists are immutable.
691  addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg,
692  const Optional<unsigned> &NumElemsArg);
693 
694  //===--------------------------------------------------------------------===//
695  // AttributeList Accessors
696  //===--------------------------------------------------------------------===//
697 
698  /// The attributes for the specified index are returned.
699  AttributeSet getAttributes(unsigned Index) const;
700 
701  /// The attributes for the argument or parameter at the given index are
702  /// returned.
703  AttributeSet getParamAttrs(unsigned ArgNo) const;
704 
705  /// The attributes for the ret value are returned.
706  AttributeSet getRetAttrs() const;
707 
708  /// The function attributes are returned.
709  AttributeSet getFnAttrs() const;
710 
711  /// Return true if the attribute exists at the given index.
712  bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const;
713 
714  /// Return true if the attribute exists at the given index.
715  bool hasAttributeAtIndex(unsigned Index, StringRef Kind) const;
716 
717  /// Return true if attribute exists at the given index.
718  bool hasAttributesAtIndex(unsigned Index) const;
719 
720  /// Return true if the attribute exists for the given argument
721  bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
722  return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
723  }
724 
725  /// Return true if the attribute exists for the given argument
726  bool hasParamAttr(unsigned ArgNo, StringRef Kind) const {
727  return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
728  }
729 
730  /// Return true if attributes exists for the given argument
731  bool hasParamAttrs(unsigned ArgNo) const {
732  return hasAttributesAtIndex(ArgNo + FirstArgIndex);
733  }
734 
735  /// Return true if the attribute exists for the return value.
738  }
739 
740  /// Return true if the attribute exists for the return value.
741  bool hasRetAttr(StringRef Kind) const {
743  }
744 
745  /// Return true if attributes exist for the return value.
746  bool hasRetAttrs() const { return hasAttributesAtIndex(ReturnIndex); }
747 
748  /// Return true if the attribute exists for the function.
749  bool hasFnAttr(Attribute::AttrKind Kind) const;
750 
751  /// Return true if the attribute exists for the function.
752  bool hasFnAttr(StringRef Kind) const;
753 
754  /// Return true the attributes exist for the function.
756 
757  /// Return true if the specified attribute is set for at least one
758  /// parameter or for the return value. If Index is not nullptr, the index
759  /// of a parameter with the specified attribute is provided.
761  unsigned *Index = nullptr) const;
762 
763  /// Return the attribute object that exists at the given index.
765 
766  /// Return the attribute object that exists at the given index.
768 
769  /// Return the attribute object that exists at the arg index.
771  return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
772  }
773 
774  /// Return the attribute object that exists at the given index.
775  Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const {
776  return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
777  }
778 
779  /// Return the attribute object that exists for the function.
782  }
783 
784  /// Return the attribute object that exists for the function.
787  }
788 
789  /// Return the alignment of the return value.
790  MaybeAlign getRetAlignment() const;
791 
792  /// Return the alignment for the specified function parameter.
793  MaybeAlign getParamAlignment(unsigned ArgNo) const;
794 
795  /// Return the stack alignment for the specified function parameter.
796  MaybeAlign getParamStackAlignment(unsigned ArgNo) const;
797 
798  /// Return the byval type for the specified function parameter.
799  Type *getParamByValType(unsigned ArgNo) const;
800 
801  /// Return the sret type for the specified function parameter.
802  Type *getParamStructRetType(unsigned ArgNo) const;
803 
804  /// Return the byref type for the specified function parameter.
805  Type *getParamByRefType(unsigned ArgNo) const;
806 
807  /// Return the preallocated type for the specified function parameter.
808  Type *getParamPreallocatedType(unsigned ArgNo) const;
809 
810  /// Return the inalloca type for the specified function parameter.
811  Type *getParamInAllocaType(unsigned ArgNo) const;
812 
813  /// Return the elementtype type for the specified function parameter.
814  Type *getParamElementType(unsigned ArgNo) const;
815 
816  /// Get the stack alignment of the function.
818 
819  /// Get the stack alignment of the return value.
821 
822  /// Get the number of dereferenceable bytes (or zero if unknown) of the return
823  /// value.
825 
826  /// Get the number of dereferenceable bytes (or zero if unknown) of an arg.
828 
829  /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of
830  /// the return value.
832 
833  /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of an
834  /// arg.
835  uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const;
836 
837  /// Return the attributes at the index as a string.
838  std::string getAsString(unsigned Index, bool InAttrGrp = false) const;
839 
840  /// Return true if this attribute list belongs to the LLVMContext.
841  bool hasParentContext(LLVMContext &C) const;
842 
843  //===--------------------------------------------------------------------===//
844  // AttributeList Introspection
845  //===--------------------------------------------------------------------===//
846 
847  using iterator = const AttributeSet *;
848 
849  iterator begin() const;
850  iterator end() const;
851 
852  unsigned getNumAttrSets() const;
853 
854  // Implementation of indexes(). Produces iterators that wrap an index. Mostly
855  // to hide the awkwardness of unsigned wrapping when iterating over valid
856  // indexes.
857  struct index_iterator {
858  unsigned NumAttrSets;
860  struct int_wrapper {
861  int_wrapper(unsigned i) : i(i) {}
862  unsigned i;
863  unsigned operator*() { return i; }
864  bool operator!=(const int_wrapper &Other) { return i != Other.i; }
866  // This is expected to undergo unsigned wrapping since FunctionIndex is
867  // ~0 and that's where we start.
868  ++i;
869  return *this;
870  }
871  };
872 
874 
876  };
877 
878  /// Use this to iterate over the valid attribute indexes.
880 
881  /// operator==/!= - Provide equality predicates.
882  bool operator==(const AttributeList &RHS) const { return pImpl == RHS.pImpl; }
883  bool operator!=(const AttributeList &RHS) const { return pImpl != RHS.pImpl; }
884 
885  /// Return a raw pointer that uniquely identifies this attribute list.
886  void *getRawPointer() const {
887  return pImpl;
888  }
889 
890  /// Return true if there are no attributes.
891  bool isEmpty() const { return pImpl == nullptr; }
892 
893  void print(raw_ostream &O) const;
894 
895  void dump() const;
896 };
897 
898 //===----------------------------------------------------------------------===//
899 /// \class
900 /// Provide DenseMapInfo for AttributeList.
901 template <> struct DenseMapInfo<AttributeList, void> {
903  auto Val = static_cast<uintptr_t>(-1);
904  Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
905  return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
906  }
907 
909  auto Val = static_cast<uintptr_t>(-2);
910  Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
911  return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
912  }
913 
914  static unsigned getHashValue(AttributeList AS) {
915  return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
916  (unsigned((uintptr_t)AS.pImpl) >> 9);
917  }
918 
919  static bool isEqual(AttributeList LHS, AttributeList RHS) {
920  return LHS == RHS;
921  }
922 };
923 
924 //===----------------------------------------------------------------------===//
925 /// \class
926 /// This class is used in conjunction with the Attribute::get method to
927 /// create an Attribute object. The object itself is uniquified. The Builder's
928 /// value, however, is not. So this can be used as a quick way to test for
929 /// equality, presence of attributes, etc.
930 class AttrBuilder {
931  std::bitset<Attribute::EndAttrKinds> Attrs;
932  std::map<SmallString<32>, SmallString<32>, std::less<>> TargetDepAttrs;
933  std::array<uint64_t, Attribute::NumIntAttrKinds> IntAttrs = {};
934  std::array<Type *, Attribute::NumTypeAttrKinds> TypeAttrs = {};
935 
936  Optional<unsigned> kindToIntIndex(Attribute::AttrKind Kind) const;
937  Optional<unsigned> kindToTypeIndex(Attribute::AttrKind Kind) const;
938 
939 public:
940  AttrBuilder() = default;
941 
942  AttrBuilder(const Attribute &A) {
943  addAttribute(A);
944  }
945 
946  AttrBuilder(AttributeList AS, unsigned Idx);
948 
949  void clear();
950 
951  /// Add an attribute to the builder.
953  assert((unsigned)Val < Attribute::EndAttrKinds &&
954  "Attribute out of range!");
956  "Adding integer/type attribute without an argument!");
957  Attrs[Val] = true;
958  return *this;
959  }
960 
961  /// Add the Attribute object to the builder.
963 
964  /// Add the target-dependent attribute to the builder.
966 
967  /// Remove an attribute from the builder.
969 
970  /// Remove the attributes from the builder.
972 
973  /// Remove the target-dependent attribute to the builder.
975 
976  /// Add the attributes from the builder.
977  AttrBuilder &merge(const AttrBuilder &B);
978 
979  /// Remove the attributes from the builder.
980  AttrBuilder &remove(const AttrBuilder &B);
981 
982  /// Return true if the builder has any attribute that's in the
983  /// specified builder.
984  bool overlaps(const AttrBuilder &B) const;
985 
986  /// Return true if the builder has the specified attribute.
988  assert((unsigned)A < Attribute::EndAttrKinds && "Attribute out of range!");
989  return Attrs[A];
990  }
991 
992  /// Return true if the builder has the specified target-dependent
993  /// attribute.
994  bool contains(StringRef A) const;
995 
996  /// Return true if the builder has IR-level attributes.
997  bool hasAttributes() const;
998 
999  /// Return true if the builder has any attribute that's in the
1000  /// specified attribute.
1001  bool hasAttributes(AttributeList A, uint64_t Index) const;
1002 
1003  /// Return true if the builder has an alignment attribute.
1004  bool hasAlignmentAttr() const;
1005 
1006  /// Return raw (possibly packed/encoded) value of integer attribute or 0 if
1007  /// not set.
1009 
1010  /// Retrieve the alignment attribute, if it exists.
1012  return MaybeAlign(getRawIntAttr(Attribute::Alignment));
1013  }
1014 
1015  /// Retrieve the stack alignment attribute, if it exists.
1017  return MaybeAlign(getRawIntAttr(Attribute::StackAlignment));
1018  }
1019 
1020  /// Retrieve the number of dereferenceable bytes, if the
1021  /// dereferenceable attribute exists (zero is returned otherwise).
1023  return getRawIntAttr(Attribute::Dereferenceable);
1024  }
1025 
1026  /// Retrieve the number of dereferenceable_or_null bytes, if the
1027  /// dereferenceable_or_null attribute exists (zero is returned otherwise).
1029  return getRawIntAttr(Attribute::DereferenceableOrNull);
1030  }
1031 
1032  /// Retrieve type for the given type attribute.
1034 
1035  /// Retrieve the byval type.
1036  Type *getByValType() const { return getTypeAttr(Attribute::ByVal); }
1037 
1038  /// Retrieve the sret type.
1039  Type *getStructRetType() const { return getTypeAttr(Attribute::StructRet); }
1040 
1041  /// Retrieve the byref type.
1042  Type *getByRefType() const { return getTypeAttr(Attribute::ByRef); }
1043 
1044  /// Retrieve the preallocated type.
1046  return getTypeAttr(Attribute::Preallocated);
1047  }
1048 
1049  /// Retrieve the inalloca type.
1050  Type *getInAllocaType() const { return getTypeAttr(Attribute::InAlloca); }
1051 
1052  /// Retrieve the allocsize args, if the allocsize attribute exists. If it
1053  /// doesn't exist, pair(0, 0) is returned.
1054  std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const;
1055 
1056  /// Retrieve the vscale_range args, if the vscale_range attribute exists. If
1057  /// it doesn't exist, pair(0, 0) is returned.
1058  std::pair<unsigned, unsigned> getVScaleRangeArgs() const;
1059 
1060  /// Add integer attribute with raw value (packed/encoded if necessary).
1062 
1063  /// This turns an alignment into the form used internally in Attribute.
1064  /// This call has no effect if Align is not set.
1066 
1067  /// This turns an int alignment (which must be a power of 2) into the
1068  /// form used internally in Attribute.
1069  /// This call has no effect if Align is 0.
1070  /// Deprecated, use the version using a MaybeAlign.
1071  inline AttrBuilder &addAlignmentAttr(unsigned Align) {
1073  }
1074 
1075  /// This turns a stack alignment into the form used internally in Attribute.
1076  /// This call has no effect if Align is not set.
1078 
1079  /// This turns an int stack alignment (which must be a power of 2) into
1080  /// the form used internally in Attribute.
1081  /// This call has no effect if Align is 0.
1082  /// Deprecated, use the version using a MaybeAlign.
1085  }
1086 
1087  /// This turns the number of dereferenceable bytes into the form used
1088  /// internally in Attribute.
1090 
1091  /// This turns the number of dereferenceable_or_null bytes into the
1092  /// form used internally in Attribute.
1094 
1095  /// This turns one (or two) ints into the form used internally in Attribute.
1096  AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg,
1097  const Optional<unsigned> &NumElemsArg);
1098 
1099  /// This turns two ints into the form used internally in Attribute.
1100  AttrBuilder &addVScaleRangeAttr(unsigned MinValue, unsigned MaxValue);
1101 
1102  /// Add a type attribute with the given type.
1104 
1105  /// This turns a byval type into the form used internally in Attribute.
1107 
1108  /// This turns a sret type into the form used internally in Attribute.
1110 
1111  /// This turns a byref type into the form used internally in Attribute.
1113 
1114  /// This turns a preallocated type into the form used internally in Attribute.
1116 
1117  /// This turns an inalloca type into the form used internally in Attribute.
1119 
1120  /// Add an allocsize attribute, using the representation returned by
1121  /// Attribute.getIntValue().
1123 
1124  /// Add a vscale_range attribute, using the representation returned by
1125  /// Attribute.getIntValue().
1126  AttrBuilder &addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr);
1127 
1128  /// Return true if the builder contains no target-independent
1129  /// attributes.
1130  bool empty() const { return Attrs.none(); }
1131 
1132  // Iterators for target-dependent attributes.
1133  using td_type = decltype(TargetDepAttrs)::value_type;
1134  using td_iterator = decltype(TargetDepAttrs)::iterator;
1135  using td_const_iterator = decltype(TargetDepAttrs)::const_iterator;
1138 
1139  td_iterator td_begin() { return TargetDepAttrs.begin(); }
1140  td_iterator td_end() { return TargetDepAttrs.end(); }
1141 
1142  td_const_iterator td_begin() const { return TargetDepAttrs.begin(); }
1143  td_const_iterator td_end() const { return TargetDepAttrs.end(); }
1144 
1146 
1148  return td_const_range(td_begin(), td_end());
1149  }
1150 
1151  bool td_empty() const { return TargetDepAttrs.empty(); }
1152 
1153  bool operator==(const AttrBuilder &B) const;
1154  bool operator!=(const AttrBuilder &B) const { return !(*this == B); }
1155 };
1156 
1157 namespace AttributeFuncs {
1158 
1159 /// Which attributes cannot be applied to a type.
1161 
1162 /// Get param/return attributes which imply immediate undefined behavior if an
1163 /// invalid value is passed. For example, this includes noundef (where undef
1164 /// implies UB), but not nonnull (where null implies poison). It also does not
1165 /// include attributes like nocapture, which constrain the function
1166 /// implementation rather than the passed value.
1168 
1169 /// \returns Return true if the two functions have compatible target-independent
1170 /// attributes for inlining purposes.
1171 bool areInlineCompatible(const Function &Caller, const Function &Callee);
1172 
1173 
1174 /// Checks if there are any incompatible function attributes between
1175 /// \p A and \p B.
1176 ///
1177 /// \param [in] A - The first function to be compared with.
1178 /// \param [in] B - The second function to be compared with.
1179 /// \returns true if the functions have compatible attributes.
1180 bool areOutlineCompatible(const Function &A, const Function &B);
1181 
1182 /// Merge caller's and callee's attributes.
1183 void mergeAttributesForInlining(Function &Caller, const Function &Callee);
1184 
1185 /// Merges the functions attributes from \p ToMerge into function \p Base.
1186 ///
1187 /// \param [in,out] Base - The function being merged into.
1188 /// \param [in] ToMerge - The function to merge attributes from.
1189 void mergeAttributesForOutlining(Function &Base, const Function &ToMerge);
1190 
1191 } // end namespace AttributeFuncs
1192 
1193 } // end namespace llvm
1194 
1195 #endif // LLVM_IR_ATTRIBUTES_H
llvm::AttributeList::removeAttributeAtIndex
LLVM_NODISCARD 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:1265
llvm::AttributeList::removeParamAttributes
LLVM_NODISCARD AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo) const
Remove all attributes at the specified arg index from this attribute list.
Definition: Attributes.h:656
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:1653
llvm::AttributeList::removeRetAttribute
LLVM_NODISCARD AttributeList removeRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:614
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:1454
llvm::AttributeList::getParamInAllocaType
Type * getParamInAllocaType(unsigned ArgNo) const
Return the inalloca type for the specified function parameter.
Definition: Attributes.cpp:1430
llvm::AttributeList::print
void print(raw_ostream &O) const
Definition: Attributes.cpp:1498
llvm::Attribute::getWithPreallocatedType
static Attribute getWithPreallocatedType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:200
llvm::Attribute::EndAttrKinds
@ EndAttrKinds
Sentinal value useful for loops.
Definition: Attributes.h:75
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::AttributeFuncs::mergeAttributesForOutlining
void mergeAttributesForOutlining(Function &Base, const Function &ToMerge)
Merges the functions attributes from ToMerge into function Base.
Definition: Attributes.cpp:2034
llvm::AttrBuilder::getStackAlignment
MaybeAlign getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
Definition: Attributes.h:1016
llvm::AttributeFuncs::getUBImplyingAttributes
AttrBuilder getUBImplyingAttributes()
Get param/return attributes which imply immediate undefined behavior if an invalid value is passed.
Definition: Attributes.cpp:1845
llvm::AttrBuilder::getByValType
Type * getByValType() const
Retrieve the byval type.
Definition: Attributes.h:1036
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::Attribute::isEnumAttribute
bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
Definition: Attributes.cpp:257
llvm::AttributeList::addRetAttributes
LLVM_NODISCARD AttributeList addRetAttributes(LLVMContext &C, const AttrBuilder &B) const
Add a return value attribute to the list.
Definition: Attributes.h:525
llvm::Attribute::isValid
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition: Attributes.h:167
llvm::AttributeList::addDereferenceableParamAttr
LLVM_NODISCARD 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:1325
llvm::AttributeSet::hasAttributes
bool hasAttributes() const
Return true if attributes exists in this set.
Definition: Attributes.h:326
llvm::AttributeList::hasAttributesAtIndex
bool hasAttributesAtIndex(unsigned Index) const
Return true if attribute exists at the given index.
Definition: Attributes.cpp:1375
llvm::AttributeList::addFnAttribute
LLVM_NODISCARD AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
Definition: Attributes.h:483
Optional.h
llvm::AttrBuilder::hasAlignmentAttr
bool hasAlignmentAttr() const
Return true if the builder has an alignment attribute.
Definition: Attributes.cpp:1791
llvm::Attribute::getStackAlignment
MaybeAlign getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
Definition: Attributes.cpp:331
llvm::AttrBuilder::overlaps
bool overlaps(const AttrBuilder &B) const
Return true if the builder has any attribute that's in the specified builder.
Definition: Attributes.cpp:1754
llvm::Attribute::getWithAllocSizeArgs
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
Definition: Attributes.cpp:209
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:1387
llvm::AttrBuilder::addTypeAttr
AttrBuilder & addTypeAttr(Attribute::AttrKind Kind, Type *Ty)
Add a type attribute with the given type.
Definition: Attributes.cpp:1690
llvm::AttributeSet::getDereferenceableOrNullBytes
uint64_t getDereferenceableOrNullBytes() const
Definition: Attributes.cpp:687
llvm::Attribute::hasAttribute
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
Definition: Attributes.cpp:316
llvm::AttributeList::AttributeList
AttributeList()=default
llvm::Function
Definition: Function.h:62
llvm::AttrBuilder::getDereferenceableBytes
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
Definition: Attributes.h:1022
llvm::AttrBuilder::removeAttributes
AttrBuilder & removeAttributes(AttributeList A, uint64_t WithoutIndex)
Remove the attributes from the builder.
Definition: Attributes.cpp:1596
llvm::Attribute
Definition: Attributes.h:51
StringRef.h
llvm::AttrBuilder::hasAttributes
bool hasAttributes() const
Return true if the builder has IR-level attributes.
Definition: Attributes.cpp:1771
llvm::AttributeList::index_iterator::index_iterator
index_iterator(int NumAttrSets)
Definition: Attributes.h:859
llvm::AttributeList::index_iterator::int_wrapper
Definition: Attributes.h:860
llvm::AttributeSet::removeAttributes
LLVM_NODISCARD AttributeSet removeAttributes(LLVMContext &C, const AttrBuilder &AttrsToRemove) const
Remove the specified attributes from this set.
Definition: Attributes.cpp:644
llvm::AttributeList::removeAttributesAtIndex
LLVM_NODISCARD AttributeList removeAttributesAtIndex(LLVMContext &C, unsigned Index, const AttrBuilder &AttrsToRemove) const
Remove the specified attributes at the specified index from this attribute list.
Definition: Attributes.cpp:1295
llvm::AttributeList::getParamPreallocatedType
Type * getParamPreallocatedType(unsigned ArgNo) const
Return the preallocated type for the specified function parameter.
Definition: Attributes.cpp:1426
llvm::Attribute::TombstoneKey
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
Definition: Attributes.h:77
llvm::DenseMapInfo< AttributeSet, void >::getTombstoneKey
static AttributeSet getTombstoneKey()
Definition: Attributes.h:376
llvm::Attribute::getAttrKindFromName
static Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
Definition: Attributes.cpp:222
llvm::Attribute::get
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Definition: Attributes.cpp:92
llvm::Attribute::isTypeAttribute
bool isTypeAttribute() const
Return true if the attribute is a type attribute.
Definition: Attributes.cpp:269
llvm::Attribute::isIntAttrKind
static bool isIntAttrKind(AttrKind Kind)
Definition: Attributes.h:86
Types.h
getImpl
static LazyValueInfoImpl & getImpl(void *&PImpl, AssumptionCache *AC, const Module *M)
This lazily constructs the LazyValueInfoImpl.
Definition: LazyValueInfo.cpp:1517
llvm::AttributeList::addParamAttribute
LLVM_NODISCARD AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
Definition: Attributes.h:532
llvm::AttributeSet::addAttributes
LLVM_NODISCARD AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
Definition: Attributes.cpp:613
llvm::AttrBuilder::td_iterator
decltype(TargetDepAttrs)::iterator td_iterator
Definition: Attributes.h:1134
llvm::AttrBuilder::td_end
td_iterator td_end()
Definition: Attributes.h:1140
llvm::AttributeList::end
iterator end() const
Definition: Attributes.cpp:1486
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:1011
llvm::Attribute::EmptyKey
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
Definition: Attributes.h:76
llvm::Attribute::getWithStackAlignment
static Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment)
Definition: Attributes.cpp:171
llvm::AttrBuilder::getAlignment
MaybeAlign getAlignment() const
Retrieve the alignment attribute, if it exists.
Definition: Attributes.h:1011
llvm::AttributeFuncs::typeIncompatible
AttrBuilder typeIncompatible(Type *Ty)
Which attributes cannot be applied to a type.
Definition: Attributes.cpp:1811
llvm::AttributeList::getParamByValType
Type * getParamByValType(unsigned ArgNo) const
Return the byval type for the specified function parameter.
Definition: Attributes.cpp:1414
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:1660
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:216
llvm::AttributeList
Definition: Attributes.h:398
llvm::AttributeList::addDereferenceableRetAttr
LLVM_NODISCARD AttributeList addDereferenceableRetAttr(LLVMContext &C, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
Definition: Attributes.cpp:1318
llvm::Attribute::isTypeAttrKind
static bool isTypeAttrKind(AttrKind Kind)
Definition: Attributes.h:89
llvm::Attribute::operator==
bool operator==(Attribute A) const
Equality and non-equality operators.
Definition: Attributes.h:231
llvm::AttributeList::getFnAttrs
AttributeSet getFnAttrs() const
The function attributes are returned.
Definition: Attributes.cpp:1362
llvm::Optional< unsigned >
llvm::AttrBuilder::addPreallocatedAttr
AttrBuilder & addPreallocatedAttr(Type *Ty)
This turns a preallocated type into the form used internally in Attribute.
Definition: Attributes.cpp:1710
llvm::AttributeList::removeFnAttributes
LLVM_NODISCARD AttributeList removeFnAttributes(LLVMContext &C) const
Remove the attributes at the function index from this attribute list.
Definition: Attributes.h:607
llvm::AttributeSet::operator==
bool operator==(const AttributeSet &O) const
Definition: Attributes.h:289
llvm::AttributeList::getRawPointer
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute list.
Definition: Attributes.h:886
llvm::Attribute::getAlignment
MaybeAlign getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
Definition: Attributes.cpp:325
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:1071
llvm::AttrBuilder::addRawIntAttr
AttrBuilder & addRawIntAttr(Attribute::AttrKind Kind, uint64_t Value)
Add integer attribute with raw value (packed/encoded if necessary).
Definition: Attributes.cpp:1612
llvm::AttributeList::index_iterator::int_wrapper::int_wrapper
int_wrapper(unsigned i)
Definition: Attributes.h:861
llvm::DenseMapInfo< AttributeList, void >::getTombstoneKey
static AttributeList getTombstoneKey()
Definition: Attributes.h:908
llvm::AttrBuilder::AttrBuilder
AttrBuilder()=default
llvm::AttrBuilder::merge
AttrBuilder & merge(const AttrBuilder &B)
Add the attributes from the builder.
Definition: Attributes.cpp:1718
llvm::AttributeList::removeParamAttribute
LLVM_NODISCARD 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:641
llvm::Attribute::getValueAsBool
bool getValueAsBool() const
Return the attribute's value as a boolean.
Definition: Attributes.cpp:287
llvm::AttrBuilder::removeAttribute
AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
Definition: Attributes.cpp:1584
llvm::Attribute::NumIntAttrKinds
static const unsigned NumIntAttrKinds
Definition: Attributes.h:80
Context
ManagedStatic< detail::RecordContext > Context
Definition: Record.cpp:96
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:1450
llvm::AttrBuilder::getVScaleRangeArgs
std::pair< unsigned, unsigned > getVScaleRangeArgs() const
Retrieve the vscale_range args, if the vscale_range attribute exists.
Definition: Attributes.cpp:1626
llvm::AttributeList::getParamStackAlignment
MaybeAlign getParamStackAlignment(unsigned ArgNo) const
Return the stack alignment for the specified function parameter.
Definition: Attributes.cpp:1410
llvm::Attribute::getValueAsInt
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
Definition: Attributes.cpp:280
llvm::AttributeSet::addAttribute
LLVM_NODISCARD AttributeSet addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add an argument attribute.
Definition: Attributes.cpp:598
llvm::AttributeList::hasAttributeAtIndex
bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
Definition: Attributes.cpp:1366
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: APInt.h:34
llvm::AttributeList::index_iterator
Definition: Attributes.h:857
llvm::AttributeList::hasRetAttrs
bool hasRetAttrs() const
Return true if attributes exist for the return value.
Definition: Attributes.h:746
llvm::Attribute::getWithInAllocaType
static Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:204
llvm::AttributeSet::operator!=
bool operator!=(const AttributeSet &O) const
Definition: Attributes.h:290
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:1606
llvm::AttrBuilder::getTypeAttr
Type * getTypeAttr(Attribute::AttrKind Kind) const
Retrieve type for the given type attribute.
Definition: Attributes.cpp:1684
llvm::AttributeList::hasParentContext
bool hasParentContext(LLVMContext &C) const
Return true if this attribute list belongs to the LLVMContext.
Definition: Attributes.cpp:1474
llvm::AttributeListImpl
Definition: AttributeImpl.h:279
llvm::AttributeList::removeRetAttribute
LLVM_NODISCARD AttributeList removeRetAttribute(LLVMContext &C, StringRef Kind) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:620
llvm::AttrBuilder::addByValAttr
AttrBuilder & addByValAttr(Type *Ty)
This turns a byval type into the form used internally in Attribute.
Definition: Attributes.cpp:1698
SmallString.h
llvm::AttributeSet::getAsString
std::string getAsString(bool InAttrGrp=false) const
Definition: Attributes.cpp:725
llvm::AttributeList::begin
iterator begin() const
Definition: Attributes.cpp:1482
llvm::AttributeList::removeParamAttributes
LLVM_NODISCARD AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &AttrsToRemove) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:649
llvm::AttributeList::index_iterator::int_wrapper::operator!=
bool operator!=(const int_wrapper &Other)
Definition: Attributes.h:864
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:1459
llvm::AttributeList::removeFnAttributes
LLVM_NODISCARD AttributeList removeFnAttributes(LLVMContext &C, const AttrBuilder &AttrsToRemove) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:601
llvm::AttributeSet::hasAttribute
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
Definition: Attributes.cpp:659
llvm::AttrBuilder::operator==
bool operator==(const AttrBuilder &B) const
Definition: Attributes.cpp:1795
llvm::AttrBuilder::td_const_iterator
decltype(TargetDepAttrs)::const_iterator td_const_iterator
Definition: Attributes.h:1135
llvm::AttributeList::index_iterator::int_wrapper::operator++
int_wrapper & operator++()
Definition: Attributes.h:865
llvm::AttributeSet::getDereferenceableBytes
uint64_t getDereferenceableBytes() const
Definition: Attributes.cpp:683
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:2024
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:109
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::AttrBuilder::empty
bool empty() const
Return true if the builder contains no target-independent attributes.
Definition: Attributes.h:1130
llvm::Attribute::getVScaleRangeArgs
std::pair< unsigned, unsigned > getVScaleRangeArgs() const
Returns the argument numbers for the vscale_range attribute (or pair(0, 0) if not known).
Definition: Attributes.cpp:357
llvm::AttributeList::hasFnAttr
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
Definition: Attributes.cpp:1379
llvm::AttributeSet::getVScaleRangeArgs
std::pair< unsigned, unsigned > getVScaleRangeArgs() const
Definition: Attributes.cpp:720
llvm::AttributeList::getAttributes
AttributeSet getAttributes(unsigned Index) const
The attributes for the specified index are returned.
Definition: Attributes.cpp:1467
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:256
llvm::AttributeList::getRetAlignment
MaybeAlign getRetAlignment() const
Return the alignment of the return value.
Definition: Attributes.cpp:1402
llvm::AttrBuilder::td_end
td_const_iterator td_end() const
Definition: Attributes.h:1143
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:53
llvm::AttributeSet::getInAllocaType
Type * getInAllocaType() const
Definition: Attributes.cpp:707
llvm::AttributeList::addFnAttribute
LLVM_NODISCARD AttributeList addFnAttribute(LLVMContext &C, Attribute Attr) const
Add a function attribute to the list.
Definition: Attributes.h:490
llvm::Attribute::getKindAsString
StringRef getKindAsString() const
Return the attribute's kind as a string.
Definition: Attributes.cpp:294
llvm::Attribute::isStringAttribute
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
Definition: Attributes.cpp:265
llvm::AttributeList::getParamElementType
Type * getParamElementType(unsigned ArgNo) const
Return the elementtype type for the specified function parameter.
Definition: Attributes.cpp:1434
llvm::AttributeList::removeParamAttribute
LLVM_NODISCARD 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:634
llvm::AttributeList::addDereferenceableOrNullParamAttr
LLVM_NODISCARD 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:1334
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
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:192
llvm::AttrBuilder::getByRefType
Type * getByRefType() const
Retrieve the byref type.
Definition: Attributes.h:1042
llvm::AttrBuilder::clear
void clear()
Definition: Attributes.cpp:1541
llvm::AttributeList::replaceAttributeTypeAtIndex
LLVM_NODISCARD 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:663
llvm::Attribute::isEnumAttrKind
static bool isEnumAttrKind(AttrKind Kind)
Definition: Attributes.h:83
llvm::AttrBuilder::contains
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
Definition: Attributes.h:987
llvm::Attribute::getValueAsString
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:301
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::AttrBuilder::addAlignmentAttr
AttrBuilder & addAlignmentAttr(MaybeAlign Align)
This turns an alignment into the form used internally in Attribute.
Definition: Attributes.cpp:1630
llvm::AttrBuilder::getStructRetType
Type * getStructRetType() const
Retrieve the sret type.
Definition: Attributes.h:1039
llvm::SmallString< 32 >
llvm::DenseMapInfo< AttributeList, void >::isEqual
static bool isEqual(AttributeList LHS, AttributeList RHS)
Definition: Attributes.h:919
llvm::AttrBuilder::td_type
decltype(TargetDepAttrs)::value_type td_type
Definition: Attributes.h:1133
llvm::AttributeList::addFnAttributes
LLVM_NODISCARD AttributeList addFnAttributes(LLVMContext &C, const AttrBuilder &B) const
Add function attribute to the list.
Definition: Attributes.h:504
llvm::AttributeList::hasRetAttr
bool hasRetAttr(StringRef Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:741
llvm::AttributeSet::end
iterator end() const
Definition: Attributes.cpp:741
llvm::AttributeList::index_iterator::end
int_wrapper end()
Definition: Attributes.h:875
llvm::AttributeList::index_iterator::int_wrapper::i
unsigned i
Definition: Attributes.h:862
llvm::AttributeList::removeRetAttributes
LLVM_NODISCARD AttributeList removeRetAttributes(LLVMContext &C, const AttrBuilder &AttrsToRemove) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:628
llvm::AttributeList::ReturnIndex
@ ReturnIndex
Definition: Attributes.h:401
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:206
llvm::AttributeList::getRetAttrs
AttributeSet getRetAttrs() const
The attributes for the ret value are returned.
Definition: Attributes.cpp:1358
llvm::AttrBuilder::addStackAlignmentAttr
AttrBuilder & addStackAlignmentAttr(MaybeAlign Align)
This turns a stack alignment into the form used internally in Attribute.
Definition: Attributes.cpp:1638
llvm::Attribute::canUseAsFnAttr
static bool canUseAsFnAttr(AttrKind Kind)
Definition: Attributes.cpp:505
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::AttributeList::index_iterator::begin
int_wrapper begin()
Definition: Attributes.h:873
uint64_t
llvm::Attribute::operator!=
bool operator!=(Attribute A) const
Definition: Attributes.h:232
llvm::Attribute::getRawPointer
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute.
Definition: Attributes.h:240
llvm::Attribute::None
@ None
No attributes have been set.
Definition: Attributes.h:72
llvm::AttributeList::getRetDereferenceableBytes
uint64_t getRetDereferenceableBytes() const
Get the number of dereferenceable bytes (or zero if unknown) of the return value.
Definition: Attributes.cpp:1446
llvm::AttrBuilder::addVScaleRangeAttrFromRawRepr
AttrBuilder & addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr)
Add a vscale_range attribute, using the representation returned by Attribute.getIntValue().
Definition: Attributes.cpp:1676
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:136
llvm::AttrBuilder::td_const_range
iterator_range< td_const_iterator > td_const_range
Definition: Attributes.h:1137
llvm::AttributeList::addParamAttributes
LLVM_NODISCARD AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
Definition: Attributes.h:553
llvm::AttributeSet::get
static AttributeSet get(LLVMContext &C, const AttrBuilder &B)
Definition: Attributes.cpp:590
llvm::AttrBuilder::addInAllocaAttr
AttrBuilder & addInAllocaAttr(Type *Ty)
This turns an inalloca type into the form used internally in Attribute.
Definition: Attributes.cpp:1714
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:1028
llvm::AttrBuilder::td_range
iterator_range< td_iterator > td_range
Definition: Attributes.h:1136
llvm::AttrBuilder::operator!=
bool operator!=(const AttrBuilder &B) const
Definition: Attributes.h:1154
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::AttributeList::getAsString
std::string getAsString(unsigned Index, bool InAttrGrp=false) const
Return the attributes at the index as a string.
Definition: Attributes.cpp:1463
llvm::AttributeList::dump
void dump() const
Definition: Attributes.cpp:1522
llvm::Attribute::getKindAsEnum
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
Definition: Attributes.cpp:273
llvm::AttrBuilder
Definition: Attributes.h:930
llvm::Attribute::AttrKind
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:70
llvm::Attribute::getWithDereferenceableBytes
static Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
Definition: Attributes.cpp:176
llvm::AttributeList::getParamAlignment
MaybeAlign getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
Definition: Attributes.cpp:1406
llvm::AttributeList::removeAttribute
LLVM_NODISCARD AttributeList removeAttribute(LLVMContext &C, unsigned Index, StringRef Kind) const
Definition: Attributes.h:569
ArrayRef.h
TemplateParamKind::Type
@ Type
llvm::Attribute::canUseAsParamAttr
static bool canUseAsParamAttr(AttrKind Kind)
Definition: Attributes.cpp:509
llvm::AttributeList::index_iterator::NumAttrSets
unsigned NumAttrSets
Definition: Attributes.h:858
llvm::AttributeSet::hasParentContext
bool hasParentContext(LLVMContext &C) const
Return true if this attribute set belongs to the LLVMContext.
Definition: Attributes.cpp:729
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:1706
llvm::AttributeList::addParamAttribute
LLVM_NODISCARD AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind, StringRef Value=StringRef()) const
Add an argument attribute to the list.
Definition: Attributes.h:540
llvm::Attribute::getAsString
std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
Definition: Attributes.cpp:363
iterator_range.h
llvm::AttrBuilder::AttrBuilder
AttrBuilder(const Attribute &A)
Definition: Attributes.h:942
llvm::AttributeList::removeFnAttribute
LLVM_NODISCARD AttributeList removeFnAttribute(LLVMContext &C, StringRef Kind) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:593
llvm::AttributeSet::removeAttribute
LLVM_NODISCARD AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
Definition: Attributes.cpp:628
llvm::AttrBuilder::getPreallocatedType
Type * getPreallocatedType() const
Retrieve the preallocated type.
Definition: Attributes.h:1045
llvm::AttrBuilder::td_empty
bool td_empty() const
Definition: Attributes.h:1151
llvm::AttributeSet::getNumAttributes
unsigned getNumAttributes() const
Return the number of attributes in this set.
Definition: Attributes.cpp:655
llvm::AttributeList::addRetAttribute
LLVM_NODISCARD AttributeList addRetAttribute(LLVMContext &C, Attribute Attr) const
Add a return value attribute to the list.
Definition: Attributes.h:518
llvm::AttributeList::operator==
bool operator==(const AttributeList &RHS) const
operator==/!= - Provide equality predicates.
Definition: Attributes.h:882
llvm::AttributeList::AttrIndex
AttrIndex
Definition: Attributes.h:400
llvm::wrap
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:251
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:1083
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:57
llvm::AttributeSet::~AttributeSet
~AttributeSet()=default
const_iterator
llvm::AttributeSet::dump
void dump() const
Definition: Attributes.cpp:746
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:344
llvm::AttributeList::getParamByRefType
Type * getParamByRefType(unsigned ArgNo) const
Return the byref type for the specified function parameter.
Definition: Attributes.cpp:1422
llvm::FoldingSetNodeID
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition: FoldingSet.h:313
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:1665
llvm::AttributeSet::getAllocSizeArgs
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Definition: Attributes.cpp:715
llvm::Attribute::getWithDereferenceableOrNullBytes
static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
Definition: Attributes.cpp:182
llvm::AttributeList::getRetStackAlignment
MaybeAlign getRetStackAlignment() const
Get the stack alignment of the return value.
Definition: Attributes.cpp:1442
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:1702
llvm::AttributeList::addAttributesAtIndex
LLVM_NODISCARD AttributeList addAttributesAtIndex(LLVMContext &C, unsigned Index, const AttrBuilder &B) const
Add attributes to the attribute set at the given index.
Definition: Attributes.cpp:1221
Callee
amdgpu Simplify well known AMD library false FunctionCallee Callee
Definition: AMDGPULibCalls.cpp:206
llvm::Attribute::getWithAlignment
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
Definition: Attributes.cpp:166
llvm::DenseMapInfo< AttributeSet, void >::getHashValue
static unsigned getHashValue(AttributeSet AS)
Definition: Attributes.h:382
llvm::DenseMapInfo< AttributeSet, void >::getEmptyKey
static AttributeSet getEmptyKey()
Definition: Attributes.h:370
llvm::Attribute::getDereferenceableBytes
uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
Definition: Attributes.cpp:337
llvm::Attribute::hasParentContext
bool hasParentContext(LLVMContext &C) const
Return true if this attribute belongs to the LLVMContext.
Definition: Attributes.cpp:469
Alignment.h
llvm::AttributeSet::getPreallocatedType
Type * getPreallocatedType() const
Definition: Attributes.cpp:703
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::AttrBuilder::remove
AttrBuilder & remove(const AttrBuilder &B)
Remove the attributes from the builder.
Definition: Attributes.cpp:1736
llvm::AttributeSet::getByRefType
Type * getByRefType() const
Definition: Attributes.cpp:691
llvm::Attribute::isExistingAttribute
static bool isExistingAttribute(StringRef Name)
Return true if the provided string matches the IR name of an attribute.
Definition: Attributes.cpp:245
llvm::AttributeList::getFnAttr
Attribute getFnAttr(StringRef Kind) const
Return the attribute object that exists for the function.
Definition: Attributes.h:785
llvm::Attribute::Attribute
Attribute()=default
llvm::AttributeSet::getByValType
Type * getByValType() const
Definition: Attributes.cpp:695
llvm::AttributeList::hasParamAttr
bool hasParamAttr(unsigned ArgNo, StringRef Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:726
llvm::AttributeList::getParamStructRetType
Type * getParamStructRetType(unsigned ArgNo) const
Return the sret type for the specified function parameter.
Definition: Attributes.cpp:1418
llvm::AttrBuilder::td_attrs
td_const_range td_attrs() const
Definition: Attributes.h:1147
llvm::Attribute::getValueAsType
Type * getValueAsType() const
Return the attribute's value as a Type.
Definition: Attributes.cpp:308
LLVM_NODISCARD
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
Definition: Compiler.h:161
llvm::AttributeList::getNumAttrSets
unsigned getNumAttrSets() const
Definition: Attributes.cpp:1494
llvm::AttributeSet::begin
iterator begin() const
Definition: Attributes.cpp:737
llvm::AttributeList::addFnAttribute
LLVM_NODISCARD AttributeList addFnAttribute(LLVMContext &C, StringRef Kind, StringRef Value=StringRef()) const
Add a function attribute to the list.
Definition: Attributes.h:497
llvm::AttributeList::addRetAttribute
LLVM_NODISCARD AttributeList addRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a return value attribute to the list.
Definition: Attributes.h:511
llvm::AttributeList::getAttributeAtIndex
Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
Definition: Attributes.cpp:1392
llvm::AttributeSet::getElementType
Type * getElementType() const
Definition: Attributes.cpp:711
llvm::AttrBuilder::td_begin
td_const_iterator td_begin() const
Definition: Attributes.h:1142
llvm::AttributeList::addAllocSizeParamAttr
LLVM_NODISCARD 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:1342
llvm::DenseMapInfo< AttributeSet, void >::isEqual
static bool isEqual(AttributeSet LHS, AttributeSet RHS)
Definition: Attributes.h:387
llvm::Attribute::NumTypeAttrKinds
static const unsigned NumTypeAttrKinds
Definition: Attributes.h:81
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:1647
llvm::Attribute::getWithByRefType
static Attribute getWithByRefType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:196
llvm::AttributeList::FunctionIndex
@ FunctionIndex
Definition: Attributes.h:402
llvm::Attribute::getNameFromAttrKind
static StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind)
Definition: Attributes.cpp:231
llvm::AttrBuilder::addAttribute
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
Definition: Attributes.h:952
llvm::AttributeFuncs::areInlineCompatible
bool areInlineCompatible(const Function &Caller, const Function &Callee)
Definition: Attributes.cpp:2019
llvm::AttributeList::index_iterator::int_wrapper::operator*
unsigned operator*()
Definition: Attributes.h:863
llvm::AttributeSet
Definition: Attributes.h:266
llvm::AttributeList::hasFnAttrs
bool hasFnAttrs() const
Return true the attributes exist for the function.
Definition: Attributes.h:755
llvm::AttributeSet::getAttribute
Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
Definition: Attributes.cpp:667
llvm::AttributeList::operator!=
bool operator!=(const AttributeList &RHS) const
Definition: Attributes.h:883
llvm::AttributeList::hasRetAttr
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:736
llvm::AttributeList::removeFnAttribute
LLVM_NODISCARD AttributeList removeFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:587
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::AttributeList::hasParamAttrs
bool hasParamAttrs(unsigned ArgNo) const
Return true if attributes exists for the given argument.
Definition: Attributes.h:731
llvm::AttributeList::indexes
index_iterator indexes() const
Use this to iterate over the valid attribute indexes.
Definition: Attributes.h:879
llvm::AttributeList::addAttributeAtIndex
LLVM_NODISCARD AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
Definition: Attributes.cpp:1184
llvm::Attribute::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Attributes.cpp:484
llvm::AttributeSet::getStackAlignment
MaybeAlign getStackAlignment() const
Definition: Attributes.cpp:679
llvm::Attribute::isIntAttribute
bool isIntAttribute() const
Return true if the attribute is an integer attribute.
Definition: Attributes.cpp:261
llvm::AttributeSet::getStructRetType
Type * getStructRetType() const
Definition: Attributes.cpp:699
llvm::AttrBuilder::addVScaleRangeAttr
AttrBuilder & addVScaleRangeAttr(unsigned MinValue, unsigned MaxValue)
This turns two ints into the form used internally in Attribute.
Definition: Attributes.cpp:1671
llvm::DenseMapInfo< AttributeList, void >::getEmptyKey
static AttributeList getEmptyKey()
Definition: Attributes.h:902
llvm::DenseMapInfo< AttributeList, void >::getHashValue
static unsigned getHashValue(AttributeList AS)
Definition: Attributes.h:914
llvm::AttributeFuncs::mergeAttributesForInlining
void mergeAttributesForInlining(Function &Caller, const Function &Callee)
Merge caller's and callee's attributes.
Definition: Attributes.cpp:2029
llvm::AttributeSet::getAlignment
MaybeAlign getAlignment() const
Definition: Attributes.cpp:675
llvm::AttributeList::hasParamAttr
bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:721
llvm::Attribute::getWithByValType
static Attribute getWithByValType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:188
llvm::AttributeList::getParamAttrs
AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
Definition: Attributes.cpp:1354
llvm::AttrBuilder::getInAllocaType
Type * getInAllocaType() const
Retrieve the inalloca type.
Definition: Attributes.h:1050
llvm::AttrBuilder::getAllocSizeArgs
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Retrieve the allocsize args, if the allocsize attribute exists.
Definition: Attributes.cpp:1622
llvm::AttributeList::getFnAttr
Attribute getFnAttr(Attribute::AttrKind Kind) const
Return the attribute object that exists for the function.
Definition: Attributes.h:780
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::AttrBuilder::td_begin
td_iterator td_begin()
Definition: Attributes.h:1139
llvm::AttributeList::FirstArgIndex
@ FirstArgIndex
Definition: Attributes.h:403
llvm::AttributeList::getParamAttr
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
Definition: Attributes.h:770
llvm::Attribute::operator<
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
Definition: Attributes.cpp:477
llvm::AttributeList::isEmpty
bool isEmpty() const
Return true if there are no attributes.
Definition: Attributes.h:891
llvm::AttributeList::getParamAttr
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const
Return the attribute object that exists at the given index.
Definition: Attributes.h:775
llvm::Attribute::fromRawPointer
static Attribute fromRawPointer(void *RawPtr)
Get an attribute from a raw pointer created by getRawPointer.
Definition: Attributes.h:245
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::Attribute::canUseAsRetAttr
static bool canUseAsRetAttr(AttrKind Kind)
Definition: Attributes.cpp:513
llvm::sampleprof::Base
@ Base
Definition: Discriminator.h:58
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1191
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:351
llvm::AttributeList::getFnStackAlignment
MaybeAlign getFnStackAlignment() const
Get the stack alignment of the function.
Definition: Attributes.cpp:1438
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::AttrBuilder::td_attrs
td_range td_attrs()
Definition: Attributes.h:1145