Skip to content

[HLSL] Use HLSLToolChain for Vulkan #110306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 30, 2024
Merged

Conversation

s-perron
Copy link
Contributor

The options are not translated correctly when targeting Vulkan using the dxc
driver mode. Resuing the translator used for HLSL.

Fixes problem 2 in #108567.

The options are not translated correctly when targeting Vulkan using the dxc
driver mode. Resuing the translator used for HLSL.

Fixes problem 2 in llvm#108567.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' HLSL HLSL Language Support labels Sep 27, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 27, 2024

@llvm/pr-subscribers-hlsl

@llvm/pr-subscribers-clang

Author: Steven Perron (s-perron)

Changes

The options are not translated correctly when targeting Vulkan using the dxc
driver mode. Resuing the translator used for HLSL.

Fixes problem 2 in #108567.


Full diff: https://github.com/llvm/llvm-project/pull/110306.diff

3 Files Affected:

  • (modified) clang/lib/Driver/Driver.cpp (+1)
  • (modified) clang/test/CodeGenHLSL/entry.hlsl (+4)
  • (modified) clang/test/Driver/dxc_E.hlsl (+1)
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d0c8bdba0ede95..fba6a8853c3960 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6481,6 +6481,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
     case llvm::Triple::ZOS:
       TC = std::make_unique<toolchains::ZOS>(*this, Target, Args);
       break;
+    case llvm::Triple::Vulkan:
     case llvm::Triple::ShaderModel:
       TC = std::make_unique<toolchains::HLSLToolChain>(*this, Target, Args);
       break;
diff --git a/clang/test/CodeGenHLSL/entry.hlsl b/clang/test/CodeGenHLSL/entry.hlsl
index ec4254e76fb66b..cd3bf948df48c4 100644
--- a/clang/test/CodeGenHLSL/entry.hlsl
+++ b/clang/test/CodeGenHLSL/entry.hlsl
@@ -2,6 +2,10 @@
 // RUN:   dxil-pc-shadermodel6.3-compute %s -hlsl-entry foo \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
 
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-compute %s -hlsl-entry foo \
+// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
 // Make sure not mangle entry.
 // CHECK:define void @foo()
 // Make sure add function attribute and numthreads attribute.
diff --git a/clang/test/Driver/dxc_E.hlsl b/clang/test/Driver/dxc_E.hlsl
index 05cfca685c9a65..07715a2e2259af 100644
--- a/clang/test/Driver/dxc_E.hlsl
+++ b/clang/test/Driver/dxc_E.hlsl
@@ -1,4 +1,5 @@
 // RUN: not %clang_dxc -Efoo -Tlib_6_7 foo.hlsl -### %s 2>&1 | FileCheck %s
+// RUN: not %clang_dxc -Efoo -Tlib_6_7 -spirv foo.hlsl -### %s 2>&1 | FileCheck %s
 
 // Make sure E option flag which translated into "-hlsl-entry".
 // CHECK:"-hlsl-entry" "foo"

@llvmbot
Copy link
Member

llvmbot commented Sep 27, 2024

@llvm/pr-subscribers-clang-driver

Author: Steven Perron (s-perron)

Changes

The options are not translated correctly when targeting Vulkan using the dxc
driver mode. Resuing the translator used for HLSL.

Fixes problem 2 in #108567.


Full diff: https://github.com/llvm/llvm-project/pull/110306.diff

3 Files Affected:

  • (modified) clang/lib/Driver/Driver.cpp (+1)
  • (modified) clang/test/CodeGenHLSL/entry.hlsl (+4)
  • (modified) clang/test/Driver/dxc_E.hlsl (+1)
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d0c8bdba0ede95..fba6a8853c3960 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6481,6 +6481,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
     case llvm::Triple::ZOS:
       TC = std::make_unique<toolchains::ZOS>(*this, Target, Args);
       break;
+    case llvm::Triple::Vulkan:
     case llvm::Triple::ShaderModel:
       TC = std::make_unique<toolchains::HLSLToolChain>(*this, Target, Args);
       break;
diff --git a/clang/test/CodeGenHLSL/entry.hlsl b/clang/test/CodeGenHLSL/entry.hlsl
index ec4254e76fb66b..cd3bf948df48c4 100644
--- a/clang/test/CodeGenHLSL/entry.hlsl
+++ b/clang/test/CodeGenHLSL/entry.hlsl
@@ -2,6 +2,10 @@
 // RUN:   dxil-pc-shadermodel6.3-compute %s -hlsl-entry foo \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
 
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-compute %s -hlsl-entry foo \
+// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
 // Make sure not mangle entry.
 // CHECK:define void @foo()
 // Make sure add function attribute and numthreads attribute.
diff --git a/clang/test/Driver/dxc_E.hlsl b/clang/test/Driver/dxc_E.hlsl
index 05cfca685c9a65..07715a2e2259af 100644
--- a/clang/test/Driver/dxc_E.hlsl
+++ b/clang/test/Driver/dxc_E.hlsl
@@ -1,4 +1,5 @@
 // RUN: not %clang_dxc -Efoo -Tlib_6_7 foo.hlsl -### %s 2>&1 | FileCheck %s
+// RUN: not %clang_dxc -Efoo -Tlib_6_7 -spirv foo.hlsl -### %s 2>&1 | FileCheck %s
 
 // Make sure E option flag which translated into "-hlsl-entry".
 // CHECK:"-hlsl-entry" "foo"

@s-perron s-perron merged commit 9f6cd56 into llvm:main Sep 30, 2024
8 checks passed
@s-perron s-perron deleted the different_entry_point branch September 30, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category HLSL HLSL Language Support
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants