- case ISD::BIT_CONVERT:
- switch (TLI.getOperationAction(ISD::BIT_CONVERT,
- Node->getOperand(0).getValueType())) {
- default: assert(0 && "Unknown operation action!");
- case TargetLowering::Expand:
- Result = EmitStackConvert(Node->getOperand(0), Node->getValueType(0),
- Node->getValueType(0), dl);
- break;
- case TargetLowering::Legal:
- Tmp1 = LegalizeOp(Node->getOperand(0));
- Result = DAG.UpdateNodeOperands(Result, Tmp1);
- break;
- }
- break;
- case ISD::CONVERT_RNDSAT: {
- ISD::CvtCode CvtCode = cast<CvtRndSatSDNode>(Node)->getCvtCode();
- switch (CvtCode) {
- default: assert(0 && "Unknown cvt code!");
- case ISD::CVT_SF:
- case ISD::CVT_UF:
- case ISD::CVT_FF:
- break;
- case ISD::CVT_FS:
- case ISD::CVT_FU:
- case ISD::CVT_SS:
- case ISD::CVT_SU:
- case ISD::CVT_US:
- case ISD::CVT_UU: {
- SDValue DTyOp = Node->getOperand(1);
- SDValue STyOp = Node->getOperand(2);
- SDValue RndOp = Node->getOperand(3);
- SDValue SatOp = Node->getOperand(4);
- Tmp1 = LegalizeOp(Node->getOperand(0));
- Result = DAG.UpdateNodeOperands(Result, Tmp1, DTyOp, STyOp,
- RndOp, SatOp);
- if (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0)) ==
- TargetLowering::Custom) {
- Tmp1 = TLI.LowerOperation(Result, DAG);
- if (Tmp1.getNode()) Result = Tmp1;
- }
- break;
- }
- } // end switch CvtCode
- break;
- }
- // Conversion operators. The source and destination have different types.
- case ISD::SINT_TO_FP:
- case ISD::UINT_TO_FP: {
- bool isSigned = Node->getOpcode() == ISD::SINT_TO_FP;
- Result = LegalizeINT_TO_FP(Result, isSigned,
- Node->getValueType(0), Node->getOperand(0), dl);
- break;
- }
- case ISD::TRUNCATE:
- Tmp1 = LegalizeOp(Node->getOperand(0));
- switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))) {
- default: assert(0 && "Unknown TRUNCATE legalization operation action!");
- case TargetLowering::Custom:
- isCustom = true;
- // FALLTHROUGH
- case TargetLowering::Legal:
- Result = DAG.UpdateNodeOperands(Result, Tmp1);
- if (isCustom) {
- Tmp1 = TLI.LowerOperation(Result, DAG);
- if (Tmp1.getNode()) Result = Tmp1;
- }
- break;
- }
- break;
-
- case ISD::FP_TO_SINT:
- case ISD::FP_TO_UINT:
- Tmp1 = LegalizeOp(Node->getOperand(0));
-
- switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))){
- default: assert(0 && "Unknown operation action!");
- case TargetLowering::Custom:
- isCustom = true;
- // FALLTHROUGH
- case TargetLowering::Legal:
- Result = DAG.UpdateNodeOperands(Result, Tmp1);
- if (isCustom) {
- Tmp1 = TLI.LowerOperation(Result, DAG);
- if (Tmp1.getNode()) Result = Tmp1;
- }
- break;
- case TargetLowering::Promote:
- Result = PromoteLegalFP_TO_INT(Tmp1, Node->getValueType(0),
- Node->getOpcode() == ISD::FP_TO_SINT,
- dl);
- break;
- case TargetLowering::Expand:
- if (Node->getOpcode() == ISD::FP_TO_UINT) {
- SDValue True, False;
- MVT VT = Node->getOperand(0).getValueType();
- MVT NVT = Node->getValueType(0);
- const uint64_t zero[] = {0, 0};
- APFloat apf = APFloat(APInt(VT.getSizeInBits(), 2, zero));
- APInt x = APInt::getSignBit(NVT.getSizeInBits());
- (void)apf.convertFromAPInt(x, false, APFloat::rmNearestTiesToEven);
- Tmp2 = DAG.getConstantFP(apf, VT);
- Tmp3 = DAG.getSetCC(dl, TLI.getSetCCResultType(VT),
- Node->getOperand(0),
- Tmp2, ISD::SETLT);
- True = DAG.getNode(ISD::FP_TO_SINT, dl, NVT, Node->getOperand(0));
- False = DAG.getNode(ISD::FP_TO_SINT, dl, NVT,
- DAG.getNode(ISD::FSUB, dl, VT,
- Node->getOperand(0), Tmp2));
- False = DAG.getNode(ISD::XOR, dl, NVT, False,
- DAG.getConstant(x, NVT));
- Result = DAG.getNode(ISD::SELECT, dl, NVT, Tmp3, True, False);
- } else {
- assert(0 && "Do not know how to expand FP_TO_SINT yet!");
- }
- break;
- }
- break;
-
- case ISD::FP_EXTEND: {
- MVT DstVT = Op.getValueType();
- MVT SrcVT = Op.getOperand(0).getValueType();
- if (TLI.getConvertAction(SrcVT, DstVT) == TargetLowering::Expand) {
- // The only other way we can lower this is to turn it into a STORE,
- // LOAD pair, targetting a temporary location (a stack slot).
- Result = EmitStackConvert(Node->getOperand(0), SrcVT, DstVT, dl);
- break;
- }
- Tmp1 = LegalizeOp(Node->getOperand(0));
- Result = DAG.UpdateNodeOperands(Result, Tmp1);
- break;
- }
- case ISD::FP_ROUND: {
- MVT DstVT = Op.getValueType();
- MVT SrcVT = Op.getOperand(0).getValueType();
- if (TLI.getConvertAction(SrcVT, DstVT) == TargetLowering::Expand) {
- if (SrcVT == MVT::ppcf128) {
- // FIXME: Figure out how to extract the double without
- // help from type legalization
- }
- // The only other way we can lower this is to turn it into a STORE,
- // LOAD pair, targetting a temporary location (a stack slot).
- Result = EmitStackConvert(Node->getOperand(0), DstVT, DstVT, dl);
- break;
- }
- Tmp1 = LegalizeOp(Node->getOperand(0));
- Result = DAG.UpdateNodeOperands(Result, Tmp1, Node->getOperand(1));
- break;
- }
- case ISD::ANY_EXTEND:
- case ISD::ZERO_EXTEND:
- case ISD::SIGN_EXTEND:
- Tmp1 = LegalizeOp(Node->getOperand(0));
- Result = DAG.UpdateNodeOperands(Result, Tmp1);
- if (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0)) ==
- TargetLowering::Custom) {
- Tmp1 = TLI.LowerOperation(Result, DAG);
- if (Tmp1.getNode()) Result = Tmp1;
- }
- break;
- case ISD::FP_ROUND_INREG:
- case ISD::SIGN_EXTEND_INREG: {
- Tmp1 = LegalizeOp(Node->getOperand(0));
- MVT ExtraVT = cast<VTSDNode>(Node->getOperand(1))->getVT();
-
- // If this operation is not supported, convert it to a shl/shr or load/store
- // pair.
- switch (TLI.getOperationAction(Node->getOpcode(), ExtraVT)) {
- default: assert(0 && "This action not supported for this op yet!");
- case TargetLowering::Legal:
- Result = DAG.UpdateNodeOperands(Result, Tmp1, Node->getOperand(1));
- break;
- case TargetLowering::Expand:
- // If this is an integer extend and shifts are supported, do that.
- if (Node->getOpcode() == ISD::SIGN_EXTEND_INREG) {
- // NOTE: we could fall back on load/store here too for targets without
- // SAR. However, it is doubtful that any exist.
- unsigned BitsDiff = Node->getValueType(0).getSizeInBits() -
- ExtraVT.getSizeInBits();
- SDValue ShiftCst = DAG.getConstant(BitsDiff, TLI.getShiftAmountTy());
- Result = DAG.getNode(ISD::SHL, dl, Node->getValueType(0),
- Node->getOperand(0), ShiftCst);
- Result = DAG.getNode(ISD::SRA, dl, Node->getValueType(0),
- Result, ShiftCst);
- } else if (Node->getOpcode() == ISD::FP_ROUND_INREG) {
- // The only way we can lower this is to turn it into a TRUNCSTORE,
- // EXTLOAD pair, targetting a temporary location (a stack slot).
-
- // NOTE: there is a choice here between constantly creating new stack
- // slots and always reusing the same one. We currently always create
- // new ones, as reuse may inhibit scheduling.
- Result = EmitStackConvert(Node->getOperand(0), ExtraVT,
- Node->getValueType(0), dl);
- } else {
- assert(0 && "Unknown op");
- }
- break;
- }
- break;
- }
- case ISD::TRAMPOLINE: {
- SDValue Ops[6];
- for (unsigned i = 0; i != 6; ++i)
- Ops[i] = LegalizeOp(Node->getOperand(i));
- Result = DAG.UpdateNodeOperands(Result, Ops, 6);
- // The only option for this node is to custom lower it.
- Result = TLI.LowerOperation(Result, DAG);
- assert(Result.getNode() && "Should always custom lower!");
-
- // Since trampoline produces two values, make sure to remember that we
- // legalized both of them.
- Tmp1 = LegalizeOp(Result.getValue(1));
- Result = LegalizeOp(Result);
- AddLegalizedOperand(SDValue(Node, 0), Result);
- AddLegalizedOperand(SDValue(Node, 1), Tmp1);
- return Op.getResNo() ? Tmp1 : Result;
- }
- case ISD::FLT_ROUNDS_: {
- MVT VT = Node->getValueType(0);
- switch (TLI.getOperationAction(Node->getOpcode(), VT)) {
- default: assert(0 && "This action not supported for this op yet!");
- case TargetLowering::Custom:
- Result = TLI.LowerOperation(Op, DAG);
- if (Result.getNode()) break;
- // Fall Thru
- case TargetLowering::Legal:
- // If this operation is not supported, lower it to constant 1
- Result = DAG.getConstant(1, VT);
- break;
- }
- break;
- }
- case ISD::TRAP: {
- MVT VT = Node->getValueType(0);
- switch (TLI.getOperationAction(Node->getOpcode(), VT)) {
- default: assert(0 && "This action not supported for this op yet!");
- case TargetLowering::Legal:
- Tmp1 = LegalizeOp(Node->getOperand(0));
- Result = DAG.UpdateNodeOperands(Result, Tmp1);
- break;
- case TargetLowering::Custom:
- Result = TLI.LowerOperation(Op, DAG);
- if (Result.getNode()) break;
- // Fall Thru
- case TargetLowering::Expand:
- // If this operation is not supported, lower it to 'abort()' call
- Tmp1 = LegalizeOp(Node->getOperand(0));
- TargetLowering::ArgListTy Args;
- std::pair<SDValue, SDValue> CallResult =
- TLI.LowerCallTo(Tmp1, Type::VoidTy,
- false, false, false, false, CallingConv::C, false,
- DAG.getExternalSymbol("abort", TLI.getPointerTy()),
- Args, DAG, dl);
- Result = CallResult.second;
- break;
- }
- break;
- }
-