Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HLSL] MS-style for and while statement unroll attribute #70114

Closed
llvm-beanz opened this issue Oct 24, 2023 · 4 comments · Fixed by #93879
Closed

[HLSL] MS-style for and while statement unroll attribute #70114

llvm-beanz opened this issue Oct 24, 2023 · 4 comments · Fixed by #93879
Assignees
Labels
clang:codegen clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support

Comments

@llvm-beanz
Copy link
Collaborator

llvm-beanz commented Oct 24, 2023

HLSL for and while loops support Microsoft-syntax attributes. For Phase 1 we need to support parsing the unroll attribute:

https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-for
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-while

AC:
Investigate if we can implement the unroll attribute via the clang loophint attribute
if there are differences then additional work items will be created for later phases

@llvm-beanz llvm-beanz added HLSL HLSL Language Support and removed new issue labels Oct 24, 2023
@damyanp
Copy link
Contributor

damyanp commented Mar 29, 2024

@llvm-beanz - checking here - the title seems to suggest that this involves actually implementing [unroll], but the AC suggests it is more of an investigation?

@llvm-beanz
Copy link
Collaborator Author

That's probably poor issue writing on my part. The AC should really be "this feature should work and be tested".

My hope is that this can just be implemented in terms of the existing loop hint support, and I wanted to track that since I probably won't be the person to actually do this work. I haven't had time to investigate further to verify that the existing mechanisms will handle our needs so it is possible this task is bigger than I suspect.

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:codegen labels Jul 11, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jul 11, 2024

@llvm/issue-subscribers-clang-codegen

Author: Chris B (llvm-beanz)

HLSL `for` and `while` loops support Microsoft-syntax attributes. For Phase 1 we need to support parsing the `unroll` attribute:

https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-for
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-while

AC:
Investigate if we can implement the unroll attribute via the clang loophint attribute
if there are differences then additional work items will be created for later phases

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 11, 2024

@llvm/issue-subscribers-clang-frontend

Author: Chris B (llvm-beanz)

HLSL `for` and `while` loops support Microsoft-syntax attributes. For Phase 1 we need to support parsing the `unroll` attribute:

https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-for
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-while

AC:
Investigate if we can implement the unroll attribute via the clang loophint attribute
if there are differences then additional work items will be created for later phases

aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this issue Jul 14, 2024
spec: microsoft/hlsl-specs#263

- `Attr.td` - Define the HLSL loop attribute hints (unroll and loop)
- `AttrDocs.td` - Add documentation for unroll and loop
- `CGLoopInfo.cpp` - Add codegen for HLSL unroll that maps to clang
unroll expectations
- `ParseStmt.cpp` - For statements if HLSL define DeclSpecAttrs via
MaybeParseMicrosoftAttributes
- `SemaStmtAttr.cpp` - Add the HLSL loop unroll handeling

resolves llvm#70114

dxc examples: 
- for loop: https://hlsl.godbolt.org/z/8EK6Pa139
- while loop:  https://hlsl.godbolt.org/z/ebr5MvEcK
- do while: https://hlsl.godbolt.org/z/be8cedoTs 

Documentation:

![Screenshot_20240531_143000](https://github.com/llvm/llvm-project/assets/1802579/9da9df9b-68a6-49eb-9d4f-e080aa2eff7f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants