Cosmetic change.
[oota-llvm.git] / include / llvm / Instructions.h
index 96ca43d6cad68232aed639b88264fe2e789de512..3c8673e627aead6c4705e4de86a288107a4cf2fb 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "llvm/InstrTypes.h"
 #include "llvm/DerivedTypes.h"
+#include "llvm/ParameterAttributes.h"
 
 namespace llvm {
 
@@ -454,7 +455,8 @@ public:
                     Instruction *InsertBefore =0)
       : Instruction(PointerType::get(
                       checkType(getIndexedType(Ptr->getType(),
-                                               IdxBegin, IdxEnd, true))),
+                                               IdxBegin, IdxEnd, true)),
+                      cast<PointerType>(Ptr->getType())->getAddressSpace()),
                     GetElementPtr, 0, 0, InsertBefore) {
     init(Ptr, IdxBegin, IdxEnd, Name,
          typename std::iterator_traits<InputIterator>::iterator_category());
@@ -464,7 +466,8 @@ public:
                     const std::string &Name, BasicBlock *InsertAtEnd)
       : Instruction(PointerType::get(
                       checkType(getIndexedType(Ptr->getType(),
-                                               IdxBegin, IdxEnd, true))),
+                                               IdxBegin, IdxEnd, true)),
+                      cast<PointerType>(Ptr->getType())->getAddressSpace()),
                     GetElementPtr, 0, 0, InsertAtEnd) {
     init(Ptr, IdxBegin, IdxEnd, Name,
          typename std::iterator_traits<InputIterator>::iterator_category());
@@ -923,8 +926,34 @@ public:
   /// @brief Set the parameter attributes.
   void setParamAttrs(const ParamAttrsList *attrs);
 
+  /// @brief Determine whether the call or the callee has the given attribute.
+  bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
+
+  /// @brief Determine if the call does not access memory.
+  bool doesNotAccessMemory() const {
+    return paramHasAttr(0, ParamAttr::ReadNone);
+  }
+
+  /// @brief Determine if the call does not access or only reads memory.
+  bool onlyReadsMemory() const {
+    return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+  }
+
+  /// @brief Determine if the call cannot return.
+  bool isNoReturn() const {
+    return paramHasAttr(0, ParamAttr::NoReturn);
+  }
+
+  /// @brief Determine if the call cannot unwind.
+  bool isNoUnwind() const {
+    return paramHasAttr(0, ParamAttr::NoUnwind);
+  }
+
   /// @brief Determine if the call returns a structure.
-  bool isStructReturn() const;
+  bool isStructReturn() const {
+    // Be friendly and also check the callee.
+    return paramHasAttr(1, ParamAttr::StructRet);
+  }
 
   /// getCalledFunction - Return the function being called by this instruction
   /// if it is a direct call.  If it is a call through a function pointer,
@@ -1701,8 +1730,34 @@ public:
   /// @brief Set the parameter attributes.
   void setParamAttrs(const ParamAttrsList *attrs);
 
+  /// @brief Determine whether the call or the callee has the given attribute.
+  bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
+
+  /// @brief Determine if the call does not access memory.
+  bool doesNotAccessMemory() const {
+    return paramHasAttr(0, ParamAttr::ReadNone);
+  }
+
+  /// @brief Determine if the call does not access or only reads memory.
+  bool onlyReadsMemory() const {
+    return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+  }
+
+  /// @brief Determine if the call cannot return.
+  bool isNoReturn() const {
+    return paramHasAttr(0, ParamAttr::NoReturn);
+  }
+
+  /// @brief Determine if the call cannot unwind.
+  bool isNoUnwind() const {
+    return paramHasAttr(0, ParamAttr::NoUnwind);
+  }
+
   /// @brief Determine if the call returns a structure.
-  bool isStructReturn() const;
+  bool isStructReturn() 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.