[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Apr 8 20:30:33 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.75 -> 1.76
---
Log message:

Legalize BRCONDTWOWAY into a BRCOND/BR pair if a target doesn't support it.


---
Diffs of the changes:  (+33 -0)

 LegalizeDAG.cpp |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.75 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.76
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.75	Wed Apr  6 16:13:14 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Fri Apr  8 22:30:19 2005
@@ -391,6 +391,39 @@
       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.






More information about the llvm-commits mailing list