[PATCH] D131799: [HLSL] clang codeGen for HLSLNumThreadsAttr
Xiang Li via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 12 14:31:41 PDT 2022
python3kgae updated this revision to Diff 452305.
python3kgae added a comment.
Change attribute name to hlsl.numthreads
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131799/new/
https://reviews.llvm.org/D131799
Files:
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/test/CodeGenHLSL/entry.hlsl
Index: clang/test/CodeGenHLSL/entry.hlsl
===================================================================
--- clang/test/CodeGenHLSL/entry.hlsl
+++ clang/test/CodeGenHLSL/entry.hlsl
@@ -3,8 +3,9 @@
// Make sure not mangle entry.
// CHECK:define void @foo()
// Make sure add function attribute.
-// CHECK:"dx.shader"="compute"
-[numthreads(1,1,1)]
+// CHECK:"hlsl.numthreads"="16,8,1"
+// CHECK-SAME:"dx.shader"="compute"
+[numthreads(16,8,1)]
void foo() {
}
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===================================================================
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -94,4 +94,13 @@
F->addFnAttr(ShaderAttrKindStr,
ShaderAttr->ConvertShaderTypeToStr(ShaderAttr->getType()));
}
+ if (HLSLNumThreadsAttr *NumThreadsAttr = FD->getAttr<HLSLNumThreadsAttr>()) {
+ const StringRef NumThreadsKindStr = "hlsl.numthreads";
+ std::string NumThreadsStr;
+ raw_string_ostream OS(NumThreadsStr);
+ OS << NumThreadsAttr->getX() << "," << NumThreadsAttr->getY() << ","
+ << NumThreadsAttr->getZ();
+ OS.flush();
+ F->addFnAttr(NumThreadsKindStr, NumThreadsStr);
+ }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131799.452305.patch
Type: text/x-patch
Size: 1201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220812/05edcc4d/attachment.bin>
More information about the cfe-commits
mailing list