Skip to content

Commit 2ed7b22

Browse files
authored
[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 #145589
1 parent 218fd69 commit 2ed7b22

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9353,6 +9353,8 @@ def dxc_validator_path_EQ : Joined<["--"], "dxv-path=">, Group<dxc_Group>,
93539353
HelpText<"DXIL validator installation path">;
93549354
def dxc_disable_validation : DXCFlag<"Vd">,
93559355
HelpText<"Disable validation">;
9356+
def dxc_gis : DXCFlag<"Gis">,
9357+
HelpText<"Enable IEEE strict mode (equivalent to -ffp-model=strict)">;
93569358
def : Option<["/", "-"], "Qembed_debug", KIND_FLAG>, Group<dxc_Group>,
93579359
Flags<[Ignored]>, Visibility<[DXCOption]>,
93589360
HelpText<"Embed PDB in shader container (ignored)">;

clang/lib/Driver/ToolChains/HLSL.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,13 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch,
339339
A->claim();
340340
continue;
341341
}
342-
342+
if (A->getOption().getID() == options::OPT_dxc_gis) {
343+
// Translate -Gis into -ffp_model_EQ=strict
344+
DAL->AddSeparateArg(nullptr, Opts.getOption(options::OPT_ffp_model_EQ),
345+
"strict");
346+
A->claim();
347+
continue;
348+
}
343349
if (A->getOption().getID() == options::OPT_fvk_use_dx_layout) {
344350
// This is the only implemented layout so far.
345351
A->claim();

clang/test/Options/Gis.hlsl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang_dxc -T lib_6_4 -Gis %s 2>&1 -### | FileCheck -check-prefix=Gis %s
2+
// RUN: %clang_dxc -T lib_6_4 %s 2>&1 -### | FileCheck -check-prefix=NO_Gis %s
3+
4+
// Gis: "-ffp-contract=off" "-frounding-math" "-ffp-exception-behavior=strict" "-complex-range=full"
5+
// assert expected floating point options are present
6+
// NO_Gis-NOT: "-ffp-contract=off"
7+
// NO_Gis-NOT: "-frounding-math"
8+
// NO_Gis-NOT: "-ffp-exception-behavior=strict"
9+
// NO_Gis-NOT: "-complex-range=full"
10+
float4 main(float4 a : A) : SV_TARGET
11+
{
12+
return -a.yxxx;
13+
}

0 commit comments

Comments
 (0)