Add AsmPrinter support for i128 and larger static initializer data.

llvm-svn: 55919
This commit is contained in:
Dan Gohman 2008-09-08 16:40:13 +00:00
parent 8f658bac2f
commit f9b2054df1
2 changed files with 44 additions and 18 deletions

View File

@ -1062,26 +1062,41 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
} }
return; return;
} else assert(0 && "Floating point constant type not handled"); } 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)) { 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!");
if (TAI->getData64bitsDirective()) // We don't expect assemblers to support integer data directives
O << TAI->getData64bitsDirective() << Val << '\n'; // for more than 64 bits, so we emit the data in at most 64-bit
else if (TD->isBigEndian()) { // quantities at a time.
O << TAI->getData32bitsDirective() << unsigned(Val >> 32) const uint64_t *RawData = CI->getValue().getRawData();
<< '\t' << TAI->getCommentString() for (unsigned i = 0, e = BitWidth / 64; i != e; ++i) {
<< " Double-word most significant word " << Val << '\n'; uint64_t Val;
O << TAI->getData32bitsDirective() << unsigned(Val) if (TD->isBigEndian())
<< '\t' << TAI->getCommentString() Val = RawData[e - i - 1];
<< " Double-word least significant word " << Val << '\n'; else
} else { Val = RawData[i];
O << TAI->getData32bitsDirective() << unsigned(Val)
<< '\t' << TAI->getCommentString() if (TAI->getData64bitsDirective())
<< " Double-word least significant word " << Val << '\n'; O << TAI->getData64bitsDirective() << Val << '\n';
O << TAI->getData32bitsDirective() << unsigned(Val >> 32) else if (TD->isBigEndian()) {
<< '\t' << TAI->getCommentString() O << TAI->getData32bitsDirective() << unsigned(Val >> 32)
<< " Double-word most significant word " << Val << '\n'; << '\t' << TAI->getCommentString()
<< " Double-word most significant word " << Val << '\n';
O << TAI->getData32bitsDirective() << unsigned(Val)
<< '\t' << TAI->getCommentString()
<< " Double-word least significant word " << Val << '\n';
} else {
O << TAI->getData32bitsDirective() << unsigned(Val)
<< '\t' << TAI->getCommentString()
<< " Double-word least significant word " << Val << '\n';
O << TAI->getData32bitsDirective() << unsigned(Val >> 32)
<< '\t' << TAI->getCommentString()
<< " Double-word most significant word " << Val << '\n';
}
} }
return; return;
} }
@ -1440,6 +1455,8 @@ void AsmPrinter::printDataDirective(const Type *type) {
assert(TAI->getData64bitsDirective() && assert(TAI->getData64bitsDirective() &&
"Target cannot handle 64-bit constant exprs!"); "Target cannot handle 64-bit constant exprs!");
O << TAI->getData64bitsDirective(); O << TAI->getData64bitsDirective();
} else {
assert(0 && "Target cannot handle given data directive width!");
} }
break; break;
} }

View 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