From 152289ce167152a3a66791a4754674fec5234595 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 27 Jan 2013 12:50:02 +0000 Subject: [PATCH] In the AttributeSetImpl c'tor, fill in the AttrNodes data structure with the attributes being passed in. llvm-svn: 173618 --- llvm/lib/IR/AttributeImpl.h | 6 ++---- llvm/lib/IR/Attributes.cpp | 44 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/llvm/lib/IR/AttributeImpl.h b/llvm/lib/IR/AttributeImpl.h index d7ebec5..b4c788f 100644 --- a/llvm/lib/IR/AttributeImpl.h +++ b/llvm/lib/IR/AttributeImpl.h @@ -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 attrs) - : Context(C), AttrList(attrs.begin(), attrs.end()) {} + AttributeSetImpl(LLVMContext &C, ArrayRef attrs); AttributeSetImpl(LLVMContext &C, - ArrayRef > attrs) - : Context(C), AttrNodes(attrs.begin(), attrs.end()) {} + ArrayRef > attrs); LLVMContext &getContext() { return Context; } ArrayRef getAttributes() const { return AttrList; } diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 8ec192b..780da00 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -525,6 +525,46 @@ AttributeSetNode *AttributeSetNode::get(LLVMContext &C, // AttributeSetImpl Definition //===----------------------------------------------------------------------===// +AttributeSetImpl:: +AttributeSetImpl(LLVMContext &C, + ArrayRef 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 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 > 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 Attrs) { return get(C, AttrList); } -//===----------------------------------------------------------------------===// -// AttributeSet Method Implementations -//===----------------------------------------------------------------------===// - const AttributeSet &AttributeSet::operator=(const AttributeSet &RHS) { AttrList = RHS.AttrList; return *this; -- 2.7.4