X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FSelectionDAG%2FLegalizeIntegerTypes.cpp;h=9e4ff4a8a01c3999da7a9fae51c02f66013bb060;hb=ef5b199905cee0b78eb30cd44836e5b6ca5cbd09;hp=1dc933cc7e49f9435ba8bdce4edfb615c453be51;hpb=475871a144eb604ddaf37503397ba0941442e5fb;p=oota-llvm.git diff --git a/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index 1dc933cc7e4..9e4ff4a8a01 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -99,7 +99,7 @@ void DAGTypeLegalizer::PromoteIntegerResult(SDNode *N, unsigned ResNo) { } // If Result is null, the sub-method took care of registering the result. - if (Result.Val) + if (Result.getNode()) SetPromotedInteger(SDValue(N, ResNo), Result); } @@ -167,7 +167,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_BIT_CONVERT(SDNode *N) { // Otherwise, lower the bit-convert to a store/load from the stack, then // promote the load. SDValue Op = CreateStackStoreLoad(InOp, N->getValueType(0)); - return PromoteIntRes_LOAD(cast(Op.Val)); + return PromoteIntRes_LOAD(cast(Op.getNode())); } SDValue DAGTypeLegalizer::PromoteIntRes_BSWAP(SDNode *N) { @@ -272,8 +272,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(SDNode *N) { if (TLI.isBigEndian()) std::swap(Lo, Hi); - SDValue Odd = DAG.getNode(ISD::AND, OldIdx.getValueType(), OldIdx, - DAG.getConstant(1, TLI.getShiftAmountTy())); + SDValue Odd = DAG.getNode(ISD::TRUNCATE, MVT::i1, OldIdx); return DAG.getNode(ISD::SELECT, NewVT, Odd, Hi, Lo); } @@ -365,10 +364,14 @@ SDValue DAGTypeLegalizer::PromoteIntRes_SELECT_CC(SDNode *N) { } SDValue DAGTypeLegalizer::PromoteIntRes_SETCC(SDNode *N) { - assert(isTypeLegal(TLI.getSetCCResultType(N->getOperand(0))) - && "SetCC type is not legal??"); - return DAG.getNode(ISD::SETCC, TLI.getSetCCResultType(N->getOperand(0)), - N->getOperand(0), N->getOperand(1), N->getOperand(2)); + MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0)); + MVT SVT = TLI.getSetCCResultType(N->getOperand(0)); + assert(isTypeLegal(SVT) && "SetCC type not legal??"); + assert(NVT.getSizeInBits() <= SVT.getSizeInBits() && + "Integer type overpromoted?"); + return DAG.getNode(ISD::TRUNCATE, NVT, + DAG.getNode(ISD::SETCC, SVT, N->getOperand(0), + N->getOperand(1), N->getOperand(2))); } SDValue DAGTypeLegalizer::PromoteIntRes_SHL(SDNode *N) { @@ -494,7 +497,7 @@ bool DAGTypeLegalizer::PromoteIntegerOperand(SDNode *N, unsigned OpNo) { == TargetLowering::Custom) Res = TLI.LowerOperation(SDValue(N, OpNo), DAG); - if (Res.Val == 0) { + if (Res.getNode() == 0) { switch (N->getOpcode()) { default: #ifndef NDEBUG @@ -529,9 +532,9 @@ bool DAGTypeLegalizer::PromoteIntegerOperand(SDNode *N, unsigned OpNo) { } // If the result is null, the sub-method took care of registering results etc. - if (!Res.Val) return false; + if (!Res.getNode()) return false; // If the result is N, the sub-method updated N in place. - if (Res.Val == N) { + if (Res.getNode() == N) { // Mark N as new and remark N and its operands. This allows us to correctly // revisit N if it needs another step of promotion and allows us to visit // any new operands to N. @@ -885,7 +888,7 @@ void DAGTypeLegalizer::ExpandIntegerResult(SDNode *N, unsigned ResNo) { } // If Lo/Hi is null, the sub-method took care of registering results etc. - if (Lo.Val) + if (Lo.getNode()) SetExpandedInteger(SDValue(N, ResNo), Lo, Hi); } @@ -1195,7 +1198,7 @@ void DAGTypeLegalizer::ExpandIntRes_CTLZ(SDNode *N, MVT NVT = Lo.getValueType(); SDValue HiNotZero = DAG.getSetCC(TLI.getSetCCResultType(Hi), Hi, - DAG.getConstant(0, NVT), ISD::SETNE); + DAG.getConstant(0, NVT), ISD::SETNE); SDValue LoLZ = DAG.getNode(ISD::CTLZ, NVT, Lo); SDValue HiLZ = DAG.getNode(ISD::CTLZ, NVT, Hi); @@ -1223,7 +1226,7 @@ void DAGTypeLegalizer::ExpandIntRes_CTTZ(SDNode *N, MVT NVT = Lo.getValueType(); SDValue LoNotZero = DAG.getSetCC(TLI.getSetCCResultType(Lo), Lo, - DAG.getConstant(0, NVT), ISD::SETNE); + DAG.getConstant(0, NVT), ISD::SETNE); SDValue LoLZ = DAG.getNode(ISD::CTTZ, NVT, Lo); SDValue HiLZ = DAG.getNode(ISD::CTTZ, NVT, Hi); @@ -1395,7 +1398,7 @@ void DAGTypeLegalizer::ExpandIntRes_MUL(SDNode *N, if (HasUMUL_LOHI) { // We can emit a umul_lohi. Lo = DAG.getNode(ISD::UMUL_LOHI, DAG.getVTList(NVT, NVT), LL, RL); - Hi = SDValue(Lo.Val, 1); + Hi = SDValue(Lo.getNode(), 1); return; } if (HasMULHU) { @@ -1410,7 +1413,7 @@ void DAGTypeLegalizer::ExpandIntRes_MUL(SDNode *N, if (HasSMUL_LOHI) { // We can emit a smul_lohi. Lo = DAG.getNode(ISD::SMUL_LOHI, DAG.getVTList(NVT, NVT), LL, RL); - Hi = SDValue(Lo.Val, 1); + Hi = SDValue(Lo.getNode(), 1); return; } if (HasMULHS) { @@ -1481,7 +1484,7 @@ void DAGTypeLegalizer::ExpandIntRes_Shift(SDNode *N, // If we can emit an efficient shift operation, do so now. Check to see if // the RHS is a constant. if (ConstantSDNode *CN = dyn_cast(N->getOperand(1))) - return ExpandShiftByConstant(N, CN->getValue(), Lo, Hi); + return ExpandShiftByConstant(N, CN->getZExtValue(), Lo, Hi); // If we can determine that the high bit of the shift is zero or one, even if // the low bits are variable, emit this shift in an optimized form. @@ -1706,7 +1709,7 @@ bool DAGTypeLegalizer::ExpandIntegerOperand(SDNode *N, unsigned OpNo) { == TargetLowering::Custom) Res = TLI.LowerOperation(SDValue(N, OpNo), DAG); - if (Res.Val == 0) { + if (Res.getNode() == 0) { switch (N->getOpcode()) { default: #ifndef NDEBUG @@ -1732,10 +1735,10 @@ bool DAGTypeLegalizer::ExpandIntegerOperand(SDNode *N, unsigned OpNo) { } // If the result is null, the sub-method took care of registering results etc. - if (!Res.Val) return false; + if (!Res.getNode()) return false; // If the result is N, the sub-method updated N in place. Check to see if any // operands are new, and if so, mark them. - if (Res.Val == N) { + if (Res.getNode() == N) { // Mark N as new and remark N and its operands. This allows us to correctly // revisit N if it needs another step of expansion and allows us to visit // any new operands to N. @@ -1814,16 +1817,16 @@ void DAGTypeLegalizer::IntegerExpandSetCCOperands(SDValue &NewLHS, SDValue Tmp1, Tmp2; Tmp1 = TLI.SimplifySetCC(TLI.getSetCCResultType(LHSLo), LHSLo, RHSLo, LowCC, false, DagCombineInfo); - if (!Tmp1.Val) + if (!Tmp1.getNode()) Tmp1 = DAG.getSetCC(TLI.getSetCCResultType(LHSLo), LHSLo, RHSLo, LowCC); Tmp2 = TLI.SimplifySetCC(TLI.getSetCCResultType(LHSHi), LHSHi, RHSHi, CCCode, false, DagCombineInfo); - if (!Tmp2.Val) + if (!Tmp2.getNode()) Tmp2 = DAG.getNode(ISD::SETCC, TLI.getSetCCResultType(LHSHi), LHSHi, RHSHi, DAG.getCondCode(CCCode)); - ConstantSDNode *Tmp1C = dyn_cast(Tmp1.Val); - ConstantSDNode *Tmp2C = dyn_cast(Tmp2.Val); + ConstantSDNode *Tmp1C = dyn_cast(Tmp1.getNode()); + ConstantSDNode *Tmp2C = dyn_cast(Tmp2.getNode()); if ((Tmp1C && Tmp1C->isNullValue()) || (Tmp2C && Tmp2C->isNullValue() && (CCCode == ISD::SETLE || CCCode == ISD::SETGE || @@ -1841,7 +1844,7 @@ void DAGTypeLegalizer::IntegerExpandSetCCOperands(SDValue &NewLHS, NewLHS = TLI.SimplifySetCC(TLI.getSetCCResultType(LHSHi), LHSHi, RHSHi, ISD::SETEQ, false, DagCombineInfo); - if (!NewLHS.Val) + if (!NewLHS.getNode()) NewLHS = DAG.getSetCC(TLI.getSetCCResultType(LHSHi), LHSHi, RHSHi, ISD::SETEQ); NewLHS = DAG.getNode(ISD::SELECT, Tmp1.getValueType(), @@ -1856,7 +1859,7 @@ SDValue DAGTypeLegalizer::ExpandIntOp_BR_CC(SDNode *N) { // If ExpandSetCCOperands returned a scalar, we need to compare the result // against zero to select between true and false values. - if (NewRHS.Val == 0) { + if (NewRHS.getNode() == 0) { NewRHS = DAG.getConstant(0, NewLHS.getValueType()); CCCode = ISD::SETNE; } @@ -1874,7 +1877,7 @@ SDValue DAGTypeLegalizer::ExpandIntOp_SELECT_CC(SDNode *N) { // If ExpandSetCCOperands returned a scalar, we need to compare the result // against zero to select between true and false values. - if (NewRHS.Val == 0) { + if (NewRHS.getNode() == 0) { NewRHS = DAG.getConstant(0, NewLHS.getValueType()); CCCode = ISD::SETNE; } @@ -1891,7 +1894,7 @@ SDValue DAGTypeLegalizer::ExpandIntOp_SETCC(SDNode *N) { IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode); // If ExpandSetCCOperands returned a scalar, use it. - if (NewRHS.Val == 0) { + if (NewRHS.getNode() == 0) { assert(NewLHS.getValueType() == N->getValueType(0) && "Unexpected setcc expansion!"); return NewLHS; @@ -2029,8 +2032,8 @@ SDValue DAGTypeLegalizer::ExpandIntOp_UINT_TO_FP(SDNode *N) { SDValue Lo, Hi; GetExpandedInteger(Op, Lo, Hi); SDValue SignSet = DAG.getSetCC(TLI.getSetCCResultType(Hi), Hi, - DAG.getConstant(0, Hi.getValueType()), - ISD::SETLT); + DAG.getConstant(0, Hi.getValueType()), + ISD::SETLT); // Build a 64 bit pair (0, FF) in the constant pool, with FF in the lo bits. SDValue FudgePtr = DAG.getConstantPool(ConstantInt::get(FF.zext(64)), @@ -2041,13 +2044,17 @@ SDValue DAGTypeLegalizer::ExpandIntOp_UINT_TO_FP(SDNode *N) { SDValue Four = DAG.getIntPtrConstant(4); if (TLI.isBigEndian()) std::swap(Zero, Four); SDValue Offset = DAG.getNode(ISD::SELECT, Zero.getValueType(), SignSet, - Zero, Four); + Zero, Four); + unsigned Alignment = + 1 << cast(FudgePtr)->getAlignment(); FudgePtr = DAG.getNode(ISD::ADD, TLI.getPointerTy(), FudgePtr, Offset); + Alignment = std::min(Alignment, 4u); // Load the value out, extending it from f32 to the destination float type. // FIXME: Avoid the extend by constructing the right constant pool? SDValue Fudge = DAG.getExtLoad(ISD::EXTLOAD, DstVT, DAG.getEntryNode(), - FudgePtr, NULL, 0, MVT::f32); + FudgePtr, NULL, 0, MVT::f32, + false, Alignment); return DAG.getNode(ISD::FADD, DstVT, SignedConv, Fudge); }