From d50c3f34a2eda5bf5e278c78d32cc9923fd83b82 Mon Sep 17 00:00:00 2001 From: aidanfnv Date: Tue, 1 Jul 2025 00:41:52 -0700 Subject: Add arguments for controlling floating point denormal mode (#7461) * Implement -fp-denorm-mode slangc arg * Split fp-denorm-mode into 3 args for fp16/32/64 * Remove redundant option categories * Use emitInst for multiple of the same OpExecutionMode * Fix formatting * Remove -denorm any * Re-add option categories * emitinst for ftz * Use enums for type text * Remove extra categories again * Add tests for denorm mode * Move denorm mode to post linking * format code (#8) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * regenerate command line reference (#9) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Clean up tests * Fix option text * format code (#10) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Add tests for "any" mode * Return "any" enum if option not set * Simplify emission logic * Add support for generic entrypoints * Move denorm modes to end of CompilerOptionName enum * format code (#11) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Move new enum members to before CountOf * Add not checks to tests, fix generic test, add functionality tests * Rename denorm to fpDenormal * Clean up functional test * Rename denorm test dir * Fix formatting, regenerate cmdline ref * Fold simple tests into functional tests, add more dxil checks * Remove no-op DX tests, make tests more consistent * Disable VK functionality tests that will fail on the CI configs * Fix formatting * Add comments to disabled tests explaining why --------- Co-authored-by: slangbot Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/core/slang-type-text-util.cpp | 13 +++++++++++++ source/core/slang-type-text-util.h | 2 ++ 2 files changed, 15 insertions(+) (limited to 'source/core') diff --git a/source/core/slang-type-text-util.cpp b/source/core/slang-type-text-util.cpp index 9f55b69e2..39b68db45 100644 --- a/source/core/slang-type-text-util.cpp +++ b/source/core/slang-type-text-util.cpp @@ -171,6 +171,14 @@ static const NamesDescriptionValue s_floatingPointModes[] = { "by the target."}, {SLANG_FLOATING_POINT_MODE_DEFAULT, "default", "Default floating point mode"}}; +static const NamesDescriptionValue s_fpDenormalModes[] = { + {SLANG_FP_DENORM_MODE_ANY, + "any", + "Use any denormal handling mode (default). The mode used is implementation defined."}, + {SLANG_FP_DENORM_MODE_PRESERVE, "preserve", "Preserve denormal values"}, + {SLANG_FP_DENORM_MODE_FTZ, "ftz", "Flush denormals to zero"}, +}; + static const NamesDescriptionValue s_optimizationLevels[] = { {SLANG_OPTIMIZATION_LEVEL_NONE, "0,none", "Disable all optimizations"}, {SLANG_OPTIMIZATION_LEVEL_DEFAULT, @@ -253,6 +261,11 @@ static const NamesDescriptionValue s_fileSystemTypes[] = { return makeConstArrayView(s_floatingPointModes); } +/* static */ ConstArrayView TypeTextUtil::getFpDenormalModeInfos() +{ + return makeConstArrayView(s_fpDenormalModes); +} + /* static */ ConstArrayView TypeTextUtil::getOptimizationLevelInfos() { return makeConstArrayView(s_optimizationLevels); diff --git a/source/core/slang-type-text-util.h b/source/core/slang-type-text-util.h index eddbcec5e..684d109c3 100644 --- a/source/core/slang-type-text-util.h +++ b/source/core/slang-type-text-util.h @@ -45,6 +45,8 @@ struct TypeTextUtil static ConstArrayView getDebugLevelInfos(); /// Get the floating point modes static ConstArrayView getFloatingPointModeInfos(); + /// Get the floating point denormal handling modes + static ConstArrayView getFpDenormalModeInfos(); // Get the line directive infos static ConstArrayView getLineDirectiveInfos(); /// Get the optimization level info -- cgit v1.2.3