diff options
author | Duncan Sands <baldrick@free.fr> | 2008-03-11 06:41:14 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2008-03-11 06:41:14 +0000 |
commit | ac7613a3263caa80d735f3fbf2b9f7b81deabc08 (patch) | |
tree | 823e83e402b13e4ea5dc9e80609d64002785b53f /lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp | |
parent | 5d03f21744f30988b962f023bd397bb5c6a20178 (diff) |
Some LegalizeTypes code factorization and minor
enhancements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48215 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp index f6fdd2b8a3..2e76cebf16 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp @@ -45,7 +45,7 @@ static void GetSplitDestVTs(MVT::ValueType InVT, /// legalization, we just know that (at least) one result needs vector /// splitting. void DAGTypeLegalizer::SplitResult(SDNode *N, unsigned ResNo) { - DEBUG(cerr << "Expand node result: "; N->dump(&DAG); cerr << "\n"); + DEBUG(cerr << "Split node result: "; N->dump(&DAG); cerr << "\n"); SDOperand Lo, Hi; #if 0 @@ -257,26 +257,20 @@ void DAGTypeLegalizer::SplitRes_BIT_CONVERT(SDNode *N, SDOperand InOp = N->getOperand(0); MVT::ValueType InVT = InOp.getValueType(); - MVT::ValueType NewInVT = TLI.getTypeToTransformTo(InVT); + // Handle some special cases efficiently. switch (getTypeAction(InVT)) { default: assert(false && "Unknown type action!"); case Legal: - break; case Promote: - break; case Scalarize: - // While it is tempting to extract the scalarized operand, check whether it - // needs expansion, and if so process it in the Expand case below, there is - // no guarantee that the scalarized operand has been processed yet. If it - // hasn't then the call to GetExpandedOp will abort. So just give up. break; case Expand: // A scalar to vector conversion, where the scalar needs expansion. - // Check that the vector is being split in two. - if (MVT::getSizeInBits(NewInVT) == MVT::getSizeInBits(LoVT)) { - // Convert each expanded piece of the scalar now. + // If the vector is being split in two then we can just convert the + // expanded pieces. + if (LoVT == HiVT) { GetExpandedOp(InOp, Lo, Hi); if (TLI.isBigEndian()) std::swap(Lo, Hi); @@ -294,9 +288,21 @@ void DAGTypeLegalizer::SplitRes_BIT_CONVERT(SDNode *N, return; } - // Lower the bit-convert to a store/load from the stack, then split the load. - SDOperand Op = CreateStackStoreLoad(InOp, N->getValueType(0)); - SplitRes_LOAD(cast<LoadSDNode>(Op.Val), Lo, Hi); + // In the general case, convert the input to an integer and split it by hand. + InVT = MVT::getIntegerType(MVT::getSizeInBits(InVT)); + InOp = DAG.getNode(ISD::BIT_CONVERT, InVT, InOp); + + MVT::ValueType LoIntVT = MVT::getIntegerType(MVT::getSizeInBits(LoVT)); + MVT::ValueType HiIntVT = MVT::getIntegerType(MVT::getSizeInBits(HiVT)); + if (TLI.isBigEndian()) + std::swap(LoIntVT, HiIntVT); + + SplitInteger(InOp, LoIntVT, HiIntVT, Lo, Hi); + + if (TLI.isBigEndian()) + std::swap(Lo, Hi); + Lo = DAG.getNode(ISD::BIT_CONVERT, LoVT, Lo); + Hi = DAG.getNode(ISD::BIT_CONVERT, HiVT, Hi); } void DAGTypeLegalizer::SplitRes_BinOp(SDNode *N, SDOperand &Lo, SDOperand &Hi) { @@ -448,11 +454,8 @@ SDOperand DAGTypeLegalizer::SplitOp_BIT_CONVERT(SDNode *N) { if (TLI.isBigEndian()) std::swap(Lo, Hi); - assert(LoBits == HiBits && "Do not know how to assemble odd sized vectors!"); - return DAG.getNode(ISD::BIT_CONVERT, N->getValueType(0), - DAG.getNode(ISD::BUILD_PAIR, - MVT::getIntegerType(LoBits+HiBits), Lo, Hi)); + JoinIntegers(Lo, Hi)); } SDOperand DAGTypeLegalizer::SplitOp_EXTRACT_VECTOR_ELT(SDNode *N) { |