[llvm-commits] [llvm] r173618 - In the AttributeSetImpl c'tor, fill in the AttrNodes data structure with the attributes being passed in.

Bill Wendling isanbard at gmail.com
Sun Jan 27 04:50:02 PST 2013


Author: void
Date: Sun Jan 27 06:50:02 2013
New Revision: 173618

URL: http://llvm.org/viewvc/llvm-project?rev=173618&view=rev
Log:
In the AttributeSetImpl c'tor, fill in the AttrNodes data structure with the attributes being passed in.

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=173618&r1=173617&r2=173618&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AttributeImpl.h (original)
+++ llvm/trunk/lib/IR/AttributeImpl.h Sun Jan 27 06:50:02 2013
@@ -115,11 +115,9 @@ class AttributeSetImpl : public FoldingS
   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; }

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=173618&r1=173617&r2=173618&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Sun Jan 27 06:50:02 2013
@@ -525,6 +525,46 @@ AttributeSetNode *AttributeSetNode::get(
 // 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(LLVMConte
   return get(C, AttrList);
 }
 
-//===----------------------------------------------------------------------===//
-// AttributeSet Method Implementations
-//===----------------------------------------------------------------------===//
-
 const AttributeSet &AttributeSet::operator=(const AttributeSet &RHS) {
   AttrList = RHS.AttrList;
   return *this;





More information about the llvm-commits mailing list