mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-19 19:29:31 +00:00
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
This commit is contained in:
parent
505e783d8c
commit
469ab79584
@ -195,21 +195,24 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
|
|||||||
// FP Constants are printed as integer constants to avoid losing
|
// FP Constants are printed as integer constants to avoid losing
|
||||||
// precision...
|
// precision...
|
||||||
double Val = CFP->getValue();
|
double Val = CFP->getValue();
|
||||||
if (1 || CFP->getType() == Type::DoubleTy) {
|
if (CFP->getType() == Type::DoubleTy) {
|
||||||
union DU { // Abide by C TBAA rules
|
union DU { // Abide by C TBAA rules
|
||||||
double FVal;
|
double FVal;
|
||||||
uint64_t UVal;
|
uint64_t UVal;
|
||||||
struct {
|
|
||||||
uint32_t MSWord;
|
|
||||||
uint32_t LSWord;
|
|
||||||
} T;
|
|
||||||
} U;
|
} U;
|
||||||
U.FVal = Val;
|
U.FVal = Val;
|
||||||
|
|
||||||
O << ".long\t" << U.T.MSWord << "\t; double most significant word "
|
if (TD.isBigEndian()) {
|
||||||
<< Val << "\n";
|
O << ".long\t" << unsigned(U.UVal >> 32)
|
||||||
O << ".long\t" << U.T.LSWord << "\t; double least significant word "
|
<< "\t; double most significant word " << Val << "\n";
|
||||||
<< 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;
|
return;
|
||||||
} else {
|
} else {
|
||||||
union FU { // Abide by C TBAA rules
|
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) {
|
} else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) {
|
||||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
||||||
union DU { // Abide by C TBAA rules
|
uint64_t Val = CI->getRawValue();
|
||||||
int64_t UVal;
|
|
||||||
struct {
|
|
||||||
uint32_t MSWord;
|
|
||||||
uint32_t LSWord;
|
|
||||||
} T;
|
|
||||||
} U;
|
|
||||||
U.UVal = CI->getRawValue();
|
|
||||||
|
|
||||||
O << ".long\t" << U.T.MSWord << "\t; Double-word most significant word "
|
if (TD.isBigEndian()) {
|
||||||
<< U.UVal << "\n";
|
O << ".long\t" << unsigned(Val >> 32)
|
||||||
O << ".long\t" << U.T.LSWord << "\t; Double-word least significant word "
|
<< "\t; Double-word most significant word " << Val << "\n";
|
||||||
<< U.UVal << "\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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,21 +195,24 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
|
|||||||
// FP Constants are printed as integer constants to avoid losing
|
// FP Constants are printed as integer constants to avoid losing
|
||||||
// precision...
|
// precision...
|
||||||
double Val = CFP->getValue();
|
double Val = CFP->getValue();
|
||||||
if (1 || CFP->getType() == Type::DoubleTy) {
|
if (CFP->getType() == Type::DoubleTy) {
|
||||||
union DU { // Abide by C TBAA rules
|
union DU { // Abide by C TBAA rules
|
||||||
double FVal;
|
double FVal;
|
||||||
uint64_t UVal;
|
uint64_t UVal;
|
||||||
struct {
|
|
||||||
uint32_t MSWord;
|
|
||||||
uint32_t LSWord;
|
|
||||||
} T;
|
|
||||||
} U;
|
} U;
|
||||||
U.FVal = Val;
|
U.FVal = Val;
|
||||||
|
|
||||||
O << ".long\t" << U.T.MSWord << "\t; double most significant word "
|
if (TD.isBigEndian()) {
|
||||||
<< Val << "\n";
|
O << ".long\t" << unsigned(U.UVal >> 32)
|
||||||
O << ".long\t" << U.T.LSWord << "\t; double least significant word "
|
<< "\t; double most significant word " << Val << "\n";
|
||||||
<< 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;
|
return;
|
||||||
} else {
|
} else {
|
||||||
union FU { // Abide by C TBAA rules
|
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) {
|
} else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) {
|
||||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
||||||
union DU { // Abide by C TBAA rules
|
uint64_t Val = CI->getRawValue();
|
||||||
int64_t UVal;
|
|
||||||
struct {
|
|
||||||
uint32_t MSWord;
|
|
||||||
uint32_t LSWord;
|
|
||||||
} T;
|
|
||||||
} U;
|
|
||||||
U.UVal = CI->getRawValue();
|
|
||||||
|
|
||||||
O << ".long\t" << U.T.MSWord << "\t; Double-word most significant word "
|
if (TD.isBigEndian()) {
|
||||||
<< U.UVal << "\n";
|
O << ".long\t" << unsigned(Val >> 32)
|
||||||
O << ".long\t" << U.T.LSWord << "\t; Double-word least significant word "
|
<< "\t; Double-word most significant word " << Val << "\n";
|
||||||
<< U.UVal << "\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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user