1010#define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
1111
1212#include " SIDefines.h"
13+ #include " llvm/ADT/FloatingPointMode.h"
1314#include " llvm/IR/CallingConv.h"
1415#include " llvm/Support/Alignment.h"
1516#include < array>
@@ -1299,21 +1300,17 @@ struct SIModeRegisterDefaults {
12991300
13001301 // / If this is set, neither input or output denormals are flushed for most f32
13011302 // / instructions.
1302- bool FP32InputDenormals : 1 ;
1303- bool FP32OutputDenormals : 1 ;
1303+ DenormalMode FP32Denormals;
13041304
13051305 // / If this is set, neither input or output denormals are flushed for both f64
13061306 // / and f16/v2f16 instructions.
1307- bool FP64FP16InputDenormals : 1 ;
1308- bool FP64FP16OutputDenormals : 1 ;
1307+ DenormalMode FP64FP16Denormals;
13091308
13101309 SIModeRegisterDefaults () :
13111310 IEEE (true ),
13121311 DX10Clamp (true ),
1313- FP32InputDenormals (true ),
1314- FP32OutputDenormals (true ),
1315- FP64FP16InputDenormals (true ),
1316- FP64FP16OutputDenormals (true ) {}
1312+ FP32Denormals (DenormalMode::getIEEE()),
1313+ FP64FP16Denormals (DenormalMode::getIEEE()) {}
13171314
13181315 SIModeRegisterDefaults (const Function &F);
13191316
@@ -1325,42 +1322,40 @@ struct SIModeRegisterDefaults {
13251322
13261323 bool operator ==(const SIModeRegisterDefaults Other) const {
13271324 return IEEE == Other.IEEE && DX10Clamp == Other.DX10Clamp &&
1328- FP32InputDenormals == Other.FP32InputDenormals &&
1329- FP32OutputDenormals == Other.FP32OutputDenormals &&
1330- FP64FP16InputDenormals == Other.FP64FP16InputDenormals &&
1331- FP64FP16OutputDenormals == Other.FP64FP16OutputDenormals ;
1325+ FP32Denormals == Other.FP32Denormals &&
1326+ FP64FP16Denormals == Other.FP64FP16Denormals ;
13321327 }
13331328
13341329 bool allFP32Denormals () const {
1335- return FP32InputDenormals && FP32OutputDenormals ;
1330+ return FP32Denormals == DenormalMode::getIEEE () ;
13361331 }
13371332
13381333 bool allFP64FP16Denormals () const {
1339- return FP64FP16InputDenormals && FP64FP16OutputDenormals ;
1334+ return FP64FP16Denormals == DenormalMode::getIEEE () ;
13401335 }
13411336
13421337 // / Get the encoding value for the FP_DENORM bits of the mode register for the
13431338 // / FP32 denormal mode.
13441339 uint32_t fpDenormModeSPValue () const {
1345- if (FP32InputDenormals && FP32OutputDenormals )
1346- return FP_DENORM_FLUSH_NONE ;
1347- if (FP32InputDenormals )
1340+ if (FP32Denormals == DenormalMode::getPreserveSign () )
1341+ return FP_DENORM_FLUSH_IN_FLUSH_OUT ;
1342+ if (FP32Denormals. Output == DenormalMode::PreserveSign )
13481343 return FP_DENORM_FLUSH_OUT;
1349- if (FP32OutputDenormals )
1344+ if (FP32Denormals. Input == DenormalMode::PreserveSign )
13501345 return FP_DENORM_FLUSH_IN;
1351- return FP_DENORM_FLUSH_IN_FLUSH_OUT ;
1346+ return FP_DENORM_FLUSH_NONE ;
13521347 }
13531348
13541349 // / Get the encoding value for the FP_DENORM bits of the mode register for the
13551350 // / FP64/FP16 denormal mode.
13561351 uint32_t fpDenormModeDPValue () const {
1357- if (FP64FP16InputDenormals && FP64FP16OutputDenormals )
1358- return FP_DENORM_FLUSH_NONE ;
1359- if (FP64FP16InputDenormals )
1352+ if (FP64FP16Denormals == DenormalMode::getPreserveSign () )
1353+ return FP_DENORM_FLUSH_IN_FLUSH_OUT ;
1354+ if (FP64FP16Denormals. Output == DenormalMode::PreserveSign )
13601355 return FP_DENORM_FLUSH_OUT;
1361- if (FP64FP16OutputDenormals )
1356+ if (FP64FP16Denormals. Input == DenormalMode::PreserveSign )
13621357 return FP_DENORM_FLUSH_IN;
1363- return FP_DENORM_FLUSH_IN_FLUSH_OUT ;
1358+ return FP_DENORM_FLUSH_NONE ;
13641359 }
13651360
13661361 // / Returns true if a flag is compatible if it's enabled in the callee, but
@@ -1378,10 +1373,20 @@ struct SIModeRegisterDefaults {
13781373 return false ;
13791374
13801375 // Allow inlining denormals enabled into denormals flushed functions.
1381- return oneWayCompatible (FP64FP16InputDenormals, CalleeMode.FP64FP16InputDenormals ) &&
1382- oneWayCompatible (FP64FP16OutputDenormals, CalleeMode.FP64FP16OutputDenormals ) &&
1383- oneWayCompatible (FP32InputDenormals, CalleeMode.FP32InputDenormals ) &&
1384- oneWayCompatible (FP32OutputDenormals, CalleeMode.FP32OutputDenormals );
1376+ return oneWayCompatible (FP64FP16Denormals.Input !=
1377+ DenormalMode::PreserveSign,
1378+ CalleeMode.FP64FP16Denormals .Input !=
1379+ DenormalMode::PreserveSign) &&
1380+ oneWayCompatible (FP64FP16Denormals.Output !=
1381+ DenormalMode::PreserveSign,
1382+ CalleeMode.FP64FP16Denormals .Output !=
1383+ DenormalMode::PreserveSign) &&
1384+ oneWayCompatible (FP32Denormals.Input != DenormalMode::PreserveSign,
1385+ CalleeMode.FP32Denormals .Input !=
1386+ DenormalMode::PreserveSign) &&
1387+ oneWayCompatible (FP32Denormals.Output != DenormalMode::PreserveSign,
1388+ CalleeMode.FP32Denormals .Output !=
1389+ DenormalMode::PreserveSign);
13851390 }
13861391};
13871392
0 commit comments