summaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-04-09 03:30:19 +0000
committerChris Lattner <sabre@nondot.org>2005-04-09 03:30:19 +0000
commit411e888c1b4155190c8cffe388631ee20693b309 (patch)
treeb2fce1a415ac8f4008f5ced1a69ae5a483cd4a36 /lib/CodeGen
parentef847df0870b9e3407bdc24ccb9db9ba2df817e6 (diff)
downloadllvm-411e888c1b4155190c8cffe388631ee20693b309.tar.gz
llvm-411e888c1b4155190c8cffe388631ee20693b309.tar.bz2
llvm-411e888c1b4155190c8cffe388631ee20693b309.tar.xz
Legalize BRCONDTWOWAY into a BRCOND/BR pair if a target doesn't support it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21166 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 9441078d10..256aa2513e 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -391,6 +391,39 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
Result = DAG.getNode(ISD::BRCOND, MVT::Other, Tmp1, Tmp2,
Node->getOperand(2));
break;
+ case ISD::BRCONDTWOWAY:
+ Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
+ switch (getTypeAction(Node->getOperand(1).getValueType())) {
+ case Expand: assert(0 && "It's impossible to expand bools");
+ case Legal:
+ Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the condition.
+ break;
+ case Promote:
+ Tmp2 = PromoteOp(Node->getOperand(1)); // Promote the condition.
+ break;
+ }
+ // If this target does not support BRCONDTWOWAY, lower it to a BRCOND/BR
+ // pair.
+ switch (TLI.getOperationAction(ISD::BRCONDTWOWAY, MVT::Other)) {
+ case TargetLowering::Promote:
+ default: assert(0 && "This action is not supported yet!");
+ case TargetLowering::Legal:
+ if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1)) {
+ std::vector<SDOperand> Ops;
+ Ops.push_back(Tmp1);
+ Ops.push_back(Tmp2);
+ Ops.push_back(Node->getOperand(2));
+ Ops.push_back(Node->getOperand(3));
+ Result = DAG.getNode(ISD::BRCONDTWOWAY, MVT::Other, Ops);
+ }
+ break;
+ case TargetLowering::Expand:
+ Result = DAG.getNode(ISD::BRCOND, MVT::Other, Tmp1, Tmp2,
+ Node->getOperand(2));
+ Result = DAG.getNode(ISD::BR, MVT::Other, Result, Node->getOperand(3));
+ break;
+ }
+ break;
case ISD::LOAD:
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.