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/LegalizeTypes.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/LegalizeTypes.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeTypes.cpp | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp index 43acb5ba31..d13fefab43 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp @@ -464,19 +464,42 @@ SDOperand DAGTypeLegalizer::HandleMemIntrinsic(SDNode *N) { return DAG.UpdateNodeOperands(SDOperand(N, 0), Ops, 6); } -/// SplitOp - Return the lower and upper halves of Op's bits in a value type -/// half the size of Op's. -void DAGTypeLegalizer::SplitOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi) { - unsigned NVTBits = MVT::getSizeInBits(Op.getValueType())/2; - assert(MVT::getSizeInBits(Op.getValueType()) == 2*NVTBits && - "Cannot split odd sized integer type"); - MVT::ValueType NVT = MVT::getIntegerType(NVTBits); - Lo = DAG.getNode(ISD::TRUNCATE, NVT, Op); +/// JoinIntegers - Build an integer with low bits Lo and high bits Hi. +SDOperand DAGTypeLegalizer::JoinIntegers(SDOperand Lo, SDOperand Hi) { + MVT::ValueType LVT = Lo.getValueType(); + MVT::ValueType HVT = Hi.getValueType(); + MVT::ValueType NVT = MVT::getIntegerType(MVT::getSizeInBits(LVT) + + MVT::getSizeInBits(HVT)); + + Lo = DAG.getNode(ISD::ZERO_EXTEND, NVT, Lo); + Hi = DAG.getNode(ISD::ANY_EXTEND, NVT, Hi); + Hi = DAG.getNode(ISD::SHL, NVT, Hi, DAG.getConstant(MVT::getSizeInBits(LVT), + TLI.getShiftAmountTy())); + return DAG.getNode(ISD::OR, NVT, Lo, Hi); +} + +/// SplitInteger - Return the lower LoVT bits of Op in Lo and the upper HiVT +/// bits in Hi. +void DAGTypeLegalizer::SplitInteger(SDOperand Op, + MVT::ValueType LoVT, MVT::ValueType HiVT, + SDOperand &Lo, SDOperand &Hi) { + assert(MVT::getSizeInBits(LoVT) + MVT::getSizeInBits(HiVT) == + MVT::getSizeInBits(Op.getValueType()) && "Invalid integer splitting!"); + Lo = DAG.getNode(ISD::TRUNCATE, LoVT, Op); Hi = DAG.getNode(ISD::SRL, Op.getValueType(), Op, - DAG.getConstant(NVTBits, TLI.getShiftAmountTy())); - Hi = DAG.getNode(ISD::TRUNCATE, NVT, Hi); + DAG.getConstant(MVT::getSizeInBits(LoVT), + TLI.getShiftAmountTy())); + Hi = DAG.getNode(ISD::TRUNCATE, HiVT, Hi); } +/// SplitInteger - Return the lower and upper halves of Op's bits in a value type +/// half the size of Op's. +void DAGTypeLegalizer::SplitInteger(SDOperand Op, + SDOperand &Lo, SDOperand &Hi) { + MVT::ValueType HalfVT = + MVT::getIntegerType(MVT::getSizeInBits(Op.getValueType())/2); + SplitInteger(Op, HalfVT, HalfVT, Lo, Hi); +} //===----------------------------------------------------------------------===// // Entry Point |