[llvm-commits] CVS: llvm/include/llvm/iPHINode.h iOther.h iOperators.h iMemory.h InstrTypes.h

Alkis Evlogimenos alkis at cs.uiuc.edu
Wed May 26 19:19:00 PDT 2004


Changes in directory llvm/include/llvm:

iPHINode.h updated: 1.16 -> 1.17
iOther.h updated: 1.45 -> 1.46
iOperators.h updated: 1.15 -> 1.16
iMemory.h updated: 1.45 -> 1.46
InstrTypes.h updated: 1.37 -> 1.38

---
Log message:

Add constructors that take a BasicBlock to append to, to the rest of
the llvm::Instruction hierarchy.


---
Diffs of the changes:  (+129 -28)

Index: llvm/include/llvm/iPHINode.h
diff -u llvm/include/llvm/iPHINode.h:1.16 llvm/include/llvm/iPHINode.h:1.17
--- llvm/include/llvm/iPHINode.h:1.16	Thu Feb 26 17:20:08 2004
+++ llvm/include/llvm/iPHINode.h	Wed May 26 19:15:23 2004
@@ -36,6 +36,10 @@
     : Instruction(Ty, Instruction::PHI, Name, InsertBefore) {
   }
 
+  PHINode(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd)
+    : Instruction(Ty, Instruction::PHI, Name, InsertAtEnd) {
+  }
+
   virtual Instruction *clone() const { return new PHINode(*this); }
 
   /// getNumIncomingValues - Return the number of incoming edges


Index: llvm/include/llvm/iOther.h
diff -u llvm/include/llvm/iOther.h:1.45 llvm/include/llvm/iOther.h:1.46
--- llvm/include/llvm/iOther.h:1.45	Thu Mar 11 23:51:05 2004
+++ llvm/include/llvm/iOther.h	Wed May 26 19:15:23 2004
@@ -31,12 +31,20 @@
     Operands.reserve(1);
     Operands.push_back(Use(CI.Operands[0], this));
   }
+  void init(Value *S) {
+    Operands.reserve(1);
+    Operands.push_back(Use(S, this));
+  }
 public:
   CastInst(Value *S, const Type *Ty, const std::string &Name = "",
            Instruction *InsertBefore = 0)
     : Instruction(Ty, Cast, Name, InsertBefore) {
-    Operands.reserve(1);
-    Operands.push_back(Use(S, this));
+    init(S);
+  }
+  CastInst(Value *S, const Type *Ty, const std::string &Name,
+           BasicBlock *InsertAtEnd)
+    : Instruction(Ty, Cast, Name, InsertAtEnd) {
+    init(S);
   }
 
   virtual Instruction *clone() const { return new CastInst(*this); }
@@ -61,15 +69,25 @@
 ///
 class CallInst : public Instruction {
   CallInst(const CallInst &CI);
+  void init(Value *Func, const std::vector<Value*> &Params);
+  void init(Value *Func, Value *Actual);
+  void init(Value *Func);
+
 public:
   CallInst(Value *F, const std::vector<Value*> &Par,
            const std::string &Name = "", Instruction *InsertBefore = 0);
+  CallInst(Value *F, const std::vector<Value*> &Par,
+           const std::string &Name, BasicBlock *InsertAtEnd);
 
-  // Alternate CallInst ctors w/ no actuals & one actual, respectively.
-  CallInst(Value *F, const std::string &Name = "", 
-           Instruction *InsertBefore = 0);
+  // Alternate CallInst ctors w/ one actual & no actuals, respectively.
   CallInst(Value *F, Value *Actual, const std::string& Name = "",
            Instruction *InsertBefore = 0);
+  CallInst(Value *F, Value *Actual, const std::string& Name,
+           BasicBlock *InsertAtEnd);
+  explicit CallInst(Value *F, const std::string &Name = "", 
+                    Instruction *InsertBefore = 0);
+  explicit CallInst(Value *F, const std::string &Name, 
+                    BasicBlock *InsertAtEnd);
 
   virtual Instruction *clone() const { return new CallInst(*this); }
   bool mayWriteToMemory() const { return true; }
@@ -106,16 +124,25 @@
     Operands.push_back(Use(SI.Operands[0], this));
     Operands.push_back(Use(SI.Operands[1], this));
   }
