mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-22 10:24:26 +00:00
Implement writing of arbitrary precision integers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34717 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -307,13 +307,23 @@ void BytecodeWriter::outputConstant(const Constant *CPV) {
|
|||||||
|
|
||||||
switch (CPV->getType()->getTypeID()) {
|
switch (CPV->getType()->getTypeID()) {
|
||||||
case Type::IntegerTyID: { // Integer types...
|
case Type::IntegerTyID: { // Integer types...
|
||||||
|
const ConstantInt *CI = cast<ConstantInt>(CPV);
|
||||||
unsigned NumBits = cast<IntegerType>(CPV->getType())->getBitWidth();
|
unsigned NumBits = cast<IntegerType>(CPV->getType())->getBitWidth();
|
||||||
if (NumBits <= 32)
|
if (NumBits <= 32)
|
||||||
output_vbr(uint32_t(cast<ConstantInt>(CPV)->getZExtValue()));
|
output_vbr(uint32_t(CI->getZExtValue()));
|
||||||
else if (NumBits <= 64)
|
else if (NumBits <= 64)
|
||||||
output_vbr(uint64_t(cast<ConstantInt>(CPV)->getZExtValue()));
|
output_vbr(uint64_t(CI->getZExtValue()));
|
||||||
else
|
else {
|
||||||
assert(0 && "Integer types > 64 bits not supported.");
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user