diff options
author | Reid Kleckner <rnk@google.com> | 2017-04-11 00:16:00 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-04-11 00:16:00 +0000 |
commit | a82be60da2ad251d5590c05a22fb8a4209bd9c2f (patch) | |
tree | 1fbf9eea4a0ff27b49e7f5e9812f8818a9023cf4 | |
parent | b3e30c32ce6ac2cc73192df19dfe712e5be0364d (diff) | |
download | bcm5719-llvm-a82be60da2ad251d5590c05a22fb8a4209bd9c2f.tar.gz bcm5719-llvm-a82be60da2ad251d5590c05a22fb8a4209bd9c2f.zip |
[IR] Sink some AttributeListImpl methods out of headers NFC
llvm-svn: 299906
-rw-r--r-- | llvm/lib/IR/AttributeImpl.h | 44 | ||||
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 46 |
2 files changed, 49 insertions, 41 deletions
diff --git a/llvm/lib/IR/AttributeImpl.h b/llvm/lib/IR/AttributeImpl.h index 77f1067c7ac..0cd53f1de00 100644 --- a/llvm/lib/IR/AttributeImpl.h +++ b/llvm/lib/IR/AttributeImpl.h @@ -172,38 +172,7 @@ private: public: AttributeListImpl(LLVMContext &C, - ArrayRef<std::pair<unsigned, AttributeSetNode *>> Slots) - : Context(C), NumSlots(Slots.size()), AvailableFunctionAttrs(0) { - static_assert(Attribute::EndAttrKinds <= - sizeof(AvailableFunctionAttrs) * CHAR_BIT, - "Too many attributes"); - -#ifndef NDEBUG - if (Slots.size() >= 2) { - for (const std::pair<unsigned, AttributeSetNode *> *i = Slots.begin() + 1, - *e = Slots.end(); - i != e; ++i) { - assert((i-1)->first <= i->first && "Attribute set not ordered!"); - } - } -#endif - // There's memory after the node where we can store the entries in. - std::copy(Slots.begin(), Slots.end(), getTrailingObjects<IndexAttrPair>()); - - // Initialize AvailableFunctionAttrs summary bitset. - if (NumSlots > 0) { - static_assert(AttributeList::FunctionIndex == ~0u, - "FunctionIndex should be biggest possible index"); - const std::pair<unsigned, AttributeSetNode *> &Last = Slots.back(); - if (Last.first == AttributeList::FunctionIndex) { - const AttributeSetNode *Node = Last.second; - for (Attribute I : *Node) { - if (!I.isStringAttribute()) - AvailableFunctionAttrs |= ((uint64_t)1) << I.getKindAsEnum(); - } - } - } - } + ArrayRef<std::pair<unsigned, AttributeSetNode *>> Slots); // AttributesSetImpt is uniqued, these should not be available. AttributeListImpl(const AttributeListImpl &) = delete; @@ -250,16 +219,9 @@ public: iterator begin(unsigned Slot) const { return getSlotNode(Slot)->begin(); } iterator end(unsigned Slot) const { return getSlotNode(Slot)->end(); } - void Profile(FoldingSetNodeID &ID) const { - Profile(ID, makeArrayRef(getNode(0), getNumSlots())); - } + void Profile(FoldingSetNodeID &ID) const; static void Profile(FoldingSetNodeID &ID, - ArrayRef<std::pair<unsigned, AttributeSetNode*>> Nodes) { - for (const auto &Node : Nodes) { - ID.AddInteger(Node.first); - ID.AddPointer(Node.second); - } - } + ArrayRef<std::pair<unsigned, AttributeSetNode*>> Nodes); void dump() const; }; diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 158a02337ad..7077da14a18 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -656,6 +656,52 @@ std::string AttributeSetNode::getAsString(bool InAttrGrp) const { // AttributeListImpl Definition //===----------------------------------------------------------------------===// +AttributeListImpl::AttributeListImpl( + LLVMContext &C, ArrayRef<std::pair<unsigned, AttributeSetNode *>> Slots) + : Context(C), NumSlots(Slots.size()), AvailableFunctionAttrs(0) { +#ifndef NDEBUG + if (Slots.size() >= 2) { + auto &PrevPair = Slots.front(); + for (auto &CurPair : Slots.drop_front()) { + assert(PrevPair.first <= CurPair.first && "Attribute set not ordered!"); + } + } +#endif + + // There's memory after the node where we can store the entries in. + std::copy(Slots.begin(), Slots.end(), getTrailingObjects<IndexAttrPair>()); + + // Initialize AvailableFunctionAttrs summary bitset. + if (NumSlots > 0) { + static_assert(Attribute::EndAttrKinds <= + sizeof(AvailableFunctionAttrs) * CHAR_BIT, + "Too many attributes"); + static_assert(AttributeList::FunctionIndex == ~0u, + "FunctionIndex should be biggest possible index"); + const std::pair<unsigned, AttributeSetNode *> &Last = Slots.back(); + if (Last.first == AttributeList::FunctionIndex) { + const AttributeSetNode *Node = Last.second; + for (Attribute I : *Node) { + if (!I.isStringAttribute()) + AvailableFunctionAttrs |= ((uint64_t)1) << I.getKindAsEnum(); + } + } + } +} + +void AttributeListImpl::Profile(FoldingSetNodeID &ID) const { + Profile(ID, makeArrayRef(getNode(0), getNumSlots())); +} + +void AttributeListImpl::Profile( + FoldingSetNodeID &ID, + ArrayRef<std::pair<unsigned, AttributeSetNode *>> Nodes) { + for (const auto &Node : Nodes) { + ID.AddInteger(Node.first); + ID.AddPointer(Node.second); + } +} + #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void AttributeListImpl::dump() const { AttributeList(const_cast<AttributeListImpl *>(this)).dump(); |