-public:
-  ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "",
-            Instruction *InsertBefore = 0)
-    : Instruction(S->getType(), Opcode, Name, InsertBefore) {
+  void init(OtherOps Opcode, Value *S, Value *SA) {
     assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
     Operands.reserve(2);
     Operands.push_back(Use(S, this));
     Operands.push_back(Use(SA, this));
   }
 
+public:
+  ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "",
+            Instruction *InsertBefore = 0)
+    : Instruction(S->getType(), Opcode, Name, InsertBefore) {
+    init(Opcode, S, SA);
+  }
+  ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name,
+            BasicBlock *InsertAtEnd)
+    : Instruction(S->getType(), Opcode, Name, InsertAtEnd) {
+    init(Opcode, S, SA);
+  }
+
   OtherOps getOpcode() const {
     return static_cast<OtherOps>(Instruction::getOpcode());
   }
@@ -146,16 +173,25 @@
     Operands.push_back(Use(SI.Operands[1], this));
     Operands.push_back(Use(SI.Operands[2], this));
   }
-public:
-  SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
-             Instruction *InsertBefore = 0)
-    : Instruction(S1->getType(), Instruction::Select, Name, InsertBefore) {
+  void init(Value *C, Value *S1, Value *S2) {
     Operands.reserve(3);
     Operands.push_back(Use(C, this));
     Operands.push_back(Use(S1, this));
     Operands.push_back(Use(S2, this));
   }
 
+public:
+  SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
+             Instruction *InsertBefore = 0)
+    : Instruction(S1->getType(), Instruction::Select, Name, InsertBefore) {
+    init(C, S1, S2);
+  }
+  SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name,
+             BasicBlock *InsertAtEnd)
+    : Instruction(S1->getType(), Instruction::Select, Name, InsertAtEnd) {
+    init(C, S1, S2);
+  }
+
   Value *getCondition() const { return Operands[0]; }
   Value *getTrueValue() const { return Operands[1]; }
   Value *getFalseValue() const { return Operands[2]; }
