Skip to content

size_of_val, min_align_of_val implementation#1092

Open
mariaKt wants to merge 10 commits into
masterfrom
mk/intrinsics-impl
Open

size_of_val, min_align_of_val implementation#1092
mariaKt wants to merge 10 commits into
masterfrom
mk/intrinsics-impl

Conversation

@mariaKt

@mariaKt mariaKt commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

This PR implements size_of_val, min_align_of_val for sized types.

I show the stuck state and passing state before and after each one's implementation, and remove the output files at the end (included only to help review).

We do not handle unsized types atm, left for future work (their dynamic size calculation is likely to change).

Finally, we update the skip lists for the LLVM and Haskell backend. Note that these newly passing tests reflect not just this PR, but also PR #1091.

@mariaKt mariaKt force-pushed the mk/intrinsics-impl branch from cf7ad67 to ddd1c22 Compare June 26, 2026 22:14
@mariaKt mariaKt requested a review from dkcumming June 27, 2026 00:58

@dkcumming dkcumming left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice! I left a comment about the sentinel value that I think we should consider. But approving as it should not block this.

<types> TYPESMAP </types>
requires isTy(#extractOperandType(TYPESMAP, ARG, LOCALS))
andBool isTy(pointeeTy(lookupTy(TYPESMAP, {#extractOperandType(TYPESMAP, ARG, LOCALS)}:>Ty)))
andBool #metadataSize(TYPESMAP, pointeeTy(lookupTy(TYPESMAP, {#extractOperandType(TYPESMAP, ARG, LOCALS)}:>Ty))) =/=K dynamicSize(1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

At first I thought this was too permissive as it only restricts dynamicSize(1) for all slices. However, looking at rt/types.md the codomain of #metadataSize is { staticSize(N), dynamicSize(1), noMetadataSize }. So in this case, dynamicSize(1) is a sentinel value only.

Not sure if it is worth changing but it would be nice to continue the pattern of using sentinels that are logically distinct from sensible values. I think dynamicSize(-1) would be better here because if one knows that it is impossible immediately by reading it so either there is an error or it is a sentinel only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants