From 57030e36e41ebd982a24632e7cea5b584b2d49fc Mon Sep 17 00:00:00 2001 From: Andrew Lenharth Date: Sun, 25 Dec 2005 01:07:37 +0000 Subject: [PATCH] allow custom lowering to return null for legal results git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25007 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 32 +++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 1d684191219..1d9dd5c2c89 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -1956,11 +1956,6 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { break; } switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))) { - case TargetLowering::Legal: - if (Tmp1 != Node->getOperand(0) || - Tmp2 != Node->getOperand(1)) - Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1,Tmp2); - break; case TargetLowering::Custom: { Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1, Tmp2); SDOperand Tmp = TLI.LowerOperation(Result, DAG); @@ -1968,9 +1963,13 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { Tmp = LegalizeOp(Tmp); // Relegalize input. AddLegalizedOperand(Op, Tmp); return Tmp; - } - break; + } //else it was considered legal and we fall through } + case TargetLowering::Legal: + if (Tmp1 != Node->getOperand(0) || + Tmp2 != Node->getOperand(1)) + Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1,Tmp2); + break; default: assert(0 && "Operation not supported"); } @@ -2007,6 +2006,15 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { Tmp1 = LegalizeOp(Node->getOperand(0)); // LHS Tmp2 = LegalizeOp(Node->getOperand(1)); // RHS switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))) { + case TargetLowering::Custom: { + Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1, Tmp2); + SDOperand Tmp = TLI.LowerOperation(Result, DAG); + if (Tmp.Val) { + Tmp = LegalizeOp(Tmp); // Relegalize input. + AddLegalizedOperand(Op, Tmp); + return Tmp; + } //else it was considered legal and we fall through + } case TargetLowering::Legal: if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1)) @@ -2015,16 +2023,6 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { break; case TargetLowering::Promote: assert(0 && "Cannot promote handle this yet!"); - case TargetLowering::Custom: { - Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1, Tmp2); - SDOperand Tmp = TLI.LowerOperation(Result, DAG); - if (Tmp.Val) { - Tmp = LegalizeOp(Tmp); // Relegalize input. - AddLegalizedOperand(Op, Tmp); - return Tmp; - } - break; - } case TargetLowering::Expand: if (MVT::isInteger(Node->getValueType(0))) { MVT::ValueType VT = Node->getValueType(0);