/// should be treated by optimizations and code generation. This enumeration
/// lists the attributes that can be associated with parameters, function
/// results or the function itself.
- ///
+ ///
/// Note that uwtable is about the ABI or the user mandating an entry in the
/// unwind table. The nounwind attribute is about an exception passing by the
/// function.
- ///
+ ///
/// In a theoretical system that uses tables for profiling and sjlj for
/// exceptions, they would be fully independent. In a normal system that uses
/// tables for both, the semantics are:
- ///
+ ///
/// nil = Needs an entry because an exception might pass by.
/// nounwind = No need for an entry
/// uwtable = Needs an entry because the ABI says so and because
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
- InlineHint = 5, ///< Source said inlining was desirable
- InReg = 6, ///< Force argument to be passed in register
- Naked = 7, ///< Naked function
- Nest = 8, ///< Nested function static chain
- NoAlias = 9, ///< Considered to not alias after call
- NoCapture = 10, ///< Function creates no aliases of pointer
- NoImplicitFloat = 11, ///< Disable implicit floating point insts
- NoInline = 12, ///< inline=never
- NonLazyBind = 13, ///< 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 = 14, ///< Disable redzone
- NoReturn = 15, ///< Mark the function as not returning
- NoUnwind = 16, ///< Function doesn't unwind stack
- OptimizeForSize = 17, ///< opt_size
- ReadNone = 18, ///< Function does not access memory
- ReadOnly = 19, ///< Function only reads from memory
- ReturnsTwice = 20, ///< Function can return twice
- SExt = 21, ///< Sign extended before/after call
- StackAlignment = 22, ///< 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 = 23, ///< Stack protection.
- StackProtectReq = 24, ///< Stack protection required.
- StructRet = 25, ///< Hidden pointer to structure to return
- UWTable = 26, ///< Function must be in a unwind table
- ZExt = 27 ///< 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);
+ Attributes(AttributesImpl *A) : Attrs(A) {}
public:
Attributes() : Attrs(0) {}
- Attributes(const Attributes &A);
+ Attributes(const Attributes &A) : Attrs(A.Attrs) {}
Attributes &operator=(const Attributes &A) {
Attrs = A.Attrs;
return *this;
hasAttribute(Attributes::UWTable) ||
hasAttribute(Attributes::NonLazyBind) ||
hasAttribute(Attributes::ReturnsTwice) ||
- hasAttribute(Attributes::AddressSafety);
+ hasAttribute(Attributes::AddressSafety) ||
+ hasAttribute(Attributes::MinSize);
}
bool operator==(const Attributes &A) const {
/// Builder's value, however, is not. So this can be used as a quick way to test
/// for equality, presence of attributes, etc.
class AttrBuilder {
- friend class Attributes;
uint64_t Bits;
public:
AttrBuilder() : Bits(0) {}
.removeAttribute(Attributes::UWTable)
.removeAttribute(Attributes::NonLazyBind)
.removeAttribute(Attributes::ReturnsTwice)
- .removeAttribute(Attributes::AddressSafety);
+ .removeAttribute(Attributes::AddressSafety)
+ .removeAttribute(Attributes::MinSize);
}
+ uint64_t Raw() const { return Bits; }
+
bool operator==(const AttrBuilder &B) {
return Bits == B.Bits;
}
static AttributeWithIndex get(LLVMContext &C, unsigned Idx,
ArrayRef<Attributes::AttrVal> Attrs) {
- AttrBuilder B;
-
- for (ArrayRef<Attributes::AttrVal>::iterator I = Attrs.begin(),
- E = Attrs.end(); I != E; ++I)
- B.addAttribute(*I);
-
- AttributeWithIndex P;
- P.Index = Idx;
- P.Attrs = Attributes::get(C, B);
- return P;
+ return get(Idx, Attributes::get(C, Attrs));
}
static AttributeWithIndex get(unsigned Idx, Attributes Attrs) {
AttributeWithIndex P;
FunctionIndex = ~0U
};
private:
- /// AttrList - The attributes that we are managing. This can be null
- /// to represent the empty attributes list.
+ /// AttrList - The attributes that we are managing. This can be null to
+ /// represent the empty attributes list.
AttributeListImpl *AttrList;
public:
AttrListPtr() : AttrList(0) {}
bool operator!=(const AttrListPtr &RHS) const
{ return AttrList != RHS.AttrList; }
- void dump() const;
-
//===--------------------------------------------------------------------===//
// Attribute List Introspection
//===--------------------------------------------------------------------===//
/// holds a index number plus a set of attributes.
const AttributeWithIndex &getSlot(unsigned Slot) const;
+ void dump() const;
+
private:
explicit AttrListPtr(AttributeListImpl *L);