[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Aug 25 17:14:27 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.170 -> 1.171
---
Log message:

Allow LowerOperation to return a null SDOperand in case it wants to lower
some things given to it, but not all.


---
Diffs of the changes:  (+39 -21)

 LegalizeDAG.cpp |   60 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 39 insertions(+), 21 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.170 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.171
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.170	Wed Aug 24 11:35:28 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Thu Aug 25 19:14:16 2005
@@ -1320,6 +1320,16 @@
 
     switch (TLI.getOperationAction(Node->getOpcode(), MVT::Other)) {
     default: assert(0 && "This action not implemented for this operation!");
+    case TargetLowering::Custom: {
+      SDOperand Tmp =
+        TLI.LowerOperation(DAG.getNode(Node->getOpcode(), MVT::Other, Tmp1, 
+                                       Tmp2, Tmp3, Tmp4, Tmp5), DAG);
+      if (Tmp.Val) {
+        Result = LegalizeOp(Tmp);
+        break;
+      }
+      // FALLTHROUGH if the target thinks it is legal.
+    }
     case TargetLowering::Legal:
       if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1) ||
           Tmp3 != Node->getOperand(2) || Tmp4 != Node->getOperand(3) ||
@@ -1363,14 +1373,6 @@
       NeedsAnotherIteration = true;
       break;
     }
-    case TargetLowering::Custom:
-      std::vector<SDOperand> Ops;
-      Ops.push_back(Tmp1); Ops.push_back(Tmp2); Ops.push_back(Tmp3);
-      Ops.push_back(Tmp4); Ops.push_back(Tmp5);
-      Result = DAG.getNode(Node->getOpcode(), MVT::Other, Ops);
-      Result = TLI.LowerOperation(Result, DAG);
-      Result = LegalizeOp(Result);
-      break;
     }
     break;
   }
@@ -1817,14 +1819,21 @@
                                        Node->getOpcode() == ISD::FP_TO_SINT);
         AddLegalizedOperand(Op, Result);
         return Result;
+      case TargetLowering::Custom: {
+        SDOperand Tmp =
+          DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1);
+        Tmp = TLI.LowerOperation(Tmp, DAG);
+        if (Tmp.Val) {
+          AddLegalizedOperand(Op, Tmp);
+          NeedsAnotherIteration = true;
+          return Result;
+        } else {
+          // The target thinks this is legal afterall.
+          break;
+        }
+      }
       case TargetLowering::Legal:
         break;
-      case TargetLowering::Custom:
-        Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1);
-        Result = TLI.LowerOperation(Result, DAG);
-        AddLegalizedOperand(Op, Result);
-        NeedsAnotherIteration = true;
-        return Result;
       }
 
       if (Tmp1 != Node->getOperand(0))
@@ -2746,9 +2755,13 @@
   case TargetLowering::Legal:
   case TargetLowering::Expand:
     break;   // This case is handled below.
-  case TargetLowering::Custom:
-    Source = DAG.getNode(ISD::SINT_TO_FP, DestTy, Source);
-    return LegalizeOp(TLI.LowerOperation(Source, DAG));
+  case TargetLowering::Custom: {
+    SDOperand NV = TLI.LowerOperation(DAG.getNode(ISD::SINT_TO_FP, DestTy,
+                                                  Source), DAG);
+    if (NV.Val)
+      return LegalizeOp(NV);
+    break;   // The target decided this was legal after all
+  }
   }
 
   // Expand the source, then glue it back together for the call.  We must expand
@@ -3040,8 +3053,10 @@
 
       // Now that the custom expander is done, expand the result, which is still
       // VT.
-      ExpandOp(Op, Lo, Hi);
-      break;
+      if (Op.Val) {
+        ExpandOp(Op, Lo, Hi);
+        break;
+      }
     }
 
     if (Node->getOperand(0).getValueType() == MVT::f32)
@@ -3056,8 +3071,11 @@
                                  LegalizeOp(Node->getOperand(0)));
       // Now that the custom expander is done, expand the result, which is still
       // VT.
-      ExpandOp(TLI.LowerOperation(Op, DAG), Lo, Hi);
-      break;
+      Op = TLI.LowerOperation(Op, DAG);
+      if (Op.Val) {
+        ExpandOp(Op, Lo, Hi);
+        break;
+      }
     }
 
     if (Node->getOperand(0).getValueType() == MVT::f32)






More information about the llvm-commits mailing list