Add a argument to storeRegToStackSlot and storeRegToAddr to specify whether
[oota-llvm.git] / include / llvm / Function.h
index 7776c29f1d7b09bde281dcad84dad2712a33caf8..20a43e285cfff021f35792936927e1f0563df6e9 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/GlobalValue.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Argument.h"
+#include "llvm/ParameterAttributes.h"
 #include "llvm/Support/Annotation.h"
 
 namespace llvm {
@@ -68,7 +69,7 @@ private:
   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;*/
@@ -138,7 +139,7 @@ public:
   /// 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
@@ -150,7 +151,27 @@ public:
   /// 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.