diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-01-21 22:44:49 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-01-21 22:44:49 +0000 |
commit | c90d9f89b7d85c6b4ae3692a78046e1496c8537e (patch) | |
tree | 4698bab5e4e80201bd516e46994bc43390d780d6 /llvm/lib/IR/Attributes.cpp | |
parent | 60ccb9b2a926329de3d49716704c51cf7958b437 (diff) | |
download | bcm5719-llvm-c90d9f89b7d85c6b4ae3692a78046e1496c8537e.tar.gz bcm5719-llvm-c90d9f89b7d85c6b4ae3692a78046e1496c8537e.zip |
Have AttributeSet::getRetAttributes() return an AttributeSet instead of Attribute.
This further restricts the use of the Attribute class to the Attribute family of
classes.
llvm-svn: 173098
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index d3f284a41d8..5c95d4a380a 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -544,9 +544,18 @@ AttributeWithIndex AttributeWithIndex::get(LLVMContext &C, unsigned Idx, // AttributeSetImpl Definition //===----------------------------------------------------------------------===// +AttributeSet AttributeSet::getRetAttributes() const { + // FIXME: Remove. + return AttrList && hasAttributes(ReturnIndex) ? + AttributeSet::get(AttrList->getContext(), + AttributeWithIndex::get(ReturnIndex, + getAttributes(ReturnIndex))) : + AttributeSet(); +} + AttributeSet AttributeSet::getFnAttributes() const { // FIXME: Remove. - return AttrList ? + return AttrList && hasAttributes(FunctionIndex) ? AttributeSet::get(AttrList->getContext(), AttributeWithIndex::get(FunctionIndex, getAttributes(FunctionIndex))) : @@ -588,20 +597,22 @@ AttributeSet AttributeSet::get(LLVMContext &C, } AttributeSet AttributeSet::get(LLVMContext &C, unsigned Idx, AttrBuilder &B) { - SmallVector<AttributeWithIndex, 8> Attrs; - for (AttrBuilder::iterator I = B.begin(), E = B.end(); I != E; ++I) { - Attribute::AttrKind Kind = *I; - Attribute A = Attribute::get(C, Kind); + // FIXME: This should be implemented as a loop that creates the + // AttributeWithIndexes that then are used to create the AttributeSet. + if (!B.hasAttributes()) + return AttributeSet(); - if (Kind == Attribute::Alignment) - A.setAlignment(B.getAlignment()); - else if (Kind == Attribute::StackAlignment) - A.setStackAlignment(B.getStackAlignment()); + uint64_t Mask = 0; - Attrs.push_back(AttributeWithIndex::get(Idx, A)); - } + for (AttrBuilder::iterator I = B.begin(), E = B.end(); I != E; ++I) + Mask |= AttributeImpl::getAttrMask(*I); - return get(C, Attrs); + Attribute A = Attribute::decodeLLVMAttributesForBitcode(C, Mask); + if (B.getAlignment()) + A.setAlignment(B.getAlignment()); + if (B.getStackAlignment()) + A.setStackAlignment(B.getStackAlignment()); + return get(C, AttributeWithIndex::get(Idx, A)); } //===----------------------------------------------------------------------===// |