16 #ifndef LLVM_LIB_IR_ATTRIBUTEIMPL_H
17 #define LLVM_LIB_IR_ATTRIBUTEIMPL_H
103 virtual void anchor();
118 void anchor()
override;
124 assert((Kind == Attribute::Alignment || Kind == Attribute::StackAlignment ||
125 Kind == Attribute::Dereferenceable ||
126 Kind == Attribute::DereferenceableOrNull ||
127 Kind == Attribute::AllocSize) &&
128 "Wrong kind for int attribute!");
135 virtual void anchor();
163 uint64_t AvailableFunctionAttrs;
166 size_t numTrailingObjects(OverloadToken<IndexAttrPair>) {
return NumSlots; }
170 return getTrailingObjects<IndexAttrPair>() + Slot;
175 ArrayRef<std::pair<unsigned, AttributeSetNode *>> Slots)
176 :
Context(C), NumSlots(Slots.size()), AvailableFunctionAttrs(0) {
178 sizeof(AvailableFunctionAttrs) * CHAR_BIT,
179 "Too many attributes");
182 if (Slots.size() >= 2) {
183 for (
const std::pair<unsigned, AttributeSetNode *> *
i = Slots.begin() + 1,
186 assert((
i-1)->first <= i->first &&
"Attribute set not ordered!");
191 std::copy(Slots.begin(), Slots.end(), getTrailingObjects<IndexAttrPair>());
196 "FunctionIndex should be biggest possible index");
197 const std::pair<unsigned, AttributeSetNode *> &Last = Slots.back();
201 if (!
I.isStringAttribute())
202 AvailableFunctionAttrs |= ((uint64_t)1) <<
I.getKindAsEnum();
212 void operator delete(
void *p) { ::operator
delete(p); }
227 return getNode(Slot)->first;
234 return AttributeSet::get(
Context, *getNode(Slot));
240 return getNode(Slot)->second;
246 return AvailableFunctionAttrs & ((uint64_t)1) <<
Kind;
257 ArrayRef<std::pair<unsigned, AttributeSetNode*>> Nodes) {
258 for (
const auto &
Node : Nodes) {
269 #endif // LLVM_LIB_IR_ATTRIBUTEIMPL_H
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
AttributeSet getSlotAttributes(unsigned Slot) const
Retrieve the attributes for the given "slot" in the AttrNode list.
StringRef getStringValue() const
StringAttributeImpl(StringRef Kind, StringRef Val=StringRef())
void Profile(FoldingSetNodeID &ID) const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
static void Profile(FoldingSetNodeID &ID, ArrayRef< std::pair< unsigned, AttributeSetNode * >> Nodes)
This file contains the simple types necessary to represent the attributes associated with functions a...
Attribute::AttrKind getKindAsEnum() const
void AddInteger(signed I)
EnumAttributeImpl(AttrEntryKind ID, Attribute::AttrKind Kind)
bool operator<(const AttributeImpl &AI) const
Used when sorting the attributes.
EnumAttributeImpl(Attribute::AttrKind Kind)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
iterator end(unsigned Slot) const
AttributeSetNode::iterator iterator
AttributeSetImpl & operator=(const AttributeSetImpl &)=delete
StringRef getKindAsString() const
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
StringRef getStringKind() const
AttributeSetImpl(LLVMContext &C, ArrayRef< std::pair< unsigned, AttributeSetNode * >> Slots)
iterator begin(unsigned Slot) const
This is an important class for using LLVM in a threaded context.
bool isStringAttribute() const
IntAttributeImpl(Attribute::AttrKind Kind, uint64_t Val)
unsigned getSlotIndex(unsigned Slot) const
Get the index of the given "slot" in the AttrNodes list.
See the file comment for details on the usage of the TrailingObjects type.
Sentinal value useful for loops.
StringRef getValueAsString() const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the AttributeSetNode for the FunctionIndex has an enum attribute of the given kind...
bool isIntAttribute() const
bool hasAttribute(Attribute::AttrKind A) const
uint64_t getValueAsInt() const
Attribute::AttrKind getEnumKind() const
AttributeSetNode * getSlotNode(unsigned Slot) const
Retrieve the attribute set node for the given "slot" in the AttrNode list.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Node - This class is used to maintain the singly linked bucket list in a folding set.
LLVMContext & getContext()
Get the context that created this AttributeSetImpl.
uint64_t getValue() const
AttributeImpl(AttrEntryKind KindID)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
static void Profile(FoldingSetNodeID &ID, Attribute::AttrKind Kind, uint64_t Val)
bool isEnumAttribute() const
void AddString(StringRef String)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void Profile(FoldingSetNodeID &ID) const
This header defines support for implementing classes that have some trailing object (or arrays of obj...
StringRef - Represent a constant reference to a string, i.e.
unsigned getNumSlots() const
Return the number of slots used in this attribute list.
This file defines the node class used internally by AttributeSet.
std::pair< unsigned, AttributeSetNode * > IndexAttrPair
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
static void Profile(FoldingSetNodeID &ID, StringRef Kind, StringRef Values)
AttributeImpl & operator=(const AttributeImpl &)=delete
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...