diff options
author | Chris Lattner <sabre@nondot.org> | 2005-01-18 19:27:06 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-01-18 19:27:06 +0000 |
commit | 47e9223e06390897c3834f8c527001df392570ff (patch) | |
tree | 2aa415e89a95d8d5fdefcbf1408b1720360f3100 /lib/CodeGen | |
parent | 4a9b4f1943c6c56c749c8709ed28680408afc577 (diff) |
Fix some fixmes (promoting bools for select and brcond), fix promotion
of zero and sign extends.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19671 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index de1cfa2103..8c6c10d583 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -320,8 +320,16 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { case ISD::BRCOND: Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. - // FIXME: booleans might not be legal! - Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the condition. + + 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; + } // Basic block destination (Op#2) is always legal. if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1)) Result = DAG.getNode(ISD::BRCOND, MVT::Other, Tmp1, Tmp2, @@ -524,8 +532,15 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { } break; case ISD::SELECT: - // FIXME: BOOLS MAY REQUIRE PROMOTION! - Tmp1 = LegalizeOp(Node->getOperand(0)); // Cond + switch (getTypeAction(Node->getOperand(0).getValueType())) { + case Expand: assert(0 && "It's impossible to expand bools"); + case Legal: + Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the condition. + break; + case Promote: + Tmp1 = PromoteOp(Node->getOperand(0)); // Promote the condition. + break; + } Tmp2 = LegalizeOp(Node->getOperand(1)); // TrueVal Tmp3 = LegalizeOp(Node->getOperand(2)); // FalseVal @@ -770,11 +785,15 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { switch (Node->getOpcode()) { case ISD::ZERO_EXTEND: Result = PromoteOp(Node->getOperand(0)); - Result = DAG.getNode(ISD::ZERO_EXTEND_INREG, Result.getValueType(), + // NOTE: Any extend would work here... + Result = DAG.getNode(ISD::ZERO_EXTEND, Op.getValueType(), Result); + Result = DAG.getNode(ISD::ZERO_EXTEND_INREG, Op.getValueType(), Result, Node->getOperand(0).getValueType()); break; case ISD::SIGN_EXTEND: Result = PromoteOp(Node->getOperand(0)); + // NOTE: Any extend would work here... + Result = DAG.getNode(ISD::SIGN_EXTEND, Op.getValueType(), Result); Result = DAG.getNode(ISD::SIGN_EXTEND_INREG, Result.getValueType(), Result, Node->getOperand(0).getValueType()); break; @@ -1101,7 +1120,15 @@ SDOperand SelectionDAGLegalize::PromoteOp(SDOperand Op) { AddLegalizedOperand(Op.getValue(1), Result.getValue(1)); break; case ISD::SELECT: - Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the condition + switch (getTypeAction(Node->getOperand(0).getValueType())) { + case Expand: assert(0 && "It's impossible to expand bools"); + case Legal: + Tmp1 = LegalizeOp(Node->getOperand(0));// Legalize the condition. + break; + case Promote: + Tmp1 = PromoteOp(Node->getOperand(0)); // Promote the condition. + break; + } Tmp2 = PromoteOp(Node->getOperand(1)); // Legalize the op0 Tmp3 = PromoteOp(Node->getOperand(2)); // Legalize the op1 Result = DAG.getNode(ISD::SELECT, NVT, Tmp1, Tmp2, Tmp3); @@ -1238,8 +1265,16 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){ } case ISD::SELECT: { SDOperand C, LL, LH, RL, RH; - // FIXME: BOOLS MAY REQUIRE PROMOTION! - C = LegalizeOp(Node->getOperand(0)); + + switch (getTypeAction(Node->getOperand(0).getValueType())) { + case Expand: assert(0 && "It's impossible to expand bools"); + case Legal: + C = LegalizeOp(Node->getOperand(0)); // Legalize the condition. + break; + case Promote: + C = PromoteOp(Node->getOperand(0)); // Promote the condition. + break; + } ExpandOp(Node->getOperand(1), LL, LH); ExpandOp(Node->getOperand(2), RL, RH); Lo = DAG.getNode(ISD::SELECT, NVT, C, LL, RL); |