diff options
author | Chris Lattner <sabre@nondot.org> | 2006-01-29 06:26:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-01-29 06:26:56 +0000 |
commit | 758b0ac54bb5a062806a713968419ebb59bb6a40 (patch) | |
tree | 20019986709578dd6053cd74d05199d0a6d1d7b3 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 61c9a8e942ae46ad09980bd491750e22f6965aa3 (diff) | |
download | bcm5719-llvm-758b0ac54bb5a062806a713968419ebb59bb6a40.tar.gz bcm5719-llvm-758b0ac54bb5a062806a713968419ebb59bb6a40.zip |
Legalize ConstantFP into TargetConstantFP when the target allows. Implement
custom expansion of ConstantFP nodes.
llvm-svn: 25772
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 1b12d311731..b9a6ec0d452 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -277,6 +277,11 @@ void SelectionDAG::RemoveNodeFromCSEMaps(SDNode *N) { 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 @@ SDOperand SelectionDAG::getConstantFP(double Val, MVT::ValueType VT) { // 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); } |