aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-02-28 02:25:20 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-02-28 02:25:20 +0000
commit9abd138a309d3810ee84e4227ca33091423d9729 (patch)
tree62558cacf2ee3164d86e49112b16f46daa84383a /lib/Bytecode
parent38c91a9927523099189149a515418b116c3aefd5 (diff)
Implement writing of arbitrary precision integers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34717 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Writer/Writer.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index de15267d5c..e0aa110d5c 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -307,13 +307,23 @@ void BytecodeWriter::outputConstant(const Constant *CPV) {
switch (CPV->getType()->getTypeID()) {
case Type::IntegerTyID: { // Integer types...
+ const ConstantInt *CI = cast<ConstantInt>(CPV);
unsigned NumBits = cast<IntegerType>(CPV->getType())->getBitWidth();
if (NumBits <= 32)
- output_vbr(uint32_t(cast<ConstantInt>(CPV)->getZExtValue()));
+ output_vbr(uint32_t(CI->getZExtValue()));
else if (NumBits <= 64)
- output_vbr(uint64_t(cast<ConstantInt>(CPV)->getZExtValue()));
- else
- assert(0 && "Integer types > 64 bits not supported.");
+ output_vbr(uint64_t(CI->getZExtValue()));
+ else {
+ // We have an arbitrary precision integer value to write whose
+ // bit width is > 64. However, in canonical unsigned integer
+ // format it is likely that the high bits are going to be zero.
+ // So, we only write the number of active words.
+ uint32_t activeWords = CI->getValue().getActiveWords();
+ const uint64_t *rawData = CI->getValue().getRawData();
+ output_vbr(activeWords);
+ for (uint32_t i = 0; i < activeWords; ++i)
+ output_vbr(rawData[i]);
+ }
break;
}