Allow custom lowering of DYNAMIC_STACKALLOC.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 11 Jan 2006 22:14:47 +0000 (22:14 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 11 Jan 2006 22:14:47 +0000 (22:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25224 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

index fe6c47681757e9375c92f850e61e69e6e7110946..e62c6d32e8edd155b29513e0b5f68fb1dd5cb96e 100644 (file)
@@ -829,7 +829,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
     // legalization process more efficient and also makes libcall insertion
     // easier.
     break;
-  case ISD::DYNAMIC_STACKALLOC:
+  case ISD::DYNAMIC_STACKALLOC: {
     Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
     Tmp2 = LegalizeOp(Node->getOperand(1));  // Legalize the size.
     Tmp3 = LegalizeOp(Node->getOperand(2));  // Legalize the alignment.
@@ -842,12 +842,25 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
     } else
       Result = Op.getValue(0);
 
-    // Since this op produces two values, make sure to remember that we
-    // legalized both of them.
-    AddLegalizedOperand(SDOperand(Node, 0), Result);
-    AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
-    return Result.getValue(Op.ResNo);
-
+    switch (TLI.getOperationAction(Node->getOpcode(),
+                                   Node->getValueType(0))) {
+    default: assert(0 && "This action is not supported yet!");
+    case TargetLowering::Custom: {
+      SDOperand Tmp = TLI.LowerOperation(Result, DAG);
+      if (Tmp.Val) {
+        Result = LegalizeOp(Tmp);
+      }
+      // FALLTHROUGH if the target thinks it is legal.
+    }
+    case TargetLowering::Legal:
+      // Since this op produce two values, make sure to remember that we
+      // legalized both of them.
+      AddLegalizedOperand(SDOperand(Node, 0), Result);
+      AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
+      return Result.getValue(Op.ResNo);
+    }
+    assert(0 && "Unreachable");
+  }
   case ISD::TAILCALL:
   case ISD::CALL: {
     Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.