LLVM 22.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"
21#include "llvm/ADT/StringRef.h"
22#include "llvm/Config/llvm-config.h"
26#include "llvm/Support/ModRef.h"
28#include <cassert>
29#include <cstdint>
30#include <optional>
31#include <string>
32#include <utility>
33
34namespace llvm {
35
36class AttrBuilder;
37class AttributeMask;
38class AttributeImpl;
39class AttributeListImpl;
40class AttributeSetNode;
41class ConstantRange;
42class ConstantRangeList;
43class FoldingSetNodeID;
44class Function;
45class LLVMContext;
46class Instruction;
47class Type;
48class raw_ostream;
50
51enum class AllocFnKind : uint64_t {
52 Unknown = 0,
53 Alloc = 1 << 0, // Allocator function returns a new allocation
54 Realloc = 1 << 1, // Allocator function resizes the `allocptr` argument
55 Free = 1 << 2, // Allocator function frees the `allocptr` argument
56 Uninitialized = 1 << 3, // Allocator function returns uninitialized memory
57 Zeroed = 1 << 4, // Allocator function returns zeroed memory
58 Aligned = 1 << 5, // Allocator function aligns allocations per the
59 // `allocalign` argument
60 LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ Aligned)
61};
62
63//===----------------------------------------------------------------------===//
64/// \class
65/// Functions, function parameters, and return types can have attributes
66/// to indicate how they should be treated by optimizations and code
67/// generation. This class represents one of those attributes. It's light-weight
68/// and should be passed around by-value.
69class Attribute {
70public:
71 /// This enumeration lists the attributes that can be associated with
72 /// parameters, function results, or the function itself.
73 ///
74 /// Note: The `uwtable' attribute is about the ABI or the user mandating an
75 /// entry in the unwind table. The `nounwind' attribute is about an exception
76 /// passing by the function.
77 ///
78 /// In a theoretical system that uses tables for profiling and SjLj for
79 /// exceptions, they would be fully independent. In a normal system that uses
80 /// tables for both, the semantics are:
81 ///
82 /// nil = Needs an entry because an exception might pass by.
83 /// nounwind = No need for an entry
84 /// uwtable = Needs an entry because the ABI says so and because
85 /// an exception might pass by.
86 /// uwtable + nounwind = Needs an entry because the ABI says so.
87
88 enum AttrKind {
89 // IR-Level Attributes
90 None, ///< No attributes have been set
91 #define GET_ATTR_ENUM
92 #include "llvm/IR/Attributes.inc"
93 EndAttrKinds, ///< Sentinel value useful for loops
94 EmptyKey, ///< Use as Empty key for DenseMap of AttrKind
95 TombstoneKey, ///< Use as Tombstone key for DenseMap of AttrKind
96 };
97
98 static const unsigned NumIntAttrKinds = LastIntAttr - FirstIntAttr + 1;
99 static const unsigned NumTypeAttrKinds = LastTypeAttr - FirstTypeAttr + 1;
100
101 static bool isEnumAttrKind(AttrKind Kind) {
102 return Kind >= FirstEnumAttr && Kind <= LastEnumAttr;
103 }
104 static bool isIntAttrKind(AttrKind Kind) {
105 return Kind >= FirstIntAttr && Kind <= LastIntAttr;
106 }
107 static bool isTypeAttrKind(AttrKind Kind) {
108 return Kind >= FirstTypeAttr && Kind <= LastTypeAttr;
109 }
111 return Kind >= FirstConstantRangeAttr && Kind <= LastConstantRangeAttr;
112 }
114 return Kind >= FirstConstantRangeListAttr &&
115 Kind <= LastConstantRangeListAttr;
116 }
117
118 LLVM_ABI static bool canUseAsFnAttr(AttrKind Kind);
119 LLVM_ABI static bool canUseAsParamAttr(AttrKind Kind);
120 LLVM_ABI static bool canUseAsRetAttr(AttrKind Kind);
121
122 LLVM_ABI static bool intersectMustPreserve(AttrKind Kind);
123 LLVM_ABI static bool intersectWithAnd(AttrKind Kind);
124 LLVM_ABI static bool intersectWithMin(AttrKind Kind);
125 LLVM_ABI static bool intersectWithCustom(AttrKind Kind);
126
127private:
128 AttributeImpl *pImpl = nullptr;
129
130 Attribute(AttributeImpl *A) : pImpl(A) {}
131
132public:
133 Attribute() = default;
134
135 //===--------------------------------------------------------------------===//
136 // Attribute Construction
137 //===--------------------------------------------------------------------===//
138
139 /// Return a uniquified Attribute object.
140 LLVM_ABI static Attribute get(LLVMContext &Context, AttrKind Kind,
141 uint64_t Val = 0);
142 LLVM_ABI static Attribute get(LLVMContext &Context, StringRef Kind,
143 StringRef Val = StringRef());
144 LLVM_ABI static Attribute get(LLVMContext &Context, AttrKind Kind, Type *Ty);
145 LLVM_ABI static Attribute get(LLVMContext &Context, AttrKind Kind,
146 const ConstantRange &CR);
147 LLVM_ABI static Attribute get(LLVMContext &Context, AttrKind Kind,
149
150 /// Return a uniquified Attribute object that has the specific
151 /// alignment set.
153 Align Alignment);
155 Align Alignment);
157 uint64_t Bytes);
158 LLVM_ABI static Attribute
160 LLVM_ABI static Attribute
161 getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg,
162 const std::optional<unsigned> &NumElemsArg);
164 AllocFnKind Kind);
166 unsigned MinValue,
167 unsigned MaxValue);
168 LLVM_ABI static Attribute getWithByValType(LLVMContext &Context, Type *Ty);
170 Type *Ty);
171 LLVM_ABI static Attribute getWithByRefType(LLVMContext &Context, Type *Ty);
173 Type *Ty);
176 UWTableKind Kind);
178 MemoryEffects ME);
180 FPClassTest Mask);
182 CaptureInfo CI);
183
184 /// For a typed attribute, return the equivalent attribute with the type
185 /// changed to \p ReplacementTy.
186 Attribute getWithNewType(LLVMContext &Context, Type *ReplacementTy) {
187 assert(isTypeAttribute() && "this requires a typed attribute");
188 return get(Context, getKindAsEnum(), ReplacementTy);
189 }
190
192
194
195 /// Return true if the provided string matches the IR name of an attribute.
196 /// example: "noalias" return true but not "NoAlias"
198
199 //===--------------------------------------------------------------------===//
200 // Attribute Accessors
201 //===--------------------------------------------------------------------===//
202
203 /// Return true if the attribute is an Attribute::AttrKind type.
204 LLVM_ABI bool isEnumAttribute() const;
205
206 /// Return true if the attribute is an integer attribute.
207 LLVM_ABI bool isIntAttribute() const;
208
209 /// Return true if the attribute is a string (target-dependent)
210 /// attribute.
211 LLVM_ABI bool isStringAttribute() const;
212
213 /// Return true if the attribute is a type attribute.
214 LLVM_ABI bool isTypeAttribute() const;
215
216 /// Return true if the attribute is a ConstantRange attribute.
218
219 /// Return true if the attribute is a ConstantRangeList attribute.
221
222 /// Return true if the attribute is any kind of attribute.
223 bool isValid() const { return pImpl; }
224
225 /// Return true if the attribute is present.
226 LLVM_ABI bool hasAttribute(AttrKind Val) const;
227
228 /// Return true if the target-dependent attribute is present.
229 LLVM_ABI bool hasAttribute(StringRef Val) const;
230
231 /// Returns true if the attribute's kind can be represented as an enum (Enum,
232 /// Integer, Type, ConstantRange, or ConstantRangeList attribute).
233 bool hasKindAsEnum() const { return !isStringAttribute(); }
234
235 /// Return the attribute's kind as an enum (Attribute::AttrKind). This
236 /// requires the attribute be representable as an enum (see: `hasKindAsEnum`).
238
239 /// Return the attribute's value as an integer. This requires that the
240 /// attribute be an integer attribute.
242
243 /// Return the attribute's value as a boolean. This requires that the
244 /// attribute be a string attribute.
245 LLVM_ABI bool getValueAsBool() const;
246
247 /// Return the attribute's kind as a string. This requires the
248 /// attribute to be a string attribute.
250
251 /// Return the attribute's value as a string. This requires the
252 /// attribute to be a string attribute.
254
255 /// Return the attribute's value as a Type. This requires the attribute to be
256 /// a type attribute.
258
259 /// Return the attribute's value as a ConstantRange. This requires the
260 /// attribute to be a ConstantRange attribute.
262
263 /// Return the attribute's value as a ConstantRange array. This requires the
264 /// attribute to be a ConstantRangeList attribute.
266
267 /// Returns the alignment field of an attribute as a byte alignment
268 /// value.
270
271 /// Returns the stack alignment field of an attribute as a byte
272 /// alignment value.
274
275 /// Returns the number of dereferenceable bytes from the
276 /// dereferenceable attribute.
278
279 /// Returns the number of dereferenceable_or_null bytes from the
280 /// dereferenceable_or_null attribute.
282
283 /// Returns the argument numbers for the allocsize attribute.
284 LLVM_ABI std::pair<unsigned, std::optional<unsigned>>
285 getAllocSizeArgs() const;
286
287 /// Returns the minimum value for the vscale_range attribute.
288 LLVM_ABI unsigned getVScaleRangeMin() const;
289
290 /// Returns the maximum value for the vscale_range attribute or std::nullopt
291 /// when unknown.
292 LLVM_ABI std::optional<unsigned> getVScaleRangeMax() const;
293
294 // Returns the unwind table kind.
296
297 // Returns the allocator function kind.
299
300 /// Returns memory effects.
302
303 /// Returns information from captures attribute.
305
306 /// Return the FPClassTest for nofpclass
308
309 /// Returns the value of the range attribute.
310 LLVM_ABI const ConstantRange &getRange() const;
311
312 /// Returns the value of the initializes attribute.
314
315 /// The Attribute is converted to a string of equivalent mnemonic. This
316 /// is, presumably, for writing out the mnemonics for the assembly writer.
317 LLVM_ABI std::string getAsString(bool InAttrGrp = false) const;
318
319 /// Return true if this attribute belongs to the LLVMContext.
321
322 /// Equality and non-equality operators.
323 bool operator==(Attribute A) const { return pImpl == A.pImpl; }
324 bool operator!=(Attribute A) const { return pImpl != A.pImpl; }
325
326 /// Used to sort attribute by kind.
327 LLVM_ABI int cmpKind(Attribute A) const;
328
329 /// Less-than operator. Useful for sorting the attributes list.
330 LLVM_ABI bool operator<(Attribute A) const;
331
332 LLVM_ABI void Profile(FoldingSetNodeID &ID) const;
333
334 /// Return a raw pointer that uniquely identifies this attribute.
335 void *getRawPointer() const {
336 return pImpl;
337 }
338
339 /// Get an attribute from a raw pointer created by getRawPointer.
340 static Attribute fromRawPointer(void *RawPtr) {
341 return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
342 }
343};
344
345// Specialized opaque value conversions.
347 return reinterpret_cast<LLVMAttributeRef>(Attr.getRawPointer());
348}
349
350// Specialized opaque value conversions.
352 return Attribute::fromRawPointer(Attr);
353}
354
355//===----------------------------------------------------------------------===//
356/// \class
357/// This class holds the attributes for a particular argument, parameter,
358/// function, or return value. It is an immutable value type that is cheap to
359/// copy. Adding and removing enum attributes is intended to be fast, but adding
360/// and removing string or integer attributes involves a FoldingSet lookup.
362 friend AttributeListImpl;
363 template <typename Ty, typename Enable> friend struct DenseMapInfo;
364
365 // TODO: Extract AvailableAttrs from AttributeSetNode and store them here.
366 // This will allow an efficient implementation of addAttribute and
367 // removeAttribute for enum attrs.
368
369 /// Private implementation pointer.
370 AttributeSetNode *SetNode = nullptr;
371
372private:
373 explicit AttributeSet(AttributeSetNode *ASN) : SetNode(ASN) {}
374
375public:
376 /// AttributeSet is a trivially copyable value type.
377 AttributeSet() = default;
378 AttributeSet(const AttributeSet &) = default;
379 ~AttributeSet() = default;
380
383
384 bool operator==(const AttributeSet &O) const { return SetNode == O.SetNode; }
385 bool operator!=(const AttributeSet &O) const { return !(*this == O); }
386
387 /// Add an argument attribute. Returns a new set because attribute sets are
388 /// immutable.
389 [[nodiscard]] LLVM_ABI AttributeSet
391
392 /// Add a target-dependent attribute. Returns a new set because attribute sets
393 /// are immutable.
394 [[nodiscard]] LLVM_ABI AttributeSet addAttribute(
395 LLVMContext &C, StringRef Kind, StringRef Value = StringRef()) const;
396
397 /// Add attributes to the attribute set. Returns a new set because attribute
398 /// sets are immutable.
400 AttributeSet AS) const;
401
402 /// Add attributes to the attribute set. Returns a new set because attribute
403 /// sets are immutable.
405
406 /// Remove the specified attribute from this set. Returns a new set because
407 /// attribute sets are immutable.
408 [[nodiscard]] LLVM_ABI AttributeSet
410
411 /// Remove the specified attribute from this set. Returns a new set because
412 /// attribute sets are immutable.
414 StringRef Kind) const;
415
416 /// Remove the specified attributes from this set. Returns a new set because
417 /// attribute sets are immutable.
418 [[nodiscard]] LLVM_ABI AttributeSet
419 removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const;
420
421 /// Try to intersect this AttributeSet with Other. Returns std::nullopt if
422 /// the two lists are inherently incompatible (imply different behavior, not
423 /// just analysis).
424 [[nodiscard]] LLVM_ABI std::optional<AttributeSet>
426
427 /// Return the number of attributes in this set.
428 LLVM_ABI unsigned getNumAttributes() const;
429
430 /// Return true if attributes exists in this set.
431 bool hasAttributes() const { return SetNode != nullptr; }
432
433 /// Return true if the attribute exists in this set.
435
436 /// Return true if the attribute exists in this set.
437 LLVM_ABI bool hasAttribute(StringRef Kind) const;
438
439 /// Return the attribute object.
441
442 /// Return the target-dependent attribute object.
444
449 LLVM_ABI Type *getByValType() const;
451 LLVM_ABI Type *getByRefType() const;
455 LLVM_ABI std::optional<std::pair<unsigned, std::optional<unsigned>>>
456 getAllocSizeArgs() const;
457 LLVM_ABI unsigned getVScaleRangeMin() const;
458 LLVM_ABI std::optional<unsigned> getVScaleRangeMax() const;
464 LLVM_ABI std::string getAsString(bool InAttrGrp = false) const;
465
466 /// Return true if this attribute set belongs to the LLVMContext.
468
469 using iterator = const Attribute *;
470
471 LLVM_ABI iterator begin() const;
472 LLVM_ABI iterator end() const;
473#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
474 void dump() const;
475#endif
476};
477
478//===----------------------------------------------------------------------===//
479/// \class
480/// Provide DenseMapInfo for AttributeSet.
481template <> struct DenseMapInfo<AttributeSet, void> {
483 auto Val = static_cast<uintptr_t>(-1);
484 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
485 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
486 }
487
489 auto Val = static_cast<uintptr_t>(-2);
490 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
491 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
492 }
493
494 static unsigned getHashValue(AttributeSet AS) {
495 return (unsigned((uintptr_t)AS.SetNode) >> 4) ^
496 (unsigned((uintptr_t)AS.SetNode) >> 9);
497 }
498
499 static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
500};
501
502//===----------------------------------------------------------------------===//
503/// \class
504/// This class holds the attributes for a function, its return value, and
505/// its parameters. You access the attributes for each of them via an index into
506/// the AttributeList object. The function attributes are at index
507/// `AttributeList::FunctionIndex', the return value is at index
508/// `AttributeList::ReturnIndex', and the attributes for the parameters start at
509/// index `AttributeList::FirstArgIndex'.
511public:
512 enum AttrIndex : unsigned {
516 };
517
518private:
519 friend class AttrBuilder;
520 friend class AttributeListImpl;
521 friend class AttributeSet;
522 friend class AttributeSetNode;
523 template <typename Ty, typename Enable> friend struct DenseMapInfo;
524
525 /// The attributes that we are managing. This can be null to represent
526 /// the empty attributes list.
527 AttributeListImpl *pImpl = nullptr;
528
529public:
530 /// Create an AttributeList with the specified parameters in it.
532 get(LLVMContext &C, ArrayRef<std::pair<unsigned, Attribute>> Attrs);
534 get(LLVMContext &C, ArrayRef<std::pair<unsigned, AttributeSet>> Attrs);
535
536 /// Create an AttributeList from attribute sets for a function, its
537 /// return value, and all of its arguments.
539 AttributeSet RetAttrs,
540 ArrayRef<AttributeSet> ArgAttrs);
541
542private:
543 explicit AttributeList(AttributeListImpl *LI) : pImpl(LI) {}
544
545 static AttributeList getImpl(LLVMContext &C, ArrayRef<AttributeSet> AttrSets);
546
547 AttributeList setAttributesAtIndex(LLVMContext &C, unsigned Index,
548 AttributeSet Attrs) const;
549
550public:
551 AttributeList() = default;
552
553 //===--------------------------------------------------------------------===//
554 // AttributeList Construction and Mutation
555 //===--------------------------------------------------------------------===//
556
557 /// Return an AttributeList with the specified parameters in it.
560 LLVM_ABI static AttributeList get(LLVMContext &C, unsigned Index,
562 LLVM_ABI static AttributeList get(LLVMContext &C, unsigned Index,
564 ArrayRef<uint64_t> Values);
565 LLVM_ABI static AttributeList get(LLVMContext &C, unsigned Index,
567 LLVM_ABI static AttributeList get(LLVMContext &C, unsigned Index,
568 AttributeSet Attrs);
569 LLVM_ABI static AttributeList get(LLVMContext &C, unsigned Index,
570 const AttrBuilder &B);
571
572 // TODO: remove non-AtIndex versions of these methods.
573 /// Add an attribute to the attribute set at the given index.
574 /// Returns a new list because attribute lists are immutable.
576 LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const;
577
578 /// Add an attribute to the attribute set at the given index.
579 /// Returns a new list because attribute lists are immutable.
580 [[nodiscard]] LLVM_ABI AttributeList
582 StringRef Value = StringRef()) const;
583
584 /// Add an attribute to the attribute set at the given index.
585 /// Returns a new list because attribute lists are immutable.
587 unsigned Index,
588 Attribute A) const;
589
590 /// Add attributes to the attribute set at the given index.
591 /// Returns a new list because attribute lists are immutable.
593 LLVMContext &C, unsigned Index, const AttrBuilder &B) const;
594
595 /// Add a function attribute to the list. Returns a new list because
596 /// attribute lists are immutable.
598 Attribute::AttrKind Kind) const {
599 return addAttributeAtIndex(C, FunctionIndex, Kind);
600 }
601
602 /// Add a function attribute to the list. Returns a new list because
603 /// attribute lists are immutable.
605 Attribute Attr) const {
606 return addAttributeAtIndex(C, FunctionIndex, Attr);
607 }
608
609 /// Add a function attribute to the list. Returns a new list because
610 /// attribute lists are immutable.
611 [[nodiscard]] AttributeList
613 StringRef Value = StringRef()) const {
615 }
616
617 /// Add function attribute to the list. Returns a new list because
618 /// attribute lists are immutable.
620 const AttrBuilder &B) const {
622 }
623
624 /// Add a return value attribute to the list. Returns a new list because
625 /// attribute lists are immutable.
627 Attribute::AttrKind Kind) const {
628 return addAttributeAtIndex(C, ReturnIndex, Kind);
629 }
630
631 /// Add a return value attribute to the list. Returns a new list because
632 /// attribute lists are immutable.
634 Attribute Attr) const {
635 return addAttributeAtIndex(C, ReturnIndex, Attr);
636 }
637
638 /// Add a return value attribute to the list. Returns a new list because
639 /// attribute lists are immutable.
641 const AttrBuilder &B) const {
643 }
644
645 /// Add an argument attribute to the list. Returns a new list because
646 /// attribute lists are immutable.
647 [[nodiscard]] AttributeList
649 Attribute::AttrKind Kind) const {
650 return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
651 }
652
653 /// Add an argument attribute to the list. Returns a new list because
654 /// attribute lists are immutable.
655 [[nodiscard]] AttributeList
656 addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind,
657 StringRef Value = StringRef()) const {
658 return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind, Value);
659 }
660
661 /// Add an attribute to the attribute list at the given arg indices. Returns a
662 /// new list because attribute lists are immutable.
664 LLVMContext &C, ArrayRef<unsigned> ArgNos, Attribute A) const;
665
666 /// Add an argument attribute to the list. Returns a new list because
667 /// attribute lists are immutable.
668 [[nodiscard]] AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo,
669 const AttrBuilder &B) const {
670 return addAttributesAtIndex(C, ArgNo + FirstArgIndex, B);
671 }
672
673 /// Remove the specified attribute at the specified index from this
674 /// attribute list. Returns a new list because attribute lists are immutable.
676 LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const;
677
678 /// Remove the specified attribute at the specified index from this
679 /// attribute list. Returns a new list because attribute lists are immutable.
680 [[nodiscard]] LLVM_ABI AttributeList
681 removeAttributeAtIndex(LLVMContext &C, unsigned Index, StringRef Kind) const;
683 StringRef Kind) const {
684 return removeAttributeAtIndex(C, Index, Kind);
685 }
686
687 /// Remove the specified attributes at the specified index from this
688 /// attribute list. Returns a new list because attribute lists are immutable.
690 LLVMContext &C, unsigned Index, const AttributeMask &AttrsToRemove) const;
691
692 /// Remove all attributes at the specified index from this
693 /// attribute list. Returns a new list because attribute lists are immutable.
694 [[nodiscard]] LLVM_ABI AttributeList
695 removeAttributesAtIndex(LLVMContext &C, unsigned Index) const;
696
697 /// Remove the specified attribute at the function index from this
698 /// attribute list. Returns a new list because attribute lists are immutable.
699 [[nodiscard]] AttributeList
702 }
703
704 /// Remove the specified attribute at the function index from this
705 /// attribute list. Returns a new list because attribute lists are immutable.
707 StringRef Kind) const {
709 }
710
711 /// Remove the specified attribute at the function index from this
712 /// attribute list. Returns a new list because attribute lists are immutable.
713 [[nodiscard]] AttributeList
714 removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const {
715 return removeAttributesAtIndex(C, FunctionIndex, AttrsToRemove);
716 }
717
718 /// Remove the attributes at the function index from this
719 /// attribute list. Returns a new list because attribute lists are immutable.
722 }
723
724 /// Remove the specified attribute at the return value index from this
725 /// attribute list. Returns a new list because attribute lists are immutable.
726 [[nodiscard]] AttributeList
728 return removeAttributeAtIndex(C, ReturnIndex, Kind);
729 }
730
731 /// Remove the specified attribute at the return value index from this
732 /// attribute list. Returns a new list because attribute lists are immutable.
734 StringRef Kind) const {
735 return removeAttributeAtIndex(C, ReturnIndex, Kind);
736 }
737
738 /// Remove the specified attribute at the return value index from this
739 /// attribute list. Returns a new list because attribute lists are immutable.
740 [[nodiscard]] AttributeList
742 const AttributeMask &AttrsToRemove) const {
743 return removeAttributesAtIndex(C, ReturnIndex, AttrsToRemove);
744 }
745
746 /// Remove the specified attribute at the specified arg index from this
747 /// attribute list. Returns a new list because attribute lists are immutable.
748 [[nodiscard]] AttributeList
750 Attribute::AttrKind Kind) const {
751 return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
752 }
753
754 /// Remove the specified attribute at the specified arg index from this
755 /// attribute list. Returns a new list because attribute lists are immutable.
756 [[nodiscard]] AttributeList
757 removeParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind) const {
758 return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
759 }
760
761 /// Remove the specified attribute at the specified arg index from this
762 /// attribute list. Returns a new list because attribute lists are immutable.
763 [[nodiscard]] AttributeList
765 const AttributeMask &AttrsToRemove) const {
766 return removeAttributesAtIndex(C, ArgNo + FirstArgIndex, AttrsToRemove);
767 }
768
769 /// Remove all attributes at the specified arg index from this
770 /// attribute list. Returns a new list because attribute lists are immutable.
772 unsigned ArgNo) const {
773 return removeAttributesAtIndex(C, ArgNo + FirstArgIndex);
774 }
775
776 /// Replace the type contained by attribute \p AttrKind at index \p ArgNo wih
777 /// \p ReplacementTy, preserving all other attributes.
778 [[nodiscard]] AttributeList
781 Type *ReplacementTy) const {
782 Attribute Attr = getAttributeAtIndex(ArgNo, Kind);
783 auto Attrs = removeAttributeAtIndex(C, ArgNo, Kind);
784 return Attrs.addAttributeAtIndex(C, ArgNo,
785 Attr.getWithNewType(C, ReplacementTy));
786 }
787
788 /// \brief Add the dereferenceable attribute to the attribute set at the given
789 /// index. Returns a new list because attribute lists are immutable.
790 [[nodiscard]] LLVM_ABI AttributeList
792
793 /// \brief Add the dereferenceable attribute to the attribute set at the given
794 /// arg index. Returns a new list because attribute lists are immutable.
796 LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const;
797
798 /// Add the dereferenceable_or_null attribute to the attribute set at
799 /// the given arg index. Returns a new list because attribute lists are
800 /// immutable.
802 LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const;
803
804 /// Add the range attribute to the attribute set at the return value index.
805 /// Returns a new list because attribute lists are immutable.
806 [[nodiscard]] LLVM_ABI AttributeList
807 addRangeRetAttr(LLVMContext &C, const ConstantRange &CR) const;
808
809 /// Add the allocsize attribute to the attribute set at the given arg index.
810 /// Returns a new list because attribute lists are immutable.
811 [[nodiscard]] LLVM_ABI AttributeList
812 addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg,
813 const std::optional<unsigned> &NumElemsArg) const;
814
815 /// Try to intersect this AttributeList with Other. Returns std::nullopt if
816 /// the two lists are inherently incompatible (imply different behavior, not
817 /// just analysis).
818 [[nodiscard]] LLVM_ABI std::optional<AttributeList>
820
821 //===--------------------------------------------------------------------===//
822 // AttributeList Accessors
823 //===--------------------------------------------------------------------===//
824
825 /// The attributes for the specified index are returned.
827
828 /// The attributes for the argument or parameter at the given index are
829 /// returned.
830 LLVM_ABI AttributeSet getParamAttrs(unsigned ArgNo) const;
831
832 /// The attributes for the ret value are returned.
834
835 /// The function attributes are returned.
837
838 /// Return true if the attribute exists at the given index.
839 LLVM_ABI bool hasAttributeAtIndex(unsigned Index,
840 Attribute::AttrKind Kind) const;
841
842 /// Return true if the attribute exists at the given index.
843 LLVM_ABI bool hasAttributeAtIndex(unsigned Index, StringRef Kind) const;
844
845 /// Return true if attribute exists at the given index.
846 LLVM_ABI bool hasAttributesAtIndex(unsigned Index) const;
847
848 /// Return true if the attribute exists for the given argument
849 bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
850 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
851 }
852
853 /// Return true if the attribute exists for the given argument
854 bool hasParamAttr(unsigned ArgNo, StringRef Kind) const {
855 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
856 }
857
858 /// Return true if attributes exists for the given argument
859 bool hasParamAttrs(unsigned ArgNo) const {
860 return hasAttributesAtIndex(ArgNo + FirstArgIndex);
861 }
862
863 /// Return true if the attribute exists for the return value.
865 return hasAttributeAtIndex(ReturnIndex, Kind);
866 }
867
868 /// Return true if the attribute exists for the return value.
869 bool hasRetAttr(StringRef Kind) const {
870 return hasAttributeAtIndex(ReturnIndex, Kind);
871 }
872
873 /// Return true if attributes exist for the return value.
875
876 /// Return true if the attribute exists for the function.
877 LLVM_ABI bool hasFnAttr(Attribute::AttrKind Kind) const;
878
879 /// Return true if the attribute exists for the function.
880 LLVM_ABI bool hasFnAttr(StringRef Kind) const;
881
882 /// Return true the attributes exist for the function.
884
885 /// Return true if the specified attribute is set for at least one
886 /// parameter or for the return value. If Index is not nullptr, the index
887 /// of a parameter with the specified attribute is provided.
889 unsigned *Index = nullptr) const;
890
891 /// Return the attribute object that exists at the given index.
893 Attribute::AttrKind Kind) const;
894
895 /// Return the attribute object that exists at the given index.
897
898 /// Return the attribute object that exists at the arg index.
899 Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
900 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
901 }
902
903 /// Return the attribute object that exists at the given index.
904 Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const {
905 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
906 }
907
908 /// Return the attribute object that exists for the function.
911 }
912
913 /// Return the attribute object that exists for the function.
916 }
917
918 /// Return the attribute for the given attribute kind for the return value.
920 return getAttributeAtIndex(ReturnIndex, Kind);
921 }
922
923 /// Return the alignment of the return value.
925
926 /// Return the alignment for the specified function parameter.
927 LLVM_ABI MaybeAlign getParamAlignment(unsigned ArgNo) const;
928
929 /// Return the stack alignment for the specified function parameter.
930 LLVM_ABI MaybeAlign getParamStackAlignment(unsigned ArgNo) const;
931
932 /// Return the byval type for the specified function parameter.
933 LLVM_ABI Type *getParamByValType(unsigned ArgNo) const;
934
935 /// Return the sret type for the specified function parameter.
936 LLVM_ABI Type *getParamStructRetType(unsigned ArgNo) const;
937
938 /// Return the byref type for the specified function parameter.
939 LLVM_ABI Type *getParamByRefType(unsigned ArgNo) const;
940
941 /// Return the preallocated type for the specified function parameter.
942 LLVM_ABI Type *getParamPreallocatedType(unsigned ArgNo) const;
943
944 /// Return the inalloca type for the specified function parameter.
945 LLVM_ABI Type *getParamInAllocaType(unsigned ArgNo) const;
946
947 /// Return the elementtype type for the specified function parameter.
948 LLVM_ABI Type *getParamElementType(unsigned ArgNo) const;
949
950 /// Get the stack alignment of the function.
952
953 /// Get the stack alignment of the return value.
955
956 /// Get the number of dereferenceable bytes (or zero if unknown) of the return
957 /// value.
959
960 /// Get the number of dereferenceable bytes (or zero if unknown) of an arg.
962
963 /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of
964 /// the return value.
966
967 /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of an
968 /// arg.
970
971 /// Get range (or std::nullopt if unknown) of an arg.
972 LLVM_ABI std::optional<ConstantRange> getParamRange(unsigned ArgNo) const;
973
974 /// Get the disallowed floating-point classes of the return value.
976
977 /// Get the disallowed floating-point classes of the argument value.
978 LLVM_ABI FPClassTest getParamNoFPClass(unsigned ArgNo) const;
979
980 /// Get the unwind table kind requested for the function.
982
984
985 /// Returns memory effects of the function.
987
988 /// Return the attributes at the index as a string.
989 LLVM_ABI std::string getAsString(unsigned Index,
990 bool InAttrGrp = false) const;
991
992 /// Return true if this attribute list belongs to the LLVMContext.
994
995 //===--------------------------------------------------------------------===//
996 // AttributeList Introspection
997 //===--------------------------------------------------------------------===//
998
999 using iterator = const AttributeSet *;
1000
1001 LLVM_ABI iterator begin() const;
1002 LLVM_ABI iterator end() const;
1003
1004 LLVM_ABI unsigned getNumAttrSets() const;
1005
1006 // Implementation of indexes(). Produces iterators that wrap an index. Mostly
1007 // to hide the awkwardness of unsigned wrapping when iterating over valid
1008 // indexes.
1010 unsigned NumAttrSets;
1013 int_wrapper(unsigned i) : i(i) {}
1014 unsigned i;
1015 unsigned operator*() { return i; }
1016 bool operator!=(const int_wrapper &Other) { return i != Other.i; }
1018 // This is expected to undergo unsigned wrapping since FunctionIndex is
1019 // ~0 and that's where we start.
1020 ++i;
1021 return *this;
1022 }
1023 };
1024
1026
1028 };
1029
1030 /// Use this to iterate over the valid attribute indexes.
1032
1033 /// operator==/!= - Provide equality predicates.
1034 bool operator==(const AttributeList &RHS) const { return pImpl == RHS.pImpl; }
1035 bool operator!=(const AttributeList &RHS) const { return pImpl != RHS.pImpl; }
1036
1037 /// Return a raw pointer that uniquely identifies this attribute list.
1038 void *getRawPointer() const {
1039 return pImpl;
1040 }
1041
1042 /// Return true if there are no attributes.
1043 bool isEmpty() const { return pImpl == nullptr; }
1044
1045 LLVM_ABI void print(raw_ostream &O) const;
1046
1047 LLVM_ABI void dump() const;
1048};
1049
1050//===----------------------------------------------------------------------===//
1051/// \class
1052/// Provide DenseMapInfo for AttributeList.
1053template <> struct DenseMapInfo<AttributeList, void> {
1055 auto Val = static_cast<uintptr_t>(-1);
1056 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
1057 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
1058 }
1059
1061 auto Val = static_cast<uintptr_t>(-2);
1062 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
1063 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
1064 }
1065
1066 static unsigned getHashValue(AttributeList AS) {
1067 return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
1068 (unsigned((uintptr_t)AS.pImpl) >> 9);
1069 }
1070
1072 return LHS == RHS;
1073 }
1074};
1075
1076//===----------------------------------------------------------------------===//
1077/// \class
1078/// This class is used in conjunction with the Attribute::get method to
1079/// create an Attribute object. The object itself is uniquified. The Builder's
1080/// value, however, is not. So this can be used as a quick way to test for
1081/// equality, presence of attributes, etc.
1083 LLVMContext &Ctx;
1085
1086public:
1087 AttrBuilder(LLVMContext &Ctx) : Ctx(Ctx) {}
1088 AttrBuilder(const AttrBuilder &) = delete;
1090
1091 AttrBuilder(LLVMContext &Ctx, const Attribute &A) : Ctx(Ctx) {
1092 addAttribute(A);
1093 }
1094
1096
1097 LLVM_ABI void clear();
1098
1099 /// Add an attribute to the builder.
1101
1102 /// Add the Attribute object to the builder.
1104
1105 /// Add the target-dependent attribute to the builder.
1107
1108 /// Remove an attribute from the builder.
1110
1111 /// Remove the target-dependent attribute from the builder.
1113
1114 /// Remove the target-dependent attribute from the builder.
1116 if (A.isStringAttribute())
1117 return removeAttribute(A.getKindAsString());
1118 else
1119 return removeAttribute(A.getKindAsEnum());
1120 }
1121
1122 /// Add the attributes from the builder. Attributes in the passed builder
1123 /// overwrite attributes in this builder if they have the same key.
1125
1126 /// Remove the attributes from the builder.
1128
1129 /// Return true if the builder has any attribute that's in the
1130 /// specified builder.
1131 LLVM_ABI bool overlaps(const AttributeMask &AM) const;
1132
1133 /// Return true if the builder has the specified attribute.
1135
1136 /// Return true if the builder has the specified target-dependent
1137 /// attribute.
1138 LLVM_ABI bool contains(StringRef A) const;
1139
1140 /// Return true if the builder has IR-level attributes.
1141 bool hasAttributes() const { return !Attrs.empty(); }
1142
1143 /// Return Attribute with the given Kind. The returned attribute will be
1144 /// invalid if the Kind is not present in the builder.
1146
1147 /// Return Attribute with the given Kind. The returned attribute will be
1148 /// invalid if the Kind is not present in the builder.
1150
1151 /// Retrieve the range if the attribute exists (std::nullopt is returned
1152 /// otherwise).
1153 LLVM_ABI std::optional<ConstantRange> getRange() const;
1154
1155 /// Return raw (possibly packed/encoded) value of integer attribute or
1156 /// std::nullopt if not set.
1157 LLVM_ABI std::optional<uint64_t>
1159
1160 /// Retrieve the alignment attribute, if it exists.
1162 return MaybeAlign(getRawIntAttr(Attribute::Alignment).value_or(0));
1163 }
1164
1165 /// Retrieve the stack alignment attribute, if it exists.
1167 return MaybeAlign(getRawIntAttr(Attribute::StackAlignment).value_or(0));
1168 }
1169
1170 /// Retrieve the number of dereferenceable bytes, if the
1171 /// dereferenceable attribute exists (zero is returned otherwise).
1173 return getRawIntAttr(Attribute::Dereferenceable).value_or(0);
1174 }
1175
1176 /// Retrieve the number of dereferenceable_or_null bytes, if the
1177 /// dereferenceable_or_null attribute exists (zero is returned otherwise).
1179 return getRawIntAttr(Attribute::DereferenceableOrNull).value_or(0);
1180 }
1181
1182 /// Retrieve the bitmask for nofpclass, if the nofpclass attribute exists
1183 /// (fcNone is returned otherwise).
1185 std::optional<uint64_t> Raw = getRawIntAttr(Attribute::NoFPClass);
1186 return static_cast<FPClassTest>(Raw.value_or(0));
1187 }
1188
1189 /// Retrieve type for the given type attribute.
1191
1192 /// Retrieve the byval type.
1193 Type *getByValType() const { return getTypeAttr(Attribute::ByVal); }
1194
1195 /// Retrieve the sret type.
1196 Type *getStructRetType() const { return getTypeAttr(Attribute::StructRet); }
1197
1198 /// Retrieve the byref type.
1199 Type *getByRefType() const { return getTypeAttr(Attribute::ByRef); }
1200
1201 /// Retrieve the preallocated type.
1203 return getTypeAttr(Attribute::Preallocated);
1204 }
1205
1206 /// Retrieve the inalloca type.
1207 Type *getInAllocaType() const { return getTypeAttr(Attribute::InAlloca); }
1208
1209 /// Retrieve the allocsize args, or std::nullopt if the attribute does not
1210 /// exist.
1211 LLVM_ABI std::optional<std::pair<unsigned, std::optional<unsigned>>>
1212 getAllocSizeArgs() const;
1213
1214 /// Add integer attribute with raw value (packed/encoded if necessary).
1216
1217 /// This turns an alignment into the form used internally in Attribute.
1218 /// This call has no effect if Align is not set.
1220
1221 /// This turns an int alignment (which must be a power of 2) into the
1222 /// form used internally in Attribute.
1223 /// This call has no effect if Align is 0.
1224 /// Deprecated, use the version using a MaybeAlign.
1227 }
1228
1229 /// This turns a stack alignment into the form used internally in Attribute.
1230 /// This call has no effect if Align is not set.
1232
1233 /// This turns an int stack alignment (which must be a power of 2) into
1234 /// the form used internally in Attribute.
1235 /// This call has no effect if Align is 0.
1236 /// Deprecated, use the version using a MaybeAlign.
1239 }
1240
1241 /// This turns the number of dereferenceable bytes into the form used
1242 /// internally in Attribute.
1244
1245 /// This turns the number of dereferenceable_or_null bytes into the
1246 /// form used internally in Attribute.
1248
1249 /// This turns one (or two) ints into the form used internally in Attribute.
1251 addAllocSizeAttr(unsigned ElemSizeArg,
1252 const std::optional<unsigned> &NumElemsArg);
1253
1254 /// This turns two ints into the form used internally in Attribute.
1255 LLVM_ABI AttrBuilder &addVScaleRangeAttr(unsigned MinValue,
1256 std::optional<unsigned> MaxValue);
1257
1258 /// Add a type attribute with the given type.
1260
1261 /// This turns a byval type into the form used internally in Attribute.
1263
1264 /// This turns a sret type into the form used internally in Attribute.
1266
1267 /// This turns a byref type into the form used internally in Attribute.
1269
1270 /// This turns a preallocated type into the form used internally in Attribute.
1272
1273 /// This turns an inalloca type into the form used internally in Attribute.
1275
1276 /// Add an allocsize attribute, using the representation returned by
1277 /// Attribute.getIntValue().
1279
1280 /// Add a vscale_range attribute, using the representation returned by
1281 /// Attribute.getIntValue().
1283 addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr);
1284
1285 /// This turns the unwind table kind into the form used internally in
1286 /// Attribute.
1288
1289 // This turns the allocator kind into the form used internally in Attribute.
1291
1292 /// Add memory effect attribute.
1294
1295 /// Add captures attribute.
1297
1298 // Add nofpclass attribute
1300
1301 /// Add a ConstantRange attribute with the given range.
1303 const ConstantRange &CR);
1304
1305 /// Add range attribute.
1307
1308 /// Add a ConstantRangeList attribute with the given ranges.
1311
1312 /// Add initializes attribute.
1314
1315 /// Add 0 or more parameter attributes which are equivalent to metadata
1316 /// attached to \p I. e.g. !align -> align. This assumes the argument type is
1317 /// the same as the original instruction and the attribute is compatible.
1319
1320 ArrayRef<Attribute> attrs() const { return Attrs; }
1321
1322 LLVM_ABI bool operator==(const AttrBuilder &B) const;
1323 bool operator!=(const AttrBuilder &B) const { return !(*this == B); }
1324};
1325
1326namespace AttributeFuncs {
1327
1332};
1333
1334/// Returns true if this is a type legal for the 'nofpclass' attribute. This
1335/// follows the same type rules as FPMathOperator.
1337
1338/// Which attributes cannot be applied to a type. The argument \p AS
1339/// is used as a hint for the attributes whose compatibility is being
1340/// checked against \p Ty. This does not mean the return will be a
1341/// subset of \p AS, just that attributes that have specific dynamic
1342/// type compatibilities (i.e `range`) will be checked against what is
1343/// contained in \p AS. The argument \p ASK indicates, if only
1344/// attributes that are known to be safely droppable are contained in
1345/// the mask; only attributes that might be unsafe to drop (e.g.,
1346/// ABI-related attributes) are in the mask; or both.
1349
1350/// Get param/return attributes which imply immediate undefined behavior if an
1351/// invalid value is passed. For example, this includes noundef (where undef
1352/// implies UB), but not nonnull (where null implies poison). It also does not
1353/// include attributes like nocapture, which constrain the function
1354/// implementation rather than the passed value.
1356
1357/// \returns Return true if the two functions have compatible target-independent
1358/// attributes for inlining purposes.
1359LLVM_ABI bool areInlineCompatible(const Function &Caller,
1360 const Function &Callee);
1361
1362/// Checks if there are any incompatible function attributes between
1363/// \p A and \p B.
1364///
1365/// \param [in] A - The first function to be compared with.
1366/// \param [in] B - The second function to be compared with.
1367/// \returns true if the functions have compatible attributes.
1368LLVM_ABI bool areOutlineCompatible(const Function &A, const Function &B);
1369
1370/// Merge caller's and callee's attributes.
1372 const Function &Callee);
1373
1374/// Merges the functions attributes from \p ToMerge into function \p Base.
1375///
1376/// \param [in,out] Base - The function being merged into.
1377/// \param [in] ToMerge - The function to merge attributes from.
1379 const Function &ToMerge);
1380
1381/// Update min-legal-vector-width if it is in Attribute and less than Width.
1383
1384} // end namespace AttributeFuncs
1385
1386} // end namespace llvm
1387
1388#endif // LLVM_IR_ATTRIBUTES_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
RelocType Type
Definition: COFFYAML.cpp:410
#define LLVM_ABI
Definition: Compiler.h:213
std::string Name
uint32_t Index
#define I(x, y, z)
Definition: MD5.cpp:58
Load MIR Sample Profile
Value * RHS
Value * LHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
LLVM_ABI AttrBuilder & addStructRetAttr(Type *Ty)
This turns a sret type into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addAlignmentAttr(MaybeAlign Align)
This turns an alignment into the form used internally in Attribute.
Type * getByValType() const
Retrieve the byval type.
Definition: Attributes.h:1193
AttrBuilder(AttrBuilder &&)=default
LLVM_ABI AttrBuilder & addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr)
Add a vscale_range attribute, using the representation returned by Attribute.getIntValue().
AttrBuilder(const AttrBuilder &)=delete
LLVM_ABI void clear()
LLVM_ABI std::optional< uint64_t > getRawIntAttr(Attribute::AttrKind Kind) const
Return raw (possibly packed/encoded) value of integer attribute or std::nullopt if not set.
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:1237
LLVM_ABI AttrBuilder & addAllocKindAttr(AllocFnKind Kind)
LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const
Return Attribute with the given Kind.
LLVM_ABI AttrBuilder & addByRefAttr(Type *Ty)
This turns a byref type into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addNoFPClassAttr(FPClassTest NoFPClassMask)
LLVM_ABI AttrBuilder & addCapturesAttr(CaptureInfo CI)
Add captures attribute.
LLVM_ABI bool overlaps(const AttributeMask &AM) const
Return true if the builder has any attribute that's in the specified builder.
LLVM_ABI AttrBuilder & merge(const AttrBuilder &B)
Add the attributes from the builder.
MaybeAlign getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
Definition: Attributes.h:1166
Type * getByRefType() const
Retrieve the byref type.
Definition: Attributes.h:1199
LLVM_ABI AttrBuilder & addVScaleRangeAttr(unsigned MinValue, std::optional< unsigned > MaxValue)
This turns two ints into the form used internally in Attribute.
AttrBuilder(LLVMContext &Ctx)
Definition: Attributes.h:1087
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
Definition: Attributes.h:1172
bool hasAttributes() const
Return true if the builder has IR-level attributes.
Definition: Attributes.h:1141
LLVM_ABI AttrBuilder & addRawIntAttr(Attribute::AttrKind Kind, uint64_t Value)
Add integer attribute with raw value (packed/encoded if necessary).
LLVM_ABI AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
MaybeAlign getAlignment() const
Retrieve the alignment attribute, if it exists.
Definition: Attributes.h:1161
LLVM_ABI AttrBuilder & addByValAttr(Type *Ty)
This turns a byval type into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addDereferenceableAttr(uint64_t Bytes)
This turns the number of dereferenceable bytes into the form used internally in Attribute.
Type * getPreallocatedType() const
Retrieve the preallocated type.
Definition: Attributes.h:1202
LLVM_ABI AttrBuilder & addInitializesAttr(const ConstantRangeList &CRL)
Add initializes attribute.
LLVM_ABI bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
LLVM_ABI AttrBuilder & addMemoryAttr(MemoryEffects ME)
Add memory effect attribute.
LLVM_ABI AttrBuilder & addConstantRangeListAttr(Attribute::AttrKind Kind, ArrayRef< ConstantRange > Val)
Add a ConstantRangeList attribute with the given ranges.
LLVM_ABI AttrBuilder & addConstantRangeAttr(Attribute::AttrKind Kind, const ConstantRange &CR)
Add a ConstantRange attribute with the given range.
FPClassTest getNoFPClass() const
Retrieve the bitmask for nofpclass, if the nofpclass attribute exists (fcNone is returned otherwise).
Definition: Attributes.h:1184
LLVM_ABI AttrBuilder & addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr)
Add an allocsize attribute, using the representation returned by Attribute.getIntValue().
LLVM_ABI AttrBuilder & addPreallocatedAttr(Type *Ty)
This turns a preallocated type into the form used internally in Attribute.
Type * getInAllocaType() const
Retrieve the inalloca type.
Definition: Attributes.h:1207
LLVM_ABI AttrBuilder & addStackAlignmentAttr(MaybeAlign Align)
This turns a stack alignment into the form used internally in Attribute.
AttrBuilder & removeAttribute(Attribute A)
Remove the target-dependent attribute from the builder.
Definition: Attributes.h:1115
uint64_t getDereferenceableOrNullBytes() const
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists...
Definition: Attributes.h:1178
ArrayRef< Attribute > attrs() const
Definition: Attributes.h:1320
LLVM_ABI AttrBuilder & addInAllocaAttr(Type *Ty)
This turns an inalloca type into the form used internally in Attribute.
LLVM_ABI AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
LLVM_ABI Type * getTypeAttr(Attribute::AttrKind Kind) const
Retrieve type for the given type attribute.
LLVM_ABI AttrBuilder & remove(const AttributeMask &AM)
Remove the attributes from the builder.
LLVM_ABI AttrBuilder & addFromEquivalentMetadata(const Instruction &I)
Add 0 or more parameter attributes which are equivalent to metadata attached to I.
LLVM_ABI std::optional< ConstantRange > getRange() const
Retrieve the range if the attribute exists (std::nullopt is returned otherwise).
LLVM_ABI AttrBuilder & addDereferenceableOrNullAttr(uint64_t Bytes)
This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute.
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:1225
LLVM_ABI AttrBuilder & addTypeAttr(Attribute::AttrKind Kind, Type *Ty)
Add a type attribute with the given type.
LLVM_ABI std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
Retrieve the allocsize args, or std::nullopt if the attribute does not exist.
LLVM_ABI AttrBuilder & addAllocSizeAttr(unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
This turns one (or two) ints into the form used internally in Attribute.
bool operator!=(const AttrBuilder &B) const
Definition: Attributes.h:1323
Type * getStructRetType() const
Retrieve the sret type.
Definition: Attributes.h:1196
LLVM_ABI AttrBuilder & addRangeAttr(const ConstantRange &CR)
Add range attribute.
AttrBuilder(LLVMContext &Ctx, const Attribute &A)
Definition: Attributes.h:1091
LLVM_ABI AttrBuilder & addUWTableAttr(UWTableKind Kind)
This turns the unwind table kind into the form used internally in Attribute.
Attribute getFnAttr(StringRef Kind) const
Return the attribute object that exists for the function.
Definition: Attributes.h:914
bool operator==(const AttributeList &RHS) const
operator==/!= - Provide equality predicates.
Definition: Attributes.h:1034
LLVM_ABI bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
LLVM_ABI Type * getParamStructRetType(unsigned ArgNo) const
Return the sret type for the specified function parameter.
LLVM_ABI AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
LLVM_ABI AttributeList removeAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo) const
Remove all attributes at the specified arg index from this attribute list.
Definition: Attributes.h:771
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:764
LLVM_ABI AttributeList addRangeRetAttr(LLVMContext &C, const ConstantRange &CR) const
Add the range attribute to the attribute set at the return value index.
LLVM_ABI bool hasAttributesAtIndex(unsigned Index) const
Return true if attribute exists at the given index.
AttributeList removeRetAttribute(LLVMContext &C, StringRef Kind) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:733
bool hasRetAttr(StringRef Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:869
LLVM_ABI AttributeSet getFnAttrs() const
The function attributes are returned.
index_iterator indexes() const
Use this to iterate over the valid attribute indexes.
Definition: Attributes.h:1031
LLVM_ABI AttributeList removeAttributesAtIndex(LLVMContext &C, unsigned Index, const AttributeMask &AttrsToRemove) const
Remove the specified attributes at the specified index from this attribute list.
AttributeList()=default
AttributeList addRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a return value attribute to the list.
Definition: Attributes.h:626
LLVM_ABI iterator begin() const
bool hasParamAttrs(unsigned ArgNo) const
Return true if attributes exists for the given argument.
Definition: Attributes.h:859
LLVM_ABI MaybeAlign getRetStackAlignment() const
Get the stack alignment of the return value.
AttributeList addRetAttributes(LLVMContext &C, const AttrBuilder &B) const
Add a return value attribute to the list.
Definition: Attributes.h:640
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI AttributeList addDereferenceableRetAttr(LLVMContext &C, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
AttributeList removeRetAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:741
static LLVM_ABI AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute > > Attrs)
Create an AttributeList with the specified parameters in it.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
Definition: Attributes.h:899
AttributeList removeAttribute(LLVMContext &C, unsigned Index, StringRef Kind) const
Definition: Attributes.h:682
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute list.
Definition: Attributes.h:1038
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:757
LLVM_ABI AllocFnKind getAllocKind() const
bool isEmpty() const
Return true if there are no attributes.
Definition: Attributes.h:1043
AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
Definition: Attributes.h:597
LLVM_ABI AttributeSet getRetAttrs() const
The attributes for the ret value are returned.
AttributeList addFnAttributes(LLVMContext &C, const AttrBuilder &B) const
Add function attribute to the list.
Definition: Attributes.h:619
LLVM_ABI bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
LLVM_ABI uint64_t getParamDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
LLVM_ABI MaybeAlign getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
bool hasParamAttr(unsigned ArgNo, StringRef Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:854
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind, StringRef Value=StringRef()) const
Add an argument attribute to the list.
Definition: Attributes.h:656
LLVM_ABI 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.
LLVM_ABI iterator end() const
LLVM_ABI Type * getParamInAllocaType(unsigned ArgNo) const
Return the inalloca type for the specified function parameter.
LLVM_ABI unsigned getNumAttrSets() const
bool operator!=(const AttributeList &RHS) const
Definition: Attributes.h:1035
LLVM_ABI FPClassTest getRetNoFPClass() const
Get the disallowed floating-point classes of the return value.
Attribute getFnAttr(Attribute::AttrKind Kind) const
Return the attribute object that exists for the function.
Definition: Attributes.h:909
LLVM_ABI std::string getAsString(unsigned Index, bool InAttrGrp=false) const
Return the attributes at the index as a string.
LLVM_ABI UWTableKind getUWTableKind() const
Get the unwind table kind requested for the function.
LLVM_ABI MaybeAlign getRetAlignment() const
Return the alignment of the return value.
LLVM_ABI Type * getParamElementType(unsigned ArgNo) const
Return the elementtype type for the specified function parameter.
LLVM_ABI Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
LLVM_ABI Type * getParamPreallocatedType(unsigned ArgNo) const
Return the preallocated type for the specified function parameter.
LLVM_ABI bool hasParentContext(LLVMContext &C) const
Return true if this attribute list belongs to the LLVMContext.
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:749
AttributeList addFnAttribute(LLVMContext &C, StringRef Kind, StringRef Value=StringRef()) const
Add a function attribute to the list.
Definition: Attributes.h:612
bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:849
LLVM_ABI MaybeAlign getFnStackAlignment() const
Get the stack alignment of the function.
LLVM_ABI AttributeList addAttributesAtIndex(LLVMContext &C, unsigned Index, const AttrBuilder &B) const
Add attributes to the attribute set at the given index.
LLVM_ABI Type * getParamByValType(unsigned ArgNo) const
Return the byval type for the specified function parameter.
AttributeList removeFnAttributes(LLVMContext &C) const
Remove the attributes at the function index from this attribute list.
Definition: Attributes.h:720
Attribute getRetAttr(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind for the return value.
Definition: Attributes.h:919
LLVM_ABI MaybeAlign getParamStackAlignment(unsigned ArgNo) const
Return the stack alignment for the specified function parameter.
LLVM_ABI uint64_t getRetDereferenceableBytes() const
Get the number of dereferenceable bytes (or zero if unknown) of the return value.
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const
Return the attribute object that exists at the given index.
Definition: Attributes.h:904
LLVM_ABI AttributeList addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg) const
Add the allocsize attribute to the attribute set at the given arg index.
AttributeList removeFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:700
LLVM_ABI uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
bool hasRetAttrs() const
Return true if attributes exist for the return value.
Definition: Attributes.h:874
LLVM_ABI 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.
LLVM_ABI AttributeSet getAttributes(unsigned Index) const
The attributes for the specified index are returned.
AttributeList addRetAttribute(LLVMContext &C, Attribute Attr) const
Add a return value attribute to the list.
Definition: Attributes.h:633
LLVM_ABI FPClassTest getParamNoFPClass(unsigned ArgNo) const
Get the disallowed floating-point classes of the argument value.
AttributeList removeFnAttribute(LLVMContext &C, StringRef Kind) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:706
AttributeList removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:714
LLVM_ABI std::optional< AttributeList > intersectWith(LLVMContext &C, AttributeList Other) const
Try to intersect this AttributeList with Other.
bool hasFnAttrs() const
Return true the attributes exist for the function.
Definition: Attributes.h:883
LLVM_ABI Type * getParamByRefType(unsigned ArgNo) const
Return the byref type for the specified function parameter.
LLVM_ABI AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
LLVM_ABI AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
Definition: Attributes.h:668
LLVM_ABI std::optional< ConstantRange > getParamRange(unsigned ArgNo) const
Get range (or std::nullopt if unknown) of an arg.
LLVM_ABI uint64_t getRetDereferenceableOrNullBytes() const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of the return value.
LLVM_ABI void dump() const
AttributeList removeRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:727
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
Definition: Attributes.h:648
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:779
AttributeList addFnAttribute(LLVMContext &C, Attribute Attr) const
Add a function attribute to the list.
Definition: Attributes.h:604
LLVM_ABI MemoryEffects getMemoryEffects() const
Returns memory effects of the function.
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:864
LLVM_ABI AllocFnKind getAllocKind() const
bool hasAttributes() const
Return true if attributes exists in this set.
Definition: Attributes.h:431
LLVM_ABI AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
Definition: Attributes.cpp:970
LLVM_ABI Type * getInAllocaType() const
LLVM_ABI Type * getByValType() const
bool operator!=(const AttributeSet &O) const
Definition: Attributes.h:385
LLVM_ABI AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
Definition: Attributes.cpp:944
LLVM_ABI MemoryEffects getMemoryEffects() const
LLVM_ABI bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
bool operator==(const AttributeSet &O) const
Definition: Attributes.h:384
LLVM_ABI std::optional< AttributeSet > intersectWith(LLVMContext &C, AttributeSet Other) const
Try to intersect this AttributeSet with Other.
Definition: Attributes.cpp:998
LLVM_ABI Type * getStructRetType() const
LLVM_ABI std::string getAsString(bool InAttrGrp=false) const
~AttributeSet()=default
LLVM_ABI unsigned getVScaleRangeMin() const
LLVM_ABI std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
LLVM_ABI UWTableKind getUWTableKind() const
LLVM_ABI bool hasParentContext(LLVMContext &C) const
Return true if this attribute set belongs to the LLVMContext.
LLVM_ABI iterator begin() const
LLVM_ABI iterator end() const
LLVM_ABI AttributeSet removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attributes from this set.
Definition: Attributes.cpp:986
LLVM_ABI std::optional< unsigned > getVScaleRangeMax() const
LLVM_ABI MaybeAlign getStackAlignment() const
LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
LLVM_ABI Type * getPreallocatedType() const
LLVM_ABI uint64_t getDereferenceableBytes() const
LLVM_ABI MaybeAlign getAlignment() const
LLVM_ABI FPClassTest getNoFPClass() const
AttributeSet(const AttributeSet &)=default
LLVM_ABI Type * getElementType() const
LLVM_ABI Type * getByRefType() const
LLVM_ABI CaptureInfo getCaptureInfo() const
AttributeSet()=default
AttributeSet is a trivially copyable value type.
static LLVM_ABI AttributeSet get(LLVMContext &C, const AttrBuilder &B)
Definition: Attributes.cpp:921
LLVM_ABI uint64_t getDereferenceableOrNullBytes() const
LLVM_ABI unsigned getNumAttributes() const
Return the number of attributes in this set.
LLVM_ABI AttributeSet addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add an argument attribute.
Definition: Attributes.cpp:929
void dump() const
static const unsigned NumTypeAttrKinds
Definition: Attributes.h:99
LLVM_ABI bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
Definition: Attributes.cpp:356
static LLVM_ABI Attribute getWithStructRetType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:260
bool operator==(Attribute A) const
Equality and non-equality operators.
Definition: Attributes.h:323
static LLVM_ABI Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
Definition: Attributes.cpp:313
LLVM_ABI bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
Definition: Attributes.cpp:348
static LLVM_ABI Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment)
Definition: Attributes.cpp:239
LLVM_ABI const ConstantRange & getRange() const
Returns the value of the range attribute.
Definition: Attributes.cpp:510
static LLVM_ABI bool intersectWithCustom(AttrKind Kind)
Definition: Attributes.cpp:817
LLVM_ABI bool isIntAttribute() const
Return true if the attribute is an integer attribute.
Definition: Attributes.cpp:352
static LLVM_ABI Attribute getWithByRefType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:264
LLVM_ABI std::optional< unsigned > getVScaleRangeMax() const
Returns the maximum value for the vscale_range attribute or std::nullopt when unknown.
Definition: Attributes.cpp:474
LLVM_ABI uint64_t getValueAsInt() const
Return the attribute's value as an integer.
Definition: Attributes.cpp:379
LLVM_ABI unsigned getVScaleRangeMin() const
Returns the minimum value for the vscale_range attribute.
Definition: Attributes.cpp:468
LLVM_ABI AllocFnKind getAllocKind() const
Definition: Attributes.cpp:486
LLVM_ABI bool isConstantRangeAttribute() const
Return true if the attribute is a ConstantRange attribute.
Definition: Attributes.cpp:364
static LLVM_ABI Attribute getWithAllocKind(LLVMContext &Context, AllocFnKind Kind)
Definition: Attributes.cpp:303
LLVM_ABI StringRef getKindAsString() const
Return the attribute's kind as a string.
Definition: Attributes.cpp:393
static LLVM_ABI Attribute getWithPreallocatedType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:268
static LLVM_ABI bool intersectWithMin(AttrKind Kind)
Definition: Attributes.cpp:814
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Definition: Attributes.cpp:95
static LLVM_ABI bool canUseAsRetAttr(AttrKind Kind)
Definition: Attributes.cpp:793
static bool isTypeAttrKind(AttrKind Kind)
Definition: Attributes.h:107
LLVM_ABI std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
Definition: Attributes.cpp:536
LLVM_ABI uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute.
Definition: Attributes.cpp:454
static LLVM_ABI Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
Definition: Attributes.cpp:244
LLVM_ABI std::pair< unsigned, std::optional< unsigned > > getAllocSizeArgs() const
Returns the argument numbers for the allocsize attribute.
Definition: Attributes.cpp:462
static LLVM_ABI Attribute getWithUWTableKind(LLVMContext &Context, UWTableKind Kind)
Definition: Attributes.cpp:276
bool operator!=(Attribute A) const
Definition: Attributes.h:324
LLVM_ABI FPClassTest getNoFPClass() const
Return the FPClassTest for nofpclass.
Definition: Attributes.cpp:504
static LLVM_ABI Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
Definition: Attributes.cpp:296
LLVM_ABI Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
Definition: Attributes.cpp:372
Attribute()=default
LLVM_ABI bool getValueAsBool() const
Return the attribute's value as a boolean.
Definition: Attributes.cpp:386
LLVM_ABI ArrayRef< ConstantRange > getInitializes() const
Returns the value of the initializes attribute.
Definition: Attributes.cpp:516
LLVM_ABI const ConstantRange & getValueAsConstantRange() const
Return the attribute's value as a ConstantRange.
Definition: Attributes.cpp:414
LLVM_ABI uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
Definition: Attributes.cpp:447
static LLVM_ABI Attribute getWithVScaleRangeArgs(LLVMContext &Context, unsigned MinValue, unsigned MaxValue)
Definition: Attributes.cpp:307
LLVM_ABI MemoryEffects getMemoryEffects() const
Returns memory effects.
Definition: Attributes.cpp:492
LLVM_ABI UWTableKind getUWTableKind() const
Definition: Attributes.cpp:480
static LLVM_ABI Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
Definition: Attributes.cpp:250
LLVM_ABI ArrayRef< ConstantRange > getValueAsConstantRangeList() const
Return the attribute's value as a ConstantRange array.
Definition: Attributes.cpp:420
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:400
static LLVM_ABI bool isExistingAttribute(StringRef Name)
Return true if the provided string matches the IR name of an attribute.
Definition: Attributes.cpp:336
bool hasKindAsEnum() const
Returns true if the attribute's kind can be represented as an enum (Enum, Integer,...
Definition: Attributes.h:233
static LLVM_ABI StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind)
Definition: Attributes.cpp:322
static LLVM_ABI bool canUseAsFnAttr(AttrKind Kind)
Definition: Attributes.cpp:785
static LLVM_ABI bool intersectWithAnd(AttrKind Kind)
Definition: Attributes.cpp:811
static LLVM_ABI Attribute getWithNoFPClass(LLVMContext &Context, FPClassTest Mask)
Definition: Attributes.cpp:286
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:88
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
Definition: Attributes.h:95
@ None
No attributes have been set.
Definition: Attributes.h:90
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
Definition: Attributes.h:94
@ EndAttrKinds
Sentinel value useful for loops.
Definition: Attributes.h:93
static bool isConstantRangeAttrKind(AttrKind Kind)
Definition: Attributes.h:110
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute.
Definition: Attributes.h:335
LLVM_ABI bool hasParentContext(LLVMContext &C) const
Return true if this attribute belongs to the LLVMContext.
Definition: Attributes.cpp:731
LLVM_ABI bool isTypeAttribute() const
Return true if the attribute is a type attribute.
Definition: Attributes.cpp:360
static LLVM_ABI Attribute getWithCaptureInfo(LLVMContext &Context, CaptureInfo CI)
Definition: Attributes.cpp:291
static LLVM_ABI Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:272
static bool isIntAttrKind(AttrKind Kind)
Definition: Attributes.h:104
static bool isConstantRangeListAttrKind(AttrKind Kind)
Definition: Attributes.h:113
LLVM_ABI bool isConstantRangeListAttribute() const
Return true if the attribute is a ConstantRangeList attribute.
Definition: Attributes.cpp:368
static LLVM_ABI Attribute getWithByValType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:256
Attribute getWithNewType(LLVMContext &Context, Type *ReplacementTy)
For a typed attribute, return the equivalent attribute with the type changed to ReplacementTy.
Definition: Attributes.h:186
LLVM_ABI bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
Definition: Attributes.cpp:426
static bool isEnumAttrKind(AttrKind Kind)
Definition: Attributes.h:101
static LLVM_ABI Attribute getWithMemoryEffects(LLVMContext &Context, MemoryEffects ME)
Definition: Attributes.cpp:281
static LLVM_ABI bool canUseAsParamAttr(AttrKind Kind)
Definition: Attributes.cpp:789
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition: Attributes.h:223
LLVM_ABI MaybeAlign getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
Definition: Attributes.cpp:441
static Attribute fromRawPointer(void *RawPtr)
Get an attribute from a raw pointer created by getRawPointer.
Definition: Attributes.h:340
static const unsigned NumIntAttrKinds
Definition: Attributes.h:98
LLVM_ABI MaybeAlign getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
Definition: Attributes.cpp:435
LLVM_ABI CaptureInfo getCaptureInfo() const
Returns information from captures attribute.
Definition: Attributes.cpp:498
static LLVM_ABI bool intersectMustPreserve(AttrKind Kind)
Definition: Attributes.cpp:808
LLVM_ABI int cmpKind(Attribute A) const
Used to sort attribute by kind.
Definition: Attributes.cpp:739
LLVM_ABI bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
Definition: Attributes.cpp:749
static LLVM_ABI Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
Definition: Attributes.cpp:234
LLVM_ABI Type * getValueAsType() const
Return the attribute's value as a Type.
Definition: Attributes.cpp:407
Represents which components of the pointer may be captured in which location.
Definition: ModRef.h:354
This class represents a list of constant ranges.
This class represents a range of values.
Definition: ConstantRange.h:47
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition: FoldingSet.h:330
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
struct LLVMOpaqueAttributeRef * LLVMAttributeRef
Used to represent an attributes.
Definition: Types.h:145
LLVM_ABI bool areInlineCompatible(const Function &Caller, const Function &Callee)
LLVM_ABI AttributeMask getUBImplyingAttributes()
Get param/return attributes which imply immediate undefined behavior if an invalid value is passed.
LLVM_ABI bool isNoFPClassCompatibleType(Type *Ty)
Returns true if this is a type legal for the 'nofpclass' attribute.
LLVM_ABI bool areOutlineCompatible(const Function &A, const Function &B)
Checks if there are any incompatible function attributes between A and B.
LLVM_ABI void updateMinLegalVectorWidthAttr(Function &Fn, uint64_t Width)
Update min-legal-vector-width if it is in Attribute and less than Width.
LLVM_ABI void mergeAttributesForOutlining(Function &Base, const Function &ToMerge)
Merges the functions attributes from ToMerge into function Base.
LLVM_ABI AttributeMask typeIncompatible(Type *Ty, AttributeSet AS, AttributeSafetyKind ASK=ASK_ALL)
Which attributes cannot be applied to a type.
LLVM_ABI void mergeAttributesForInlining(Function &Caller, const Function &Callee)
Merge caller's and callee's attributes.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Uninitialized
Definition: Threading.h:60
AllocFnKind
Definition: Attributes.h:51
UWTableKind
Definition: CodeGen.h:148
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
@ Other
Any other memory.
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:351
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:346
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
bool operator!=(const int_wrapper &Other)
Definition: Attributes.h:1016
static unsigned getHashValue(AttributeList AS)
Definition: Attributes.h:1066
static AttributeList getTombstoneKey()
Definition: Attributes.h:1060
static bool isEqual(AttributeList LHS, AttributeList RHS)
Definition: Attributes.h:1071
static AttributeSet getTombstoneKey()
Definition: Attributes.h:488
static bool isEqual(AttributeSet LHS, AttributeSet RHS)
Definition: Attributes.h:499
static unsigned getHashValue(AttributeSet AS)
Definition: Attributes.h:494
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: DenseMapInfo.h:54
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117