diff options
author | Chris Lattner <sabre@nondot.org> | 2006-04-11 01:31:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-04-11 01:31:51 +0000 |
commit | f87324e44de88da5b3d57d6aeda5bc9d30f86374 (patch) | |
tree | a9ca176822a36ace702328d68188bdce38eab60b /lib/CodeGen | |
parent | 06c24350a92dff027cf1b4ddb91704cb82d976ae (diff) |
Add basic support for legalizing returns of vectors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 27c770913e..0bb6dd0301 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -1397,20 +1397,47 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { Tmp1 = DAG.getNode(ISD::TokenFactor, MVT::Other, Tmp1, LastCALLSEQ_END); Tmp1 = LegalizeOp(Tmp1); LastCALLSEQ_END = DAG.getEntryNode(); - + Tmp2 = Node->getOperand(1); + switch (Node->getNumOperands()) { case 2: // ret val - switch (getTypeAction(Node->getOperand(1).getValueType())) { + switch (getTypeAction(Tmp2.getValueType())) { case Legal: - Tmp2 = LegalizeOp(Node->getOperand(1)); - Result = DAG.UpdateNodeOperands(Result, Tmp1, Tmp2); + Result = DAG.UpdateNodeOperands(Result, Tmp1, LegalizeOp(Tmp2)); break; - case Expand: { - SDOperand Lo, Hi; - ExpandOp(Node->getOperand(1), Lo, Hi); - Result = DAG.getNode(ISD::RET, MVT::Other, Tmp1, Lo, Hi); + case Expand: + if (Tmp2.getValueType() != MVT::Vector) { + SDOperand Lo, Hi; + ExpandOp(Tmp2, Lo, Hi); + Result = DAG.getNode(ISD::RET, MVT::Other, Tmp1, Lo, Hi); + } else { + SDNode *InVal = Tmp2.Val; + unsigned NumElems = + cast<ConstantSDNode>(*(InVal->op_end()-2))->getValue(); + MVT::ValueType EVT = cast<VTSDNode>(*(InVal->op_end()-1))->getVT(); + + // Figure out if there is a Packed type corresponding to this Vector + // type. If so, convert to the packed type. + MVT::ValueType TVT = MVT::getVectorType(EVT, NumElems); + if (TVT != MVT::Other && TLI.isTypeLegal(TVT)) { + // Turn this into a return of the packed type. + Tmp2 = PackVectorOp(Tmp2, TVT); + Result = DAG.UpdateNodeOperands(Result, Tmp1, Tmp2); + } else if (NumElems == 1) { + // Turn this into a return of the scalar type. + Tmp2 = PackVectorOp(Tmp2, EVT); + Result = DAG.UpdateNodeOperands(Result, Tmp1, Tmp2); + // The scalarized value type may not be legal, e.g. it might require + // promotion or expansion. Relegalize the return. + Result = LegalizeOp(Result); + } else { + SDOperand Lo, Hi; + SplitVectorOp(Tmp2, Lo, Hi); + Result = DAG.getNode(ISD::RET, MVT::Other, Tmp1, Lo, Hi); + Result = LegalizeOp(Result); + } + } break; - } case Promote: Tmp2 = PromoteOp(Node->getOperand(1)); Result = DAG.UpdateNodeOperands(Result, Tmp1, Tmp2); |