summaryrefslogtreecommitdiff
path: root/lib/VMCore/iSwitch.cpp
blob: e5e3c50cfd5efa0c3916cc29f9f7d4151cc0ec36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//===-- iSwitch.cpp - Implement the Switch instruction -----------*- C++ -*--=//
//
// This file implements the Switch instruction...
//
//===----------------------------------------------------------------------===//

#include "llvm/iTerminators.h"
#include "llvm/BasicBlock.h"
#ifndef NDEBUG
#include "llvm/Type.h"
#endif

SwitchInst::SwitchInst(Value *V, BasicBlock *DefDest) 
  : TerminatorInst(Instruction::Switch) {
  assert(V && DefDest);
  Operands.push_back(Use(V, this));
  Operands.push_back(Use(DefDest, this));
}

SwitchInst::SwitchInst(const SwitchInst &SI) 
  : TerminatorInst(Instruction::Switch) {
  Operands.reserve(SI.Operands.size());

  for (unsigned i = 0, E = SI.Operands.size(); i != E; i+=2) {
    Operands.push_back(Use(SI.Operands[i], this));
    Operands.push_back(Use(SI.Operands[i+1], this));
  }
}

void SwitchInst::dest_push_back(ConstPoolVal *OnVal, BasicBlock *Dest) {
  Operands.push_back(Use(OnVal, this));
  Operands.push_back(Use(Dest, this));
}