diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-02-28 02:25:20 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-02-28 02:25:20 +0000 |
commit | 90c26a31acab7067ec71fae5aa2c4282977e2671 (patch) | |
tree | 1c9240f61d28c50495d77ed6e8777883de14d14b /llvm/lib/Bytecode | |
parent | c7a686b62d77a9753515fb371b1a26bd69b11072 (diff) | |
download | bcm5719-llvm-90c26a31acab7067ec71fae5aa2c4282977e2671.tar.gz bcm5719-llvm-90c26a31acab7067ec71fae5aa2c4282977e2671.zip |
Implement writing of arbitrary precision integers.
llvm-svn: 34717
Diffstat (limited to 'llvm/lib/Bytecode')
-rw-r--r-- | llvm/lib/Bytecode/Writer/Writer.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp index de15267d5ca..e0aa110d5cc 100644 --- a/llvm/lib/Bytecode/Writer/Writer.cpp +++ b/llvm/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; } |