Skip to content

Commit 8c2fd96

Browse files
committed
define hlsl-rootsig-ver for the clang/cc1/dxc drivers
- allow for fall-through from dxcoptions to cc1 options - defined as a langopts and only allow when we are compiling HLSL
1 parent fde2b30 commit 8c2fd96

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

clang/include/clang/Basic/LangOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "clang/Basic/Visibility.h"
2525
#include "llvm/ADT/FloatingPointMode.h"
2626
#include "llvm/ADT/StringRef.h"
27+
#include "llvm/Support/DXILABI.h"
2728
#include "llvm/TargetParser/Triple.h"
2829
#include <optional>
2930
#include <string>
@@ -623,6 +624,10 @@ class LangOptions : public LangOptionsBase {
623624
// implementation on real-world examples.
624625
std::string OpenACCMacroOverride;
625626

627+
/// The HLSL root signature version for dxil.
628+
llvm::dxil::RootSignatureVersion HLSLRootSigVer =
629+
llvm::dxil::RootSignatureVersion::rootsig_1_1;
630+
626631
// Indicates if the wasm-opt binary must be ignored in the case of a
627632
// WebAssembly target.
628633
bool NoWasmOpt = false;

clang/include/clang/Driver/Options.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9288,6 +9288,15 @@ def fcgl : DXCFlag<"fcgl">, Alias<emit_pristine_llvm>;
92889288
def enable_16bit_types : DXCFlag<"enable-16bit-types">, Alias<fnative_half_type>,
92899289
HelpText<"Enable 16-bit types and disable min precision types."
92909290
"Available in HLSL 2018 and shader model 6.2.">;
9291+
def hlsl_rootsig_ver :
9292+
Option<["-"], "hlsl-rootsig-ver", KIND_SEPARATE>,
9293+
Group<dxc_Group>,
9294+
Visibility<[ClangOption, CC1Option, DXCOption]>,
9295+
HelpText<"Root Signature Version">,
9296+
Values<"rootsig_1_0,rootsig_1_1">,
9297+
NormalizedValuesScope<"llvm::dxil::RootSignatureVersion">,
9298+
NormalizedValues<["rootsig_1_0", "rootsig_1_1"]>,
9299+
MarshallingInfoEnum<LangOpts<"HLSLRootSigVer">, "rootsig_1_1">;
92919300
def hlsl_entrypoint : Option<["-"], "hlsl-entry", KIND_SEPARATE>,
92929301
Group<dxc_Group>,
92939302
Visibility<[ClangOption, CC1Option]>,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3834,7 +3834,8 @@ static void RenderHLSLOptions(const ArgList &Args, ArgStringList &CmdArgs,
38343834
options::OPT_emit_obj,
38353835
options::OPT_disable_llvm_passes,
38363836
options::OPT_fnative_half_type,
3837-
options::OPT_hlsl_entrypoint};
3837+
options::OPT_hlsl_entrypoint,
3838+
options::OPT_hlsl_rootsig_ver};
38383839
if (!types::isHLSL(InputType))
38393840
return;
38403841
for (const auto &Arg : ForwardedArguments)

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,10 @@ static bool FixupInvocation(CompilerInvocation &Invocation,
636636
Diags.Report(diag::err_drv_argument_not_allowed_with)
637637
<< "-hlsl-entry" << GetInputKindName(IK);
638638

639+
if (Args.hasArg(OPT_hlsl_rootsig_ver) && !LangOpts.HLSL)
640+
Diags.Report(diag::err_drv_argument_not_allowed_with)
641+
<< "-hlsl-rootsig-ver" << GetInputKindName(IK);
642+
639643
if (Args.hasArg(OPT_fgpu_allow_device_init) && !LangOpts.HIP)
640644
Diags.Report(diag::warn_ignored_hip_only_option)
641645
<< Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);

0 commit comments

Comments
 (0)