__builtin_ia32_movntdqa reads memory
[oota-llvm.git] / include / llvm / Instructions.h
index 1335031e5a35eede9e2bd6d14edd1984e89d6d1a..c80154c76d0a3804820078ed04dcf15b426fd7e8 100644 (file)
@@ -30,7 +30,6 @@ class PointerType;
 class VectorType;
 class ConstantRange;
 class APInt;
-class ParamAttrsList;
 
 //===----------------------------------------------------------------------===//
 //                             AllocationInst Class
@@ -58,12 +57,12 @@ public:
   /// getArraySize - Get the number of element allocated, for a simple
   /// allocation of a single element, this will return a constant 1 value.
   ///
-  inline const Value *getArraySize() const { return getOperand(0); }
-  inline Value *getArraySize() { return getOperand(0); }
+  const Value *getArraySize() const { return getOperand(0); }
+  Value *getArraySize() { return getOperand(0); }
 
   /// getType - Overload to return most specific pointer type
   ///
-  inline const PointerType *getType() const {
+  const PointerType *getType() const {
     return reinterpret_cast<const PointerType*>(Instruction::getType());
   }
 
@@ -484,7 +483,7 @@ public:
   virtual GetElementPtrInst *clone() const;
 
   // getType - Overload to return most specific pointer type...
-  inline const PointerType *getType() const {
+  const PointerType *getType() const {
     return reinterpret_cast<const PointerType*>(Instruction::getType());
   }
 
@@ -520,11 +519,11 @@ public:
     return 0U;                      // get index for modifying correct operand
   }
 
-  inline unsigned getNumIndices() const {  // Note: always non-negative
+  unsigned getNumIndices() const {  // Note: always non-negative
     return getNumOperands() - 1;
   }
 
-  inline bool hasIndices() const {
+  bool hasIndices() const {
     return getNumOperands() > 1;
   }
   
@@ -851,7 +850,7 @@ public:
 ///
 
 class CallInst : public Instruction {
-  const ParamAttrsList *ParamAttrs; ///< parameter attributes for call
+  PAListPtr 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);
@@ -927,41 +926,53 @@ public:
     SubclassData = (SubclassData & 1) | (CC << 1);
   }
 
-  /// Obtains a pointer to the ParamAttrsList object which holds the
-  /// parameter attributes information, if any.
-  /// @returns 0 if no attributes have been set.
-  /// @brief Get the parameter attributes.
-  const ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
+  /// getParamAttrs - Return the parameter attributes for this call.
+  ///
+  const PAListPtr &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(const ParamAttrsList *attrs);
+  /// setParamAttrs - Sets the parameter attributes for this call.
+  void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; }
 
   /// @brief Determine whether the call or the callee has the given attribute.
-  bool paramHasAttr(uint16_t i, unsigned attr) const;
+  bool paramHasAttr(unsigned i, unsigned attr) const;
 
   /// @brief Extract the alignment for a call or parameter (0=unknown).
-  uint16_t getParamAlignment(uint16_t i) const;
+  unsigned getParamAlignment(unsigned i) const {
+    return ParamAttrs.getParamAlignment(i);
+  }
 
   /// @brief Determine if the call does not access memory.
-  bool doesNotAccessMemory() const;
+  bool doesNotAccessMemory() const {
+    return paramHasAttr(0, ParamAttr::ReadNone);
+  }
   
   /// @brief Determine if the call does not access or only reads memory.
-  bool onlyReadsMemory() const;
+  bool onlyReadsMemory() const {
+    return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+  }
   
   /// @brief Determine if the call cannot return.
-  bool doesNotReturn() const;
+  bool doesNotReturn() const {
+    return paramHasAttr(0, ParamAttr::NoReturn);
+  }
 
   /// @brief Determine if the call cannot unwind.
-  bool doesNotThrow() const;
+  bool doesNotThrow() const {
+    return paramHasAttr(0, ParamAttr::NoUnwind);
+  }
   void setDoesNotThrow(bool doesNotThrow = true);
 
-  /// @brief Determine if the call returns a structure.
-  bool isStructReturn() const;
+  /// @brief Determine if the call returns a structure through first 
+  /// pointer argument.
+  bool hasStructRetAttr() const {
+    // Be friendly and also check the callee.
+    return paramHasAttr(1, ParamAttr::StructRet);
+  }
 
   /// @brief Determine if any call argument is an aggregate passed by value.
-  bool hasByValArgument() const;
+  bool hasByValArgument() const {
+    return ParamAttrs.hasAttrSomewhere(ParamAttr::ByVal);
+  }
 
   /// getCalledFunction - Return the function being called by this instruction
   /// if it is a direct call.  If it is a call through a function pointer,
@@ -972,8 +983,8 @@ public:
 
   /// getCalledValue - Get a pointer to the function that is invoked by this 
   /// instruction
-  inline const Value *getCalledValue() const { return getOperand(0); }
-  inline       Value *getCalledValue()       { return getOperand(0); }
+  const Value *getCalledValue() const { return getOperand(0); }
+        Value *getCalledValue()       { return getOperand(0); }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const CallInst *) { return true; }
@@ -1164,7 +1175,7 @@ public:
 
   /// getType - Overload to return most specific vector type.
   ///
