-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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] Default literal floating point types to float #85714
Comments
Spec PR: microsoft/hlsl-specs#175 |
Blocked on spec being approved and agreed upon. |
This implements the HLSL 202x conforming literals feature. The feature proposal is available here: https://github.com/microsoft/hlsl-specs/blob/main/proposals/0017-conform ing-literals.md The language specification for this behavior is available in (poorly rendered) HTML or PDF: https://microsoft.github.io/hlsl-specs/specs/hlsl.html#Lex.Literal.Float https://microsoft.github.io/hlsl-specs/specs/hlsl.pdf The main implementation details are: 1) Unsuffixed floating literals are `float`. 2) The integer `ll` suffix specifies `int64_t (aka long)` which is 64-bit because HLSL has no defined `long` keyword or `long long` type. Resolves llvm#85714
This implements the HLSL 202x conforming literals feature. The feature proposal is available here: https://github.com/microsoft/hlsl-specs/blob/main/proposals/0017-conforming-literals.md The language specification for this behavior is available in (poorly rendered) HTML or PDF: https://microsoft.github.io/hlsl-specs/specs/hlsl.html#Lex.Literal.Float https://microsoft.github.io/hlsl-specs/specs/hlsl.pdf The main implementation details are: 1) Unsuffixed floating literals are `float`. 2) The integer `ll` suffix specifies `int64_t (aka long)` which is 64-bit because HLSL has no defined `long` keyword or `long long` type. Resolves #85714
@llvm/issue-subscribers-clang-frontend Author: Chris B (llvm-beanz)
In C/C++ literal floating point values default as double. In HLSL the behavior is a bit more complicated.
In DXC, literal types were given their own type which was then preserved through instantiation of builtin functions. This ends up being extremely complicated and fragile as templates and other type inference were added to the language. For Clang, we can accomplish a comparable source-compatible implementation by having the default type for floating point literals resolve to the smallest supported type (i.e. 32-bits by default or 16-bit if 16-bit types are enabled). This implementation will prevent some bugs that exist in DXC today like the bugs described in this issue or this one, which incorrectly emit 64-bit types instead of 32-bit. It also is a way simpler approach to the problem that will not collide with template type deduction or other language features that rely on type inference. Acceptance Criteria
|
In C/C++ literal floating point values default as double. In HLSL the behavior is a bit more complicated.
In DXC, literal types were given their own type which was then preserved through instantiation of builtin functions. This ends up being extremely complicated and fragile as templates and other type inference were added to the language.
For Clang, we can accomplish a comparable source-compatible implementation by having the default type for floating point literals resolve to the smallest supported type (i.e. 32-bits by default or 16-bit if 16-bit types are enabled).
This implementation will prevent some bugs that exist in DXC today like the bugs described in this issue or this one, which incorrectly emit 64-bit types instead of 32-bit.
It also is a way simpler approach to the problem that will not collide with template type deduction or other language features that rely on type inference.
Acceptance Criteria
The text was updated successfully, but these errors were encountered: