operator== returns false when two bitvectors have different sizes.
[oota-llvm.git] / include / llvm / Instructions.h
index 3a88b990749a2d9f27bfafc4a507eebae1a3e33f..9fc76019aa6a6b5057fff91699afd582509f737b 100644 (file)
@@ -23,7 +23,7 @@ namespace llvm {
 class BasicBlock;
 class ConstantInt;
 class PointerType;
-class PackedType;
+class VectorType;
 
 //===----------------------------------------------------------------------===//
 //                             AllocationInst Class
@@ -222,11 +222,18 @@ class LoadInst : public UnaryInstruction {
 public:
   LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
   LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd);
-  explicit LoadInst(Value *Ptr, const std::string &Name = "",
-                    bool isVolatile = false, Instruction *InsertBefore = 0);
+  LoadInst(Value *Ptr, const std::string &Name, bool isVolatile = false,
+           Instruction *InsertBefore = 0);
   LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
            BasicBlock *InsertAtEnd);
 
+  LoadInst(Value *Ptr, const char *Name, Instruction *InsertBefore);
+  LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAtEnd);
+  explicit LoadInst(Value *Ptr, const char *Name = 0, bool isVolatile = false,
+                    Instruction *InsertBefore = 0);
+  LoadInst(Value *Ptr, const char *Name, bool isVolatile,
+           BasicBlock *InsertAtEnd);
+  
   /// isVolatile - Return true if this is a load from a volatile memory
   /// location.
   ///
@@ -336,7 +343,7 @@ class GetElementPtrInst : public Instruction {
     for (unsigned i = 0, E = NumOperands; i != E; ++i)
       OL[i].init(GEPIOL[i], this);
   }
-  void init(Value *Ptr, const std::vector<Value*> &Idx);
+  void init(Value *Ptr, Value* const *Idx, unsigned NumIdx);
   void init(Value *Ptr, Value *Idx0, Value *Idx1);
   void init(Value *Ptr, Value *Idx);
 public:
@@ -344,11 +351,11 @@ public:
   /// list of indices.  The first ctor can optionally insert before an existing
   /// instruction, the second appends the new instruction to the specified
   /// BasicBlock.
-  GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
+  GetElementPtrInst(Value *Ptr, Value* const *Idx, unsigned NumIdx,
                     const std::string &Name = "", Instruction *InsertBefore =0);
-  GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
+  GetElementPtrInst(Value *Ptr, Value* const *Idx, unsigned NumIdx,
                     const std::string &Name, BasicBlock *InsertAtEnd);
