python3kgae created this revision. python3kgae added reviewers: bogner, beanz, pow2clk. Herald added a subscriber: Anastasia. Herald added a project: All. python3kgae requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Translate HLSLNumThreadsAttr into function attribute with name "dx.numthreads" and value format as "x,y,z". Repository: rG LLVM Github Monorepo 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:"dx.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 = "dx.numthreads"; + std::string NumThreadsStr; + raw_string_ostream OS(NumThreadsStr); + OS << NumThreadsAttr->getX() << "," << NumThreadsAttr->getY() << "," + << NumThreadsAttr->getZ(); + OS.flush(); + F->addFnAttr(NumThreadsKindStr, NumThreadsStr); + } }
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:"dx.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 = "dx.numthreads"; + std::string NumThreadsStr; + raw_string_ostream OS(NumThreadsStr); + OS << NumThreadsAttr->getX() << "," << NumThreadsAttr->getY() << "," + << NumThreadsAttr->getZ(); + OS.flush(); + F->addFnAttr(NumThreadsKindStr, NumThreadsStr); + } }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits