From 10194a51a9d304ab9f68432f244749c672f9012a Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Fri, 2 Sep 2022 10:45:53 -0500 Subject: [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 --- clang/lib/Frontend/CompilerInvocation.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') 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; } -- cgit v1.1