summaryrefslogtreecommitdiff
path: root/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorStepan Dyatkovskiy <stpworld@narod.ru>2012-05-28 12:39:09 +0000
committerStepan Dyatkovskiy <stpworld@narod.ru>2012-05-28 12:39:09 +0000
commit484fc93eff0295b1aa52b9a64d22346580e4b0e2 (patch)
treedbc21435d80fafd02b9ac6f182186edbcf010acc /lib/Bitcode/Reader/BitcodeReader.cpp
parentff208a79ced0377f5f6474b571a6a2168643e1e1 (diff)
downloadllvm-484fc93eff0295b1aa52b9a64d22346580e4b0e2.tar.gz
llvm-484fc93eff0295b1aa52b9a64d22346580e4b0e2.tar.bz2
llvm-484fc93eff0295b1aa52b9a64d22346580e4b0e2.tar.xz
PR1255: Case Ranges
Implemented IntItem - the wrapper around APInt. Why not to use APInt item directly right now? 1. It will very difficult to implement case ranges as series of small patches. We got several large and heavy patches. Each patch will about 90-120 kb. If you replace ConstantInt with APInt in SwitchInst you will need to changes at the same time all Readers,Writers and absolutely all passes that uses SwitchInst. 2. We can implement APInt pool inside and save memory space. E.g. we use several switches that works with 256 bit items (switch on signatures, or strings). We can avoid value duplicates in this case. 3. IntItem can be easyly easily replaced with APInt. 4. Currenly we can interpret IntItem both as ConstantInt and as APInt. It allows to provide SwitchInst methods that works with ConstantInt for non-updated passes. Why I need it right now? Currently I need to update SimplifyCFG pass (EqualityComparisons). I need to work with APInts directly a lot, so peaces of code ConstantInt *V = ...; if (V->getValue().ugt(AnotherV->getValue()) { ... } will look awful. Much more better this way: IntItem V = ConstantIntVal->getValue(); if (AnotherV < V) { } Of course any reviews are welcome. P.S.: I'm also going to rename ConstantRangesSet to IntegersSubset, and CRSBuilder to IntegersSubsetMapping (allows to map individual subsets of integers to the BasicBlocks). Since in future these classes will founded on APInt, it will possible to use them in more generic ways. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157576 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 5a132a4f2f..3477bbc02b 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2283,18 +2283,21 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
ActiveWords = Record[CurIdx++];
Low = ReadWideAPInt(&Record[CurIdx], ActiveWords, ValueBitWidth);
CurIdx += ActiveWords;
-
+
if (!isSingleNumber) {
ActiveWords = 1;
if (ValueBitWidth > 64)
ActiveWords = Record[CurIdx++];
APInt High =
ReadWideAPInt(&Record[CurIdx], ActiveWords, ValueBitWidth);
- CaseBuilder.add(cast<ConstantInt>(ConstantInt::get(OpTy, Low)),
- cast<ConstantInt>(ConstantInt::get(OpTy, High)));
+ IntItemConstantIntImpl HighImpl =
+ cast<ConstantInt>(ConstantInt::get(OpTy, High));
+
+ CaseBuilder.add(IntItem::fromType(OpTy, Low),
+ IntItem::fromType(OpTy, High));
CurIdx += ActiveWords;
} else
- CaseBuilder.add(cast<ConstantInt>(ConstantInt::get(OpTy, Low)));
+ CaseBuilder.add(IntItem::fromType(OpTy, Low));
}
BasicBlock *DestBB = getBasicBlock(Record[CurIdx++]);
ConstantRangesSet Case = CaseBuilder.getCase();