diff options
Diffstat (limited to 'llvm/include')
-rw-r--r-- | llvm/include/llvm/Attributes.h | 71 | ||||
-rw-r--r-- | llvm/include/llvm/AttributesImpl.h | 4 | ||||
-rw-r--r-- | llvm/include/llvm/Function.h | 18 | ||||
-rw-r--r-- | llvm/include/llvm/Instructions.h | 4 |
4 files changed, 56 insertions, 41 deletions
diff --git a/llvm/include/llvm/Attributes.h b/llvm/include/llvm/Attributes.h index a41c9e1ed4d..eae384a4669 100644 --- a/llvm/include/llvm/Attributes.h +++ b/llvm/include/llvm/Attributes.h @@ -142,8 +142,47 @@ class AttributesImpl; /// Attributes - A bitset of attributes. class Attributes { +public: + enum AttrVal { + None = 0, ///< No attributes have been set + ZExt = 1, ///< Zero extended before/after call + SExt = 2, ///< Sign extended before/after call + NoReturn = 3, ///< Mark the function as not returning + InReg = 4, ///< Force argument to be passed in register + StructRet = 5, ///< Hidden pointer to structure to return + NoUnwind = 6, ///< Function doesn't unwind stack + NoAlias = 7, ///< Considered to not alias after call + ByVal = 8, ///< Pass structure by value + Nest = 9, ///< Nested function static chain + ReadNone = 10, ///< Function does not access memory + ReadOnly = 11, ///< Function only reads from memory + NoInline = 12, ///< inline=never + AlwaysInline = 13, ///< inline=always + OptimizeForSize = 14, ///< opt_size + StackProtect = 15, ///< Stack protection. + StackProtectReq = 16, ///< Stack protection required. + Alignment = 17, ///< Alignment of parameter (5 bits) + ///< stored as log2 of alignment with +1 bias + ///< 0 means unaligned different from align 1 + NoCapture = 18, ///< Function creates no aliases of pointer + NoRedZone = 19, ///< Disable redzone + NoImplicitFloat = 20, ///< Disable implicit floating point insts + Naked = 21, ///< Naked function + InlineHint = 22, ///< Source said inlining was desirable + StackAlignment = 23, ///< Alignment of stack for function (3 bits) + ///< stored as log2 of alignment with +1 bias 0 + ///< means unaligned (different from + ///< alignstack={1)) + ReturnsTwice = 24, ///< Function can return twice + UWTable = 25, ///< Function must be in a unwind table + NonLazyBind = 26, ///< Function is called early and/or + ///< often, so lazy binding isn't worthwhile + AddressSafety = 27 ///< Address safety checking is on. + }; +private: // Currently, we need less than 64 bits. AttributesImpl Attrs; + explicit Attributes(AttributesImpl *A); public: Attributes() : Attrs(0) {} @@ -234,7 +273,7 @@ public: /// @brief Parameter attributes that do not apply to vararg call arguments. bool hasIncompatibleWithVarArgsAttrs() const { - return hasStructRetAttr(); + return hasAttribute(Attributes::StructRet); } // Attribute query methods. @@ -243,33 +282,7 @@ public: return Attrs.hasAttributes(); } bool hasAttributes(const Attributes &A) const; - bool hasAddressSafetyAttr() const; - bool hasAlignmentAttr() const; - bool hasAlwaysInlineAttr() const; - bool hasByValAttr() const; - bool hasInRegAttr() const; - bool hasInlineHintAttr() const; - bool hasNakedAttr() const; - bool hasNestAttr() const; - bool hasNoAliasAttr() const; - bool hasNoCaptureAttr() const; - bool hasNoImplicitFloatAttr() const; - bool hasNoInlineAttr() const; - bool hasNonLazyBindAttr() const; - bool hasNoRedZoneAttr() const; - bool hasNoReturnAttr() const; - bool hasNoUnwindAttr() const; - bool hasOptimizeForSizeAttr() const; - bool hasReadNoneAttr() const; - bool hasReadOnlyAttr() const; - bool hasReturnsTwiceAttr() const; - bool hasSExtAttr() const; - bool hasStackAlignmentAttr() const; - bool hasStackProtectAttr() const; - bool hasStackProtectReqAttr() const; - bool hasStructRetAttr() const; - bool hasUWTableAttr() const; - bool hasZExtAttr() const; + bool hasAttribute(AttrVal Val) const; /// This returns the alignment field of an attribute as a byte alignment /// value. @@ -341,7 +354,7 @@ public: // 5-bit log2 encoded value. Shift the bits above the alignment up by 11 // bits. uint64_t EncodedAttrs = Attrs.Raw() & 0xffff; - if (Attrs.hasAlignmentAttr()) + if (Attrs.hasAttribute(Attributes::Alignment)) EncodedAttrs |= (1ULL << 16) << (((Attrs.Raw() & Attribute::Alignment_i) - 1) >> 16); EncodedAttrs |= (Attrs.Raw() & (0xfffULL << 21)) << 11; diff --git a/llvm/include/llvm/AttributesImpl.h b/llvm/include/llvm/AttributesImpl.h index 26e873bd834..4f68cb4c3ee 100644 --- a/llvm/include/llvm/AttributesImpl.h +++ b/llvm/include/llvm/AttributesImpl.h @@ -23,12 +23,14 @@ class Attributes; class AttributesImpl : public FoldingSetNode { friend class Attributes; - uint64_t Bits; // FIXME: We will be expanding this. + + uint64_t getAttrMask(uint64_t Val) const; public: AttributesImpl(uint64_t bits) : Bits(bits) {} bool hasAttribute(uint64_t A) const; + bool hasAttributes() const; bool hasAttributes(const Attributes &A) const; diff --git a/llvm/include/llvm/Function.h b/llvm/include/llvm/Function.h index f5bed69e654..5601c471f28 100644 --- a/llvm/include/llvm/Function.h +++ b/llvm/include/llvm/Function.h @@ -219,7 +219,7 @@ public: /// @brief Determine if the function does not access memory. bool doesNotAccessMemory() const { - return getFnAttributes().hasReadNoneAttr(); + return getFnAttributes().hasAttribute(Attributes::ReadNone); } void setDoesNotAccessMemory(bool DoesNotAccessMemory = true) { if (DoesNotAccessMemory) addFnAttr(Attribute::ReadNone); @@ -228,7 +228,8 @@ public: /// @brief Determine if the function does not access or only reads memory. bool onlyReadsMemory() const { - return doesNotAccessMemory() || getFnAttributes().hasReadOnlyAttr(); + return doesNotAccessMemory() || + getFnAttributes().hasAttribute(Attributes::ReadOnly); } void setOnlyReadsMemory(bool OnlyReadsMemory = true) { if (OnlyReadsMemory) addFnAttr(Attribute::ReadOnly); @@ -237,7 +238,7 @@ public: /// @brief Determine if the function cannot return. bool doesNotReturn() const { - return getFnAttributes().hasNoReturnAttr(); + return getFnAttributes().hasAttribute(Attributes::NoReturn); } void setDoesNotReturn(bool DoesNotReturn = true) { if (DoesNotReturn) addFnAttr(Attribute::NoReturn); @@ -246,7 +247,7 @@ public: /// @brief Determine if the function cannot unwind. bool doesNotThrow() const { - return getFnAttributes().hasNoUnwindAttr(); + return getFnAttributes().hasAttribute(Attributes::NoUnwind); } void setDoesNotThrow(bool DoesNotThrow = true) { if (DoesNotThrow) addFnAttr(Attribute::NoUnwind); @@ -256,7 +257,7 @@ public: /// @brief True if the ABI mandates (or the user requested) that this /// function be in a unwind table. bool hasUWTable() const { - return getFnAttributes().hasUWTableAttr(); + return getFnAttributes().hasAttribute(Attributes::UWTable); } void setHasUWTable(bool HasUWTable = true) { if (HasUWTable) @@ -273,14 +274,13 @@ public: /// @brief Determine if the function returns a structure through first /// pointer argument. bool hasStructRetAttr() const { - return getParamAttributes(1).hasStructRetAttr(); + return getParamAttributes(1).hasAttribute(Attributes::StructRet); } /// @brief Determine if the parameter does not alias other parameters. /// @param n The parameter to check. 1 is the first parameter, 0 is the return bool doesNotAlias(unsigned n) const { - return n != 0 ? getParamAttributes(n).hasNoAliasAttr() : - AttributeList.getRetAttributes().hasNoAliasAttr(); + return getParamAttributes(n).hasAttribute(Attributes::NoAlias); } void setDoesNotAlias(unsigned n, bool DoesNotAlias = true) { if (DoesNotAlias) addAttribute(n, Attribute::NoAlias); @@ -290,7 +290,7 @@ public: /// @brief Determine if the parameter can be captured. /// @param n The parameter to check. 1 is the first parameter, 0 is the return bool doesNotCapture(unsigned n) const { - return getParamAttributes(n).hasNoCaptureAttr(); + return getParamAttributes(n).hasAttribute(Attributes::NoCapture); } void setDoesNotCapture(unsigned n, bool DoesNotCapture = true) { if (DoesNotCapture) addAttribute(n, Attribute::NoCapture); diff --git a/llvm/include/llvm/Instructions.h b/llvm/include/llvm/Instructions.h index eba57805cd0..597eca5aa46 100644 --- a/llvm/include/llvm/Instructions.h +++ b/llvm/include/llvm/Instructions.h @@ -1349,7 +1349,7 @@ public: /// @brief Determine if any call argument is an aggregate passed by value. bool hasByValArgument() const { for (unsigned I = 0, E = AttributeList.getNumAttrs(); I != E; ++I) - if (AttributeList.getAttributesAtIndex(I).hasByValAttr()) + if (AttributeList.getAttributesAtIndex(I).hasAttribute(Attributes::ByVal)) return true; return false; } @@ -3116,7 +3116,7 @@ public: /// @brief Determine if any call argument is an aggregate passed by value. bool hasByValArgument() const { for (unsigned I = 0, E = AttributeList.getNumAttrs(); I != E; ++I) - if (AttributeList.getAttributesAtIndex(I).hasByValAttr()) + if (AttributeList.getAttributesAtIndex(I).hasAttribute(Attributes::ByVal)) return true; return false; } |