diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-01-02 23:45:09 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-01-02 23:45:09 +0000 |
commit | 278bac3fba5ae8ae620c961621493e6e2ad6f953 (patch) | |
tree | ad78b1e127ef0f0d1f8dc6274df89432059bee9e /lib | |
parent | d40758b24ebab5777131533d9369e707fc852594 (diff) |
An intermediate step in the Attributes rewrite.
Modify the AttrBuilder class to store the attributes as a set instead of as a
bit mask. The Attribute class will represent only one attribute instead of a
collection of attributes.
This is the wave of the future!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171427 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/IR/Attributes.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 427134b00f..2e0b084ab5 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -233,8 +233,15 @@ std::string Attribute::getAsString() const { // AttrBuilder Implementation //===----------------------------------------------------------------------===// +void AttrBuilder::clear() { + AttrSet.clear(); + Alignment = StackAlignment = Bits = 0; +} + AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val){ Bits |= AttributeImpl::getAttrMask(Val); + + AttrSet.insert(Val); return *this; } @@ -248,19 +255,31 @@ AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned Align) { assert(isPowerOf2_32(Align) && "Alignment must be a power of two."); assert(Align <= 0x40000000 && "Alignment too large."); Bits |= (Log2_32(Align) + 1) << 16; + + AttrSet.insert(Attribute::Alignment); + Alignment = Align; return *this; } -AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align){ +AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align) { // Default alignment, allow the target to define how to align it. if (Align == 0) return *this; assert(isPowerOf2_32(Align) && "Alignment must be a power of two."); assert(Align <= 0x100 && "Alignment too large."); Bits |= (Log2_32(Align) + 1) << 26; + + AttrSet.insert(Attribute::StackAlignment); + StackAlignment = Align; return *this; } AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) { Bits &= ~AttributeImpl::getAttrMask(Val); + + AttrSet.erase(Val); + if (Val == Attribute::Alignment) + Alignment = 0; + else if (Val == Attribute::StackAlignment) + StackAlignment = 0; return *this; } |