From 181b7a382fbdd3d03ce373a6ffac2204e763f9c3 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 17 Dec 2005 23:46:46 +0000 Subject: [PATCH] allow custom expansion of BR_CC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24804 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 36 ++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index dae6af4f563..16ef90c2515 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -879,17 +879,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { break; case ISD::BR_CC: Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. - - if (isTypeLegal(Node->getOperand(2).getValueType())) { - Tmp2 = LegalizeOp(Node->getOperand(2)); // LHS - Tmp3 = LegalizeOp(Node->getOperand(3)); // RHS - if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(2) || - Tmp3 != Node->getOperand(3)) { - Result = DAG.getNode(ISD::BR_CC, MVT::Other, Tmp1, Node->getOperand(1), - Tmp2, Tmp3, Node->getOperand(4)); - } - break; - } else { + if (!isTypeLegal(Node->getOperand(2).getValueType())) { Tmp2 = LegalizeOp(DAG.getNode(ISD::SETCC, TLI.getSetCCResultTy(), Node->getOperand(2), // LHS Node->getOperand(3), // RHS @@ -908,6 +898,30 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { Tmp2, DAG.getConstant(0, Tmp2.getValueType()), Node->getOperand(4)); } + break; + } + + Tmp2 = LegalizeOp(Node->getOperand(2)); // LHS + Tmp3 = LegalizeOp(Node->getOperand(3)); // RHS + + switch (TLI.getOperationAction(ISD::BR_CC, Tmp3.getValueType())) { + default: assert(0 && "Unexpected action for BR_CC!"); + case TargetLowering::Custom: { + Tmp4 = DAG.getNode(ISD::BR_CC, MVT::Other, Tmp1, Node->getOperand(1), + Tmp2, Tmp3, Node->getOperand(4)); + Tmp4 = TLI.LowerOperation(Tmp4, DAG); + if (Tmp4.Val) { + Result = LegalizeOp(Tmp4); + break; + } + } // FALLTHROUGH if the target doesn't want to lower this op after all. + case TargetLowering::Legal: + if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(2) || + Tmp3 != Node->getOperand(3)) { + Result = DAG.getNode(ISD::BR_CC, MVT::Other, Tmp1, Node->getOperand(1), + Tmp2, Tmp3, Node->getOperand(4)); + } + break; } break; case ISD::BRCONDTWOWAY: