simplify the rest of fp constant printing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93929 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-19 22:16:33 +00:00
parent 72b5ebc6be
commit 09ce674ce8

View File

@ -1140,66 +1140,41 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
// precision... // precision...
const TargetData &TD = *TM.getTargetData(); const TargetData &TD = *TM.getTargetData();
if (CFP->getType()->isDoubleTy()) { if (CFP->getType()->isDoubleTy()) {
double Val = CFP->getValueAPF().convertToDouble(); // for comment only if (VerboseAsm) {
double Val = CFP->getValueAPF().convertToDouble(); // for comment only
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << " double " << Val << '\n';
}
uint64_t i = CFP->getValueAPF().bitcastToAPInt().getZExtValue(); uint64_t i = CFP->getValueAPF().bitcastToAPInt().getZExtValue();
if (MAI->getData64bitsDirective(AddrSpace)) { if (MAI->getData64bitsDirective(AddrSpace)) {
O << MAI->getData64bitsDirective(AddrSpace) << i; O << MAI->getData64bitsDirective(AddrSpace) << i << '\n';
if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << " double " << Val;
}
O << '\n';
} else if (TD.isBigEndian()) { } else if (TD.isBigEndian()) {
O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32); O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32) << '\n';
if (VerboseAsm) { O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i) << '\n';
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< " most significant word of double " << Val;
}
O << '\n';
O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i);
if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< " least significant word of double " << Val;
}
O << '\n';
} else { } else {
O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i); O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i) << '\n';
if (VerboseAsm) { O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32) << '\n';
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< " least significant word of double " << Val;
}
O << '\n';
O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32);
if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< " most significant word of double " << Val;
}
O << '\n';
} }
return; return;
} }
if (CFP->getType()->isFloatTy()) { if (CFP->getType()->isFloatTy()) {
float Val = CFP->getValueAPF().convertToFloat(); // for comment only
O << MAI->getData32bitsDirective(AddrSpace)
<< CFP->getValueAPF().bitcastToAPInt().getZExtValue();
if (VerboseAsm) { if (VerboseAsm) {
float Val = CFP->getValueAPF().convertToFloat(); // for comment only
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << " float " << Val; O << MAI->getCommentString() << " float " << Val << '\n';
} }
O << '\n'; O << MAI->getData32bitsDirective(AddrSpace)
<< CFP->getValueAPF().bitcastToAPInt().getZExtValue() << '\n';
return; return;
} }
if (CFP->getType()->isX86_FP80Ty()) { if (CFP->getType()->isX86_FP80Ty()) {
// all long double variants are printed as hex // all long double variants are printed as hex
// api needed to prevent premature destruction // api needed to prevent premature destruction
APInt api = CFP->getValueAPF().bitcastToAPInt(); APInt API = CFP->getValueAPF().bitcastToAPInt();
const uint64_t *p = api.getRawData(); const uint64_t *p = API.getRawData();
if (VerboseAsm) { if (VerboseAsm) {
// Convert to double so we can print the approximate val as a comment. // Convert to double so we can print the approximate val as a comment.
APFloat DoubleVal = CFP->getValueAPF(); APFloat DoubleVal = CFP->getValueAPF();
@ -1229,72 +1204,23 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
return; return;
} }
if (CFP->getType()->isPPC_FP128Ty()) { assert(CFP->getType()->isPPC_FP128Ty() &&
// all long double variants are printed as hex "Floating point constant type not handled");
// api needed to prevent premature destruction // All long double variants are printed as hex api needed to prevent
APInt api = CFP->getValueAPF().bitcastToAPInt(); // premature destruction.
const uint64_t *p = api.getRawData(); APInt API = CFP->getValueAPF().bitcastToAPInt();
if (TD.isBigEndian()) { const uint64_t *p = API.getRawData();
O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32); if (TD.isBigEndian()) {
if (VerboseAsm) { O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32)<<'\n';
O.PadToColumn(MAI->getCommentColumn()); O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0])<<'\n';
O << MAI->getCommentString() O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32)<<'\n';
<< " most significant word of ppc_fp128"; O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1])<<'\n';
} } else {
O << '\n'; O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1])<<'\n';
O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]); O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32)<<'\n';
if (VerboseAsm) { O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0])<<'\n';
O.PadToColumn(MAI->getCommentColumn()); O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32)<<'\n';
O << MAI->getCommentString() }
<< " next word";
}
O << '\n';
O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< " next word";
}
O << '\n';
O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< " least significant word";
}
O << '\n';
} else {
O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< " least significant word of ppc_fp128";
}
O << '\n';
O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< " next word";
}
O << '\n';
O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< " next word";
}
O << '\n';
O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32);
if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< " most significant word";
}
O << '\n';
}
return;
} else llvm_unreachable("Floating point constant type not handled");
} }
void AsmPrinter::EmitGlobalConstantLargeInt(const ConstantInt *CI, void AsmPrinter::EmitGlobalConstantLargeInt(const ConstantInt *CI,