Skip to content

Commit

Permalink
Add a new Attribute::getAlignmentFromAttrs method.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61517 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Dec 31, 2008
1 parent 67b9a2a commit 033ff38
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions include/llvm/Attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ inline Attributes constructAlignmentFromInt(unsigned i) {
return (Log2_32(i)+1) << 16;
}

/// This returns the alignment field of an attribute as a byte alignment value.
inline unsigned getAlignmentFromAttrs(Attributes A) {
Attributes Align = A & Attribute::Alignment;
if (Align == 0)
return 0;

return 1U << ((Align >> 16) - 1);
}


/// The set of Attributes set in Attributes is converted to a
/// string of equivalent mnemonics. This is, presumably, for writing out
/// the mnemonics for the assembly writer.
Expand Down Expand Up @@ -184,11 +194,7 @@ class AttrListPtr {
/// getParamAlignment - Return the alignment for the specified function
/// parameter.
unsigned getParamAlignment(unsigned Idx) const {
Attributes Align = getAttributes(Idx) & Attribute::Alignment;
if (Align == 0)
return 0;

return 1ull << ((Align >> 16) - 1);
return Attribute::getAlignmentFromAttrs(getAttributes(Idx));
}

/// hasAttrSomewhere - Return true if the specified attribute is set for at
Expand Down

0 comments on commit 033ff38

Please sign in to comment.