From 9e3d3abd937c9bb79d56d25ec0e0724c7cbba67c Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Fri, 14 Sep 2007 22:26:36 +0000 Subject: Remove the assumption that FP's are either float or double from some of the many places in the optimizers it appears, and do something reasonable with x86 long double. Make APInt::dump() public, remove newline, use it to dump ConstantSDNode's. Allow APFloats in FoldingSet. Expand X86 backend handling of long doubles (conversions to/from int, mostly). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41967 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp') diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 0defc12..3744c4a 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -322,13 +322,7 @@ static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) { break; case ISD::TargetConstantFP: case ISD::ConstantFP: { - APFloat V = cast(N)->getValueAPF(); - if (&V.getSemantics() == &APFloat::IEEEdouble) - ID.AddDouble(V.convertToDouble()); - else if (&V.getSemantics() == &APFloat::IEEEsingle) - ID.AddDouble((double)V.convertToFloat()); - else - assert(0); + ID.AddAPFloat(cast(N)->getValueAPF()); break; } case ISD::TargetGlobalAddress: @@ -709,25 +703,21 @@ SDOperand SelectionDAG::getConstantFP(const APFloat& V, MVT::ValueType VT, MVT::ValueType EltVT = MVT::isVector(VT) ? MVT::getVectorElementType(VT) : VT; - bool isDouble = (EltVT == MVT::f64); - double Val = isDouble ? V.convertToDouble() : (double)V.convertToFloat(); // Do the map lookup using the actual bit pattern for the floating point // value, so that we don't have problems with 0.0 comparing equal to -0.0, and // we don't have issues with SNANs. unsigned Opc = isTarget ? ISD::TargetConstantFP : ISD::ConstantFP; - // ?? Should we store float/double/longdouble separately in ID? FoldingSetNodeID ID; AddNodeIDNode(ID, Opc, getVTList(EltVT), 0, 0); - ID.AddDouble(Val); + ID.AddAPFloat(V); void *IP = 0; SDNode *N = NULL; if ((N = CSEMap.FindNodeOrInsertPos(ID, IP))) if (!MVT::isVector(VT)) return SDOperand(N, 0); if (!N) { - N = new ConstantFPSDNode(isTarget, - isDouble ? APFloat(Val) : APFloat((float)Val), EltVT); + N = new ConstantFPSDNode(isTarget, V, EltVT); CSEMap.InsertNode(N, IP); AllNodes.push_back(N); } @@ -3724,9 +3714,15 @@ void SDNode::dump(const SelectionDAG *G) const { if (const ConstantSDNode *CSDN = dyn_cast(this)) { cerr << "<" << CSDN->getValue() << ">"; } else if (const ConstantFPSDNode *CSDN = dyn_cast(this)) { - cerr << "<" << (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle ? - CSDN->getValueAPF().convertToFloat() : - CSDN->getValueAPF().convertToDouble()) << ">"; + if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle) + cerr << "<" << CSDN->getValueAPF().convertToFloat() << ">"; + else if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEdouble) + cerr << "<" << CSDN->getValueAPF().convertToDouble() << ">"; + else { + cerr << "getValueAPF().convertToAPInt().dump(); + cerr << ")>"; + } } else if (const GlobalAddressSDNode *GADN = dyn_cast(this)) { int offset = GADN->getOffset(); -- cgit v1.1