diff options
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/IR/AttributeSetNode.h | 109 | ||||
| -rw-r--r-- | llvm/include/llvm/IR/Attributes.h | 36 |
2 files changed, 7 insertions, 138 deletions
diff --git a/llvm/include/llvm/IR/AttributeSetNode.h b/llvm/include/llvm/IR/AttributeSetNode.h deleted file mode 100644 index 8a5bb3f475c..00000000000 --- a/llvm/include/llvm/IR/AttributeSetNode.h +++ /dev/null @@ -1,109 +0,0 @@ -//===-- AttributeSetNode.h - AttributeList Internal Node --------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -/// -/// \file -/// \brief This file defines the class that represents a group of attributes -/// that apply to one element: function, return type, or parameter. -/// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_IR_ATTRIBUTESETNODE_H -#define LLVM_IR_ATTRIBUTESETNODE_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/FoldingSet.h" -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/IR/Attributes.h" -#include "llvm/Support/TrailingObjects.h" -#include <algorithm> -#include <climits> -#include <cstdint> -#include <string> -#include <utility> - -namespace llvm { - -//===----------------------------------------------------------------------===// -/// \class -/// \brief This class represents a group of attributes that apply to one -/// element: function, return type, or parameter. -class AttributeSetNode final - : public FoldingSetNode, - private TrailingObjects<AttributeSetNode, Attribute> { - friend TrailingObjects; - - unsigned NumAttrs; ///< Number of attributes in this node. - /// Bitset with a bit for each available attribute Attribute::AttrKind. - uint64_t AvailableAttrs; - - AttributeSetNode(ArrayRef<Attribute> Attrs) - : NumAttrs(Attrs.size()), AvailableAttrs(0) { - static_assert(Attribute::EndAttrKinds <= sizeof(AvailableAttrs) * CHAR_BIT, - "Too many attributes for AvailableAttrs"); - // There's memory after the node where we can store the entries in. - std::copy(Attrs.begin(), Attrs.end(), getTrailingObjects<Attribute>()); - - for (Attribute I : *this) { - if (!I.isStringAttribute()) { - AvailableAttrs |= ((uint64_t)1) << I.getKindAsEnum(); - } - } - } - -public: - // AttributesSetNode is uniqued, these should not be available. - AttributeSetNode(const AttributeSetNode &) = delete; - AttributeSetNode &operator=(const AttributeSetNode &) = delete; - - void operator delete(void *p) { ::operator delete(p); } - - static AttributeSetNode *get(LLVMContext &C, const AttrBuilder &B); - - static AttributeSetNode *get(LLVMContext &C, ArrayRef<Attribute> Attrs); - - static AttributeSetNode *get(AttributeList AS, unsigned Index) { - return AS.getAttributes(Index); - } - - /// \brief Return the number of attributes this AttributeList contains. - unsigned getNumAttributes() const { return NumAttrs; } - - bool hasAttribute(Attribute::AttrKind Kind) const { - return AvailableAttrs & ((uint64_t)1) << Kind; - } - bool hasAttribute(StringRef Kind) const; - bool hasAttributes() const { return NumAttrs != 0; } - - Attribute getAttribute(Attribute::AttrKind Kind) const; - Attribute getAttribute(StringRef Kind) const; - - unsigned getAlignment() const; - unsigned getStackAlignment() const; - uint64_t getDereferenceableBytes() const; - uint64_t getDereferenceableOrNullBytes() const; - std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const; - std::string getAsString(bool InAttrGrp) const; - - typedef const Attribute *iterator; - iterator begin() const { return getTrailingObjects<Attribute>(); } - iterator end() const { return begin() + NumAttrs; } - - void Profile(FoldingSetNodeID &ID) const { - Profile(ID, makeArrayRef(begin(), end())); - } - static void Profile(FoldingSetNodeID &ID, ArrayRef<Attribute> AttrList) { - for (const auto &Attr : AttrList) - Attr.Profile(ID); - } -}; - -} // end namespace llvm - -#endif // LLVM_IR_ATTRIBUTESETNODE_H diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h index 6cc856d61e2..dd2a94559bc 100644 --- a/llvm/include/llvm/IR/Attributes.h +++ b/llvm/include/llvm/IR/Attributes.h @@ -221,26 +221,19 @@ private: /// the empty attributes list. AttributeListImpl *pImpl = nullptr; -public: + /// \brief The attributes for the specified index are returned. + AttributeSetNode *getAttributes(unsigned Index) const; + /// \brief Create an AttributeList with the specified parameters in it. static AttributeList get(LLVMContext &C, ArrayRef<std::pair<unsigned, Attribute>> Attrs); static AttributeList get(LLVMContext &C, ArrayRef<std::pair<unsigned, AttributeSetNode *>> Attrs); - /// \brief Create an AttributeList from a vector of AttributeSetNodes. The - /// index of each set is implied by its position in the array \p Attrs: - /// 0 : Return attributes - /// 1 to n-1 : Argument attributes - /// n : Function attributes - /// Any element that has no entries should be left null. - static AttributeList get(LLVMContext &C, ArrayRef<AttributeSetNode *> Attrs); - static AttributeList getImpl(LLVMContext &C, ArrayRef<std::pair<unsigned, AttributeSetNode *>> Attrs); -private: explicit AttributeList(AttributeListImpl *LI) : pImpl(LI) {} public: @@ -279,12 +272,6 @@ public: AttributeList addAttributes(LLVMContext &C, unsigned Index, AttributeList Attrs) const; - AttributeList addAttributes(LLVMContext &C, unsigned Index, - AttributeSetNode *AS) const; - - AttributeList addAttributes(LLVMContext &C, unsigned Index, - const AttrBuilder &B) const; - /// \brief Remove the specified attribute at the specified index from this /// attribute list. Because attribute lists are immutable, this returns the /// new list. @@ -309,11 +296,6 @@ public: AttributeList removeAttributes(LLVMContext &C, unsigned Index, const AttrBuilder &Attrs) const; - /// \brief Remove all attributes at the specified index from this - /// attribute list. Because attribute lists are immutable, this returns the - /// new list. - AttributeList removeAttributes(LLVMContext &C, unsigned Index) const; - /// \brief Add the dereferenceable attribute to the attribute set at the given /// index. Because attribute sets are immutable, this returns a new set. AttributeList addDereferenceableAttr(LLVMContext &C, unsigned Index, @@ -339,16 +321,13 @@ public: LLVMContext &getContext() const; /// \brief The attributes for the specified index are returned. - AttributeSetNode *getAttributes(unsigned Index) const; - - /// \brief The attributes for the specified index are returned. - AttributeSetNode *getParamAttributes(unsigned Index) const; + AttributeList getParamAttributes(unsigned Index) const; /// \brief The attributes for the ret value are returned. - AttributeSetNode *getRetAttributes() const; + AttributeList getRetAttributes() const; /// \brief The function attributes are returned. - AttributeSetNode *getFnAttributes() const; + AttributeList getFnAttributes() const; /// \brief Return true if the attribute exists at the given index. bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const; @@ -483,7 +462,6 @@ public: addAttribute(A); } AttrBuilder(AttributeList AS, unsigned Idx); - AttrBuilder(AttributeSetNode *AS); void clear(); @@ -500,7 +478,7 @@ public: AttrBuilder &removeAttribute(Attribute::AttrKind Val); /// \brief Remove the attributes from the builder. - AttrBuilder &removeAttributes(AttributeList A, uint64_t WithoutIndex); + AttrBuilder &removeAttributes(AttributeList A, uint64_t Index); /// \brief Remove the target-dependent attribute to the builder. AttrBuilder &removeAttribute(StringRef A); |