@@ -187,17 +223,25 @@
 ///
 class VANextInst : public Instruction {
   PATypeHolder ArgTy;
+  void init(Value *List) {
+    Operands.reserve(1);
+    Operands.push_back(Use(List, this));
+  }
   VANextInst(const VANextInst &VAN)
     : Instruction(VAN.getType(), VANext), ArgTy(VAN.getArgType()) {
-    Operands.reserve(1);
-    Operands.push_back(Use(VAN.Operands[0], this));
+    init(VAN.Operands[0]);
   }
+
 public:
   VANextInst(Value *List, const Type *Ty, const std::string &Name = "",
              Instruction *InsertBefore = 0)
     : Instruction(List->getType(), VANext, Name, InsertBefore), ArgTy(Ty) {
-    Operands.reserve(1);
-    Operands.push_back(Use(List, this));
+    init(List);
+  }
+  VANextInst(Value *List, const Type *Ty, const std::string &Name,
+             BasicBlock *InsertAtEnd)
+    : Instruction(List->getType(), VANext, Name, InsertAtEnd), ArgTy(Ty) {
+    init(List);
   }
 
   const Type *getArgType() const { return ArgTy; }
@@ -223,17 +267,24 @@
 /// an argument of the specified type given a va_list.
 ///
 class VAArgInst : public Instruction {
+  void init(Value* List) {
+    Operands.reserve(1);
+    Operands.push_back(Use(List, this));
+  }
   VAArgInst(const VAArgInst &VAA)
     : Instruction(VAA.getType(), VAArg) {
-    Operands.reserve(1);
-    Operands.push_back(Use(VAA.Operands[0], this));
+    init(VAA.Operands[0]);
   }
 public:
   VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
              Instruction *InsertBefore = 0)
     : Instruction(Ty, VAArg, Name, InsertBefore) {
-    Operands.reserve(1);
-    Operands.push_back(Use(List, this));
+    init(List);
+  }
+  VAArgInst(Value *List, const Type *Ty, const std::string &Name,
+            BasicBlock *InsertAtEnd)
+    : Instruction(Ty, VAArg, Name, InsertAtEnd) {
+    init(List);
   }
 
   virtual Instruction *clone() const { return new VAArgInst(*this); }


Index: llvm/include/llvm/iOperators.h
diff -u llvm/include/llvm/iOperators.h:1.15 llvm/include/llvm/iOperators.h:1.16
--- llvm/include/llvm/iOperators.h:1.15	Tue Nov 11 16:41:30 2003
+++ llvm/include/llvm/iOperators.h	Wed May 26 19:15:23 2004
@@ -26,6 +26,8 @@
 public:
   SetCondInst(BinaryOps Opcode, Value *LHS, Value *RHS,
 	      const std::string &Name = "", Instruction *InsertBefore = 0);
+  SetCondInst(BinaryOps Opcode, Value *LHS, Value *RHS,
+	      const std::string &Name, BasicBlock *InsertAtEnd);
 
   /// getInverseCondition - Return the inverse of the current condition opcode.
   /// For example seteq -> setne, setgt -> setle, setlt -> setge, etc...


Index: llvm/include/llvm/iMemory.h
diff -u llvm/include/llvm/iMemory.h:1.45 llvm/include/llvm/iMemory.h:1.46
--- llvm/include/llvm/iMemory.h:1.45	Wed May 26 16:41:09 2004
+++ llvm/include/llvm/iMemory.h	Wed May 26 19:15:23 2004
@@ -30,8 +30,12 @@
 ///
 class AllocationInst : public Instruction {
 protected:
+  void init(const Type *Ty, Value *ArraySize, unsigned iTy);
   AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, 
 		 const std::string &Name = "", Instruction *InsertBefore = 0);
+  AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, 
+		 const std::string &Name, BasicBlock *InsertAtEnd);
+
 public:
 
   /// isArrayAllocation - Return true if there is an allocation size parameter
@@ -79,9 +83,13 @@
 class MallocInst : public AllocationInst {
   MallocInst(const MallocInst &MI);
 public:
-  MallocInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "",
-             Instruction *InsertBefore = 0)
+  explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
+                      const std::string &Name = "",
+                      Instruction *InsertBefore = 0)
     : AllocationInst(Ty, ArraySize, Malloc, Name, InsertBefore) {}
+  MallocInst(const Type *Ty, Value *ArraySize, const std::string &Name,
+             BasicBlock *InsertAtEnd)
+    : AllocationInst(Ty, ArraySize, Malloc, Name, InsertAtEnd) {}
 
   virtual Instruction *clone() const { 
     return new MallocInst(*this);
@@ -107,9 +115,13 @@
 class AllocaInst : public AllocationInst {
   AllocaInst(const AllocaInst &);
 public:
-  AllocaInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "",
-             Instruction *InsertBefore = 0)
+  explicit AllocaInst(const Type *Ty, Value *ArraySize = 0,
+                      const std::string &Name = "",
+                      Instruction *InsertBefore = 0)
     : AllocationInst(Ty, ArraySize, Alloca, Name, InsertBefore) {}
+  AllocaInst(const Type *Ty, Value *ArraySize, const std::string &Name,
+             BasicBlock *InsertAtEnd)
+    : AllocationInst(Ty, ArraySize, Alloca, Name, InsertAtEnd) {}
 
   virtual Instruction *clone() const { 
     return new AllocaInst(*this);
@@ -132,8 +144,12 @@
 
 /// FreeInst - an instruction to deallocate memory
 ///
-struct FreeInst : public Instruction {
-  FreeInst(Value *Ptr, Instruction *InsertBefore = 0);
+class FreeInst : public Instruction {
+  void init(Value *Ptr);
+
+public:
+  explicit FreeInst(Value *Ptr, Instruction *InsertBefore = 0);
+  FreeInst(Value *Ptr, BasicBlock *InsertAfter);
 
   virtual Instruction *clone() const { return new FreeInst(Operands[0]); }
 
@@ -169,8 +185,11 @@
   }
 public:
   LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
+  LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd);
   LoadInst(Value *Ptr, const std::string &Name = "", bool isVolatile = false,
            Instruction *InsertBefore = 0);
+  LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
+           BasicBlock *InsertAtEnd);
 
   /// isVolatile - Return true if this is a load from a volatile memory
   /// location.
@@ -221,8 +240,10 @@
   }
 public:
   StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
