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

Export discriminant values in AdtDef #693

Merged
merged 3 commits into from
Jun 24, 2024
Merged

Export discriminant values in AdtDef #693

merged 3 commits into from
Jun 24, 2024

Conversation

Nadrieril
Copy link
Collaborator

The discriminant is the runtime integer value used to identify a given enum variant. It's the value on which we do a SwitchInt. This PR makes hax export them.

I would have prefered a discriminant field in VariantDef but that would have been tricky to fit into the SInto scheme.

@W95Psp
Copy link
Collaborator

W95Psp commented Jun 6, 2024

How does this compare to the field discr of type VariantDiscr of the VariantDef struct?
I guess VariantDiscr is too high level as the discriminant is not normalized yet?

Anyway, the SInto mechanism should be a convenience, not a barrier, so I'm in favor of breaking the SInto scheme here: let's kill VariantDef SInto instance, and provide a function that does this translation instead, function that can then take as an extra parameter a discriminant value.

Shall we merge VariantDiscr and DiscriminantValue? E.g. we could rename VariantDiscr as DiscriminantDefinition, and add a definition field in DiscriminantValue

@Nadrieril
Copy link
Collaborator Author

How does this compare to the field discr of type VariantDiscr of the VariantDef struct? I guess VariantDiscr is too high level as the discriminant is not normalized yet?

Yeah, it's a recipe for how to compute the DiscriminantValue but we don't want to compute it ourselves.

Anyway, the SInto mechanism should be a convenience, not a barrier, so I'm in favor of breaking the SInto scheme here: let's kill VariantDef SInto instance, and provide a function that does this translation instead, function that can then take as an extra parameter a discriminant value.

👍

Shall we merge VariantDiscr and DiscriminantValue? E.g. we could rename VariantDiscr as DiscriminantDefinition, and add a definition field in DiscriminantValue

I guess we could do that; I don't have a use for VariantDiscr atm.

@W95Psp
Copy link
Collaborator

W95Psp commented Jun 6, 2024

Nice, let's do so then. Do you want to do it?

In hax engine we rely on VariantDiscr: if a user defines an explicit discriminant we extract the discriminant expression (this was added in #571)

@Nadrieril
Copy link
Collaborator Author

If you feel like doing it, please do. Otherwise I'll do it myself in a day or two when I'm finished with other things

@Nadrieril Nadrieril marked this pull request as draft June 14, 2024 09:08
@Nadrieril
Copy link
Collaborator Author

Marking as draft while I do this

@Nadrieril
Copy link
Collaborator Author

This PR is ready, and so is the corresponding charon change: AeneasVerif/charon#255

@Nadrieril Nadrieril marked this pull request as ready for review June 14, 2024 09:58
@franziskuskiefer franziskuskiefer added the waiting-on-reviewer Status: Awaiting review from the assignee but also interested parties. label Jun 21, 2024
Copy link
Collaborator

@W95Psp W95Psp left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@W95Psp W95Psp enabled auto-merge June 24, 2024 06:56
@W95Psp W95Psp added this pull request to the merge queue Jun 24, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Jun 24, 2024
@Nadrieril Nadrieril enabled auto-merge June 24, 2024 08:33
@Nadrieril Nadrieril added this pull request to the merge queue Jun 24, 2024
Merged via the queue into main with commit 1fc4a03 Jun 24, 2024
12 of 13 checks passed
@Nadrieril Nadrieril deleted the discriminant_values branch June 24, 2024 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-reviewer Status: Awaiting review from the assignee but also interested parties.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants