Add an extra operand to LABEL nodes which distinguishes between debug, EH, or misc...
[oota-llvm.git] / include / llvm / Instructions.h
index ec03030865261985852abdece65ced5fd18d5619..49ec4f54fd5cc20227d648b7944b17901e2dca37 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.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -256,7 +256,7 @@ public:
   /// setVolatile - Specify whether this is a volatile load or not.
   ///
   void setVolatile(bool V) { 
-    SubclassData = (SubclassData & ~1) | V
+    SubclassData = (SubclassData & ~1) | (V ? 1 : 0)
   }
 
   virtual LoadInst *clone() const;
@@ -324,7 +324,7 @@ public:
   /// setVolatile - Specify whether this is a volatile load or not.
   ///
   void setVolatile(bool V) { 
-    SubclassData = (SubclassData & ~1) | V
+    SubclassData = (SubclassData & ~1) | (V ? 1 : 0)
   }
 
   /// Transparently provide more efficient getOperand methods.
@@ -454,7 +454,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 +465,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());
@@ -640,24 +642,46 @@ public:
   /// @brief Return the signed version of the predicate.
   static Predicate getSignedPredicate(Predicate pred);
 
-  /// This also tests for commutativity. If isEquality() returns true then
-  /// the predicate is also commutative. 
-  /// @returns true if the predicate of this instruction is EQ or NE.
-  /// @brief Determine if this is an equality predicate.
+  /// For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
+  /// @returns the predicate that would be the result if the operand were
+  /// regarded as unsigned.
+  /// @brief Return the unsigned version of the predicate
+  Predicate getUnsignedPredicate() const {
+    return getUnsignedPredicate(getPredicate());
+  }
+
+  /// This is a static version that you can use without an instruction.
+  /// @brief Return the unsigned version of the predicate.
+  static Predicate getUnsignedPredicate(Predicate pred);
+
+  /// isEquality - Return true if this predicate is either EQ or NE.  This also
+  /// tests for commutativity.
+  static bool isEquality(Predicate P) {
+    return P == ICMP_EQ || P == ICMP_NE;
+  }
+  
+  /// isEquality - Return true if this predicate is either EQ or NE.  This also
+  /// tests for commutativity.
   bool isEquality() const {
-    return SubclassData == ICMP_EQ || SubclassData == ICMP_NE;
+    return isEquality(getPredicate());
   }
 
   /// @returns true if the predicate of this ICmpInst is commutative
   /// @brief Determine if this relation is commutative.
   bool isCommutative() const { return isEquality(); }
 
-  /// @returns true if the predicate is relational (not EQ or NE). 
-  /// @brief Determine if this a relational predicate.
+  /// isRelational - Return true if the predicate is relational (not EQ or NE). 
+  ///
   bool isRelational() const {
     return !isEquality();
   }
 
+  /// isRelational - Return true if the predicate is relational (not EQ or NE). 
+  ///
+  static bool isRelational(Predicate P) {
+    return !isEquality(P);
+  }
+  
   /// @returns true if the predicate of this ICmpInst is signed, false otherwise
   /// @brief Determine if this instruction's predicate is signed.
   bool isSignedPredicate() const { return isSignedPredicate(getPredicate()); }
@@ -826,7 +850,7 @@ public:
 ///
 
 class CallInst : public Instruction {
-  ParamAttrsList *ParamAttrs; ///< parameter attributes for call
+  const ParamAttrsList *ParamAttrs; ///< parameter attributes for call
   CallInst(const CallInst &CI);
   void init(Value *Func, Value* const *Params, unsigned NumParams);
   void init(Value *Func, Value *Actual1, Value *Actual2);
@@ -906,12 +930,34 @@ public:
   /// parameter attributes information, if any.
   /// @returns 0 if no attributes have been set.
   /// @brief Get the parameter attributes.
-  ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
+  const ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
 
   /// Sets the parameter attributes for this CallInst. 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 call or the callee has the given attribute.
+  bool paramHasAttr(uint16_t i, unsigned 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 return.
+  bool doesNotReturn() const;
+
+  /// @brief Determine if the call cannot unwind.
+  bool doesNotThrow() const;
+  void setDoesNotThrow(bool doesNotThrow = true);
+
+  /// @brief Determine if the call returns a structure.
+  bool isStructReturn() const;
+
+  /// @brief Determine if any call argument is an aggregate passed by value.
+  bool hasByValArgument() const;
 
   /// getCalledFunction - Return the function being called by this instruction
   /// if it is a direct call.  If it is a call through a function pointer,
@@ -1610,7 +1656,7 @@ private:
 /// calling convention of the call.
 ///
 class InvokeInst : public TerminatorInst {
-  ParamAttrsList *ParamAttrs;
+  const ParamAttrsList *ParamAttrs;
   InvokeInst(const InvokeInst &BI);
   void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
             Value* const *Args, unsigned NumArgs);
@@ -1681,12 +1727,31 @@ public:
   /// parameter attributes information, if any.
   /// @returns 0 if no attributes have been set.
   /// @brief Get the parameter attributes.
-  ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
+  const ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
 
   /// Sets the parameter attributes for this InvokeInst. 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 call or the callee has the given attribute.
+  bool paramHasAttr(uint16_t i, unsigned 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 return.
+  bool doesNotReturn() const;
+
+  /// @brief Determine if the call cannot unwind.
+  bool doesNotThrow() const;
+  void setDoesNotThrow(bool doesNotThrow = true);
+
+  /// @brief Determine if the call returns a structure.
+  bool isStructReturn() const;
 
   /// getCalledFunction - Return the function called, or null if this is an
   /// indirect function invocation.