[clang] [HLSL] reenable add packoffset in AST (PR #91474)
https://github.com/python3kgae closed https://github.com/llvm/llvm-project/pull/91474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] reenable add packoffset in AST (PR #91474)
https://github.com/damyanp approved this pull request. https://github.com/llvm/llvm-project/pull/91474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] reenable add packoffset in AST (PR #91474)
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/91474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] reenable add packoffset in AST (PR #91474)
https://github.com/python3kgae updated https://github.com/llvm/llvm-project/pull/91474 >From 251bbfbd77f9fa968a3fe76156e216f27eeb973f Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Wed, 8 May 2024 09:48:30 -0400 Subject: [PATCH 1/2] Revert "Revert "[HLSL] Support packoffset attribute in AST (#89836)"" This reverts commit 5809281176c75712752fe152c160ce964993726e. --- clang/include/clang/Basic/Attr.td | 12 ++ clang/include/clang/Basic/AttrDocs.td | 20 +++ clang/include/clang/Basic/DiagnosticGroups.td | 3 + .../clang/Basic/DiagnosticParseKinds.td | 2 + .../clang/Basic/DiagnosticSemaKinds.td| 5 + clang/lib/Parse/ParseHLSL.cpp | 88 + clang/lib/Sema/SemaDeclAttr.cpp | 52 clang/lib/Sema/SemaHLSL.cpp | 80 clang/test/AST/HLSL/packoffset.hlsl | 100 ++ clang/test/SemaHLSL/packoffset-invalid.hlsl | 122 ++ 10 files changed, 484 insertions(+) create mode 100644 clang/test/AST/HLSL/packoffset.hlsl create mode 100644 clang/test/SemaHLSL/packoffset-invalid.hlsl diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 0225598cbbe8a..52552ba488560 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4415,6 +4415,18 @@ def HLSLResourceBinding: InheritableAttr { let Documentation = [HLSLResourceBindingDocs]; } +def HLSLPackOffset: HLSLAnnotationAttr { + let Spellings = [HLSLAnnotation<"packoffset">]; + let LangOpts = [HLSL]; + let Args = [IntArgument<"Subcomponent">, IntArgument<"Component">]; + let Documentation = [HLSLPackOffsetDocs]; + let AdditionalMembers = [{ + unsigned getOffset() { +return subcomponent * 4 + component; + } + }]; +} + def HLSLSV_DispatchThreadID: HLSLAnnotationAttr { let Spellings = [HLSLAnnotation<"SV_DispatchThreadID">]; let Subjects = SubjectList<[ParmVar, Field]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 8e6faabfae647..f351822ac74bd 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -7408,6 +7408,26 @@ The full documentation is available here: https://docs.microsoft.com/en-us/windo }]; } +def HLSLPackOffsetDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +The packoffset attribute is used to change the layout of a cbuffer. +Attribute spelling in HLSL is: ``packoffset( c[Subcomponent][.component] )``. +A subcomponent is a register number, which is an integer. A component is in the form of [.xyzw]. + +Examples: + +.. code-block:: c++ + + cbuffer A { +float3 a : packoffset(c0.y); +float4 b : packoffset(c4); + } + +The full documentation is available here: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-variable-packoffset + }]; +} + def HLSLSV_DispatchThreadIDDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 60f87da2a7387..2beb1d45124b4 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -1507,6 +1507,9 @@ def BranchProtection : DiagGroup<"branch-protection">; // Warnings for HLSL Clang extensions def HLSLExtension : DiagGroup<"hlsl-extensions">; +// Warning for mix packoffset and non-packoffset. +def HLSLMixPackOffset : DiagGroup<"mix-packoffset">; + // Warnings for DXIL validation def DXILValidation : DiagGroup<"dxil-validation">; diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index fdffb35ea0d95..bc9d7cacc50b7 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1754,5 +1754,7 @@ def err_hlsl_separate_attr_arg_and_number : Error<"wrong argument format for hls def ext_hlsl_access_specifiers : ExtWarn< "access specifiers are a clang HLSL extension">, InGroup; +def err_hlsl_unsupported_component : Error<"invalid component '%0' used; expected 'x', 'y', 'z', or 'w'">; +def err_hlsl_packoffset_invalid_reg : Error<"invalid resource class specifier '%0' for packoffset, expected 'c'">; } // end of Parser diagnostics diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 9317ae675c72b..d6863f90edb6e 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12184,6 +12184,11 @@ def err_hlsl_init_priority_unsupported : Error< def err_hlsl_unsupported_register_type : Error<"invalid resource class specifier '%0' used; expected 'b', 's', 't', or 'u'">; def err_hlsl_unsupported_register_number : Error<"register number should be an integer">; def
[clang] [HLSL] reenable add packoffset in AST (PR #91474)
python3kgae wrote: > When reapplying a change that was reverted, please include enough information > in the description so that it can be understood without having to dig up the > old change. Something like: > > > [HLSL] reenable add packoffset in AST > > This reapplies > > [c5509fe](https://github.com/llvm/llvm-project/commit/c5509fedc5757fffece385d9d068e36b26793ade) > > "[HLSL] Support packoffset attribute in AST (#89836)" with a fix for the > > test failure caused by missing -fnative-half-type. > > Since we have to parse the attribute manually in ParseHLSLAnnotations, we > > could create the ParsedAttribute with a integer offset parameter instead of > > string. This approach avoids parsing the string if the offset is saved as a > > string in HLSLPackOffsetAttr. Update. Thanks a lot. https://github.com/llvm/llvm-project/pull/91474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] reenable add packoffset in AST (PR #91474)
https://github.com/python3kgae edited https://github.com/llvm/llvm-project/pull/91474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] reenable add packoffset in AST (PR #91474)
bogner wrote: When reapplying a change that was reverted, please include enough information in the description so that it can be understood without having to dig up the old change. Something like: > [HLSL] reenable add packoffset in AST > > This reapplies c5509fedc575 "[HLSL] Support packoffset attribute in AST > (#89836)" with a fix for the test failure caused by missing > -fnative-half-type. > > Since we have to parse the attribute manually in ParseHLSLAnnotations, we > could create the ParsedAttribute with a integer offset parameter instead of > string. This approach avoids parsing the string if the offset is saved as a > string in HLSLPackOffsetAttr. https://github.com/llvm/llvm-project/pull/91474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] reenable add packoffset in AST (PR #91474)
https://github.com/python3kgae updated https://github.com/llvm/llvm-project/pull/91474 >From 251bbfbd77f9fa968a3fe76156e216f27eeb973f Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Wed, 8 May 2024 09:48:30 -0400 Subject: [PATCH 1/2] Revert "Revert "[HLSL] Support packoffset attribute in AST (#89836)"" This reverts commit 5809281176c75712752fe152c160ce964993726e. --- clang/include/clang/Basic/Attr.td | 12 ++ clang/include/clang/Basic/AttrDocs.td | 20 +++ clang/include/clang/Basic/DiagnosticGroups.td | 3 + .../clang/Basic/DiagnosticParseKinds.td | 2 + .../clang/Basic/DiagnosticSemaKinds.td| 5 + clang/lib/Parse/ParseHLSL.cpp | 88 + clang/lib/Sema/SemaDeclAttr.cpp | 52 clang/lib/Sema/SemaHLSL.cpp | 80 clang/test/AST/HLSL/packoffset.hlsl | 100 ++ clang/test/SemaHLSL/packoffset-invalid.hlsl | 122 ++ 10 files changed, 484 insertions(+) create mode 100644 clang/test/AST/HLSL/packoffset.hlsl create mode 100644 clang/test/SemaHLSL/packoffset-invalid.hlsl diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 0225598cbbe8a..52552ba488560 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4415,6 +4415,18 @@ def HLSLResourceBinding: InheritableAttr { let Documentation = [HLSLResourceBindingDocs]; } +def HLSLPackOffset: HLSLAnnotationAttr { + let Spellings = [HLSLAnnotation<"packoffset">]; + let LangOpts = [HLSL]; + let Args = [IntArgument<"Subcomponent">, IntArgument<"Component">]; + let Documentation = [HLSLPackOffsetDocs]; + let AdditionalMembers = [{ + unsigned getOffset() { +return subcomponent * 4 + component; + } + }]; +} + def HLSLSV_DispatchThreadID: HLSLAnnotationAttr { let Spellings = [HLSLAnnotation<"SV_DispatchThreadID">]; let Subjects = SubjectList<[ParmVar, Field]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 8e6faabfae647..f351822ac74bd 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -7408,6 +7408,26 @@ The full documentation is available here: https://docs.microsoft.com/en-us/windo }]; } +def HLSLPackOffsetDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +The packoffset attribute is used to change the layout of a cbuffer. +Attribute spelling in HLSL is: ``packoffset( c[Subcomponent][.component] )``. +A subcomponent is a register number, which is an integer. A component is in the form of [.xyzw]. + +Examples: + +.. code-block:: c++ + + cbuffer A { +float3 a : packoffset(c0.y); +float4 b : packoffset(c4); + } + +The full documentation is available here: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-variable-packoffset + }]; +} + def HLSLSV_DispatchThreadIDDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 60f87da2a7387..2beb1d45124b4 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -1507,6 +1507,9 @@ def BranchProtection : DiagGroup<"branch-protection">; // Warnings for HLSL Clang extensions def HLSLExtension : DiagGroup<"hlsl-extensions">; +// Warning for mix packoffset and non-packoffset. +def HLSLMixPackOffset : DiagGroup<"mix-packoffset">; + // Warnings for DXIL validation def DXILValidation : DiagGroup<"dxil-validation">; diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index fdffb35ea0d95..bc9d7cacc50b7 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1754,5 +1754,7 @@ def err_hlsl_separate_attr_arg_and_number : Error<"wrong argument format for hls def ext_hlsl_access_specifiers : ExtWarn< "access specifiers are a clang HLSL extension">, InGroup; +def err_hlsl_unsupported_component : Error<"invalid component '%0' used; expected 'x', 'y', 'z', or 'w'">; +def err_hlsl_packoffset_invalid_reg : Error<"invalid resource class specifier '%0' for packoffset, expected 'c'">; } // end of Parser diagnostics diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 9317ae675c72b..d6863f90edb6e 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12184,6 +12184,11 @@ def err_hlsl_init_priority_unsupported : Error< def err_hlsl_unsupported_register_type : Error<"invalid resource class specifier '%0' used; expected 'b', 's', 't', or 'u'">; def err_hlsl_unsupported_register_number : Error<"register number should be an integer">; def
[clang] [HLSL] reenable add packoffset in AST (PR #91474)
https://github.com/python3kgae created https://github.com/llvm/llvm-project/pull/91474 Fix the test fail caused by missing -fnative-half-type. For #57914 >From 5809281176c75712752fe152c160ce964993726e Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Wed, 8 May 2024 09:46:44 -0400 Subject: [PATCH 1/3] Revert "[HLSL] Support packoffset attribute in AST (#89836)" This reverts commit c5509fedc5757fffece385d9d068e36b26793ade. --- clang/include/clang/Basic/Attr.td | 12 -- clang/include/clang/Basic/AttrDocs.td | 20 --- clang/include/clang/Basic/DiagnosticGroups.td | 3 - .../clang/Basic/DiagnosticParseKinds.td | 2 - .../clang/Basic/DiagnosticSemaKinds.td| 5 - clang/lib/Parse/ParseHLSL.cpp | 88 - clang/lib/Sema/SemaDeclAttr.cpp | 52 clang/lib/Sema/SemaHLSL.cpp | 80 clang/test/AST/HLSL/packoffset.hlsl | 100 -- clang/test/SemaHLSL/packoffset-invalid.hlsl | 122 -- 10 files changed, 484 deletions(-) delete mode 100644 clang/test/AST/HLSL/packoffset.hlsl delete mode 100644 clang/test/SemaHLSL/packoffset-invalid.hlsl diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 52552ba488560..0225598cbbe8a 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4415,18 +4415,6 @@ def HLSLResourceBinding: InheritableAttr { let Documentation = [HLSLResourceBindingDocs]; } -def HLSLPackOffset: HLSLAnnotationAttr { - let Spellings = [HLSLAnnotation<"packoffset">]; - let LangOpts = [HLSL]; - let Args = [IntArgument<"Subcomponent">, IntArgument<"Component">]; - let Documentation = [HLSLPackOffsetDocs]; - let AdditionalMembers = [{ - unsigned getOffset() { -return subcomponent * 4 + component; - } - }]; -} - def HLSLSV_DispatchThreadID: HLSLAnnotationAttr { let Spellings = [HLSLAnnotation<"SV_DispatchThreadID">]; let Subjects = SubjectList<[ParmVar, Field]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index f351822ac74bd..8e6faabfae647 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -7408,26 +7408,6 @@ The full documentation is available here: https://docs.microsoft.com/en-us/windo }]; } -def HLSLPackOffsetDocs : Documentation { - let Category = DocCatFunction; - let Content = [{ -The packoffset attribute is used to change the layout of a cbuffer. -Attribute spelling in HLSL is: ``packoffset( c[Subcomponent][.component] )``. -A subcomponent is a register number, which is an integer. A component is in the form of [.xyzw]. - -Examples: - -.. code-block:: c++ - - cbuffer A { -float3 a : packoffset(c0.y); -float4 b : packoffset(c4); - } - -The full documentation is available here: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-variable-packoffset - }]; -} - def HLSLSV_DispatchThreadIDDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 2beb1d45124b4..60f87da2a7387 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -1507,9 +1507,6 @@ def BranchProtection : DiagGroup<"branch-protection">; // Warnings for HLSL Clang extensions def HLSLExtension : DiagGroup<"hlsl-extensions">; -// Warning for mix packoffset and non-packoffset. -def HLSLMixPackOffset : DiagGroup<"mix-packoffset">; - // Warnings for DXIL validation def DXILValidation : DiagGroup<"dxil-validation">; diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index bc9d7cacc50b7..fdffb35ea0d95 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1754,7 +1754,5 @@ def err_hlsl_separate_attr_arg_and_number : Error<"wrong argument format for hls def ext_hlsl_access_specifiers : ExtWarn< "access specifiers are a clang HLSL extension">, InGroup; -def err_hlsl_unsupported_component : Error<"invalid component '%0' used; expected 'x', 'y', 'z', or 'w'">; -def err_hlsl_packoffset_invalid_reg : Error<"invalid resource class specifier '%0' for packoffset, expected 'c'">; } // end of Parser diagnostics diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index d6863f90edb6e..9317ae675c72b 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12184,11 +12184,6 @@ def err_hlsl_init_priority_unsupported : Error< def err_hlsl_unsupported_register_type : Error<"invalid resource class specifier '%0' used; expected 'b', 's', 't', or 'u'">; def err_hlsl_unsupported_register_number :
[clang] [HLSL] reenable add packoffset in AST (PR #91474)
llvmbot wrote: @llvm/pr-subscribers-hlsl Author: Xiang Li (python3kgae) Changes Fix the test fail caused by missing -fnative-half-type. For #57914 --- Full diff: https://github.com/llvm/llvm-project/pull/91474.diff 2 Files Affected: - (modified) clang/test/AST/HLSL/packoffset.hlsl (+1-1) - (modified) clang/test/SemaHLSL/packoffset-invalid.hlsl (+1-1) ``diff diff --git a/clang/test/AST/HLSL/packoffset.hlsl b/clang/test/AST/HLSL/packoffset.hlsl index 9cfd88eeec330..060288c2f7f76 100644 --- a/clang/test/AST/HLSL/packoffset.hlsl +++ b/clang/test/AST/HLSL/packoffset.hlsl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple dxil-unknown-shadermodel6.3-library -S -finclude-default-header -ast-dump -x hlsl %s | FileCheck %s +// RUN: %clang_cc1 -triple dxil-unknown-shadermodel6.3-library -S -finclude-default-header -fnative-half-type -ast-dump -x hlsl %s | FileCheck %s // CHECK: HLSLBufferDecl {{.*}} cbuffer A diff --git a/clang/test/SemaHLSL/packoffset-invalid.hlsl b/clang/test/SemaHLSL/packoffset-invalid.hlsl index c5983f6fd7e07..526a511edf1f2 100644 --- a/clang/test/SemaHLSL/packoffset-invalid.hlsl +++ b/clang/test/SemaHLSL/packoffset-invalid.hlsl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.3-library -verify %s +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.3-library -fnative-half-type -verify %s // expected-warning@+1{{cannot mix packoffset elements with nonpackoffset elements in a cbuffer}} cbuffer Mix `` https://github.com/llvm/llvm-project/pull/91474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits