2001-06-07 04:29:01 +08:00
|
|
|
//===-- 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
|
|
|
|
|
2001-07-07 16:36:50 +08:00
|
|
|
SwitchInst::SwitchInst(Value *V, BasicBlock *DefDest)
|
|
|
|
: TerminatorInst(Instruction::Switch) {
|
|
|
|
assert(V && DefDest);
|
|
|
|
Operands.push_back(Use(V, this));
|
|
|
|
Operands.push_back(Use(DefDest, this));
|
2001-06-07 04:29:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SwitchInst::SwitchInst(const SwitchInst &SI)
|
2001-07-07 16:36:50 +08:00
|
|
|
: TerminatorInst(Instruction::Switch) {
|
|
|
|
Operands.reserve(SI.Operands.size());
|
2001-06-07 04:29:01 +08:00
|
|
|
|
2001-07-07 16:36:50 +08:00
|
|
|
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));
|
|
|
|
}
|
2001-06-07 04:29:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwitchInst::dest_push_back(ConstPoolVal *OnVal, BasicBlock *Dest) {
|
2001-07-07 16:36:50 +08:00
|
|
|
Operands.push_back(Use(OnVal, this));
|
|
|
|
Operands.push_back(Use(Dest, this));
|
2001-06-07 04:29:01 +08:00
|
|
|
}
|