mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 05:29:24 +00:00
Add AsmPrinter support for i128 and larger static initializer data.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55919 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
863890e2fa
commit
82f94f1ad9
@ -1062,9 +1062,23 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
|
||||
}
|
||||
return;
|
||||
} else assert(0 && "Floating point constant type not handled");
|
||||
} else if (CV->getType() == Type::Int64Ty) {
|
||||
} else if (CV->getType()->isInteger() &&
|
||||
cast<IntegerType>(CV->getType())->getBitWidth() >= 64) {
|
||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
||||
uint64_t Val = CI->getZExtValue();
|
||||
unsigned BitWidth = CI->getBitWidth();
|
||||
assert(isPowerOf2_32(BitWidth) &&
|
||||
"Non-power-of-2-sized integers not handled!");
|
||||
|
||||
// We don't expect assemblers to support integer data directives
|
||||
// for more than 64 bits, so we emit the data in at most 64-bit
|
||||
// quantities at a time.
|
||||
const uint64_t *RawData = CI->getValue().getRawData();
|
||||
for (unsigned i = 0, e = BitWidth / 64; i != e; ++i) {
|
||||
uint64_t Val;
|
||||
if (TD->isBigEndian())
|
||||
Val = RawData[e - i - 1];
|
||||
else
|
||||
Val = RawData[i];
|
||||
|
||||
if (TAI->getData64bitsDirective())
|
||||
O << TAI->getData64bitsDirective() << Val << '\n';
|
||||
@ -1083,6 +1097,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
|
||||
<< '\t' << TAI->getCommentString()
|
||||
<< " Double-word most significant word " << Val << '\n';
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (const ConstantVector *CP = dyn_cast<ConstantVector>(CV)) {
|
||||
@ -1440,6 +1455,8 @@ void AsmPrinter::printDataDirective(const Type *type) {
|
||||
assert(TAI->getData64bitsDirective() &&
|
||||
"Target cannot handle 64-bit constant exprs!");
|
||||
O << TAI->getData64bitsDirective();
|
||||
} else {
|
||||
assert(0 && "Target cannot handle given data directive width!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
9
test/CodeGen/Generic/i128-and-beyond.ll
Normal file
9
test/CodeGen/Generic/i128-and-beyond.ll
Normal file
@ -0,0 +1,9 @@
|
||||
; RUN: llvm-as < %s | llc -march=x86 | grep 18446744073709551615 | count 14
|
||||
; RUN: llvm-as < %s | llc -march=ppc32 | grep 4294967295 | count 28
|
||||
|
||||
; These static initializers are too big to hand off to assemblers
|
||||
; as monolithic blobs.
|
||||
|
||||
@x = global i128 -1
|
||||
@y = global i256 -1
|
||||
@z = global i512 -1
|
Loading…
Reference in New Issue
Block a user