Changes in directory llvm/lib/CodeGen/SelectionDAG:
LegalizeDAG.cpp updated: 1.290 -> 1.291 SelectionDAG.cpp updated: 1.248 -> 1.249 --- Log message: Legalize ConstantFP into TargetConstantFP when the target allows. Implement custom expansion of ConstantFP nodes. --- Diffs of the changes: (+39 -2) LegalizeDAG.cpp | 19 ++++++++++++++++++- SelectionDAG.cpp | 22 +++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.290 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.291 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.290 Sun Jan 29 00:00:45 2006 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sun Jan 29 00:26:56 2006 @@ -272,6 +272,8 @@ case ISD::BasicBlock: case ISD::TargetFrameIndex: case ISD::TargetConstant: + case ISD::TargetConstantFP: + case ISD::TargetConstantVec: case ISD::TargetConstantPool: case ISD::TargetGlobalAddress: case ISD::TargetExternalSymbol: @@ -481,7 +483,22 @@ break; } - if (!isLegal) { + // If this is a legal constant, turn it into a TargetConstantFP node. + if (isLegal) { + Result = DAG.getTargetConstantFP(CFP->getValue(), CFP->getValueType(0)); + break; + } + + switch (TLI.getOperationAction(ISD::ConstantFP, CFP->getValueType(0))) { + default: assert(0 && "This action is not supported yet!"); + case TargetLowering::Custom: + Tmp3 = TLI.LowerOperation(Result, DAG); + if (Tmp3.Val) { + Result = Tmp3; + break; + } + // FALLTHROUGH + case TargetLowering::Expand: // Otherwise we need to spill the constant to memory. bool Extend = false; Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.248 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.249 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.248 Sat Jan 28 04:09:25 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sun Jan 29 00:26:56 2006 @@ -277,6 +277,11 @@ Erased = ConstantFPs.erase(std::make_pair(V, N->getValueType(0))); break; } + case ISD::TargetConstantFP: { + uint64_t V = DoubleToBits(cast<ConstantFPSDNode>(N)->getValue()); + Erased = TargetConstantFPs.erase(std::make_pair(V, N->getValueType(0))); + break; + } case ISD::STRING: Erased = StringNodes.erase(cast<StringSDNode>(N)->getValue()); break; @@ -606,7 +611,22 @@ // we don't have issues with SNANs. SDNode *&N = ConstantFPs[std::make_pair(DoubleToBits(Val), VT)]; if (N) return SDOperand(N, 0); - N = new ConstantFPSDNode(Val, VT); + N = new ConstantFPSDNode(false, Val, VT); + AllNodes.push_back(N); + return SDOperand(N, 0); +} + +SDOperand SelectionDAG::getTargetConstantFP(double Val, MVT::ValueType VT) { + assert(MVT::isFloatingPoint(VT) && "Cannot create integer FP constant!"); + if (VT == MVT::f32) + Val = (float)Val; // Mask out extra precision. + + // 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. + SDNode *&N = TargetConstantFPs[std::make_pair(DoubleToBits(Val), VT)]; + if (N) return SDOperand(N, 0); + N = new ConstantFPSDNode(true, Val, VT); AllNodes.push_back(N); return SDOperand(N, 0); } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits