aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/PowerPC/PPC32AsmPrinter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-08-17 02:48:44 +0000
committerChris Lattner <sabre@nondot.org>2004-08-17 02:48:44 +0000
commit469ab79584cd31d9f632988abccefc16c7a215e0 (patch)
treed8b2f0be3789a7cdf89b8b0fb1bfb07fd7c31fad /lib/Target/PowerPC/PPC32AsmPrinter.cpp
parent505e783d8cecda3262eb5ef24326ef2e74da2ce3 (diff)
Print float constants as 4 byte values.
Also, fix endianness problems when cross compiling from little-endian host. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15847 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPC32AsmPrinter.cpp')
-rw-r--r--lib/Target/PowerPC/PPC32AsmPrinter.cpp47
1 files changed, 25 insertions, 22 deletions
diff --git a/lib/Target/PowerPC/PPC32AsmPrinter.cpp b/lib/Target/PowerPC/PPC32AsmPrinter.cpp
index 42030ff141..798a908c65 100644
--- a/lib/Target/PowerPC/PPC32AsmPrinter.cpp
+++ b/lib/Target/PowerPC/PPC32AsmPrinter.cpp
@@ -195,21 +195,24 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
// FP Constants are printed as integer constants to avoid losing
// precision...
double Val = CFP->getValue();
- if (1 || CFP->getType() == Type::DoubleTy) {
+ if (CFP->getType() == Type::DoubleTy) {
union DU { // Abide by C TBAA rules
double FVal;
uint64_t UVal;
- struct {
- uint32_t MSWord;
- uint32_t LSWord;
- } T;
} U;
U.FVal = Val;
-
- O << ".long\t" << U.T.MSWord << "\t; double most significant word "
- << Val << "\n";
- O << ".long\t" << U.T.LSWord << "\t; double least significant word "
- << Val << "\n";
+
+ if (TD.isBigEndian()) {
+ O << ".long\t" << unsigned(U.UVal >> 32)
+ << "\t; double most significant word " << Val << "\n";
+ O << ".long\t" << unsigned(U.UVal)
+ << "\t; double least significant word " << Val << "\n";
+ } else {
+ O << ".long\t" << unsigned(U.UVal)
+ << "\t; double least significant word " << Val << "\n";
+ O << ".long\t" << unsigned(U.UVal >> 32)
+ << "\t; double most significant word " << Val << "\n";
+ }
return;
} else {
union FU { // Abide by C TBAA rules
@@ -223,19 +226,19 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
}
} else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) {
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
- union DU { // Abide by C TBAA rules
- int64_t UVal;
- struct {
- uint32_t MSWord;
- uint32_t LSWord;
- } T;
- } U;
- U.UVal = CI->getRawValue();
+ uint64_t Val = CI->getRawValue();
- O << ".long\t" << U.T.MSWord << "\t; Double-word most significant word "
- << U.UVal << "\n";
- O << ".long\t" << U.T.LSWord << "\t; Double-word least significant word "
- << U.UVal << "\n";
+ if (TD.isBigEndian()) {
+ O << ".long\t" << unsigned(Val >> 32)
+ << "\t; Double-word most significant word " << Val << "\n";
+ O << ".long\t" << unsigned(Val)
+ << "\t; Double-word least significant word " << Val << "\n";
+ } else {
+ O << ".long\t" << unsigned(Val)
+ << "\t; Double-word least significant word " << Val << "\n";
+ O << ".long\t" << unsigned(Val >> 32)
+ << "\t; Double-word most significant word " << Val << "\n";
+ }
return;
}
}