@@ -35,7 +35,8 @@ static LegalityPredicate typeIsScalarFPArith(unsigned TypeIdx,
35
35
const RISCVSubtarget &ST) {
36
36
return [=, &ST](const LegalityQuery &Query) {
37
37
return Query.Types [TypeIdx].isScalar () &&
38
- ((ST.hasStdExtF () && Query.Types [TypeIdx].getSizeInBits () == 32 ) ||
38
+ ((ST.hasStdExtZfh () && Query.Types [TypeIdx].getSizeInBits () == 16 ) ||
39
+ (ST.hasStdExtF () && Query.Types [TypeIdx].getSizeInBits () == 32 ) ||
39
40
(ST.hasStdExtD () && Query.Types [TypeIdx].getSizeInBits () == 64 ));
40
41
};
41
42
}
@@ -371,25 +372,17 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
371
372
372
373
// FP Operations
373
374
374
- auto &FPArithActions = getActionDefinitionsBuilder (
375
- {G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FMA, G_FNEG,
376
- G_FABS, G_FSQRT, G_FMAXNUM, G_FMINNUM})
377
- .legalIf (typeIsScalarFPArith (0 , ST));
378
- // TODO: Fold this into typeIsScalarFPArith.
379
- if (ST.hasStdExtZfh ())
380
- FPArithActions.legalFor ({s16});
375
+ getActionDefinitionsBuilder ({G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FMA, G_FNEG,
376
+ G_FABS, G_FSQRT, G_FMAXNUM, G_FMINNUM})
377
+ .legalIf (typeIsScalarFPArith (0 , ST));
381
378
382
379
getActionDefinitionsBuilder (G_FREM)
383
380
.libcallFor ({s32, s64})
384
381
.minScalar (0 , s32)
385
382
.scalarize (0 );
386
383
387
- auto &CopySignActions =
388
- getActionDefinitionsBuilder (G_FCOPYSIGN)
389
- .legalIf (all (typeIsScalarFPArith (0 , ST), typeIsScalarFPArith (1 , ST)));
390
- // TODO: Fold this into typeIsScalarFPArith.
391
- if (ST.hasStdExtZfh ())
392
- CopySignActions.legalFor ({s16, s16});
384
+ getActionDefinitionsBuilder (G_FCOPYSIGN)
385
+ .legalIf (all (typeIsScalarFPArith (0 , ST), typeIsScalarFPArith (1 , ST)));
393
386
394
387
getActionDefinitionsBuilder (G_FPTRUNC).legalIf (
395
388
[=, &ST](const LegalityQuery &Query) -> bool {
@@ -402,40 +395,28 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
402
395
typeIs (1 , s32)(Query));
403
396
});
404
397
405
- auto &FCmpActions = getActionDefinitionsBuilder (G_FCMP).legalIf (
406
- all (typeIs (0 , sXLen ), typeIsScalarFPArith (1 , ST)));
407
- // TODO: Fold this into typeIsScalarFPArith.
408
- if (ST.hasStdExtZfh ())
409
- FCmpActions.legalFor ({sXLen , s16});
410
- FCmpActions.clampScalar (0 , sXLen , sXLen );
398
+ getActionDefinitionsBuilder (G_FCMP)
399
+ .legalIf (all (typeIs (0 , sXLen ), typeIsScalarFPArith (1 , ST)))
400
+ .clampScalar (0 , sXLen , sXLen );
411
401
412
402
// TODO: Support vector version of G_IS_FPCLASS.
413
- auto &FClassActions =
414
- getActionDefinitionsBuilder (G_IS_FPCLASS)
415
- .customIf (all (typeIs (0 , s1), typeIsScalarFPArith (1 , ST)));
416
- // TODO: Fold this into typeIsScalarFPArith.
417
- if (ST.hasStdExtZfh ())
418
- FClassActions.customFor ({s1, s16});
419
-
420
- auto &FConstantActions = getActionDefinitionsBuilder (G_FCONSTANT)
421
- .legalIf (typeIsScalarFPArith (0 , ST));
422
- if (ST.hasStdExtZfh ())
423
- FConstantActions.legalFor ({s16});
424
- FConstantActions.lowerFor ({s32, s64});
425
-
426
- auto &FPToIActions =
427
- getActionDefinitionsBuilder ({G_FPTOSI, G_FPTOUI})
428
- .legalIf (all (typeInSet (0 , {s32, sXLen }), typeIsScalarFPArith (1 , ST)));
429
- if (ST.hasStdExtZfh ())
430
- FPToIActions.legalFor ({{s32, s16}, {sXLen , s16}});
431
- FPToIActions.widenScalarToNextPow2 (0 ).clampScalar (0 , s32, sXLen ).libcall ();
432
-
433
- auto &IToFPActions =
434
- getActionDefinitionsBuilder ({G_SITOFP, G_UITOFP})
435
- .legalIf (all (typeIsScalarFPArith (0 , ST), typeInSet (1 , {s32, sXLen })));
436
- if (ST.hasStdExtZfh ())
437
- IToFPActions.legalFor ({{s16, s32}, {s16, sXLen }});
438
- IToFPActions.widenScalarToNextPow2 (1 ).clampScalar (1 , s32, sXLen );
403
+ getActionDefinitionsBuilder (G_IS_FPCLASS)
404
+ .customIf (all (typeIs (0 , s1), typeIsScalarFPArith (1 , ST)));
405
+
406
+ getActionDefinitionsBuilder (G_FCONSTANT)
407
+ .legalIf (typeIsScalarFPArith (0 , ST))
408
+ .lowerFor ({s32, s64});
409
+
410
+ getActionDefinitionsBuilder ({G_FPTOSI, G_FPTOUI})
411
+ .legalIf (all (typeInSet (0 , {s32, sXLen }), typeIsScalarFPArith (1 , ST)))
412
+ .widenScalarToNextPow2 (0 )
413
+ .clampScalar (0 , s32, sXLen )
414
+ .libcall ();
415
+
416
+ getActionDefinitionsBuilder ({G_SITOFP, G_UITOFP})
417
+ .legalIf (all (typeIsScalarFPArith (0 , ST), typeInSet (1 , {s32, sXLen })))
418
+ .widenScalarToNextPow2 (1 )
419
+ .clampScalar (1 , s32, sXLen );
439
420
440
421
// FIXME: We can do custom inline expansion like SelectionDAG.
441
422
// FIXME: Legal with Zfa.
0 commit comments