diff options
author | Charles Davis <cdavis@mines.edu> | 2010-02-12 00:31:15 +0000 |
---|---|---|
committer | Charles Davis <cdavis@mines.edu> | 2010-02-12 00:31:15 +0000 |
commit | 1e063d14df0f182626ebdd7ac7f32405aa754e03 (patch) | |
tree | 13d4b73826e6b511d2776a42af7549b53eed0371 /include | |
parent | 4a540f0593f32d928534817b59c4a528e2197e0c (diff) | |
download | external_llvm-1e063d14df0f182626ebdd7ac7f32405aa754e03.zip external_llvm-1e063d14df0f182626ebdd7ac7f32405aa754e03.tar.gz external_llvm-1e063d14df0f182626ebdd7ac7f32405aa754e03.tar.bz2 |
Add a new function attribute, 'alignstack'. It will indicate (when the backends
implement support for it) that the stack should be forcibly realigned in the
prologue (and the process reversed in the epilogue).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95945 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Attributes.h | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h index 068f81f..126c290 100644 --- a/include/llvm/Attributes.h +++ b/include/llvm/Attributes.h @@ -60,6 +60,11 @@ const Attributes NoImplicitFloat = 1<<23; /// disable implicit floating point const Attributes Naked = 1<<24; ///< Naked function const Attributes InlineHint = 1<<25; ///< source said inlining was ///desirable +const Attributes StackAlignment = 31<<26; ///< Alignment of stack for + ///function (5 bits) stored as log2 + ///of alignment with +1 bias + ///0 means unaligned (different from + ///alignstack(1)) /// @brief Attributes that only apply to function parameters. const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture; @@ -68,7 +73,7 @@ const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture; /// be used on return values or function parameters. const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly | NoInline | AlwaysInline | OptimizeForSize | StackProtect | StackProtectReq | - NoRedZone | NoImplicitFloat | Naked | InlineHint; + NoRedZone | NoImplicitFloat | Naked | InlineHint | StackAlignment; /// @brief Parameter attributes that do not apply to vararg call arguments. const Attributes VarArgsIncompatible = StructRet; @@ -105,6 +110,28 @@ inline unsigned getAlignmentFromAttrs(Attributes A) { return 1U << ((Align >> 16) - 1); } +/// This turns an int stack alignment (which must be a power of 2) into +/// the form used internally in Attributes. +inline Attributes constructStackAlignmentFromInt(unsigned i) { + // Default alignment, allow the target to define how to align it. + if (i == 0) + return 0; + + assert(isPowerOf2_32(i) && "Alignment must be a power of two."); + assert(i <= 0x40000000 && "Alignment too large."); + return (Log2_32(i)+1) << 26; +} + +/// This returns the stack alignment field of an attribute as a byte alignment +/// value. +inline unsigned getStackAlignmentFromAttrs(Attributes A) { + Attributes StackAlign = A & Attribute::StackAlignment; + if (StackAlign == 0) + return 0; + + return 1U << ((StackAlign >> 26) - 1); +} + /// The set of Attributes set in Attributes is converted to a /// string of equivalent mnemonics. This is, presumably, for writing out |