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

Access the original type's fields through a pointercast, under the Logical addressing model. #469

Merged
merged 3 commits into from
Mar 4, 2021

Conversation

eddyb
Copy link
Contributor

@eddyb eddyb commented Mar 4, 2021

This allows simple enums, like Option<u32>, to work, since they already have the variant fields in the enum itself
(thanks to ScalarPair ABI - but this could easily be extended to at least all Option<T> without much effort).

for loops that rely on those Option types also work, except Range's implementation of Iterator uses mem::swap, and that happens to have a pretty severe case of microoptimization, that we'll have to turn off upstream (frankly, given that this kind of library optimization blocks MIR optimizations, generating that SIMD loop should probably be done in the backend, not in a library).

You can see a working example of a for loop with a custom Range-like iterator, in the third commit.

@eddyb eddyb requested a review from khyperia March 4, 2021 13:34
@khyperia khyperia merged commit 7723f5d into EmbarkStudios:main Mar 4, 2021
@eddyb eddyb deleted the simple-enums branch March 4, 2021 14:39
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