-  inline const VectorType *getType() const {
+  const VectorType *getType() const {
     return reinterpret_cast<const VectorType*>(Instruction::getType());
   }
 
@@ -1214,12 +1225,16 @@ public:
 
   /// getType - Overload to return most specific vector type.
   ///
-  inline const VectorType *getType() const {
+  const VectorType *getType() const {
     return reinterpret_cast<const VectorType*>(Instruction::getType());
   }
 
   /// Transparently provide more efficient getOperand methods.
-  Value *getOperand(unsigned i) const {
+  const Value *getOperand(unsigned i) const {
+    assert(i < 3 && "getOperand() out of range!");
+    return Ops[i];
+  }
+  Value *getOperand(unsigned i) {
     assert(i < 3 && "getOperand() out of range!");
     return Ops[i];
   }
@@ -1228,6 +1243,11 @@ public:
     Ops[i] = Val;
   }
   unsigned getNumOperands() const { return 3; }
+  
+  /// getMaskValue - Return the index from the shuffle mask for the specified
+  /// output result.  This is either -1 if the element is undef or a number less
+  /// than 2*numelements.
+  int getMaskValue(unsigned i) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ShuffleVectorInst *) { return true; }
@@ -1312,6 +1332,8 @@ public:
   /// addIncoming - Add an incoming value to the end of the PHI list
   ///
   void addIncoming(Value *V, BasicBlock *BB) {
+    assert(V && "PHI node got a null value!");
+    assert(BB && "PHI node got a null basic block!");
     assert(getType() == V->getType() &&
            "All operands to PHI node must be the same type as the PHI node!");
     unsigned OpNo = NumOperands;
@@ -1379,9 +1401,9 @@ public:
 /// does not continue in this function any longer.
 ///
 class ReturnInst : public TerminatorInst {
+  Use RetVal;
   ReturnInst(const ReturnInst &RI);
-  void init(Value *RetVal);
-  void init(std::vector<Value *> &RetVals);
+  void init(Value * const* retVals, unsigned N);
 
 public:
   // ReturnInst constructors:
@@ -1392,20 +1414,32 @@ public:
   // ReturnInst(Value* X, Inst *I) - 'ret X'    instruction, insert before I
   // ReturnInst(    null, BB *B)   - 'ret void' instruction, insert @ end of BB
   // ReturnInst(Value* X, BB *B)   - 'ret X'    instruction, insert @ end of BB
+  // ReturnInst(Value* X, N)          - 'ret X,X+1...X+N-1' instruction
+  // ReturnInst(Value* X, N, Inst *)  - 'ret X,X+1...X+N-1', insert before I
+  // ReturnInst(Value* X, N, BB *)    - 'ret X,X+1...X+N-1', insert @ end of BB
   //
   // NOTE: If the Value* passed is of type void then the constructor behaves as
   // if it was passed NULL.
   explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0);
   ReturnInst(Value *retVal, BasicBlock *InsertAtEnd);
-  ReturnInst(std::vector<Value *> &retVals);
-  ReturnInst(std::vector<Value *> &retVals, Instruction *InsertBefore);
-  ReturnInst(std::vector<Value *> &retVals, BasicBlock *InsertAtEnd);
+  ReturnInst(Value * const* retVals, unsigned N);
+  ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore);
+  ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd);
   explicit ReturnInst(BasicBlock *InsertAtEnd);
   virtual ~ReturnInst();
 
   virtual ReturnInst *clone() const;
 
-  Value *getReturnValue(unsigned n = 0) const;
+  Value *getOperand(unsigned n = 0) const {
+    if (getNumOperands() > 1)
+      return TerminatorInst::getOperand(n);
+    else
+      return RetVal;
+  }
+
+  Value *getReturnValue(unsigned n = 0) const {
+    return getOperand(n);
+  }
 
   unsigned getNumSuccessors() const { return 0; }
 
@@ -1464,10 +1498,10 @@ public:
 
   virtual BranchInst *clone() const;
 
-  inline bool isUnconditional() const { return getNumOperands() == 1; }
-  inline bool isConditional()   const { return getNumOperands() == 3; }
+  bool isUnconditional() const { return getNumOperands() == 1; }
+  bool isConditional()   const { return getNumOperands() == 3; }
 
