[llvm-commits] CVS: llvm/include/llvm/iTerminators.h iMemory.h Instruction.h InstrTypes.h

Alkis Evlogimenos alkis at cs.uiuc.edu
Wed May 26 16:45:02 PDT 2004


Changes in directory llvm/include/llvm:

iTerminators.h updated: 1.40 -> 1.41
iMemory.h updated: 1.44 -> 1.45
Instruction.h updated: 1.52 -> 1.53
InstrTypes.h updated: 1.36 -> 1.37

---
Log message:

Refactor common initialization code in private init() functions.

This is a first step in supplying append to basic block constructors
for all instruction types.


---
Diffs of the changes:  (+37 -10)

Index: llvm/include/llvm/iTerminators.h
diff -u llvm/include/llvm/iTerminators.h:1.40 llvm/include/llvm/iTerminators.h:1.41
--- llvm/include/llvm/iTerminators.h:1.40	Thu Feb 26 17:20:29 2004
+++ llvm/include/llvm/iTerminators.h	Wed May 26 16:41:09 2004
@@ -32,6 +32,14 @@
       Operands.push_back(Use(RI.Operands[0], this));
     }
   }
+
+  void init(Value *RetVal) {
+    if (RetVal) {
+      Operands.reserve(1);
+      Operands.push_back(Use(RetVal, this));
+    }
+  }
+
 public:
   // ReturnInst constructors:
   // ReturnInst()                  - 'ret void' instruction
@@ -42,17 +50,11 @@
   // ReturnInst(Value* X, BB *B)   - 'ret X'    instruction, insert @ end of BB
   ReturnInst(Value *RetVal = 0, Instruction *InsertBefore = 0)
     : TerminatorInst(Instruction::Ret, InsertBefore) {
-    if (RetVal) {
-      Operands.reserve(1);
-      Operands.push_back(Use(RetVal, this));
-    }
+    init(RetVal);
   }
   ReturnInst(Value *RetVal, BasicBlock *InsertAtEnd)
     : TerminatorInst(Instruction::Ret, InsertAtEnd) {
-    if (RetVal) {
-      Operands.reserve(1);
-      Operands.push_back(Use(RetVal, this));
-    }
+    init(RetVal);
   }
 
   virtual Instruction *clone() const { return new ReturnInst(*this); }
@@ -87,6 +89,8 @@
 ///
 class BranchInst : public TerminatorInst {
   BranchInst(const BranchInst &BI);
+  void init(BasicBlock *IfTrue);
+  void init(BasicBlock *True, BasicBlock *False, Value *Cond);
 public:
   // BranchInst constructors (where {B, T, F} are blocks, and C is a condition):
   // BranchInst(BB *B)                           - 'br B'
@@ -161,6 +165,8 @@
   // Operand[2n  ] = Value to match
   // Operand[2n+1] = BasicBlock to go to on match
   SwitchInst(const SwitchInst &RI);
+  void init(Value *Value, BasicBlock *Default);
+
 public:
   SwitchInst(Value *Value, BasicBlock *Default, Instruction *InsertBefore = 0);
   SwitchInst(Value *Value, BasicBlock *Default, BasicBlock  *InsertAtEnd);
@@ -259,6 +265,8 @@
 ///
 class InvokeInst : public TerminatorInst {
   InvokeInst(const InvokeInst &BI);
+  void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
+            const std::vector<Value*> &Params);
 public:
   InvokeInst(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
 	     const std::vector<Value*> &Params, const std::string &Name = "",


Index: llvm/include/llvm/iMemory.h
diff -u llvm/include/llvm/iMemory.h:1.44 llvm/include/llvm/iMemory.h:1.45
--- llvm/include/llvm/iMemory.h:1.44	Tue Feb 10 12:44:16 2004
+++ llvm/include/llvm/iMemory.h	Wed May 26 16:41:09 2004
@@ -163,6 +163,10 @@
     Operands.push_back(Use(LI.Operands[0], this));
   }
   bool Volatile;   // True if this is a volatile load
+  void init(Value *Ptr) {
+    Operands.reserve(1);
+    Operands.push_back(Use(Ptr, this));
+  }
 public:
   LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
   LoadInst(Value *Ptr, const std::string &Name = "", bool isVolatile = false,
@@ -210,6 +214,11 @@
     Operands.push_back(Use(SI.Operands[1], this));
   }
   bool Volatile;   // True if this is a volatile store
+  void init(Value *Val, Value *Ptr) {
+    Operands.reserve(2);
+    Operands.push_back(Use(Val, this));
+    Operands.push_back(Use(Ptr, this));
+  }
 public:
   StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
   StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
@@ -258,6 +267,8 @@
     for (unsigned i = 0, E = EPI.Operands.size(); i != E; ++i)
       Operands.push_back(Use(EPI.Operands[i], this));
   }
+  void init(Value *Ptr, const std::vector<Value*> &Idx);
+
 public:
   GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
 		    const std::string &Name = "", Instruction *InsertBefore =0);


Index: llvm/include/llvm/Instruction.h
diff -u llvm/include/llvm/Instruction.h:1.52 llvm/include/llvm/Instruction.h:1.53
--- llvm/include/llvm/Instruction.h:1.52	Fri Apr 16 10:46:43 2004
+++ llvm/include/llvm/Instruction.h	Wed May 26 16:41:09 2004
@@ -36,11 +36,15 @@
   friend class SymbolTableListTraits<Instruction, BasicBlock, Function,
                                      ilist_traits<Instruction> >;
   void setParent(BasicBlock *P);
+  void init();
+
 protected:
   unsigned iType;      // InstructionType: The opcode of the instruction
 
   Instruction(const Type *Ty, unsigned iType, const std::string &Name = "",
               Instruction *InsertBefore = 0);
+  Instruction(const Type *Ty, unsigned iType, const std::string &Name,
+              BasicBlock *InsertAtEnd);
 public:
 
   ~Instruction() {


Index: llvm/include/llvm/InstrTypes.h
diff -u llvm/include/llvm/InstrTypes.h:1.36 llvm/include/llvm/InstrTypes.h:1.37
--- llvm/include/llvm/InstrTypes.h:1.36	Thu Nov 20 11:44:37 2003
+++ llvm/include/llvm/InstrTypes.h	Wed May 26 16:41:09 2004
@@ -32,9 +32,13 @@
   TerminatorInst(Instruction::TermOps iType, Instruction *InsertBefore = 0);
   TerminatorInst(const Type *Ty, Instruction::TermOps iType,
                  const std::string &Name = "", Instruction *InsertBefore = 0)
-    : Instruction(Ty, iType, Name, InsertBefore) {
-  }
+    : Instruction(Ty, iType, Name, InsertBefore) {}
+
   TerminatorInst(Instruction::TermOps iType, BasicBlock *InsertAtEnd);
+  TerminatorInst(const Type *Ty, Instruction::TermOps iType,
+                 const std::string &Name, BasicBlock *InsertAtEnd)
+    : Instruction(Ty, iType, Name, InsertAtEnd) {}
+
 public:
 
   /// Terminators must implement the methods required by Instruction...





More information about the llvm-commits mailing list