aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-07-28 23:31:12 +0000
committerChris Lattner <sabre@nondot.org>2005-07-28 23:31:12 +0000
commitfa9c801a6b42609dc2a934afb6535e3d51d61a3e (patch)
tree9838e00dd1d809c2ba84a4500b2234d32d205dfd /lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
parent70df32a138a72a66c733c8cd9db8dd6ceedf2c57 (diff)
instead of having all conversions be handled by one case value, and then have
subcases inside, break things out earlier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22546 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp150
1 files changed, 86 insertions, 64 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index a2a231b182..144de14aef 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -1438,62 +1438,103 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
break;
// Conversion operators. The source and destination have different types.
+ case ISD::SINT_TO_FP:
+ case ISD::UINT_TO_FP: {
+ bool isSigned = Node->getOpcode() == ISD::SINT_TO_FP;
+ switch (getTypeAction(Node->getOperand(0).getValueType())) {
+ case Legal:
+ switch (TLI.getOperationAction(Node->getOpcode(),
+ Node->getOperand(0).getValueType())) {
+ default: assert(0 && "Unknown operation action!");
+ case TargetLowering::Expand:
+ assert(!isSigned && "Legalize cannot Expand SINT_TO_FP yet");
+ Result = ExpandLegalUINT_TO_FP(LegalizeOp(Node->getOperand(0)),
+ Node->getValueType(0));
+ AddLegalizedOperand(Op, Result);
+ return Result;
+ case TargetLowering::Promote:
+ Result = PromoteLegalINT_TO_FP(LegalizeOp(Node->getOperand(0)),
+ Node->getValueType(0),
+ isSigned);
+ AddLegalizedOperand(Op, Result);
+ return Result;
+ case TargetLowering::Legal:
+ break;
+ }
+
+ Tmp1 = LegalizeOp(Node->getOperand(0));
+ if (Tmp1 != Node->getOperand(0))
+ Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1);
+ break;
+ case Expand:
+ Result = ExpandIntToFP(Node->getOpcode() == ISD::SINT_TO_FP,
+ Node->getValueType(0), Node->getOperand(0));
+ break;
+ case Promote:
+ if (isSigned) {
+ Result = PromoteOp(Node->getOperand(0));
+ Result = DAG.getNode(ISD::SIGN_EXTEND_INREG, Result.getValueType(),
+ Result, DAG.getValueType(Node->getOperand(0).getValueType()));
+ Result = DAG.getNode(ISD::SINT_TO_FP, Op.getValueType(), Result);
+ } else {
+ Result = PromoteOp(Node->getOperand(0));
+ Result = DAG.getZeroExtendInReg(Result,
+ Node->getOperand(0).getValueType());
+ Result = DAG.getNode(ISD::UINT_TO_FP, Op.getValueType(), Result);
+ }
+ break;
+ }
+ break;
+ }
+ case ISD::TRUNCATE:
+ switch (getTypeAction(Node->getOperand(0).getValueType())) {
+ case Legal:
+ Tmp1 = LegalizeOp(Node->getOperand(0));
+ if (Tmp1 != Node->getOperand(0))
+ Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1);
+ break;
+ case Expand:
+ ExpandOp(Node->getOperand(0), Tmp1, Tmp2);
+
+ // Since the result is legal, we should just be able to truncate the low
+ // part of the source.
+ Result = DAG.getNode(ISD::TRUNCATE, Node->getValueType(0), Tmp1);
+ break;
+ case Promote:
+ Result = PromoteOp(Node->getOperand(0));
+ Result = DAG.getNode(ISD::TRUNCATE, Op.getValueType(), Result);
+ break;
+ }
+ break;
+
+ case ISD::FP_TO_SINT:
+ case ISD::FP_TO_UINT:
+ switch (getTypeAction(Node->getOperand(0).getValueType())) {
+ case Legal:
+ Tmp1 = LegalizeOp(Node->getOperand(0));
+ if (Tmp1 != Node->getOperand(0))
+ Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1);
+ break;
+ case Expand:
+ assert(0 && "Shouldn't need to expand other operators here!");
+ case Promote:
+ Result = PromoteOp(Node->getOperand(0));
+ Result = DAG.getNode(Node->getOpcode(), Op.getValueType(), Result);
+ break;
+ }
+ break;
+
case ISD::ZERO_EXTEND:
case ISD::SIGN_EXTEND:
- case ISD::TRUNCATE:
case ISD::FP_EXTEND:
case ISD::FP_ROUND:
- case ISD::FP_TO_SINT:
- case ISD::FP_TO_UINT:
- case ISD::SINT_TO_FP:
- case ISD::UINT_TO_FP:
switch (getTypeAction(Node->getOperand(0).getValueType())) {
case Legal:
- //still made need to expand if the op is illegal, but the types are legal
- if (Node->getOpcode() == ISD::UINT_TO_FP ||
- Node->getOpcode() == ISD::SINT_TO_FP) {
- bool isSigned = Node->getOpcode() == ISD::SINT_TO_FP;
- switch (TLI.getOperationAction(Node->getOpcode(),
- Node->getOperand(0).getValueType())) {
- default: assert(0 && "Unknown operation action!");
- case TargetLowering::Expand:
- if (!isSigned)
- Result = ExpandLegalUINT_TO_FP(LegalizeOp(Node->getOperand(0)),
- Node->getValueType(0));
- else
- assert(0 && "Legalize cannot Expand SINT_TO_FP yet");
- AddLegalizedOperand(Op, Result);
- return Result;
- case TargetLowering::Promote:
- Result = PromoteLegalINT_TO_FP(LegalizeOp(Node->getOperand(0)),
- Node->getValueType(0),
- isSigned);
- AddLegalizedOperand(Op, Result);
- return Result;
- case TargetLowering::Legal:
- break;
- }
- }
Tmp1 = LegalizeOp(Node->getOperand(0));
if (Tmp1 != Node->getOperand(0))
Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1);
break;
case Expand:
- if (Node->getOpcode() == ISD::SINT_TO_FP ||
- Node->getOpcode() == ISD::UINT_TO_FP) {
- Result = ExpandIntToFP(Node->getOpcode() == ISD::SINT_TO_FP,
- Node->getValueType(0), Node->getOperand(0));
- break;
- } else if (Node->getOpcode() == ISD::TRUNCATE) {
- // In the expand case, we must be dealing with a truncate, because
- // otherwise the result would be larger than the source.
- ExpandOp(Node->getOperand(0), Tmp1, Tmp2);
-
- // Since the result is legal, we should just be able to truncate the low
- // part of the source.
- Result = DAG.getNode(ISD::TRUNCATE, Node->getValueType(0), Tmp1);
- break;
- }
assert(0 && "Shouldn't need to expand other operators here!");
case Promote:
@@ -1513,10 +1554,6 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
Result,
DAG.getValueType(Node->getOperand(0).getValueType()));
break;
- case ISD::TRUNCATE:
- Result = PromoteOp(Node->getOperand(0));
- Result = DAG.getNode(ISD::TRUNCATE, Op.getValueType(), Result);
- break;
case ISD::FP_EXTEND:
Result = PromoteOp(Node->getOperand(0));
if (Result.getValueType() != Op.getValueType())
@@ -1524,24 +1561,9 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
Result = DAG.getNode(ISD::FP_EXTEND, Op.getValueType(), Result);
break;
case ISD::FP_ROUND:
- case ISD::FP_TO_SINT:
- case ISD::FP_TO_UINT:
Result = PromoteOp(Node->getOperand(0));
Result = DAG.getNode(Node->getOpcode(), Op.getValueType(), Result);
break;
- case ISD::SINT_TO_FP:
- Result = PromoteOp(Node->getOperand(0));
- Result = DAG.getNode(ISD::SIGN_EXTEND_INREG, Result.getValueType(),
- Result,
- DAG.getValueType(Node->getOperand(0).getValueType()));
- Result = DAG.getNode(ISD::SINT_TO_FP, Op.getValueType(), Result);
- break;
- case ISD::UINT_TO_FP:
- Result = PromoteOp(Node->getOperand(0));
- Result = DAG.getZeroExtendInReg(Result,
- Node->getOperand(0).getValueType());
- Result = DAG.getNode(ISD::UINT_TO_FP, Op.getValueType(), Result);
- break;
}
}
break;