In the AttributeSetImpl c'tor, fill in the AttrNodes data structure with the attribut...
authorBill Wendling <isanbard@gmail.com>
Sun, 27 Jan 2013 12:50:02 +0000 (12:50 +0000)
committerBill Wendling <isanbard@gmail.com>
Sun, 27 Jan 2013 12:50:02 +0000 (12:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173618 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/AttributeImpl.h
lib/IR/Attributes.cpp

index d7ebec5daaa691aa2f3c67ec021cc4065499c2ca..b4c788fa9d4a910d88978ee78887e4c51371409e 100644 (file)
@@ -115,11 +115,9 @@ class AttributeSetImpl : public FoldingSetNode {
   void operator=(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
   AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
 public:
-  AttributeSetImpl(LLVMContext &C, ArrayRef<AttributeWithIndex> attrs)
-    : Context(C), AttrList(attrs.begin(), attrs.end()) {}
+  AttributeSetImpl(LLVMContext &C, ArrayRef<AttributeWithIndex> attrs);
   AttributeSetImpl(LLVMContext &C,
-                   ArrayRef<std::pair<uint64_t, AttributeSetNode*> > attrs)
-    : Context(C), AttrNodes(attrs.begin(), attrs.end()) {}
+                   ArrayRef<std::pair<uint64_t, AttributeSetNode*> > attrs);
 
   LLVMContext &getContext() { return Context; }
   ArrayRef<AttributeWithIndex> getAttributes() const { return AttrList; }
index 8ec192b813c7d00b40493422281e289483ad014f..780da00ac01689b3d68b8e527eac90859aced8c2 100644 (file)
@@ -525,6 +525,46 @@ AttributeSetNode *AttributeSetNode::get(LLVMContext &C,
 // AttributeSetImpl Definition
 //===----------------------------------------------------------------------===//
 
+AttributeSetImpl::
+AttributeSetImpl(LLVMContext &C,
+                 ArrayRef<AttributeWithIndex> attrs)
+  : Context(C), AttrList(attrs.begin(), attrs.end()) {
+  for (unsigned I = 0, E = attrs.size(); I != E; ++I) {
+    const AttributeWithIndex &AWI = attrs[I];
+    uint64_t Mask = AWI.Attrs.Raw();
+    SmallVector<Attribute, 8> Attrs;
+
+    for (Attribute::AttrKind II = Attribute::None;
+         II != Attribute::EndAttrKinds; II = Attribute::AttrKind(II + 1)) {
+      if (uint64_t A = (Mask & AttributeImpl::getAttrMask(II))) {
+        AttrBuilder B;
+
+        if (II == Attribute::Alignment)
+          B.addAlignmentAttr(1ULL << ((A >> 16) - 1));
+        else if (II == Attribute::StackAlignment)
+          B.addStackAlignmentAttr(1ULL << ((A >> 26) - 1));
+        else
+          B.addAttribute(II);
+
+        Attrs.push_back(Attribute::get(C, B));
+      }
+    }
+
+    AttrNodes.push_back(std::make_pair(AWI.Index,
+                                       AttributeSetNode::get(C, Attrs)));
+  }
+}
+
+AttributeSetImpl::
+AttributeSetImpl(LLVMContext &C,
+                 ArrayRef<std::pair<uint64_t, AttributeSetNode*> > attrs)
+  : Context(C), AttrNodes(attrs.begin(), attrs.end()) {
+}
+
+//===----------------------------------------------------------------------===//
+// AttributeSet Method Implementations
+//===----------------------------------------------------------------------===//
+
 AttributeSet AttributeSet::getParamAttributes(unsigned Idx) const {
   // FIXME: Remove.
   return AttrList && hasAttributes(Idx) ?
@@ -616,10 +656,6 @@ AttributeSet AttributeSet::get(LLVMContext &C, ArrayRef<AttributeSet> Attrs) {
   return get(C, AttrList);
 }
 
-//===----------------------------------------------------------------------===//
-// AttributeSet Method Implementations
-//===----------------------------------------------------------------------===//
-
 const AttributeSet &AttributeSet::operator=(const AttributeSet &RHS) {
   AttrList = RHS.AttrList;
   return *this;