+  StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
   StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
             Instruction *InsertBefore = 0);
+  StoreInst(Value *Val, Value *Ptr, bool isVolatile, BasicBlock *InsertAtEnd);
 
 
   /// isVolatile - Return true if this is a load from a volatile memory
@@ -272,6 +293,8 @@
 public:
   GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
 		    const std::string &Name = "", Instruction *InsertBefore =0);
+  GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
+		    const std::string &Name, BasicBlock *InsertAtEnd);
   virtual Instruction *clone() const { return new GetElementPtrInst(*this); }
   
   // getType - Overload to return most specific pointer type...


Index: llvm/include/llvm/InstrTypes.h
diff -u llvm/include/llvm/InstrTypes.h:1.37 llvm/include/llvm/InstrTypes.h:1.38
--- llvm/include/llvm/InstrTypes.h:1.37	Wed May 26 16:41:09 2004
+++ llvm/include/llvm/InstrTypes.h	Wed May 26 19:15:23 2004
@@ -76,8 +76,17 @@
 
 class BinaryOperator : public Instruction {
 protected:
+  void init(BinaryOps iType, Value *S1, Value *S2);
   BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
-                 const std::string &Name, Instruction *InsertBefore);
+                 const std::string &Name, Instruction *InsertBefore)
+    : Instruction(Ty, iType, Name, InsertBefore) {
+    init(iType, S1, S2);
+  }
+  BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
+                 const std::string &Name, BasicBlock *InsertAtEnd)
+    : Instruction(Ty, iType, Name, InsertAtEnd) {
+    init(iType, S1, S2);
+  }
 
 public:
 
@@ -90,6 +99,14 @@
 				const std::string &Name = "",
                                 Instruction *InsertBefore = 0);
                                
+  /// create() - Construct a binary instruction, given the opcode and the two
+  /// operands.  Also automatically insert this instruction to the end of the
+  /// BasicBlock specified.
+  ///
+  static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2,
+				const std::string &Name,
+                                BasicBlock *InsertAtEnd);
+                               
 
   /// Helper functions to construct and inspect unary operations (NEG and NOT)
   /// via binary operators SUB and XOR:
@@ -99,8 +116,12 @@
   ///
   static BinaryOperator *createNeg(Value *Op, const std::string &Name = "",
                                    Instruction *InsertBefore = 0);
+  static BinaryOperator *createNeg(Value *Op, const std::string &Name,
+                                   BasicBlock *InsertAtEnd);
   static BinaryOperator *createNot(Value *Op, const std::string &Name = "",
                                    Instruction *InsertBefore = 0);
+  static BinaryOperator *createNot(Value *Op, const std::string &Name,
+                                   BasicBlock *InsertAtEnd);
 
   /// isNeg, isNot - Check if the given Value is a NEG or NOT instruction.
   ///





More information about the llvm-commits mailing list