aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2023-08-29 01:03:32 -0700
committerJustin Bogner <mail@justinbogner.com>2023-09-13 10:45:39 -0700
commite504194d51e1f0f7ca5b684b4aa99db4940856c2 (patch)
tree928e4b8df57787c9ea20e906b5bde2d7fbd3aecf /clang/lib/Frontend/CompilerInvocation.cpp
parent25e8105bff4d0a9710c3d32fdf857a496fae81a8 (diff)
downloadllvm-e504194d51e1f0f7ca5b684b4aa99db4940856c2.zip
llvm-e504194d51e1f0f7ca5b684b4aa99db4940856c2.tar.gz
llvm-e504194d51e1f0f7ca5b684b4aa99db4940856c2.tar.bz2
[Driver][HLSL] Improve diagnostics for invalid shader model and stage
This adds more validation that a dxil triple is actually useable when compiling HLSL. The OS field of the triple needs to be a versioned shader model. Later, we should set a default if this is empty and check that the version is a shader model we can actually handle. The Environment field of the triple needs to be specified and be a valid shader stage. I'd like to allow this to be empty and treat it like library, but allowing that currently crashes in DXIL metadata handling. Differential Revision: https://reviews.llvm.org/D159103
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 73a3d31..730db8e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4143,10 +4143,24 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
// Validate options for HLSL
if (Opts.HLSL) {
- bool SupportedTarget = (T.getArch() == llvm::Triple::dxil ||
- T.getArch() == llvm::Triple::spirv) &&
- T.getOS() == llvm::Triple::ShaderModel;
- if (!SupportedTarget)
+ // TODO: Revisit restricting SPIR-V to logical once we've figured out how to
+ // handle PhysicalStorageBuffer64 memory model
+ if (T.isDXIL() || T.isSPIRVLogical()) {
+ enum { ShaderModel, ShaderStage };
+ if (T.getOSName().empty()) {
+ Diags.Report(diag::err_drv_hlsl_bad_shader_required_in_target)
+ << ShaderModel << T.str();
+ } else if (!T.isShaderModelOS() || T.getOSVersion() == VersionTuple(0)) {
+ Diags.Report(diag::err_drv_hlsl_bad_shader_unsupported)
+ << ShaderModel << T.getOSName() << T.str();
+ } else if (T.getEnvironmentName().empty()) {
+ Diags.Report(diag::err_drv_hlsl_bad_shader_required_in_target)
+ << ShaderStage << T.str();
+ } else if (!T.isShaderStageEnvironment()) {
+ Diags.Report(diag::err_drv_hlsl_bad_shader_unsupported)
+ << ShaderStage << T.getEnvironmentName() << T.str();
+ }
+ } else
Diags.Report(diag::err_drv_hlsl_unsupported_target) << T.str();
}