mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
Handle the FP format problem, where outputed FP constants were not precise
enough. This fixes compilation of the health benchmark. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2228 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f8b90ee366
commit
f678dc6469
@ -530,9 +530,9 @@ TypeToDataDirective(const Type* type)
|
|||||||
case Type::ULongTyID: case Type::LongTyID: case Type::PointerTyID:
|
case Type::ULongTyID: case Type::LongTyID: case Type::PointerTyID:
|
||||||
return ".xword";
|
return ".xword";
|
||||||
case Type::FloatTyID:
|
case Type::FloatTyID:
|
||||||
return ".single";
|
return ".word";
|
||||||
case Type::DoubleTyID:
|
case Type::DoubleTyID:
|
||||||
return ".double";
|
return ".xword";
|
||||||
case Type::ArrayTyID:
|
case Type::ArrayTyID:
|
||||||
if (ArrayTypeIsString((ArrayType*) type))
|
if (ArrayTypeIsString((ArrayType*) type))
|
||||||
return ".ascii";
|
return ".ascii";
|
||||||
@ -606,16 +606,33 @@ SparcModuleAsmPrinter::printSingleConstant(const Constant* CV)
|
|||||||
CV->getType() != Type::LabelTy &&
|
CV->getType() != Type::LabelTy &&
|
||||||
"Unexpected type for Constant");
|
"Unexpected type for Constant");
|
||||||
|
|
||||||
assert((! isa<ConstantArray>( CV) && ! isa<ConstantStruct>(CV))
|
assert((!isa<ConstantArray>(CV) && ! isa<ConstantStruct>(CV))
|
||||||
&& "Collective types should be handled outside this function");
|
&& "Aggregate types should be handled outside this function");
|
||||||
|
|
||||||
toAsm << "\t" << TypeToDataDirective(CV->getType()) << "\t";
|
toAsm << "\t" << TypeToDataDirective(CV->getType()) << "\t";
|
||||||
|
|
||||||
if (CV->getType()->isPrimitiveType())
|
if (CV->getType()->isPrimitiveType())
|
||||||
{
|
{
|
||||||
if (CV->getType()->isFloatingPoint())
|
if (CV->getType()->isFloatingPoint()) {
|
||||||
toAsm << "0r"; // FP constants must have this prefix
|
// FP Constants are printed as integer constants to avoid losing
|
||||||
toAsm << CV->getStrValue() << "\n";
|
// precision...
|
||||||
|
double Val = cast<ConstantFP>(CV)->getValue();
|
||||||
|
if (CV->getType() == Type::FloatTy) {
|
||||||
|
float FVal = (float)Val;
|
||||||
|
char *ProxyPtr = (char*)&FVal; // Abide by C TBAA rules
|
||||||
|
toAsm << *(unsigned int*)ProxyPtr;
|
||||||
|
} else if (CV->getType() == Type::DoubleTy) {
|
||||||
|
char *ProxyPtr = (char*)&Val; // Abide by C TBAA rules
|
||||||
|
toAsm << *(uint64_t*)ProxyPtr;
|
||||||
|
} else {
|
||||||
|
assert(0 && "Unknown floating point type!");
|
||||||
|
}
|
||||||
|
|
||||||
|
toAsm << "\t! " << CV->getType()->getDescription()
|
||||||
|
<< " value: " << Val << "\n";
|
||||||
|
} else {
|
||||||
|
toAsm << CV->getStrValue() << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (ConstantPointer* CPP = dyn_cast<ConstantPointer>(CV))
|
else if (ConstantPointer* CPP = dyn_cast<ConstantPointer>(CV))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user