Description
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
- HLSL 202x spec is accepted
- the literal is updated to use float
- A set of tests that demonstrate floating point literal values resolving to the smallest appropriate floating point type and code generation verifying correctness.
Metadata
Metadata
Assignees
Type
Projects
Status