1 //===-- iSwitch.cpp - Implement the Switch instruction -----------*- C++ -*--=//
3 // This file implements the Switch instruction...
5 //===----------------------------------------------------------------------===//
7 #include "llvm/iTerminators.h"
8 #include "llvm/BasicBlock.h"
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));
18 SwitchInst::SwitchInst(const SwitchInst &SI)
19 : TerminatorInst(Instruction::Switch) {
20 Operands.reserve(SI.Operands.size());
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));
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));