[llvm] r299906 - [IR] Sink some AttributeListImpl methods out of headers NFC
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 17:16:00 PDT 2017
Author: rnk
Date: Mon Apr 10 19:16:00 2017
New Revision: 299906
URL: http://llvm.org/viewvc/llvm-project?rev=299906&view=rev
Log:
[IR] Sink some AttributeListImpl methods out of headers NFC
Modified:
llvm/trunk/lib/IR/AttributeImpl.h
llvm/trunk/lib/IR/Attributes.cpp
Modified: llvm/trunk/lib/IR/AttributeImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AttributeImpl.h?rev=299906&r1=299905&r2=299906&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AttributeImpl.h (original)
+++ llvm/trunk/lib/IR/AttributeImpl.h Mon Apr 10 19:16:00 2017
@@ -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;
};
Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=299906&r1=299905&r2=299906&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Mon Apr 10 19:16:00 2017
@@ -656,6 +656,52 @@ std::string AttributeSetNode::getAsStrin
// 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();
More information about the llvm-commits
mailing list