aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGHLSLRuntime.cpp
diff options
context:
space:
mode:
authorZhengxing li <zhengxingli@microsoft.com>2024-12-10 13:18:49 -0800
committerGitHub <noreply@github.com>2024-12-10 13:18:49 -0800
commit951a284fdff43f9b3aa2d2dbb2d01bbce3ab0673 (patch)
tree59dbea567d2a52306f75c78c6e3baa9d84cb5d13 /clang/lib/CodeGen/CGHLSLRuntime.cpp
parent968e3b682362e46042a718036ea7a641909b6375 (diff)
downloadllvm-951a284fdff43f9b3aa2d2dbb2d01bbce3ab0673.zip
llvm-951a284fdff43f9b3aa2d2dbb2d01bbce3ab0673.tar.gz
llvm-951a284fdff43f9b3aa2d2dbb2d01bbce3ab0673.tar.bz2
[HLSL] Implement SV_GroupThreadId semantic (#117781)
Support HLSL SV_GroupThreadId attribute. For `directx` target, translate it into `dx.thread.id.in.group` in clang codeGen and lower `dx.thread.id.in.group` to `dx.op.threadIdInGroup` in LLVM DirectX backend. For `spir-v` target, translate it into `spv.thread.id.in.group` in clang codeGen and lower `spv.thread.id.in.group` to a `LocalInvocationId` builtin variable in LLVM SPIR-V backend. Fixes: #70122
Diffstat (limited to 'clang/lib/CodeGen/CGHLSLRuntime.cpp')
-rw-r--r--clang/lib/CodeGen/CGHLSLRuntime.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 2c29352..fb15b19 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -389,6 +389,11 @@ llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> &B,
CGM.getIntrinsic(getThreadIdIntrinsic());
return buildVectorInput(B, ThreadIDIntrinsic, Ty);
}
+ if (D.hasAttr<HLSLSV_GroupThreadIDAttr>()) {
+ llvm::Function *GroupThreadIDIntrinsic =
+ CGM.getIntrinsic(getGroupThreadIdIntrinsic());
+ return buildVectorInput(B, GroupThreadIDIntrinsic, Ty);
+ }
if (D.hasAttr<HLSLSV_GroupIDAttr>()) {
llvm::Function *GroupIDIntrinsic = CGM.getIntrinsic(Intrinsic::dx_group_id);
return buildVectorInput(B, GroupIDIntrinsic, Ty);