@@ -434,6 +434,7 @@ void SemaHLSL::CheckSemanticAnnotation(
434434 switch (AnnotationAttr->getKind ()) {
435435 case attr::HLSLSV_DispatchThreadID:
436436 case attr::HLSLSV_GroupIndex:
437+ case attr::HLSLSV_GroupID:
437438 if (ST == llvm::Triple::Compute)
438439 return ;
439440 DiagnoseAttrStageMismatch (AnnotationAttr, ST, {llvm::Triple::Compute});
@@ -764,26 +765,36 @@ void SemaHLSL::handleWaveSizeAttr(Decl *D, const ParsedAttr &AL) {
764765 D->addAttr (NewAttr);
765766}
766767
767- static bool isLegalTypeForHLSLSV_DispatchThreadID (QualType T) {
768- if (!T->hasUnsignedIntegerRepresentation ())
768+ bool SemaHLSL::diagnoseInputIDType (QualType T, const ParsedAttr &AL) {
769+ const auto *VT = T->getAs <VectorType>();
770+
771+ if (!T->hasUnsignedIntegerRepresentation () ||
772+ (VT && VT->getNumElements () > 3 )) {
773+ Diag (AL.getLoc (), diag::err_hlsl_attr_invalid_type)
774+ << AL << " uint/uint2/uint3" ;
769775 return false ;
770- if ( const auto *VT = T-> getAs <VectorType>())
771- return VT-> getNumElements () <= 3 ;
776+ }
777+
772778 return true ;
773779}
774780
775781void SemaHLSL::handleSV_DispatchThreadIDAttr (Decl *D, const ParsedAttr &AL) {
776782 auto *VD = cast<ValueDecl>(D);
777- if (!isLegalTypeForHLSLSV_DispatchThreadID (VD->getType ())) {
778- Diag (AL.getLoc (), diag::err_hlsl_attr_invalid_type)
779- << AL << " uint/uint2/uint3" ;
783+ if (!diagnoseInputIDType (VD->getType (), AL))
780784 return ;
781- }
782785
783786 D->addAttr (::new (getASTContext ())
784787 HLSLSV_DispatchThreadIDAttr (getASTContext (), AL));
785788}
786789
790+ void SemaHLSL::handleSV_GroupIDAttr (Decl *D, const ParsedAttr &AL) {
791+ auto *VD = cast<ValueDecl>(D);
792+ if (!diagnoseInputIDType (VD->getType (), AL))
793+ return ;
794+
795+ D->addAttr (::new (getASTContext ()) HLSLSV_GroupIDAttr (getASTContext (), AL));
796+ }
797+
787798void SemaHLSL::handlePackOffsetAttr (Decl *D, const ParsedAttr &AL) {
788799 if (!isa<VarDecl>(D) || !isa<HLSLBufferDecl>(D->getDeclContext ())) {
789800 Diag (AL.getLoc (), diag::err_hlsl_attr_invalid_ast_node)
0 commit comments