Add explicit keywords.
[oota-llvm.git] / include / llvm / Support / CallSite.h
index b613dffe97a26dcd89a590638c5f9a981435e755..401e5588db1c92444b61d501585d7a090b9fad75 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -36,6 +36,7 @@ public:
   CallSite() : I(0) {}
   CallSite(CallInst *CI) : I(reinterpret_cast<Instruction*>(CI)) {}
   CallSite(InvokeInst *II) : I(reinterpret_cast<Instruction*>(II)) {}
+  CallSite(Instruction *C);
   CallSite(const CallSite &CS) : I(CS.I) {}
   CallSite &operator=(const CallSite &CS) { I = CS.I; return *this; }
 
@@ -67,6 +68,16 @@ public:
   /// paramHasAttr - 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;
+
+  /// @brief Determine if the call does not access or only reads memory.
+  bool onlyReadsMemory() const;
+
+  /// @brief Determine if the call cannot unwind.
+  bool doesNotThrow() const;
+  void setDoesNotThrow(bool doesNotThrow = true);
+
   /// getType - Return the type of the instruction that generated this call site
   ///
   const Type *getType() const { return I->getType(); }
@@ -105,6 +116,15 @@ public:
     return *(arg_begin()+ArgNo);
   }
 
+  void setArgument(unsigned ArgNo, Value* newVal) {
+    assert(I && "Not a call or invoke instruction!");
+    assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!");
+    if (I->getOpcode() == Instruction::Call)
+      I->setOperand(ArgNo+1, newVal); // Skip Function
+    else
+      I->setOperand(ArgNo+3, newVal); // Skip Function, BB, BB
+  }
+
   /// arg_iterator - The type of iterator to use when looping over actual
   /// arguments at this call site...
   typedef User::op_iterator arg_iterator;