[clang] [llvm] [HLSL] AST support for WaveSize attribute. (PR #101240)
Xiang Li via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 30 15:59:54 PDT 2024
================
@@ -348,6 +391,77 @@ void SemaHLSL::handleNumThreadsAttr(Decl *D, const ParsedAttr &AL) {
D->addAttr(NewAttr);
}
+void SemaHLSL::handleWaveSizeAttr(Decl *D, const ParsedAttr &AL) {
+ // validate that the wavesize argument is a power of 2 between 4 and 128
+ // inclusive
+ unsigned SpelledArgsCount = AL.getNumArgs();
+ if (SpelledArgsCount == 0 || SpelledArgsCount > 3)
+ return;
+
+ uint32_t Min;
+ if (!SemaRef.checkUInt32Argument(AL, AL.getArgAsExpr(0), Min))
+ return;
+
+ uint32_t Max = 0;
+ if (SpelledArgsCount > 1 &&
+ !SemaRef.checkUInt32Argument(AL, AL.getArgAsExpr(1), Max))
+ return;
+
+ uint32_t Preferred = 0;
+ if (SpelledArgsCount > 2 &&
+ !SemaRef.checkUInt32Argument(AL, AL.getArgAsExpr(2), Preferred))
+ return;
+ llvm::hlsl::WaveSize WaveSize(Min, Max, Preferred);
+ llvm::hlsl::WaveSize::ValidationResult ValidationResult = WaveSize.validate();
----------------
python3kgae wrote:
We'll need to validate WaveSize at llvm IR level as well.
WaveSize::validate could be shared between Sema and DirectX backend.
https://github.com/llvm/llvm-project/pull/101240
More information about the cfe-commits
mailing list