diff options
author | Dan Gohman <gohman@apple.com> | 2009-04-25 17:55:53 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-04-25 17:55:53 +0000 |
commit | 2bee0afb7d023e029975abf7d3157759fa797d37 (patch) | |
tree | 7c1667dcb579753afaf3fa8691292893f89f2769 /lib/CodeGen | |
parent | 2fe4d0aacbc810a4e3838335648aef1f59bb0646 (diff) | |
download | external_llvm-2bee0afb7d023e029975abf7d3157759fa797d37.zip external_llvm-2bee0afb7d023e029975abf7d3157759fa797d37.tar.gz external_llvm-2bee0afb7d023e029975abf7d3157759fa797d37.tar.bz2 |
Refactor the code to grab the low and high parts of a value
using EXTRACT_ELEMENT into a utility function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70056 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp | 141 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeTypes.cpp | 12 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeTypes.h | 4 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp | 7 |
4 files changed, 38 insertions, 126 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp index 563b268..57e03b0 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp @@ -860,12 +860,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FADD(SDNode *N, SDValue &Lo, RTLIB::ADD_F32, RTLIB::ADD_F64, RTLIB::ADD_F80, RTLIB::ADD_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FCEIL(SDNode *N, @@ -874,12 +869,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FCEIL(SDNode *N, RTLIB::CEIL_F32, RTLIB::CEIL_F64, RTLIB::CEIL_F80, RTLIB::CEIL_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FCOS(SDNode *N, @@ -888,12 +878,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FCOS(SDNode *N, RTLIB::COS_F32, RTLIB::COS_F64, RTLIB::COS_F80, RTLIB::COS_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FDIV(SDNode *N, SDValue &Lo, @@ -906,12 +891,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FDIV(SDNode *N, SDValue &Lo, RTLIB::DIV_PPCF128), N->getValueType(0), Ops, 2, false, N->getDebugLoc()); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FEXP(SDNode *N, @@ -920,12 +900,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FEXP(SDNode *N, RTLIB::EXP_F32, RTLIB::EXP_F64, RTLIB::EXP_F80, RTLIB::EXP_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FEXP2(SDNode *N, @@ -934,12 +909,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FEXP2(SDNode *N, RTLIB::EXP2_F32, RTLIB::EXP2_F64, RTLIB::EXP2_F80, RTLIB::EXP2_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FFLOOR(SDNode *N, @@ -948,12 +918,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FFLOOR(SDNode *N, RTLIB::FLOOR_F32,RTLIB::FLOOR_F64, RTLIB::FLOOR_F80,RTLIB::FLOOR_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FLOG(SDNode *N, @@ -962,12 +927,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FLOG(SDNode *N, RTLIB::LOG_F32, RTLIB::LOG_F64, RTLIB::LOG_F80, RTLIB::LOG_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FLOG2(SDNode *N, @@ -976,12 +936,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FLOG2(SDNode *N, RTLIB::LOG2_F32, RTLIB::LOG2_F64, RTLIB::LOG2_F80, RTLIB::LOG2_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FLOG10(SDNode *N, @@ -990,12 +945,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FLOG10(SDNode *N, RTLIB::LOG10_F32,RTLIB::LOG10_F64, RTLIB::LOG10_F80,RTLIB::LOG10_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FMUL(SDNode *N, SDValue &Lo, @@ -1008,12 +958,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FMUL(SDNode *N, SDValue &Lo, RTLIB::MUL_PPCF128), N->getValueType(0), Ops, 2, false, N->getDebugLoc()); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FNEARBYINT(SDNode *N, @@ -1024,12 +969,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FNEARBYINT(SDNode *N, RTLIB::NEARBYINT_F80, RTLIB::NEARBYINT_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FNEG(SDNode *N, SDValue &Lo, @@ -1053,12 +993,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FPOW(SDNode *N, RTLIB::POW_F32, RTLIB::POW_F64, RTLIB::POW_F80, RTLIB::POW_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FPOWI(SDNode *N, @@ -1067,12 +1002,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FPOWI(SDNode *N, RTLIB::POWI_F32, RTLIB::POWI_F64, RTLIB::POWI_F80, RTLIB::POWI_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FRINT(SDNode *N, @@ -1081,12 +1011,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FRINT(SDNode *N, RTLIB::RINT_F32, RTLIB::RINT_F64, RTLIB::RINT_F80, RTLIB::RINT_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FSIN(SDNode *N, @@ -1095,12 +1020,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FSIN(SDNode *N, RTLIB::SIN_F32, RTLIB::SIN_F64, RTLIB::SIN_F80, RTLIB::SIN_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FSQRT(SDNode *N, @@ -1109,12 +1029,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FSQRT(SDNode *N, RTLIB::SQRT_F32, RTLIB::SQRT_F64, RTLIB::SQRT_F80, RTLIB::SQRT_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FSUB(SDNode *N, SDValue &Lo, @@ -1127,12 +1042,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FSUB(SDNode *N, SDValue &Lo, RTLIB::SUB_PPCF128), N->getValueType(0), Ops, 2, false, N->getDebugLoc()); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_FTRUNC(SDNode *N, @@ -1141,12 +1051,7 @@ void DAGTypeLegalizer::ExpandFloatRes_FTRUNC(SDNode *N, RTLIB::TRUNC_F32, RTLIB::TRUNC_F64, RTLIB::TRUNC_F80, RTLIB::TRUNC_PPCF128), N, false); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - DebugLoc dl = N->getDebugLoc(); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call, - DAG.getIntPtrConstant(1)); + GetPairElements(Call, Lo, Hi); } void DAGTypeLegalizer::ExpandFloatRes_LOAD(SDNode *N, SDValue &Lo, @@ -1214,10 +1119,7 @@ void DAGTypeLegalizer::ExpandFloatRes_XINT_TO_FP(SDNode *N, SDValue &Lo, assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported XINT_TO_FP!"); Hi = MakeLibCall(LC, VT, &Src, 1, true, dl); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Hi, - DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Hi, - DAG.getIntPtrConstant(1)); + GetPairElements(Hi, Lo, Hi); } if (isSigned) @@ -1252,8 +1154,7 @@ void DAGTypeLegalizer::ExpandFloatRes_XINT_TO_FP(SDNode *N, SDValue &Lo, MVT::ppcf128)); Lo = DAG.getNode(ISD::SELECT_CC, dl, VT, Src, DAG.getConstant(0, SrcVT), Lo, Hi, DAG.getCondCode(ISD::SETLT)); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Lo, DAG.getIntPtrConstant(1)); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Lo, DAG.getIntPtrConstant(0)); + GetPairElements(Lo, Lo, Hi); } diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp index 985d345..632524f 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp @@ -933,6 +933,18 @@ void DAGTypeLegalizer::GetSplitDestVTs(MVT InVT, MVT &LoVT, MVT &HiVT) { } } +/// GetPairElements - Use ISD::EXTRACT_ELEMENT nodes to extract the low and +/// high parts of the given value. +void DAGTypeLegalizer::GetPairElements(SDValue Pair, + SDValue &Lo, SDValue &Hi) { + DebugLoc dl = Pair.getDebugLoc(); + MVT NVT = TLI.getTypeToTransformTo(Pair.getValueType()); + Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Pair, + DAG.getIntPtrConstant(0)); + Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Pair, + DAG.getIntPtrConstant(1)); +} + SDValue DAGTypeLegalizer::GetVectorElementPointer(SDValue VecPtr, MVT EltVT, SDValue Index) { DebugLoc dl = Index.getDebugLoc(); diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/lib/CodeGen/SelectionDAG/LegalizeTypes.h index 8c68aef..24fb44c 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeTypes.h +++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.h @@ -695,6 +695,10 @@ private: /// which is split (or expanded) into two not necessarily identical pieces. void GetSplitDestVTs(MVT InVT, MVT &LoVT, MVT &HiVT); + /// GetPairElements - Use ISD::EXTRACT_ELEMENT nodes to extract the low and + /// high parts of the given value. + void GetPairElements(SDValue Pair, SDValue &Lo, SDValue &Hi); + // Generic Result Splitting. void SplitRes_MERGE_VALUES(SDNode *N, SDValue &Lo, SDValue &Hi); void SplitRes_SELECT (SDNode *N, SDValue &Lo, SDValue &Hi); diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp index 7826270..e8ff3fc 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp @@ -135,16 +135,11 @@ void DAGTypeLegalizer::ExpandRes_EXTRACT_ELEMENT(SDNode *N, SDValue &Lo, GetExpandedOp(N->getOperand(0), Lo, Hi); SDValue Part = cast<ConstantSDNode>(N->getOperand(1))->getZExtValue() ? Hi : Lo; - DebugLoc dl = N->getDebugLoc(); assert(Part.getValueType() == N->getValueType(0) && "Type twice as big as expanded type not itself expanded!"); - MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); - Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Part, - DAG.getConstant(0, TLI.getPointerTy())); - Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Part, - DAG.getConstant(1, TLI.getPointerTy())); + GetPairElements(Part, Lo, Hi); } void DAGTypeLegalizer::ExpandRes_EXTRACT_VECTOR_ELT(SDNode *N, SDValue &Lo, |