#include "llvm/GlobalValue.h"
#include "llvm/BasicBlock.h"
#include "llvm/Argument.h"
+#include "llvm/ParameterAttributes.h"
#include "llvm/Support/Annotation.h"
namespace llvm {
BasicBlockListType BasicBlocks; ///< The basic blocks
mutable ArgumentListType ArgumentList; ///< The formal arguments
ValueSymbolTable *SymTab; ///< Symbol table of args/instructions
- ParamAttrsList *ParamAttrs; ///< Parameter attributes
+ const ParamAttrsList *ParamAttrs; ///< Parameter attributes
// The Calling Convention is stored in Value::SubclassData.
/*unsigned CallingConvention;*/
/// calling conventions are defined in CallingConv.h.
unsigned getCallingConv() const { return SubclassData >> 1; }
void setCallingConv(unsigned CC) {
- SubclassData = (SubclassData & 1) | CC << 1;
+ SubclassData = (SubclassData & 1) | (CC << 1);
}
/// Obtains a constant pointer to the ParamAttrsList object which holds the
/// Sets the parameter attributes for this Function. To construct a
/// ParamAttrsList, see ParameterAttributes.h
/// @brief Set the parameter attributes.
- void setParamAttrs(ParamAttrsList *attrs);
+ void setParamAttrs(const ParamAttrsList *attrs);
+
+ /// @brief Determine whether the function has the given attribute.
+ bool paramHasAttr(uint16_t i, ParameterAttributes attr) const {
+ return ParamAttrs && ParamAttrs->paramHasAttr(i, attr);
+ }
+
+ /// @brief Determine if the function does not access memory.
+ bool doesNotAccessMemory() const {
+ return paramHasAttr(0, ParamAttr::ReadNone);
+ }
+
+ /// @brief Determine if the function does not access or only reads memory.
+ bool onlyReadsMemory() const {
+ return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+ }
+
+ /// @brief Determine if the function returns a structure.
+ bool isStructReturn() const {
+ return paramHasAttr(1, ParamAttr::StructRet);
+ }
/// deleteBody - This method deletes the body of the function, and converts
/// the linkage to external.