Push some more methods down to hide the use of the Attribute class.

Because the Attribute class is going to stop representing a collection of
attributes, limit the use of it as an aggregate in favor of using AttributeSet.
This replaces some of the uses for querying the function attributes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172844 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index 5024a63..173782e 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -255,9 +255,19 @@
 
   assert(AWI && "Cannot find index in attribute set!");
 
-  /// FIXME: This will be modified in the future. Basically, the
-  /// AttributeWithIndex class will contain the
+  uint64_t Mask = AWI->Attrs.Raw();
 
+  for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
+       I = Attribute::AttrKind(I + 1)) {
+    if (uint64_t A = (Mask & AttributeImpl::getAttrMask(I))) {
+      Attrs.insert(I);
+
+      if (I == Attribute::Alignment)
+        Alignment = 1ULL << ((A >> 16) - 1);
+      else if (I == Attribute::StackAlignment)
+        StackAlignment = 1ULL << ((A >> 26)-1);
+    }
+  }
 }
 
 void AttrBuilder::clear() {
@@ -610,6 +620,10 @@
   return getAttributes(Index).getAsString();
 }
 
+unsigned AttributeSet::getParamAlignment(unsigned Idx) const {
+  return getAttributes(Idx).getAlignment();
+}
+
 unsigned AttributeSet::getStackAlignment(unsigned Index) const {
   return getAttributes(Index).getStackAlignment();
 }
@@ -646,6 +660,11 @@
   return false;
 }
 
+AttributeSet AttributeSet::addFnAttributes(LLVMContext &C,
+                                           AttributeSet Attrs) const {
+  return addAttr(C, FunctionIndex, getAttributes(FunctionIndex));
+}
+
 AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
                                    Attribute Attrs) const {
   Attribute OldAttrs = getAttributes(Idx);