================ @@ -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(); ---------------- bogner wrote:
What do the `WaveSize.validate()` function and the `ValidationResult` enum gain us here? The logic below pretty much repeats everything that validate did, just checking enums that are named after the various conditions rather than the conditions themselves. Would it be simpler to just implement the logic here and keep it out of the WaveSize object entirely? https://github.com/llvm/llvm-project/pull/101240 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits