Add support for targets that have a legal ISD::TRAP.
authorChris Lattner <sabre@nondot.org>
Tue, 15 Jan 2008 21:58:08 +0000 (21:58 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 15 Jan 2008 21:58:08 +0000 (21:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46014 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
lib/CodeGen/SelectionDAG/TargetLowering.cpp

index 8e9cd7423395d84a994a763589e576aa882aa802..68c3ced6e560bbb09bc2c67f574f653ef32d156a 100644 (file)
@@ -3734,24 +3734,29 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
       break;
     }
   }
-   case ISD::TRAP: {
+  case ISD::TRAP: {
     MVT::ValueType VT = Node->getValueType(0);
     switch (TLI.getOperationAction(Node->getOpcode(), VT)) {
     default: assert(0 && "This action not supported for this op yet!");
+    case TargetLowering::Legal:
+      Tmp1 = LegalizeOp(Node->getOperand(0));
+      Result = DAG.UpdateNodeOperands(Result, Tmp1);
+      break;
     case TargetLowering::Custom:
       Result = TLI.LowerOperation(Op, DAG);
       if (Result.Val) break;
       // Fall Thru
-    case TargetLowering::Legal:
+    case TargetLowering::Expand:
       // If this operation is not supported, lower it to 'abort()' call
-      SDOperand Chain = LegalizeOp(Node->getOperand(0));
+      Tmp1 = LegalizeOp(Node->getOperand(0));
       TargetLowering::ArgListTy Args;
       std::pair<SDOperand,SDOperand> CallResult =
-        TLI.LowerCallTo(Chain, Type::VoidTy, false, false, CallingConv::C, false,
+        TLI.LowerCallTo(Tmp1, Type::VoidTy, false, false, CallingConv::C, false,
                         DAG.getExternalSymbol("abort", MVT::Other), Args, DAG);
       Result = CallResult.second;
       break;
     }
+    break;
   }
   }
   
index ac2ce8a86b41817ff9054bff3388f2bf56ce7462..cb12b7c7329899c41855b6eb73643aadfc46b46c 100644 (file)
@@ -175,6 +175,9 @@ TargetLowering::TargetLowering(TargetMachine &tm)
     setOperationAction(ISD::FGETSIGN, (MVT::ValueType)VT, Expand);
   }
 
+  // Default ISD::TRAP to expand (which turns it into abort).
+  setOperationAction(ISD::TRAP, MVT::Other, Expand);
+    
   IsLittleEndian = TD->isLittleEndian();
   UsesGlobalOffsetTable = false;
   ShiftAmountTy = SetCCResultTy = PointerTy = getValueType(TD->getIntPtrType());