Allow targets to custom legalize leaf nodes like GlobalAddress.
authorChris Lattner <sabre@nondot.org>
Thu, 17 Nov 2005 06:41:44 +0000 (06:41 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 17 Nov 2005 06:41:44 +0000 (06:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24387 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

index 6a7a53ea80a45b015d706fb6ee8d43ed3332034c..7b453a282b3fc7b52313d01504623dd89906a024 100644 (file)
@@ -532,7 +532,19 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
   case ISD::CONDCODE:
   case ISD::VALUETYPE:
   case ISD::SRCVALUE:
-    assert(isTypeLegal(Node->getValueType(0)) && "This must be legal!");
+    switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))) {
+    default: assert(0 && "This action is not supported yet!");
+    case TargetLowering::Custom: {
+      SDOperand Tmp = TLI.LowerOperation(Op, DAG);
+      if (Tmp.Val) {
+        Result = LegalizeOp(Tmp);
+        break;
+      }
+    } // FALLTHROUGH if the target doesn't want to lower this op after all.
+    case TargetLowering::Legal:
+      assert(isTypeLegal(Node->getValueType(0)) && "This must be legal!");
+      break;
+    }
     break;
   case ISD::AssertSext:
   case ISD::AssertZext: