summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-11 21:44:02 +0000
committerChris Lattner <sabre@nondot.org>2002-04-11 21:44:02 +0000
commit0b32d0d511452eaf3323a84ed8ca2d4667c5da55 (patch)
tree2837661a509133c2a9411906cdfef7cf446bad6a /llvm/lib
parentc34061fc54b1a30f73798ce32af49ed6e4202bc9 (diff)
downloadbcm5719-llvm-0b32d0d511452eaf3323a84ed8ca2d4667c5da55.tar.gz
bcm5719-llvm-0b32d0d511452eaf3323a84ed8ca2d4667c5da55.zip
Handle the FP format problem, where outputed FP constants were not precise
enough. This fixes compilation of the health benchmark. llvm-svn: 2228
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/Sparc/EmitAssembly.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/llvm/lib/Target/Sparc/EmitAssembly.cpp b/llvm/lib/Target/Sparc/EmitAssembly.cpp
index 02eeca49e53..79b7b003c71 100644
--- a/llvm/lib/Target/Sparc/EmitAssembly.cpp
+++ b/llvm/lib/Target/Sparc/EmitAssembly.cpp
@@ -530,9 +530,9 @@ TypeToDataDirective(const Type* type)
case Type::ULongTyID: case Type::LongTyID: case Type::PointerTyID:
return ".xword";
case Type::FloatTyID:
- return ".single";
+ return ".word";
case Type::DoubleTyID:
- return ".double";
+ return ".xword";
case Type::ArrayTyID:
if (ArrayTypeIsString((ArrayType*) type))
return ".ascii";
@@ -606,16 +606,33 @@ SparcModuleAsmPrinter::printSingleConstant(const Constant* CV)
CV->getType() != Type::LabelTy &&
"Unexpected type for Constant");
- assert((! isa<ConstantArray>( CV) && ! isa<ConstantStruct>(CV))
- && "Collective types should be handled outside this function");
+ assert((!isa<ConstantArray>(CV) && ! isa<ConstantStruct>(CV))
+ && "Aggregate types should be handled outside this function");
toAsm << "\t" << TypeToDataDirective(CV->getType()) << "\t";
if (CV->getType()->isPrimitiveType())
{
- if (CV->getType()->isFloatingPoint())
- toAsm << "0r"; // FP constants must have this prefix
- toAsm << CV->getStrValue() << "\n";
+ if (CV->getType()->isFloatingPoint()) {
+ // FP Constants are printed as integer constants to avoid losing
+ // 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))
{
OpenPOWER on IntegriCloud