summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore
diff options
context:
space:
mode:
authorStepan Dyatkovskiy <stpworld@narod.ru>2012-05-12 10:48:17 +0000
committerStepan Dyatkovskiy <stpworld@narod.ru>2012-05-12 10:48:17 +0000
commit0beab5e1cde833214271d533afea5405aae7e0ce (patch)
treedab10bdcbf0fa2c6fa0d069354a47feca9f94fbf /llvm/lib/VMCore
parentca0c4996098068828c7688103cd0a80edf8cba09 (diff)
downloadbcm5719-llvm-0beab5e1cde833214271d533afea5405aae7e0ce.tar.gz
bcm5719-llvm-0beab5e1cde833214271d533afea5405aae7e0ce.zip
Recommited r156374 with critical fixes in BitcodeReader/Writer:
Ordinary patch for PR1255. Added new case-ranges orientated methods for adding/removing cases in SwitchInst. After this patch cases will internally representated as ConstantArray-s instead of ConstantInt, externally cases wrapped within the ConstantRangesSet object. Old methods of SwitchInst are also works well, but marked as deprecated. So on this stage we have no side effects except that I added support for case ranges in BitcodeReader/Writer, of course test for Bitcode is also added. Old "switch" format is also supported. llvm-svn: 156704
Diffstat (limited to 'llvm/lib/VMCore')
-rw-r--r--llvm/lib/VMCore/Instructions.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index 6c5db328764..819a090cc3c 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -3169,6 +3169,13 @@ SwitchInst::~SwitchInst() {
/// addCase - Add an entry to the switch instruction...
///
void SwitchInst::addCase(ConstantInt *OnVal, BasicBlock *Dest) {
+ CRSBuilder CB;
+ CB.add(OnVal);
+ ConstantRangesSet CRS = CB.getCase();
+ addCase(CRS, Dest);
+}
+
+void SwitchInst::addCase(ConstantRangesSet& OnVal, BasicBlock *Dest) {
unsigned NewCaseIdx = getNumCases();
unsigned OpNo = NumOperands;
if (OpNo+2 > ReservedSpace)
@@ -3177,7 +3184,7 @@ void SwitchInst::addCase(ConstantInt *OnVal, BasicBlock *Dest) {
assert(OpNo+1 < ReservedSpace && "Growing didn't work!");
NumOperands = OpNo+2;
CaseIt Case(this, NewCaseIdx);
- Case.setValue(OnVal);
+ Case.setValueEx(OnVal);
Case.setSuccessor(Dest);
}
OpenPOWER on IntegriCloud