aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-03-12 21:27:04 +0000
committerDuncan Sands <baldrick@free.fr>2008-03-12 21:27:04 +0000
commitd8742eeb2f7cabc45a1c3736a2780bf87ba684ba (patch)
tree0f403e517c498e9d68fb90c237df0a354c861a35 /lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
parentb576931ca23ccd71bc702f3cdee1b365314bbf4f (diff)
Initial soft-float support for LegalizeTypes. I rewrote
the fcopysign expansion from LegalizeDAG to get rid of what seems to be a bug: the use of sign extension means that when copying the sign bit from an f32 to an f64, the upper 32 bits of the f64 (now an i64) are set, not just the top bit... I also generalized it to work for any sized floating point types, and removed the bogosity: SDOperand Mask1 = (SrcVT == MVT::f64) ? DAG.getConstantFP(BitsToDouble(1ULL << 63), SrcVT) : DAG.getConstantFP(BitsToFloat(1U << 31), SrcVT); Mask1 = DAG.getNode(ISD::BIT_CONVERT, SrcNVT, Mask1); (here SrcNVT is an integer with the same size as SrcVT). As far as I can see this takes a 1 << 63, converts to a double, converts that to a floating point constant then converts that to an integer constant, ending up with... 1 << 63 as an integer constant! So I just generate this integer constant directly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48305 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeTypes.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
index d13fefab43..cc9caf0718 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -79,6 +79,9 @@ void DAGTypeLegalizer::run() {
case Expand:
ExpandResult(N, i);
goto NodeDone;
+ case FloatToInt:
+ FloatToIntResult(N, i);
+ goto NodeDone;
case Scalarize:
ScalarizeResult(N, i);
goto NodeDone;
@@ -106,6 +109,9 @@ void DAGTypeLegalizer::run() {
case Expand:
NeedsRevisit = ExpandOperand(N, i);
break;
+ case FloatToInt:
+ NeedsRevisit = FloatToIntOperand(N, i);
+ break;
case Scalarize:
NeedsRevisit = ScalarizeOperand(N, i);
break;
@@ -355,6 +361,14 @@ void DAGTypeLegalizer::SetPromotedOp(SDOperand Op, SDOperand Result) {
OpEntry = Result;
}
+void DAGTypeLegalizer::SetIntegerOp(SDOperand Op, SDOperand Result) {
+ AnalyzeNewNode(Result.Val);
+
+ SDOperand &OpEntry = FloatToIntedNodes[Op];
+ assert(OpEntry.Val == 0 && "Node is already converted to integer!");
+ OpEntry = Result;
+}
+
void DAGTypeLegalizer::SetScalarizedOp(SDOperand Op, SDOperand Result) {
AnalyzeNewNode(Result.Val);
@@ -363,7 +377,6 @@ void DAGTypeLegalizer::SetScalarizedOp(SDOperand Op, SDOperand Result) {
OpEntry = Result;
}
-
void DAGTypeLegalizer::GetExpandedOp(SDOperand Op, SDOperand &Lo,
SDOperand &Hi) {
std::pair<SDOperand, SDOperand> &Entry = ExpandedNodes[Op];
@@ -408,6 +421,13 @@ void DAGTypeLegalizer::SetSplitOp(SDOperand Op, SDOperand Lo, SDOperand Hi) {
}
+/// BitConvertToInteger - Convert to an integer of the same size.
+SDOperand DAGTypeLegalizer::BitConvertToInteger(SDOperand Op) {
+ return DAG.getNode(ISD::BIT_CONVERT,
+ MVT::getIntegerType(MVT::getSizeInBits(Op.getValueType())),
+ Op);
+}
+
SDOperand DAGTypeLegalizer::CreateStackStoreLoad(SDOperand Op,
MVT::ValueType DestVT) {
// Create the stack frame object.