2001-06-06 20:29:01 +00:00
|
|
|
//===-- iSwitch.cpp - Implement the Switch instruction -----------*- C++ -*--=//
|
|
|
|
//
|
|
|
|
// This file implements the Switch instruction...
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/iTerminators.h"
|
|
|
|
#include "llvm/BasicBlock.h"
|
|
|
|
|
2002-09-10 15:45:53 +00:00
|
|
|
SwitchInst::SwitchInst(Value *V, BasicBlock *DefaultDest,
|
|
|
|
Instruction *InsertBefore)
|
|
|
|
: TerminatorInst(Instruction::Switch, InsertBefore) {
|
|
|
|
assert(V && DefaultDest);
|
2001-07-07 08:36:50 +00:00
|
|
|
Operands.push_back(Use(V, this));
|
2002-09-10 15:45:53 +00:00
|
|
|
Operands.push_back(Use(DefaultDest, this));
|
2001-06-06 20:29:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwitchInst::SwitchInst(const SwitchInst &SI)
|
2001-07-07 08:36:50 +00:00
|
|
|
: TerminatorInst(Instruction::Switch) {
|
|
|
|
Operands.reserve(SI.Operands.size());
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-07-07 08:36:50 +00: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-06 20:29:01 +00:00
|
|
|
}
|
|
|
|
|
2001-12-03 22:26:30 +00:00
|
|
|
void SwitchInst::dest_push_back(Constant *OnVal, BasicBlock *Dest) {
|
2002-04-09 18:37:08 +00:00
|
|
|
Operands.push_back(Use((Value*)OnVal, this));
|
|
|
|
Operands.push_back(Use((Value*)Dest, this));
|
2001-06-06 20:29:01 +00:00
|
|
|
}
|