@@ -288,15 +288,27 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
288
288
setOperationAction(ISD::FP_TO_SINT, MVT::i32, Custom);
289
289
setOperationAction(ISD::FP_TO_SINT, MVT::i64, Custom);
290
290
setOperationAction(ISD::FP_TO_SINT, MVT::i128, Custom);
291
+ setOperationAction(ISD::STRICT_FP_TO_SINT, MVT::i32, Custom);
292
+ setOperationAction(ISD::STRICT_FP_TO_SINT, MVT::i64, Custom);
293
+ setOperationAction(ISD::STRICT_FP_TO_SINT, MVT::i128, Custom);
291
294
setOperationAction(ISD::FP_TO_UINT, MVT::i32, Custom);
292
295
setOperationAction(ISD::FP_TO_UINT, MVT::i64, Custom);
293
296
setOperationAction(ISD::FP_TO_UINT, MVT::i128, Custom);
297
+ setOperationAction(ISD::STRICT_FP_TO_UINT, MVT::i32, Custom);
298
+ setOperationAction(ISD::STRICT_FP_TO_UINT, MVT::i64, Custom);
299
+ setOperationAction(ISD::STRICT_FP_TO_UINT, MVT::i128, Custom);
294
300
setOperationAction(ISD::SINT_TO_FP, MVT::i32, Custom);
295
301
setOperationAction(ISD::SINT_TO_FP, MVT::i64, Custom);
296
302
setOperationAction(ISD::SINT_TO_FP, MVT::i128, Custom);
303
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::i32, Custom);
304
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::i64, Custom);
305
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::i128, Custom);
297
306
setOperationAction(ISD::UINT_TO_FP, MVT::i32, Custom);
298
307
setOperationAction(ISD::UINT_TO_FP, MVT::i64, Custom);
299
308
setOperationAction(ISD::UINT_TO_FP, MVT::i128, Custom);
309
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::i32, Custom);
310
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::i64, Custom);
311
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::i128, Custom);
300
312
setOperationAction(ISD::FP_ROUND, MVT::f32, Custom);
301
313
setOperationAction(ISD::FP_ROUND, MVT::f64, Custom);
302
314
setOperationAction(ISD::STRICT_FP_ROUND, MVT::f32, Custom);
@@ -2332,9 +2344,16 @@ getAArch64XALUOOp(AArch64CC::CondCode &CC, SDValue Op, SelectionDAG &DAG) {
2332
2344
2333
2345
SDValue AArch64TargetLowering::LowerF128Call(SDValue Op, SelectionDAG &DAG,
2334
2346
RTLIB::Libcall Call) const {
2335
- SmallVector<SDValue, 2> Ops(Op->op_begin(), Op->op_end());
2347
+ bool IsStrict = Op->isStrictFPOpcode();
2348
+ unsigned Offset = IsStrict ? 1 : 0;
2349
+ SDValue Chain = IsStrict ? Op.getOperand(0) : SDValue();
2350
+ SmallVector<SDValue, 2> Ops(Op->op_begin() + Offset, Op->op_end());
2336
2351
MakeLibCallOptions CallOptions;
2337
- return makeLibCall(DAG, Call, MVT::f128, Ops, CallOptions, SDLoc(Op)).first;
2352
+ SDValue Result;
2353
+ SDLoc dl(Op);
2354
+ std::tie(Result, Chain) = makeLibCall(DAG, Call, Op.getValueType(), Ops,
2355
+ CallOptions, dl, Chain);
2356
+ return IsStrict ? DAG.getMergeValues({Result, Chain}, dl) : Result;
2338
2357
}
2339
2358
2340
2359
// Returns true if the given Op is the overflow flag result of an overflow
@@ -2595,32 +2614,34 @@ SDValue AArch64TargetLowering::LowerVectorFP_TO_INT(SDValue Op,
2595
2614
2596
2615
SDValue AArch64TargetLowering::LowerFP_TO_INT(SDValue Op,
2597
2616
SelectionDAG &DAG) const {
2598
- if (Op.getOperand(0).getValueType().isVector())
2617
+ bool IsStrict = Op->isStrictFPOpcode();
2618
+ SDValue SrcVal = Op.getOperand(IsStrict ? 1 : 0);
2619
+
2620
+ if (SrcVal.getValueType().isVector())
2599
2621
return LowerVectorFP_TO_INT(Op, DAG);
2600
2622
2601
2623
// f16 conversions are promoted to f32 when full fp16 is not supported.
2602
- if (Op.getOperand(0). getValueType() == MVT::f16 &&
2603
- !Subtarget->hasFullFP16()) {
2624
+ if (SrcVal. getValueType() == MVT::f16 && !Subtarget->hasFullFP16()) {
2625
+ assert(!IsStrict && "Lowering of strict fp16 not yet implemented");
2604
2626
SDLoc dl(Op);
2605
2627
return DAG.getNode(
2606
2628
Op.getOpcode(), dl, Op.getValueType(),
2607
- DAG.getNode(ISD::FP_EXTEND, dl, MVT::f32, Op.getOperand(0) ));
2629
+ DAG.getNode(ISD::FP_EXTEND, dl, MVT::f32, SrcVal ));
2608
2630
}
2609
2631
2610
- if (Op.getOperand(0) .getValueType() != MVT::f128) {
2632
+ if (SrcVal .getValueType() != MVT::f128) {
2611
2633
// It's legal except when f128 is involved
2612
2634
return Op;
2613
2635
}
2614
2636
2615
2637
RTLIB::Libcall LC;
2616
- if (Op.getOpcode() == ISD::FP_TO_SINT)
2617
- LC = RTLIB::getFPTOSINT(Op.getOperand(0).getValueType(), Op.getValueType());
2638
+ if (Op.getOpcode() == ISD::FP_TO_SINT ||
2639
+ Op.getOpcode() == ISD::STRICT_FP_TO_SINT)
2640
+ LC = RTLIB::getFPTOSINT(SrcVal.getValueType(), Op.getValueType());
2618
2641
else
2619
- LC = RTLIB::getFPTOUINT(Op.getOperand(0) .getValueType(), Op.getValueType());
2642
+ LC = RTLIB::getFPTOUINT(SrcVal .getValueType(), Op.getValueType());
2620
2643
2621
- SmallVector<SDValue, 2> Ops(Op->op_begin(), Op->op_end());
2622
- MakeLibCallOptions CallOptions;
2623
- return makeLibCall(DAG, LC, Op.getValueType(), Ops, CallOptions, SDLoc(Op)).first;
2644
+ return LowerF128Call(Op, DAG, LC);
2624
2645
}
2625
2646
2626
2647
static SDValue LowerVectorINT_TO_FP(SDValue Op, SelectionDAG &DAG) {
@@ -2656,18 +2677,22 @@ SDValue AArch64TargetLowering::LowerINT_TO_FP(SDValue Op,
2656
2677
if (Op.getValueType().isVector())
2657
2678
return LowerVectorINT_TO_FP(Op, DAG);
2658
2679
2680
+ bool IsStrict = Op->isStrictFPOpcode();
2681
+ SDValue SrcVal = Op.getOperand(IsStrict ? 1 : 0);
2682
+
2659
2683
// f16 conversions are promoted to f32 when full fp16 is not supported.
2660
2684
if (Op.getValueType() == MVT::f16 &&
2661
2685
!Subtarget->hasFullFP16()) {
2686
+ assert(!IsStrict && "Lowering of strict fp16 not yet implemented");
2662
2687
SDLoc dl(Op);
2663
2688
return DAG.getNode(
2664
2689
ISD::FP_ROUND, dl, MVT::f16,
2665
- DAG.getNode(Op.getOpcode(), dl, MVT::f32, Op.getOperand(0) ),
2690
+ DAG.getNode(Op.getOpcode(), dl, MVT::f32, SrcVal ),
2666
2691
DAG.getIntPtrConstant(0, dl));
2667
2692
}
2668
2693
2669
2694
// i128 conversions are libcalls.
2670
- if (Op.getOperand(0) .getValueType() == MVT::i128)
2695
+ if (SrcVal .getValueType() == MVT::i128)
2671
2696
return SDValue();
2672
2697
2673
2698
// Other conversions are legal, unless it's to the completely software-based
@@ -2676,10 +2701,11 @@ SDValue AArch64TargetLowering::LowerINT_TO_FP(SDValue Op,
2676
2701
return Op;
2677
2702
2678
2703
RTLIB::Libcall LC;
2679
- if (Op.getOpcode() == ISD::SINT_TO_FP)
2680
- LC = RTLIB::getSINTTOFP(Op.getOperand(0).getValueType(), Op.getValueType());
2704
+ if (Op.getOpcode() == ISD::SINT_TO_FP ||
2705
+ Op.getOpcode() == ISD::STRICT_SINT_TO_FP)
2706
+ LC = RTLIB::getSINTTOFP(SrcVal.getValueType(), Op.getValueType());
2681
2707
else
2682
- LC = RTLIB::getUINTTOFP(Op.getOperand(0) .getValueType(), Op.getValueType());
2708
+ LC = RTLIB::getUINTTOFP(SrcVal .getValueType(), Op.getValueType());
2683
2709
2684
2710
return LowerF128Call(Op, DAG, LC);
2685
2711
}
@@ -3272,9 +3298,13 @@ SDValue AArch64TargetLowering::LowerOperation(SDValue Op,
3272
3298
return LowerPREFETCH(Op, DAG);
3273
3299
case ISD::SINT_TO_FP:
3274
3300
case ISD::UINT_TO_FP:
3301
+ case ISD::STRICT_SINT_TO_FP:
3302
+ case ISD::STRICT_UINT_TO_FP:
3275
3303
return LowerINT_TO_FP(Op, DAG);
3276
3304
case ISD::FP_TO_SINT:
3277
3305
case ISD::FP_TO_UINT:
3306
+ case ISD::STRICT_FP_TO_SINT:
3307
+ case ISD::STRICT_FP_TO_UINT:
3278
3308
return LowerFP_TO_INT(Op, DAG);
3279
3309
case ISD::FSINCOS:
3280
3310
return LowerFSINCOS(Op, DAG);
0 commit comments