#ifndef LLVM_ATTRIBUTES_H
#define LLVM_ATTRIBUTES_H
-#include "llvm/Support/MathExtras.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/MathExtras.h"
#include <cassert>
#include <string>
enum AttrVal {
// IR-Level Attributes
- None = 0, ///< No attributes have been set
- AddressSafety = 1, ///< Address safety checking is on.
- Alignment = 2, ///< Alignment of parameter (5 bits)
+ None, ///< No attributes have been set
+ AddressSafety, ///< Address safety checking is on.
+ Alignment, ///< Alignment of parameter (5 bits)
///< stored as log2 of alignment with +1 bias
///< 0 means unaligned different from align 1
- AlwaysInline = 3, ///< inline=always
- ByVal = 4, ///< Pass structure by value
- ForceSizeOpt = 5, ///< Function must be optimized for size first
- InlineHint = 6, ///< Source said inlining was desirable
- InReg = 7, ///< Force argument to be passed in register
- Naked = 8, ///< Naked function
- Nest = 9, ///< Nested function static chain
- NoAlias = 10, ///< Considered to not alias after call
- NoCapture = 11, ///< Function creates no aliases of pointer
- NoImplicitFloat = 12, ///< Disable implicit floating point insts
- NoInline = 13, ///< inline=never
- NonLazyBind = 14, ///< Function is called early and/or
+ AlwaysInline, ///< inline=always
+ ByVal, ///< Pass structure by value
+ InlineHint, ///< Source said inlining was desirable
+ InReg, ///< Force argument to be passed in register
+ MinSize, ///< Function must be optimized for size first
+ Naked, ///< Naked function
+ Nest, ///< Nested function static chain
+ NoAlias, ///< Considered to not alias after call
+ NoCapture, ///< Function creates no aliases of pointer
+ NoImplicitFloat, ///< Disable implicit floating point insts
+ NoInline, ///< inline=never
+ NonLazyBind, ///< Function is called early and/or
///< often, so lazy binding isn't worthwhile
- NoRedZone = 15, ///< Disable redzone
- NoReturn = 16, ///< Mark the function as not returning
- NoUnwind = 17, ///< Function doesn't unwind stack
- OptimizeForSize = 18, ///< opt_size
- ReadNone = 19, ///< Function does not access memory
- ReadOnly = 20, ///< Function only reads from memory
- ReturnsTwice = 21, ///< Function can return twice
- SExt = 22, ///< Sign extended before/after call
- StackAlignment = 23, ///< Alignment of stack for function (3 bits)
+ NoRedZone, ///< Disable redzone
+ NoReturn, ///< Mark the function as not returning
+ NoUnwind, ///< Function doesn't unwind stack
+ OptimizeForSize, ///< opt_size
+ ReadNone, ///< Function does not access memory
+ ReadOnly, ///< Function only reads from memory
+ ReturnsTwice, ///< Function can return twice
+ SExt, ///< Sign extended before/after call
+ StackAlignment, ///< Alignment of stack for function (3 bits)
///< stored as log2 of alignment with +1 bias 0
///< means unaligned (different from
///< alignstack={1))
- StackProtect = 24, ///< Stack protection.
- StackProtectReq = 25, ///< Stack protection required.
- StructRet = 26, ///< Hidden pointer to structure to return
- UWTable = 27, ///< Function must be in a unwind table
- ZExt = 28 ///< Zero extended before/after call
+ StackProtect, ///< Stack protection.
+ StackProtectReq, ///< Stack protection required.
+ StructRet, ///< Hidden pointer to structure to return
+ UWTable, ///< Function must be in a unwind table
+ ZExt ///< Zero extended before/after call
};
private:
AttributesImpl *Attrs;
Attributes(AttributesImpl *A) : Attrs(A) {}
public:
Attributes() : Attrs(0) {}
- Attributes(const Attributes &A) : Attrs(A.Attrs) {}
- Attributes &operator=(const Attributes &A) {
- Attrs = A.Attrs;
- return *this;
- }
/// get - Return a uniquified Attributes object. This takes the uniquified
/// value from the Builder and wraps it in the Attributes class.
hasAttribute(Attributes::NonLazyBind) ||
hasAttribute(Attributes::ReturnsTwice) ||
hasAttribute(Attributes::AddressSafety) ||
- hasAttribute(Attributes::ForceSizeOpt);
+ hasAttribute(Attributes::MinSize);
}
bool operator==(const Attributes &A) const {
AttrBuilder() : Bits(0) {}
explicit AttrBuilder(uint64_t B) : Bits(B) {}
AttrBuilder(const Attributes &A) : Bits(A.Raw()) {}
- AttrBuilder(const AttrBuilder &B) : Bits(B.Bits) {}
void clear() { Bits = 0; }
.removeAttribute(Attributes::NonLazyBind)
.removeAttribute(Attributes::ReturnsTwice)
.removeAttribute(Attributes::AddressSafety)
- .removeAttribute(Attributes::ForceSizeOpt);
+ .removeAttribute(Attributes::MinSize);
}
uint64_t Raw() const { return Bits; }
FunctionIndex = ~0U
};
private:
- /// AttrList - The attributes that we are managing. This can be null to
- /// represent the empty attributes list.
+ /// @brief The attributes that we are managing. This can be null to represent
+ /// the empty attributes list.
AttributeListImpl *AttrList;
+
+ /// @brief The attributes for the specified index are returned. Attributes
+ /// for the result are denoted with Idx = 0.
+ Attributes getAttributes(unsigned Idx) const;
+
+ explicit AttrListPtr(AttributeListImpl *LI) : AttrList(LI) {}
public:
AttrListPtr() : AttrList(0) {}
- AttrListPtr(const AttrListPtr &P);
+ AttrListPtr(const AttrListPtr &P) : AttrList(P.AttrList) {}
const AttrListPtr &operator=(const AttrListPtr &RHS);
- ~AttrListPtr();
//===--------------------------------------------------------------------===//
// Attribute List Construction and Mutation
//===--------------------------------------------------------------------===//
/// get - Return a Attributes list with the specified parameters in it.
- static AttrListPtr get(ArrayRef<AttributeWithIndex> Attrs);
+ static AttrListPtr get(LLVMContext &C, ArrayRef<AttributeWithIndex> Attrs);
/// addAttr - Add the specified attribute at the specified index to this
/// attribute list. Since attribute lists are immutable, this
const AttributeWithIndex &getSlot(unsigned Slot) const;
void dump() const;
-
-private:
- explicit AttrListPtr(AttributeListImpl *L);
-
- /// getAttributes - The attributes for the specified index are
- /// returned. Attributes for the result are denoted with Idx = 0.
- Attributes getAttributes(unsigned Idx) const;
};
} // End llvm namespace