-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[HLSL] Add -Gis
option to clang-dxc
#146448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-hlsl @llvm/pr-subscribers-clang-driver Author: Joshua Batista (bob80905) ChangesThis PR adds the Full diff: https://github.com/llvm/llvm-project/pull/146448.diff 3 Files Affected:
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 0ffd8c40da7da..a1e56e2ec9b8c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -9306,6 +9306,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 dcc51e182924c..4a4938a501e9e 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -330,6 +330,14 @@ 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;
+ }
+
DAL->append(A);
}
diff --git a/clang/test/Options/Gis.hlsl b/clang/test/Options/Gis.hlsl
new file mode 100644
index 0000000000000..5a11b7ba64ff0
--- /dev/null
+++ b/clang/test/Options/Gis.hlsl
@@ -0,0 +1,12 @@
+// 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
+// RUN: not %clang_dxc -T lib_6_4 /Gis gibberish -### %s 2>&1 | FileCheck -check-prefix=CHECK-ERR %s
+
+// Gis: "-fmath-errno" "-ffp-contract=off" "-frounding-math" "-ffp-exception-behavior=strict" "-complex-range=full"
+// assert expected floating point options are present
+// NO_Gis-NOT: "-fmath-errno" "-ffp-contract=off" "-frounding-math" "-ffp-exception-behavior=strict" "-complex-range=full"
+// CHECK-ERR: error: no such file or directory: 'gibberish'
+float4 main(float4 a : A) : SV_TARGET
+{
+ return -a.yxxx;
+}
|
clang/test/Options/Gis.hlsl
Outdated
// Gis: "-fmath-errno" "-ffp-contract=off" "-frounding-math" "-ffp-exception-behavior=strict" "-complex-range=full" | ||
// assert expected floating point options are present | ||
// NO_Gis-NOT: "-fmath-errno" "-ffp-contract=off" "-frounding-math" "-ffp-exception-behavior=strict" "-complex-range=full" | ||
// CHECK-ERR: error: no such file or directory: 'gibberish' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error check seems unrelated to the change you're making here.
clang/test/Options/Gis.hlsl
Outdated
|
||
// Gis: "-fmath-errno" "-ffp-contract=off" "-frounding-math" "-ffp-exception-behavior=strict" "-complex-range=full" | ||
// assert expected floating point options are present | ||
// NO_Gis-NOT: "-fmath-errno" "-ffp-contract=off" "-frounding-math" "-ffp-exception-behavior=strict" "-complex-range=full" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably be better to split this into one NO_Gis-NOT
line per flag, that way the order of the flags doesn't matter it will verify that none of the flags ever appear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will have some nuanced differences from what DXC does today because of the differences in granularity of floating point semantic controls in LLVM today vs 3.7. That said, I think this will be conservatively correct and is probably the best approach.
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 #145589