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