aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorNatalie Chouinard <sudonatalie@google.com>2024-01-18 12:52:00 -0500
committerGitHub <noreply@github.com>2024-01-18 12:52:00 -0500
commitc21f48e5ad1799db41cc9f16541b8365e3b75e63 (patch)
treecf596d8e996fee87b75c799bdceeb4702186d22a /clang/lib/Frontend/CompilerInvocation.cpp
parentb689e1678c429b724dd898edb9e24cbb9c437667 (diff)
downloadllvm-c21f48e5ad1799db41cc9f16541b8365e3b75e63.zip
llvm-c21f48e5ad1799db41cc9f16541b8365e3b75e63.tar.gz
llvm-c21f48e5ad1799db41cc9f16541b8365e3b75e63.tar.bz2
[HLSL][SPIR-V] Add Vulkan to target triple (#76749)
Add support for specifying the logical SPIR-V target environment in the triple as Vulkan. When compiling HLSL, this replaces the DirectX Shader Model with a Vulkan environment instead. Currently, the only supported combinations of SPIR-V version and Vulkan environment are: - Vulkan 1.2 and SPIR-V 1.5 - Vulkan 1.3 and SPIR-V 1.6 Fixes #70051
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 11f3f2c..b5e192d 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4236,20 +4236,35 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
// 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 };
+ enum { ShaderModel, VulkanEnv, ShaderStage };
+ enum { OS, Environment };
+
+ int ExpectedOS = T.isSPIRVLogical() ? VulkanEnv : ShaderModel;
+
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();
+ << ExpectedOS << OS << T.str();
} else if (T.getEnvironmentName().empty()) {
Diags.Report(diag::err_drv_hlsl_bad_shader_required_in_target)
- << ShaderStage << T.str();
+ << ShaderStage << Environment << T.str();
} else if (!T.isShaderStageEnvironment()) {
Diags.Report(diag::err_drv_hlsl_bad_shader_unsupported)
<< ShaderStage << T.getEnvironmentName() << T.str();
}
+
+ if (T.isDXIL()) {
+ if (!T.isShaderModelOS() || T.getOSVersion() == VersionTuple(0)) {
+ Diags.Report(diag::err_drv_hlsl_bad_shader_unsupported)
+ << ShaderModel << T.getOSName() << T.str();
+ }
+ } else if (T.isSPIRVLogical()) {
+ if (!T.isVulkanOS() || T.getVulkanVersion() == VersionTuple(0)) {
+ Diags.Report(diag::err_drv_hlsl_bad_shader_unsupported)
+ << VulkanEnv << T.getOSName() << T.str();
+ }
+ } else {
+ llvm_unreachable("expected DXIL or SPIR-V target");
+ }
} else
Diags.Report(diag::err_drv_hlsl_unsupported_target) << T.str();
}