-  inline Value *getCondition() const {
+  Value *getCondition() const {
     assert(isConditional() && "Cannot get condition of an uncond branch!");
     return getOperand(2);
   }
@@ -1549,10 +1583,10 @@ public:
 
 
   // Accessor Methods for Switch stmt
-  inline Value *getCondition() const { return getOperand(0); }
+  Value *getCondition() const { return getOperand(0); }
   void setCondition(Value *V) { setOperand(0, V); }
 
-  inline BasicBlock *getDefaultDest() const {
+  BasicBlock *getDefaultDest() const {
     return cast<BasicBlock>(getOperand(1));
   }
 
@@ -1625,7 +1659,7 @@ public:
 
   // getSuccessorValue - Return the value associated with the specified
   // successor.
-  inline ConstantInt *getSuccessorValue(unsigned idx) const {
+  ConstantInt *getSuccessorValue(unsigned idx) const {
     assert(idx < getNumSuccessors() && "Successor # out of range!");
     return reinterpret_cast<ConstantInt*>(getOperand(idx*2));
   }
@@ -1654,7 +1688,7 @@ private:
 /// calling convention of the call.
 ///
 class InvokeInst : public TerminatorInst {
-  const ParamAttrsList *ParamAttrs;
+  PAListPtr ParamAttrs;
   InvokeInst(const InvokeInst &BI);
   void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
             Value* const *Args, unsigned NumArgs);
@@ -1721,38 +1755,49 @@ public:
     SubclassData = CC;
   }
 
-  /// Obtains a pointer to the ParamAttrsList object which holds the
-  /// parameter attributes information, if any.
-  /// @returns 0 if no attributes have been set.
-  /// @brief Get the parameter attributes.
-  const ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
+  /// getParamAttrs - Return the parameter attributes for this invoke.
+  ///
+  const PAListPtr &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(const ParamAttrsList *attrs);
+  /// setParamAttrs - Set the parameter attributes for this invoke.
+  ///
+  void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; }
 
   /// @brief Determine whether the call or the callee has the given attribute.
-  bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
+  bool paramHasAttr(unsigned i, ParameterAttributes attr) const;
 
   /// @brief Extract the alignment for a call or parameter (0=unknown).
-  uint16_t getParamAlignment(uint16_t i) const;
+  unsigned getParamAlignment(unsigned i) const {
+    return ParamAttrs.getParamAlignment(i);
+  }
 
   /// @brief Determine if the call does not access memory.
-  bool doesNotAccessMemory() const;
+  bool doesNotAccessMemory() const {
+    return paramHasAttr(0, ParamAttr::ReadNone);
+  }
 
   /// @brief Determine if the call does not access or only reads memory.
-  bool onlyReadsMemory() const;
+  bool onlyReadsMemory() const {
+    return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+  }
 
   /// @brief Determine if the call cannot return.
-  bool doesNotReturn() const;
+  bool doesNotReturn() const {
+    return paramHasAttr(0, ParamAttr::NoReturn);
+  }
 
   /// @brief Determine if the call cannot unwind.
-  bool doesNotThrow() const;
+  bool doesNotThrow() const {
+    return paramHasAttr(0, ParamAttr::NoUnwind);
+  }
   void setDoesNotThrow(bool doesNotThrow = true);
 
-  /// @brief Determine if the call returns a structure.
-  bool isStructReturn() const;
+  /// @brief Determine if the call returns a structure through first 
+  /// pointer argument.
+  bool hasStructRetAttr() 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.
@@ -1762,7 +1807,7 @@ public:
   }
 
   // getCalledValue - Get a pointer to a function that is invoked by this inst.
-  inline Value *getCalledValue() const { return getOperand(0); }
+  Value *getCalledValue() const { return getOperand(0); }
 
   // get*Dest - Return the destination basic blocks...
   BasicBlock *getNormalDest() const {
@@ -1779,7 +1824,7 @@ public:
     setOperand(2, reinterpret_cast<Value*>(B));
   }
 
-  inline BasicBlock *getSuccessor(unsigned i) const {
+  BasicBlock *getSuccessor(unsigned i) const {
     assert(i < 2 && "Successor # out of range for invoke!");
     return i == 0 ? getNormalDest() : getUnwindDest();
   }
@@ -2367,19 +2412,15 @@ public:
   
   virtual GetResultInst *clone() const;
   
-  inline Value *getAggregateValue() {
+  Value *getAggregateValue() {
     return getOperand(0);
   }
 
-  inline const Value *getAggregateValue() const {
+  const Value *getAggregateValue() const {
     return getOperand(0);
   }
 
-  inline unsigned getIndex() {
-    return Idx;
-  }
-
-  inline const unsigned getIndex() const {
+  unsigned getIndex() const {
     return Idx;
   }