-
+  
   /// Constructors - These two constructors are convenience methods because one
   /// and two index getelementptr instructions are so common.
   GetElementPtrInst(Value *Ptr, Value *Idx,
@@ -375,8 +382,9 @@ public:
   /// pointer type.
   ///
   static const Type *getIndexedType(const Type *Ptr,
-                                    const std::vector<Value*> &Indices,
+                                    Value* const *Idx, unsigned NumIdx,
                                     bool AllowStructLeaf = false);
+  
   static const Type *getIndexedType(const Type *Ptr, Value *Idx0, Value *Idx1,
                                     bool AllowStructLeaf = false);
   static const Type *getIndexedType(const Type *Ptr, Value *Idx);
@@ -687,17 +695,17 @@ public:
 ///
 class CallInst : public Instruction {
   CallInst(const CallInst &CI);
-  void init(Value *Func, const std::vector<Value*> &Params);
+  void init(Value *Func, Value* const *Params, unsigned NumParams);
   void init(Value *Func, Value *Actual1, Value *Actual2);
   void init(Value *Func, Value *Actual);
   void init(Value *Func);
 
 public:
-  CallInst(Value *F, const std::vector<Value*> &Par,
+  CallInst(Value *F, Value* const *Args, unsigned NumArgs,
            const std::string &Name = "", Instruction *InsertBefore = 0);
-  CallInst(Value *F, const std::vector<Value*> &Par,
+  CallInst(Value *F, Value *const *Args, unsigned NumArgs,
            const std::string &Name, BasicBlock *InsertAtEnd);
-
+  
   // Alternate CallInst ctors w/ two actuals, w/ one actual and no
   // actuals, respectively.
   CallInst(Value *F, Value *Actual1, Value *Actual2,
@@ -750,83 +758,6 @@ public:
   }
 };
 
-
-//===----------------------------------------------------------------------===//
-//                                 ShiftInst Class
-//===----------------------------------------------------------------------===//
-
-/// ShiftInst - This class represents left and right shift instructions.
-///
-class ShiftInst : public Instruction {
-  Use Ops[2];
-  ShiftInst(const ShiftInst &SI)
-    : Instruction(SI.getType(), SI.getOpcode(), Ops, 2) {
-    Ops[0].init(SI.Ops[0], this);
-    Ops[1].init(SI.Ops[1], this);
-  }
-  void init(OtherOps Opcode, Value *S, Value *SA) {
-    assert((Opcode == Shl || Opcode == LShr || Opcode == AShr) && 
-      "ShiftInst Opcode invalid!");
-    Ops[0].init(S, this);
-    Ops[1].init(SA, this);
-  }
-
-public:
-  ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "",
-            Instruction *InsertBefore = 0)
-    : Instruction(S->getType(), Opcode, Ops, 2, Name, InsertBefore) {
-    init(Opcode, S, SA);
-  }
-  ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name,
-            BasicBlock *InsertAtEnd)
-    : Instruction(S->getType(), Opcode, Ops, 2, Name, InsertAtEnd) {
-    init(Opcode, S, SA);
-  }
-
-  OtherOps getOpcode() const {
-    return static_cast<OtherOps>(Instruction::getOpcode());
-  }
-
-  /// Transparently provide more efficient getOperand methods.
-  Value *getOperand(unsigned i) const {
-    assert(i < 2 && "getOperand() out of range!");
-    return Ops[i];
-  }
-  void setOperand(unsigned i, Value *Val) {
-    assert(i < 2 && "setOperand() out of range!");
-    Ops[i] = Val;
-  }
-  unsigned getNumOperands() const { return 2; }
-
-  /// isLogicalShift - Return true if this is a logical shift left or a logical
-  /// shift right.
-  bool isLogicalShift() const {
-    unsigned opcode = getOpcode();
-    return opcode == Instruction::Shl || opcode == Instruction::LShr;
-  }
-
-
-  /// isArithmeticShift - Return true if this is a sign-extending shift right
-  /// operation.
-  bool isArithmeticShift() const {
-    return !isLogicalShift();
-  }
-
-
-  virtual ShiftInst *clone() const;
-
-  // Methods for support type inquiry through isa, cast, and dyn_cast:
-  static inline bool classof(const ShiftInst *) { return true; }
-  static inline bool classof(const Instruction *I) {
-    return (I->getOpcode() == Instruction::LShr) |
-           (I->getOpcode() == Instruction::AShr) |
-           (I->getOpcode() == Instruction::Shl);
-  }
-  static inline bool classof(const Value *V) {
-    return isa<Instruction>(V) && classof(cast<Instruction>(V));
-  }
-};
-
 //===----------------------------------------------------------------------===//
 //                               SelectInst Class
 //===----------------------------------------------------------------------===//
@@ -904,11 +835,13 @@ class VAArgInst : public UnaryInstruction {
 public:
   VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
              Instruction *InsertBefore = 0)
-    : UnaryInstruction(Ty, VAArg, List, Name, InsertBefore) {
+    : UnaryInstruction(Ty, VAArg, List, 0, InsertBefore) {
+    setName(Name);
   }
   VAArgInst(Value *List, const Type *Ty, const std::string &Name,
             BasicBlock *InsertAtEnd)
-    : UnaryInstruction(Ty, VAArg, List, Name, InsertAtEnd) {
+    : UnaryInstruction(Ty, VAArg, List, 0, InsertAtEnd) {
+    setName(Name);
   }
 
   virtual VAArgInst *clone() const;
@@ -929,7 +862,7 @@ public:
 //===----------------------------------------------------------------------===//
 
 /// ExtractElementInst - This instruction extracts a single (scalar)
-/// element from a PackedType value
+/// element from a VectorType value
 ///
 class ExtractElementInst : public Instruction {
   Use Ops[2];
@@ -983,7 +916,7 @@ public:
 //===----------------------------------------------------------------------===//
 
 /// InsertElementInst - This instruction inserts a single (scalar)
-/// element into a PackedType value
+/// element into a VectorType value
 ///
 class InsertElementInst : public Instruction {
   Use Ops[3];
@@ -1007,10 +940,10 @@ public:
 
   virtual bool mayWriteToMemory() const { return false; }
 
-  /// getType - Overload to return most specific packed type.
+  /// getType - Overload to return most specific vector type.
   ///
-  inline const PackedType *getType() const {
-    return reinterpret_cast<const PackedType*>(Instruction::getType());
+  inline const VectorType *getType() const {
+    return reinterpret_cast<const VectorType*>(Instruction::getType());
   }
 
   /// Transparently provide more efficient getOperand methods.
@@ -1059,10 +992,10 @@ public:
 
   virtual bool mayWriteToMemory() const { return false; }
 
-  /// getType - Overload to return most specific packed type.
+  /// getType - Overload to return most specific vector type.
   ///
-  inline const PackedType *getType() const {
-    return reinterpret_cast<const PackedType*>(Instruction::getType());
+  inline const VectorType *getType() const {
+    return reinterpret_cast<const VectorType*>(Instruction::getType());
   }
 
   /// Transparently provide more efficient getOperand methods.
@@ -1554,13 +1487,13 @@ private:
 class InvokeInst : public TerminatorInst {
   InvokeInst(const InvokeInst &BI);
   void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
-            const std::vector<Value*> &Params);
+            Value* const *Args, unsigned NumArgs);
 public:
   InvokeInst(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
-             const std::vector<Value*> &Params, const std::string &Name = "",
+             Value* const* Args, unsigned NumArgs, const std::string &Name = "",
              Instruction *InsertBefore = 0);
   InvokeInst(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
-             const std::vector<Value*> &Params, const std::string &Name,
+             Value* const* Args, unsigned NumArgs, const std::string &Name,
              BasicBlock *InsertAtEnd);
   ~InvokeInst();