diff options
author | Chris Lattner <sabre@nondot.org> | 2004-08-17 21:38:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-08-17 21:38:40 +0000 |
commit | ea7519999639f6a6bdd57390f90fc737004ae2ef (patch) | |
tree | 0317eee64ffb9ef2de55f96038e9547a3c8acd3f /llvm/lib/CodeGen/AsmPrinter.cpp | |
parent | faa6e51d6e96963514063cf870341ab13a69acf8 (diff) | |
download | bcm5719-llvm-ea7519999639f6a6bdd57390f90fc737004ae2ef.tar.gz bcm5719-llvm-ea7519999639f6a6bdd57390f90fc737004ae2ef.zip |
Add support for targets without a .zero directive
llvm-svn: 15894
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp index 35733c85646..9d99bdc4cde 100644 --- a/llvm/lib/CodeGen/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter.cpp @@ -39,6 +39,25 @@ void AsmPrinter::emitAlignment(unsigned NumBits) const { O << AlignDirective << NumBits << "\n"; } +/// emitZeros - Emit a block of zeros. +/// +void AsmPrinter::emitZeros(unsigned NumZeros) const { + if (NumZeros) { + if (ZeroDirective) + O << ZeroDirective << NumZeros << "\n"; + else { + if (NumZeros >= 8 && Data64bitsDirective) { + for (; NumZeros >= 8; NumZeros -= 8) + O << Data64bitsDirective << "0\n"; + } + for (; NumZeros >= 4; NumZeros -= 4) + O << Data32bitsDirective << "0\n"; + for (; NumZeros; --NumZeros) + O << Data8bitsDirective << "0\n"; + } + } +} + // Print out the specified constant, without a storage class. Only the // constants valid in constant expressions can occur here. void AsmPrinter::emitConstantValueOnly(const Constant *CV) { @@ -159,7 +178,7 @@ void AsmPrinter::emitGlobalConstant(const Constant *CV) { const TargetData &TD = TM.getTargetData(); if (CV->isNullValue()) { - O << ZeroDirective << TD.getTypeSize(CV->getType()) << "\n"; + emitZeros(TD.getTypeSize(CV->getType())); return; } else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) { if (CVA->isString()) { @@ -189,8 +208,7 @@ void AsmPrinter::emitGlobalConstant(const Constant *CV) { emitGlobalConstant(field); // Insert the field padding unless it's zero bytes... - if (padSize) - O << ZeroDirective << padSize << "\n"; + emitZeros(padSize); } assert(sizeSoFar == cvsLayout->StructSize && "Layout of constant struct may be incorrect!"); @@ -207,7 +225,8 @@ void AsmPrinter::emitGlobalConstant(const Constant *CV) { U.FVal = Val; if (Data64bitsDirective) - O << Data64bitsDirective << U.UVal << "\n"; + O << Data64bitsDirective << U.UVal << "\t" << CommentChar + << " double value: " << Val << "\n"; else if (TD.isBigEndian()) { O << Data32bitsDirective << unsigned(U.UVal >> 32) << "\t" << CommentChar << " double most significant word " |