diff --git a/include/llvm/Function.h b/include/llvm/Function.h index be7ea910495..36b0dd3df8c 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -160,26 +160,38 @@ public: void clearCollector(); /// @brief Determine whether the function has the given attribute. - bool paramHasAttr(uint16_t i, ParameterAttributes attr) const; + bool paramHasAttr(unsigned i, ParameterAttributes attr) const { + return ParamAttrs.paramHasAttr(i, attr); + } /// @brief Extract the alignment for a call or parameter (0=unknown). - uint16_t getParamAlignment(uint16_t i) const; + unsigned getParamAlignment(unsigned i) const { + return ParamAttrs.getParamAlignment(i); + } /// @brief Determine if the function cannot return. - bool doesNotReturn() const; + bool doesNotReturn() const { return paramHasAttr(0, ParamAttr::NoReturn); } /// @brief Determine if the function cannot unwind. - bool doesNotThrow() const; + bool doesNotThrow() const { + return paramHasAttr(0, ParamAttr::NoUnwind); + } /// @brief Determine if the function does not access memory. - bool doesNotAccessMemory() const; + bool doesNotAccessMemory() const { + return paramHasAttr(0, ParamAttr::ReadNone); + } /// @brief Determine if the function does not access or only reads memory. - bool onlyReadsMemory() const; + bool onlyReadsMemory() const { + return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly); + } /// @brief Determine if the function returns a structure through first /// pointer argument. - bool hasStructRetAttr() const; + bool hasStructRetAttr() const { + return paramHasAttr(1, ParamAttr::StructRet); + } /// deleteBody - This method deletes the body of the function, and converts /// the linkage to external. diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 741153f2883..c80154c76d0 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -934,30 +934,45 @@ public: void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; } /// @brief Determine whether the call or the callee has the given attribute. - bool paramHasAttr(uint16_t i, unsigned attr) const; + bool paramHasAttr(unsigned i, unsigned attr) const; /// @brief Extract the alignment for a call or parameter (0=unknown). - uint16_t getParamAlignment(uint16_t i) const; + unsigned getParamAlignment(unsigned i) const { + return ParamAttrs.getParamAlignment(i); + } /// @brief Determine if the call does not access memory. - bool doesNotAccessMemory() const; + bool doesNotAccessMemory() const { + return paramHasAttr(0, ParamAttr::ReadNone); + } /// @brief Determine if the call does not access or only reads memory. - bool onlyReadsMemory() const; + bool onlyReadsMemory() const { + return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly); + } /// @brief Determine if the call cannot return. - bool doesNotReturn() const; + bool doesNotReturn() const { + return paramHasAttr(0, ParamAttr::NoReturn); + } /// @brief Determine if the call cannot unwind. - bool doesNotThrow() const; + bool doesNotThrow() const { + return paramHasAttr(0, ParamAttr::NoUnwind); + } void setDoesNotThrow(bool doesNotThrow = true); /// @brief Determine if the call returns a structure through first /// pointer argument. - bool hasStructRetAttr() const; + bool hasStructRetAttr() const { + // Be friendly and also check the callee. + return paramHasAttr(1, ParamAttr::StructRet); + } /// @brief Determine if any call argument is an aggregate passed by value. - bool hasByValArgument() const; + bool hasByValArgument() const { + return ParamAttrs.hasAttrSomewhere(ParamAttr::ByVal); + } /// getCalledFunction - Return the function being called by this instruction /// if it is a direct call. If it is a call through a function pointer, @@ -1749,27 +1764,40 @@ public: void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; } /// @brief Determine whether the call or the callee has the given attribute. - bool paramHasAttr(uint16_t i, ParameterAttributes attr) const; + bool paramHasAttr(unsigned i, ParameterAttributes attr) const; /// @brief Extract the alignment for a call or parameter (0=unknown). - uint16_t getParamAlignment(uint16_t i) const; + unsigned getParamAlignment(unsigned i) const { + return ParamAttrs.getParamAlignment(i); + } /// @brief Determine if the call does not access memory. - bool doesNotAccessMemory() const; + bool doesNotAccessMemory() const { + return paramHasAttr(0, ParamAttr::ReadNone); + } /// @brief Determine if the call does not access or only reads memory. - bool onlyReadsMemory() const; + bool onlyReadsMemory() const { + return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly); + } /// @brief Determine if the call cannot return. - bool doesNotReturn() const; + bool doesNotReturn() const { + return paramHasAttr(0, ParamAttr::NoReturn); + } /// @brief Determine if the call cannot unwind. - bool doesNotThrow() const; + bool doesNotThrow() const { + return paramHasAttr(0, ParamAttr::NoUnwind); + } void setDoesNotThrow(bool doesNotThrow = true); /// @brief Determine if the call returns a structure through first /// pointer argument. - bool hasStructRetAttr() const; + bool hasStructRetAttr() const { + // Be friendly and also check the callee. + return paramHasAttr(1, ParamAttr::StructRet); + } /// getCalledFunction - Return the function called, or null if this is an /// indirect function invocation. diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 5a69c099f69..6fd3af4f9d8 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -137,42 +137,6 @@ void Function::eraseFromParent() { getParent()->getFunctionList().erase(this); } -/// @brief Determine whether the function has the given attribute. -bool Function::paramHasAttr(uint16_t i, ParameterAttributes attr) const { - return ParamAttrs.paramHasAttr(i, attr); -} - -/// @brief Extract the alignment for a call or parameter (0=unknown). -uint16_t Function::getParamAlignment(uint16_t i) const { - return ParamAttrs.getParamAlignment(i); -} - -/// @brief Determine if the function cannot return. -bool Function::doesNotReturn() const { - return paramHasAttr(0, ParamAttr::NoReturn); -} - -/// @brief Determine if the function cannot unwind. -bool Function::doesNotThrow() const { - return paramHasAttr(0, ParamAttr::NoUnwind); -} - -/// @brief Determine if the function does not access memory. -bool Function::doesNotAccessMemory() const { - return paramHasAttr(0, ParamAttr::ReadNone); -} - -/// @brief Determine if the function does not access or only reads memory. -bool Function::onlyReadsMemory() const { - return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly); -} - -/// @brief Determine if the function returns a structure through first -/// pointer argument. -bool Function::hasStructRetAttr() const { - return paramHasAttr(1, ParamAttr::StructRet); -} - //===----------------------------------------------------------------------===// // Function Implementation //===----------------------------------------------------------------------===// diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index ee9a02e91ac..df5a2fc0cfc 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -362,7 +362,7 @@ CallInst::CallInst(const CallInst &CI) OL[i].init(InOL[i], this); } -bool CallInst::paramHasAttr(uint16_t i, ParameterAttributes attr) const { +bool CallInst::paramHasAttr(unsigned i, ParameterAttributes attr) const { if (ParamAttrs.paramHasAttr(i, attr)) return true; if (const Function *F = getCalledFunction()) @@ -370,47 +370,6 @@ bool CallInst::paramHasAttr(uint16_t i, ParameterAttributes attr) const { return false; } -uint16_t CallInst::getParamAlignment(uint16_t i) const { - return ParamAttrs.getParamAlignment(i); -} - -/// @brief Determine if the call does not access memory. -bool CallInst::doesNotAccessMemory() const { - return paramHasAttr(0, ParamAttr::ReadNone); -} - -/// @brief Determine if the call does not access or only reads memory. -bool CallInst::onlyReadsMemory() const { - return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly); -} - -/// @brief Determine if the call cannot return. -bool CallInst::doesNotReturn() const { - return paramHasAttr(0, ParamAttr::NoReturn); -} - -/// @brief Determine if the call cannot unwind. -bool CallInst::doesNotThrow() const { - return paramHasAttr(0, ParamAttr::NoUnwind); -} - -/// @brief Determine if the call returns a structure through first -/// pointer argument. -bool CallInst::hasStructRetAttr() const { - // Be friendly and also check the callee. - return paramHasAttr(1, ParamAttr::StructRet); -} - -/// @brief Determine if any call argument is an aggregate passed by value. -bool CallInst::hasByValArgument() const { - if (ParamAttrs.hasAttrSomewhere(ParamAttr::ByVal)) - return true; - // Be consistent with other methods and check the callee too. - if (const Function *F = getCalledFunction()) - return F->getParamAttrs().hasAttrSomewhere(ParamAttr::ByVal); - return false; -} - void CallInst::setDoesNotThrow(bool doesNotThrow) { PAListPtr PAL = getParamAttrs(); if (doesNotThrow) @@ -473,7 +432,7 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) { return setSuccessor(idx, B); } -bool InvokeInst::paramHasAttr(uint16_t i, ParameterAttributes attr) const { +bool InvokeInst::paramHasAttr(unsigned i, ParameterAttributes attr) const { if (ParamAttrs.paramHasAttr(i, attr)) return true; if (const Function *F = getCalledFunction()) @@ -481,30 +440,6 @@ bool InvokeInst::paramHasAttr(uint16_t i, ParameterAttributes attr) const { return false; } -uint16_t InvokeInst::getParamAlignment(uint16_t i) const { - return ParamAttrs.getParamAlignment(i); -} - -/// @brief Determine if the call does not access memory. -bool InvokeInst::doesNotAccessMemory() const { - return paramHasAttr(0, ParamAttr::ReadNone); -} - -/// @brief Determine if the call does not access or only reads memory. -bool InvokeInst::onlyReadsMemory() const { - return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly); -} - -/// @brief Determine if the call cannot return. -bool InvokeInst::doesNotReturn() const { - return paramHasAttr(0, ParamAttr::NoReturn); -} - -/// @brief Determine if the call cannot unwind. -bool InvokeInst::doesNotThrow() const { - return paramHasAttr(0, ParamAttr::NoUnwind); -} - void InvokeInst::setDoesNotThrow(bool doesNotThrow) { PAListPtr PAL = getParamAttrs(); if (doesNotThrow) @@ -514,13 +449,6 @@ void InvokeInst::setDoesNotThrow(bool doesNotThrow) { setParamAttrs(PAL); } -/// @brief Determine if the invoke returns a structure through first -/// pointer argument. -bool InvokeInst::hasStructRetAttr() const { - // Be friendly and also check the callee. - return paramHasAttr(1, ParamAttr::StructRet); -} - //===----------------------------------------------------------------------===// // ReturnInst Implementation