diff options
| author | Dale Johannesen <dalej@apple.com> | 2007-09-06 18:13:44 +0000 |
|---|---|---|
| committer | Dale Johannesen <dalej@apple.com> | 2007-09-06 18:13:44 +0000 |
| commit | bed9dc423ceadd08500869cf03e4c0819145d48b (patch) | |
| tree | 1f39c25a045eca2e6d11262ae1be517e661d4010 /llvm/lib/CodeGen | |
| parent | a07765b8f4d9da2836d8f89b26d7f476715dffb4 (diff) | |
| download | bcm5719-llvm-bed9dc423ceadd08500869cf03e4c0819145d48b.tar.gz bcm5719-llvm-bed9dc423ceadd08500869cf03e4c0819145d48b.zip | |
Next round of APFloat changes.
Use APFloat in UpgradeParser and AsmParser.
Change all references to ConstantFP to use the
APFloat interface rather than double. Remove
the ConstantFP double interfaces.
Use APFloat functions for constant folding arithmetic
and comparisons.
(There are still way too many places APFloat is
just a wrapper around host float/double, but we're
getting there.)
llvm-svn: 41747
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MachOWriter.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 5 |
3 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp index fa6f5691fc3..e80afd40eed 100644 --- a/llvm/lib/CodeGen/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter.cpp @@ -829,8 +829,8 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) { } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) { // FP Constants are printed as integer constants to avoid losing // precision... - double Val = CFP->getValue(); if (CFP->getType() == Type::DoubleTy) { + double Val = CFP->getValueAPF().convertToDouble(); if (TAI->getData64bitsDirective()) O << TAI->getData64bitsDirective() << DoubleToBits(Val) << "\t" << TAI->getCommentString() << " double value: " << Val << "\n"; @@ -851,6 +851,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) { } return; } else { + float Val = CFP->getValueAPF().convertToFloat(); O << TAI->getData32bitsDirective() << FloatToBits(Val) << "\t" << TAI->getCommentString() << " float " << Val << "\n"; return; diff --git a/llvm/lib/CodeGen/MachOWriter.cpp b/llvm/lib/CodeGen/MachOWriter.cpp index 36060e150ea..af2555d3eed 100644 --- a/llvm/lib/CodeGen/MachOWriter.cpp +++ b/llvm/lib/CodeGen/MachOWriter.cpp @@ -861,7 +861,8 @@ void MachOWriter::InitMem(const Constant *C, void *Addr, intptr_t Offset, break; } case Type::FloatTyID: { - uint64_t val = FloatToBits(cast<ConstantFP>(PC)->getValue()); + uint64_t val = FloatToBits(cast<ConstantFP>(PC)-> + getValueAPF().convertToFloat()); if (TD->isBigEndian()) val = ByteSwap_32(val); ptr[0] = val; @@ -871,7 +872,8 @@ void MachOWriter::InitMem(const Constant *C, void *Addr, intptr_t Offset, break; } case Type::DoubleTyID: { - uint64_t val = DoubleToBits(cast<ConstantFP>(PC)->getValue()); + uint64_t val = DoubleToBits(cast<ConstantFP>(PC)-> + getValueAPF().convertToDouble()); if (TD->isBigEndian()) val = ByteSwap_64(val); ptr[0] = val; diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index a695048a5ad..d1e9365274a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -840,7 +840,7 @@ SDOperand SelectionDAGLowering::getValue(const Value *V) { return N = DAG.getNode(ISD::BUILD_VECTOR, VT, &Ops[0], Ops.size()); } else if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) { - return N = DAG.getConstantFP(CFP->getValue(), VT); + return N = DAG.getConstantFP(CFP->getValueAPF(), VT); } else if (const VectorType *PTy = dyn_cast<VectorType>(VTy)) { unsigned NumElements = PTy->getNumElements(); MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); @@ -2003,7 +2003,8 @@ void SelectionDAGLowering::visitSub(User &I) { const Type *ElTy = DestTy->getElementType(); if (ElTy->isFloatingPoint()) { unsigned VL = DestTy->getNumElements(); - std::vector<Constant*> NZ(VL, ConstantFP::get(ElTy, -0.0)); + std::vector<Constant*> NZ(VL, ConstantFP::get(ElTy, + ElTy==Type::FloatTy ? APFloat(-0.0f) : APFloat(-0.0))); Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size()); if (CV == CNZ) { SDOperand Op2 = getValue(I.getOperand(1)); |

