Author: Joshua Batista
Date: 2025-07-02T11:22:42-07:00
New Revision: 2ed7b22f0c9e91cf2565aafe1b0bdf387c5a366a

URL: 
https://github.com/llvm/llvm-project/commit/2ed7b22f0c9e91cf2565aafe1b0bdf387c5a366a
DIFF: 
https://github.com/llvm/llvm-project/commit/2ed7b22f0c9e91cf2565aafe1b0bdf387c5a366a.diff

LOG: [HLSL] Add `-Gis` option to clang-dxc (#146448)

This PR adds the `-Gis` option to clang-dxc, to instruct the behavior to
enable IEEE strict mode. The purpose is so that clang-dxc behaves as DXC
does when it takes the -Gis option.
Fixes https://github.com/llvm/llvm-project/issues/145589

Added: 
    clang/test/Options/Gis.hlsl

Modified: 
    clang/include/clang/Driver/Options.td
    clang/lib/Driver/ToolChains/HLSL.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0c8a219b19bf4..8e38f0062140e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -9353,6 +9353,8 @@ def dxc_validator_path_EQ : Joined<["--"], "dxv-path=">, 
Group<dxc_Group>,
   HelpText<"DXIL validator installation path">;
 def dxc_disable_validation : DXCFlag<"Vd">,
   HelpText<"Disable validation">;
+def dxc_gis : DXCFlag<"Gis">,
+  HelpText<"Enable IEEE strict mode (equivalent to -ffp-model=strict)">;
 def : Option<["/", "-"], "Qembed_debug", KIND_FLAG>, Group<dxc_Group>,
   Flags<[Ignored]>, Visibility<[DXCOption]>,
   HelpText<"Embed PDB in shader container (ignored)">;

diff  --git a/clang/lib/Driver/ToolChains/HLSL.cpp 
b/clang/lib/Driver/ToolChains/HLSL.cpp
index 2b83f408b4c07..38f4643abad98 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -339,7 +339,13 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, 
StringRef BoundArch,
       A->claim();
       continue;
     }
-
+    if (A->getOption().getID() == options::OPT_dxc_gis) {
+      // Translate -Gis into -ffp_model_EQ=strict
+      DAL->AddSeparateArg(nullptr, Opts.getOption(options::OPT_ffp_model_EQ),
+                          "strict");
+      A->claim();
+      continue;
+    }
     if (A->getOption().getID() == options::OPT_fvk_use_dx_layout) {
       // This is the only implemented layout so far.
       A->claim();

diff  --git a/clang/test/Options/Gis.hlsl b/clang/test/Options/Gis.hlsl
new file mode 100644
index 0000000000000..a124b7807eaa1
--- /dev/null
+++ b/clang/test/Options/Gis.hlsl
@@ -0,0 +1,13 @@
+// RUN: %clang_dxc -T lib_6_4 -Gis %s 2>&1 -### | FileCheck -check-prefix=Gis 
%s
+// RUN: %clang_dxc -T lib_6_4 %s 2>&1 -### | FileCheck -check-prefix=NO_Gis %s
+
+// Gis: "-ffp-contract=off" "-frounding-math" "-ffp-exception-behavior=strict" 
"-complex-range=full"
+// assert expected floating point options are present
+// NO_Gis-NOT: "-ffp-contract=off" 
+// NO_Gis-NOT: "-frounding-math" 
+// NO_Gis-NOT: "-ffp-exception-behavior=strict" 
+// NO_Gis-NOT: "-complex-range=full"
+float4 main(float4 a : A) : SV_TARGET
+{
+  return -a.yxxx;
+}


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to