Skip to content

[0004] Adding spec language for unions #520

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

Merged
merged 2 commits into from
Jul 16, 2025

Conversation

llvm-beanz
Copy link
Collaborator

@llvm-beanz llvm-beanz commented Jun 24, 2025

This fleshes out the language design for union types.

Resolves #38, resolves #523

This fleshes out the language design for union types.
@llvm-beanz llvm-beanz marked this pull request as ready for review June 24, 2025 15:10
@llvm-beanz
Copy link
Collaborator Author

I think this PR also resolves #50, but would like @s-perron's perspective.

The PR does assume that we're going to elsewhere in the spec define "standard layout", but I expect that to basically match C++'s definition with the additional constraint that a standard layout type cannot be intangible.

Copy link
Collaborator

@s-perron s-perron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is reasonable. As for the layout of the struct, saying they cannot be in constant buffers solves most of the layout issues. There is now only one layout that is used. It can change for SPIR-V with a compiler options, but the layout is still well defined by the spec.

The only concern I have is the SPIR-V implementation for function scope unions. Function scope variables in SPIR-V do not have an explicit layout. That can make an implementation awkward, but that is a SPIR-V issue. From an HLSL spec perspective this is good.

@llvm-beanz llvm-beanz linked an issue Jun 29, 2025 that may be closed by this pull request
@llvm-beanz llvm-beanz changed the title [0004] Update with detailed design [0004] Update Unions proposal with spec language Jul 8, 2025
@llvm-beanz llvm-beanz changed the title [0004] Update Unions proposal with spec language [0004] Adding spec language for unions Jul 8, 2025
@llvm-beanz llvm-beanz requested a review from farzonl July 8, 2025 16:41
@llvm-beanz
Copy link
Collaborator Author

Tagging @farzonl for review.

@llvm-beanz llvm-beanz merged commit d6cb94e into microsoft:main Jul 16, 2025
7 checks passed
@github-project-automation github-project-automation bot moved this to Triaged in HLSL Triage Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Triaged
Development

Successfully merging this pull request may close these issues.

[0004] Finish detailed design - Unions [0004] Update union spec to clarify casting behaviors
5 participants