@@ -282,15 +282,27 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
282
282
setOperationAction(ISD::FP_TO_SINT, MVT::i32, Custom);
283
283
setOperationAction(ISD::FP_TO_SINT, MVT::i64, Custom);
284
284
setOperationAction(ISD::FP_TO_SINT, MVT::i128, Custom);
285
+ setOperationAction(ISD::STRICT_FP_TO_SINT, MVT::i32, Custom);
286
+ setOperationAction(ISD::STRICT_FP_TO_SINT, MVT::i64, Custom);
287
+ setOperationAction(ISD::STRICT_FP_TO_SINT, MVT::i128, Custom);
285
288
setOperationAction(ISD::FP_TO_UINT, MVT::i32, Custom);
286
289
setOperationAction(ISD::FP_TO_UINT, MVT::i64, Custom);
287
290
setOperationAction(ISD::FP_TO_UINT, MVT::i128, Custom);
291
+ setOperationAction(ISD::STRICT_FP_TO_UINT, MVT::i32, Custom);
292
+ setOperationAction(ISD::STRICT_FP_TO_UINT, MVT::i64, Custom);
293
+ setOperationAction(ISD::STRICT_FP_TO_UINT, MVT::i128, Custom);
288
294
setOperationAction(ISD::SINT_TO_FP, MVT::i32, Custom);
289
295
setOperationAction(ISD::SINT_TO_FP, MVT::i64, Custom);
290
296
setOperationAction(ISD::SINT_TO_FP, MVT::i128, Custom);
297
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::i32, Custom);
298
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::i64, Custom);
299
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::i128, Custom);
291
300
setOperationAction(ISD::UINT_TO_FP, MVT::i32, Custom);
292
301
setOperationAction(ISD::UINT_TO_FP, MVT::i64, Custom);
293
302
setOperationAction(ISD::UINT_TO_FP, MVT::i128, Custom);
303
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::i32, Custom);
304
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::i64, Custom);
305
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::i128, Custom);
294
306
setOperationAction(ISD::FP_ROUND, MVT::f32, Custom);
295
307
setOperationAction(ISD::FP_ROUND, MVT::f64, Custom);
296
308
setOperationAction(ISD::STRICT_FP_ROUND, MVT::f32, Custom);
@@ -2324,9 +2336,16 @@ getAArch64XALUOOp(AArch64CC::CondCode &CC, SDValue Op, SelectionDAG &DAG) {
2324
2336
2325
2337
SDValue AArch64TargetLowering::LowerF128Call(SDValue Op, SelectionDAG &DAG,
2326
2338
RTLIB::Libcall Call) const {
2327
- SmallVector<SDValue, 2> Ops(Op->op_begin(), Op->op_end());
2339
+ bool IsStrict = Op->isStrictFPOpcode();
2340
+ unsigned Offset = IsStrict ? 1 : 0;
2341
+ SDValue Chain = IsStrict ? Op.getOperand(0) : SDValue();
2342
+ SmallVector<SDValue, 2> Ops(Op->op_begin() + Offset, Op->op_end());
2328
2343
MakeLibCallOptions CallOptions;
2329
- return makeLibCall(DAG, Call, MVT::f128, Ops, CallOptions, SDLoc(Op)).first;
2344
+ SDValue Result;
2345
+ SDLoc dl(Op);
2346
+ std::tie(Result, Chain) = makeLibCall(DAG, Call, Op.getValueType(), Ops,
2347
+ CallOptions, dl, Chain);
2348
+ return IsStrict ? DAG.getMergeValues({Result, Chain}, dl) : Result;
2330
2349
}
2331
2350
2332
2351
// Returns true if the given Op is the overflow flag result of an overflow
@@ -2587,32 +2606,34 @@ SDValue AArch64TargetLowering::LowerVectorFP_TO_INT(SDValue Op,
2587
2606
2588
2607
SDValue AArch64TargetLowering::LowerFP_TO_INT(SDValue Op,
2589
2608
SelectionDAG &DAG) const {
2590
- if (Op.getOperand(0).getValueType().isVector())
2609
+ bool IsStrict = Op->isStrictFPOpcode();
2610
+ SDValue SrcVal = Op.getOperand(IsStrict ? 1 : 0);
2611
+
2612
+ if (SrcVal.getValueType().isVector())
2591
2613
return LowerVectorFP_TO_INT(Op, DAG);
2592
2614
2593
2615
// f16 conversions are promoted to f32 when full fp16 is not supported.
2594
- if (Op.getOperand(0). getValueType() == MVT::f16 &&
2595
- !Subtarget->hasFullFP16()) {
2616
+ if (SrcVal. getValueType() == MVT::f16 && !Subtarget->hasFullFP16()) {
2617
+ assert(!IsStrict && "Lowering of strict fp16 not yet implemented");
2596
2618
SDLoc dl(Op);
2597
2619
return DAG.getNode(
2598
2620
Op.getOpcode(), dl, Op.getValueType(),
2599
- DAG.getNode(ISD::FP_EXTEND, dl, MVT::f32, Op.getOperand(0) ));
2621
+ DAG.getNode(ISD::FP_EXTEND, dl, MVT::f32, SrcVal ));
2600
2622
}
2601
2623
2602
- if (Op.getOperand(0) .getValueType() != MVT::f128) {
2624
+ if (SrcVal .getValueType() != MVT::f128) {
2603
2625
// It's legal except when f128 is involved
2604
2626
return Op;
2605
2627
}
2606
2628
2607
2629
RTLIB::Libcall LC;
2608
- if (Op.getOpcode() == ISD::FP_TO_SINT)
2609
- LC = RTLIB::getFPTOSINT(Op.getOperand(0).getValueType(), Op.getValueType());
2630
+ if (Op.getOpcode() == ISD::FP_TO_SINT ||
2631
+ Op.getOpcode() == ISD::STRICT_FP_TO_SINT)
2632
+ LC = RTLIB::getFPTOSINT(SrcVal.getValueType(), Op.getValueType());
2610
2633
else
2611
- LC = RTLIB::getFPTOUINT(Op.getOperand(0) .getValueType(), Op.getValueType());
2634
+ LC = RTLIB::getFPTOUINT(SrcVal .getValueType(), Op.getValueType());
2612
2635
2613
- SmallVector<SDValue, 2> Ops(Op->op_begin(), Op->op_end());
2614
- MakeLibCallOptions CallOptions;
2615
- return makeLibCall(DAG, LC, Op.getValueType(), Ops, CallOptions, SDLoc(Op)).first;
2636
+ return LowerF128Call(Op, DAG, LC);
2616
2637
}
2617
2638
2618
2639
static SDValue LowerVectorINT_TO_FP(SDValue Op, SelectionDAG &DAG) {
@@ -2648,18 +2669,22 @@ SDValue AArch64TargetLowering::LowerINT_TO_FP(SDValue Op,
2648
2669
if (Op.getValueType().isVector())
2649
2670
return LowerVectorINT_TO_FP(Op, DAG);
2650
2671
2672
+ bool IsStrict = Op->isStrictFPOpcode();
2673
+ SDValue SrcVal = Op.getOperand(IsStrict ? 1 : 0);
2674
+
2651
2675
// f16 conversions are promoted to f32 when full fp16 is not supported.
2652
2676
if (Op.getValueType() == MVT::f16 &&
2653
2677
!Subtarget->hasFullFP16()) {
2678
+ assert(!IsStrict && "Lowering of strict fp16 not yet implemented");
2654
2679
SDLoc dl(Op);
2655
2680
return DAG.getNode(
2656
2681
ISD::FP_ROUND, dl, MVT::f16,
2657
- DAG.getNode(Op.getOpcode(), dl, MVT::f32, Op.getOperand(0) ),
2682
+ DAG.getNode(Op.getOpcode(), dl, MVT::f32, SrcVal ),
2658
2683
DAG.getIntPtrConstant(0, dl));
2659
2684
}
2660
2685
2661
2686
// i128 conversions are libcalls.
2662
- if (Op.getOperand(0) .getValueType() == MVT::i128)
2687
+ if (SrcVal .getValueType() == MVT::i128)
2663
2688
return SDValue();
2664
2689
2665
2690
// Other conversions are legal, unless it's to the completely software-based
@@ -2668,10 +2693,11 @@ SDValue AArch64TargetLowering::LowerINT_TO_FP(SDValue Op,
2668
2693
return Op;
2669
2694
2670
2695
RTLIB::Libcall LC;
2671
- if (Op.getOpcode() == ISD::SINT_TO_FP)
2672
- LC = RTLIB::getSINTTOFP(Op.getOperand(0).getValueType(), Op.getValueType());
2696
+ if (Op.getOpcode() == ISD::SINT_TO_FP ||
2697
+ Op.getOpcode() == ISD::STRICT_SINT_TO_FP)
2698
+ LC = RTLIB::getSINTTOFP(SrcVal.getValueType(), Op.getValueType());
2673
2699
else
2674
- LC = RTLIB::getUINTTOFP(Op.getOperand(0) .getValueType(), Op.getValueType());
2700
+ LC = RTLIB::getUINTTOFP(SrcVal .getValueType(), Op.getValueType());
2675
2701
2676
2702
return LowerF128Call(Op, DAG, LC);
2677
2703
}
@@ -3262,9 +3288,13 @@ SDValue AArch64TargetLowering::LowerOperation(SDValue Op,
3262
3288
return LowerPREFETCH(Op, DAG);
3263
3289
case ISD::SINT_TO_FP:
3264
3290
case ISD::UINT_TO_FP:
3291
+ case ISD::STRICT_SINT_TO_FP:
3292
+ case ISD::STRICT_UINT_TO_FP:
3265
3293
return LowerINT_TO_FP(Op, DAG);
3266
3294
case ISD::FP_TO_SINT:
3267
3295
case ISD::FP_TO_UINT:
3296
+ case ISD::STRICT_FP_TO_SINT:
3297
+ case ISD::STRICT_FP_TO_UINT:
3268
3298
return LowerFP_TO_INT(Op, DAG);
3269
3299
case ISD::FSINCOS:
3270
3300
return LowerFSINCOS(Op, DAG);
0 commit comments