Add invokeinst and callinst ctors that don't take vectors.
authorChris Lattner <sabre@nondot.org>
Tue, 13 Feb 2007 01:04:01 +0000 (01:04 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 13 Feb 2007 01:04:01 +0000 (01:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34214 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Instructions.h
lib/VMCore/Instructions.cpp

index 70ae0e694fcb197774f87bda2c8d4afea235dc28..1c3ca0f614507a018dd2603701ff48d187e5184f 100644 (file)
@@ -695,6 +695,11 @@ class CallInst : public Instruction {
   void init(Value *Func);
 
 public:
+  CallInst(Value *F, Value* const *Args, unsigned NumArgs,
+           const std::string &Name = "", Instruction *InsertBefore = 0);
+  CallInst(Value *F, Value *const *Args, unsigned NumArgs,
+           const std::string &Name, BasicBlock *InsertAtEnd);
+  
   CallInst(Value *F, const std::vector<Value*> &Par,
            const std::string &Name = "", Instruction *InsertBefore = 0);
   CallInst(Value *F, const std::vector<Value*> &Par,
@@ -1479,7 +1484,7 @@ 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 = "",
@@ -1487,6 +1492,12 @@ public:
   InvokeInst(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
              const std::vector<Value*> &Params, const std::string &Name,
              BasicBlock *InsertAtEnd);
+  InvokeInst(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
+             Value* const* Args, unsigned NumArgs, const std::string &Name = "",
+             Instruction *InsertBefore = 0);
+  InvokeInst(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
+             Value* const* Args, unsigned NumArgs, const std::string &Name,
+             BasicBlock *InsertAtEnd);
   ~InvokeInst();
 
   virtual InvokeInst *clone() const;
index e02175585a7a42d7a0feb7816e03ed25d10e92a9..bc4281cb465bf10c239e6070cd8a0d80a1bb30c7 100644 (file)
@@ -276,14 +276,30 @@ CallInst::CallInst(Value *Func, const std::vector<Value*> &Params,
   init(Func, &Params[0], Params.size());
 }
 
-CallInst::CallInst(Value *Func, const std::vector<Value*> &Params,
+CallInst::CallInst(Value *Func, Value* const *Args, unsigned NumArgs,
                    const std::string &Name, BasicBlock *InsertAtEnd)
   : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
                                  ->getElementType())->getReturnType(),
                 Instruction::Call, 0, 0, Name, InsertAtEnd) {
+  init(Func, Args, NumArgs);
+}
+CallInst::CallInst(Value *Func, Value* const *Args, unsigned NumArgs,
+                   const std::string &Name, Instruction *InsertBefore)
+: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
+                                 ->getElementType())->getReturnType(),
+              Instruction::Call, 0, 0, Name, InsertBefore) {
+  init(Func, Args, NumArgs);
+}
+
+CallInst::CallInst(Value *Func, const std::vector<Value*> &Params,
+                   const std::string &Name, BasicBlock *InsertAtEnd)
+: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
+                                 ->getElementType())->getReturnType(),
+              Instruction::Call, 0, 0, Name, InsertAtEnd) {
   init(Func, &Params[0], Params.size());
 }
 
+
 CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2,
                    const std::string &Name, Instruction  *InsertBefore)
   : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
@@ -352,9 +368,9 @@ InvokeInst::~InvokeInst() {
 }
 
 void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
-                      const std::vector<Value*> &Params) {
-  NumOperands = 3+Params.size();
-  Use *OL = OperandList = new Use[3+Params.size()];
+                      Value* const *Args, unsigned NumArgs) {
+  NumOperands = 3+NumArgs;
+  Use *OL = OperandList = new Use[3+NumArgs];
   OL[0].init(Fn, this);
   OL[1].init(IfNormal, this);
   OL[2].init(IfException, this);
@@ -362,19 +378,39 @@ void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
     cast<FunctionType>(cast<PointerType>(Fn->getType())->getElementType());
   FTy = FTy;  // silence warning.
 
-  assert((Params.size() == FTy->getNumParams()) ||
-         (FTy->isVarArg() && Params.size() > FTy->getNumParams()) &&
+  assert((NumArgs == FTy->getNumParams()) ||
+         (FTy->isVarArg() && NumArgs > FTy->getNumParams()) &&
          "Calling a function with bad signature");
 
-  for (unsigned i = 0, e = Params.size(); i != e; i++) {
+  for (unsigned i = 0, e = NumArgs; i != e; i++) {
     assert((i >= FTy->getNumParams() || 
-            FTy->getParamType(i) == Params[i]->getType()) &&
+            FTy->getParamType(i) == Args[i]->getType()) &&
            "Invoking a function with a bad signature!");
     
-    OL[i+3].init(Params[i], this);
+    OL[i+3].init(Args[i], this);
   }
 }
 
+InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,
+                       BasicBlock *IfException,
+                       Value* const *Args, unsigned NumArgs,
+                       const std::string &Name, Instruction *InsertBefore)
+  : TerminatorInst(cast<FunctionType>(cast<PointerType>(Fn->getType())
+                                    ->getElementType())->getReturnType(),
+                   Instruction::Invoke, 0, 0, Name, InsertBefore) {
+  init(Fn, IfNormal, IfException, Args, NumArgs);
+}
+
+InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,
+                       BasicBlock *IfException,
+                       Value* const *Args, unsigned NumArgs,
+                       const std::string &Name, BasicBlock *InsertAtEnd)
+  : TerminatorInst(cast<FunctionType>(cast<PointerType>(Fn->getType())
+                                    ->getElementType())->getReturnType(),
+                   Instruction::Invoke, 0, 0, Name, InsertAtEnd) {
+  init(Fn, IfNormal, IfException, Args, NumArgs);
+}
+
 InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,
                        BasicBlock *IfException,
                        const std::vector<Value*> &Params,
@@ -382,7 +418,7 @@ InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,
   : TerminatorInst(cast<FunctionType>(cast<PointerType>(Fn->getType())
                                     ->getElementType())->getReturnType(),
                    Instruction::Invoke, 0, 0, Name, InsertBefore) {
-  init(Fn, IfNormal, IfException, Params);
+  init(Fn, IfNormal, IfException, &Params[0], Params.size());
 }
 
 InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,
@@ -392,7 +428,7 @@ InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,
   : TerminatorInst(cast<FunctionType>(cast<PointerType>(Fn->getType())
                                     ->getElementType())->getReturnType(),
                    Instruction::Invoke, 0, 0, Name, InsertAtEnd) {
-  init(Fn, IfNormal, IfException, Params);
+  init(Fn, IfNormal, IfException, &Params[0], Params.size());
 }
 
 InvokeInst::InvokeInst(const InvokeInst &II)