From 07dffd6af673c73352150583150b242a93694f00 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 26 Aug 2005 00:14:16 +0000 Subject: [PATCH] Allow LowerOperation to return a null SDOperand in case it wants to lower some things given to it, but not all. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23070 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 60 +++++++++++++++--------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index d07c4df1247..283b46ec106 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -1320,6 +1320,16 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { 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 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { NeedsAnotherIteration = true; break; } - case TargetLowering::Custom: - std::vector 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 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { 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 @@ ExpandIntToFP(bool isSigned, MVT::ValueType DestTy, SDOperand Source) { 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 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){ // 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 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){ 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)