aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorChris Bieneman <chris.bieneman@me.com>2022-09-02 10:45:53 -0500
committerChris Bieneman <chris.bieneman@me.com>2022-09-02 13:36:23 -0500
commit10194a51a9d304ab9f68432f244749c672f9012a (patch)
tree1e7f070fdbaecaff136310c830c333ddc93f0f57 /clang/lib/Frontend/CompilerInvocation.cpp
parent662ee93cbbaad27e8dfecfdd4731dc4b168658b4 (diff)
downloadllvm-10194a51a9d304ab9f68432f244749c672f9012a.zip
llvm-10194a51a9d304ab9f68432f244749c672f9012a.tar.gz
llvm-10194a51a9d304ab9f68432f244749c672f9012a.tar.bz2
[HLSL] Restrict to supported targets
Someday we would like to support HLSL on a wider range of targets, but today targeting anything other than `dxil` is likly to cause lots of headaches. This adds an error and tests to validate that the expected target is `dxil-?-shadermodel`. We will continue to do a best effort to ensure the code we write makes it easy to support other targets (like SPIR-V), but this error will prevent users from hitting frustrating errors for unsupported cases. Reviewed By: jcranmer-intel, Anastasia Differential Revision: https://reviews.llvm.org/D132056
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 574514b..9ac522a 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4107,6 +4107,14 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
if (const Arg *A = Args.getLastArg(OPT_frandomize_layout_seed_EQ))
Opts.RandstructSeed = A->getValue(0);
+ // Validate options for HLSL
+ if (Opts.HLSL) {
+ bool SupportedTarget = T.getArch() == llvm::Triple::dxil &&
+ T.getOS() == llvm::Triple::ShaderModel;
+ if (!SupportedTarget)
+ Diags.Report(diag::err_drv_hlsl_unsupported_target) << T.str();
+ }
+
return Diags.getNumErrors() == NumErrorsBefore;
}