Add convenience ctor to BranchInst
[oota-llvm.git] / lib / VMCore / iSwitch.cpp
1 //===-- iSwitch.cpp - Implement the Switch instruction -----------*- C++ -*--=//
2 //
3 // This file implements the Switch instruction...
4 //
5 //===----------------------------------------------------------------------===//
6
7 #include "llvm/iTerminators.h"
8 #include "llvm/BasicBlock.h"
9
10 SwitchInst::SwitchInst(Value *V, BasicBlock *DefaultDest,
11                        Instruction *InsertBefore) 
12   : TerminatorInst(Instruction::Switch, InsertBefore) {
13   assert(V && DefaultDest);
14   Operands.push_back(Use(V, this));
15   Operands.push_back(Use(DefaultDest, this));
16 }
17
18 SwitchInst::SwitchInst(const SwitchInst &SI) 
19   : TerminatorInst(Instruction::Switch) {
20   Operands.reserve(SI.Operands.size());
21
22   for (unsigned i = 0, E = SI.Operands.size(); i != E; i+=2) {
23     Operands.push_back(Use(SI.Operands[i], this));
24     Operands.push_back(Use(SI.Operands[i+1], this));
25   }
26 }
27
28 void SwitchInst::dest_push_back(Constant *OnVal, BasicBlock *Dest) {
29   Operands.push_back(Use((Value*)OnVal, this));
30   Operands.push_back(Use((Value*)Dest, this));
31 }