[llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp
Reid Spencer
reid at x10sys.com
Tue Feb 27 18:25:36 PST 2007
Changes in directory llvm/lib/Bytecode/Writer:
Writer.cpp updated: 1.168 -> 1.169
---
Log message:
Implement writing of arbitrary precision integers.
---
Diffs of the changes: (+14 -4)
Writer.cpp | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
Index: llvm/lib/Bytecode/Writer/Writer.cpp
diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.168 llvm/lib/Bytecode/Writer/Writer.cpp:1.169
--- llvm/lib/Bytecode/Writer/Writer.cpp:1.168 Wed Feb 14 20:26:09 2007
+++ llvm/lib/Bytecode/Writer/Writer.cpp Tue Feb 27 20:25:20 2007
@@ -307,13 +307,23 @@
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;
}
More information about the llvm-commits
mailing list