-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Miri and miri-related code contains repetitions of (n << amt) >> amt
#49937
Comments
This sounds pretty interesting and I may like to take it on, but I don't really understand the scope of what will be changed at the moment. |
@stevepentland the goal is to reduce code repetition. Essentially all code that looks similar to the title code should be calling dedicated functions for either sign or zero extension. These methods already exist on the EvalContext, but we need to move them to rustc::mir::interpret so we can also use them for the code in the file that declares |
I'm interested in taking this on if anything still needs to be done for it. |
I think we have the appropriate functions now, but we aren't using them everywhere, and they don't live in |
I believe these are all the locations that do sign extensions or truncates:
In each case the operations are preceded by usage of either Since an I think there are two options for where to locate the method implementations:
I'm happy to work on a pull request if this seems like a reasonable way to refactor. I haven't contributed to the project before, so might need some guidance. |
Great writeup of the current state! I think it can live directly in the impl block, because it's not something that requires any types beyond How verbose and common would it be to need to extract the
Feel free to ask anything here or on discord/zulip/irc. General build instructions can be found at https://github.com/rust-lang/rust#building-from-source and https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#the-build-system I also can advise to set |
Okay, I'll take a look at it and hopefully have something shortly. Thank you for the tip about
I think it has to peel back enough layers of I figure the helper method ( |
I'd like to tackle this issue. How shall we begin? |
I am actually not sure right now. There were a lot of changes to the compiler. You can start by going through this list and seeing whether there are any left that need to be addressed |
@oli-obk Thank you for your advice. I' ll try. |
There are also some comments |
@varkor Sorry for the delay in replying. Thanks! |
Miri and miri-related code contains repetitions of `(n << amt) >> amt` I reduced some code repetitions contains `(n << amt) >> amt`. This pull request is related to rust-lang#49937.
…=oli-obk Reduce Some Code Repetitions like `(n << amt) >> amt` This Pull Request is related to [rust-lang#49937](rust-lang#49937). This Pull Request has reduced repetition of `(n << amt) >> amt`.
…n, r=petrochenkov Reduce Miri-related Code Repetition `like (n << amt) >> amt` This Pull Request fixes a part of [rust-lang#49937](rust-lang#49937).
…n, r=petrochenkov Reduce Miri-related Code Repetition `like (n << amt) >> amt` This Pull Request fixes a part of [rust-lang#49937](rust-lang#49937).
…on, r=oli-obk Reduce Miri Code Repetition like `(n << amt) >> amt` This Pull Request fixes a part of [rust-lang#49937](rust-lang#49937).
…ri-related, r=oli-obk Reduce a Code Repetition like `(n << amt) >> amt` Fixes a part of [rust-lang#49937](rust-lang#49937).
…on, r=oli-obk Reduce Miri Code Repetition like `(n << amt) >> amt` This Pull Request fixes a part of [rust-lang#49937](rust-lang#49937).
…ri-related, r=oli-obk Reduce a Code Repetition like `(n << amt) >> amt` Fixes a part of [rust-lang#49937](rust-lang#49937).
…on, r=oli-obk Reduce Miri Code Repetition like `(n << amt) >> amt` This Pull Request fixes a part of [rust-lang#49937](rust-lang#49937).
…ri-related, r=oli-obk Reduce a Code Repetition like `(n << amt) >> amt` Fixes a part of [rust-lang#49937](rust-lang#49937).
Reduce Repetitions of (n << amt) >> amt Fixes part of [rust-lang#49937](rust-lang#49937).
Reduce Repetitions of (n << amt) >> amt Fixes part of [rust-lang#49937](rust-lang#49937).
Reduce Repetitions of (n << amt) >> amt Fixes part of [rust-lang#49937](rust-lang#49937).
Reduce Repetitions of (n << amt) >> amt Fixes part of [rust-lang#49937](rust-lang#49937).
Reduce Repetitions of (n << amt) >> amt Fixes part of [rust-lang#49937](rust-lang#49937).
I think Reducing the repetition of this list has almost finished. |
Awesome! Thank you
There might be more, but I'm fine closing this issue after the known ones are done. |
I understand. I'll keep working on this issue until the repetition of |
…=oli-obk Reduces Code Repetitions like `!n >> amt` Fixes rust-lang#49937 . This PR contains defining a function which operates bit inversion and reducing bit operation like `!0u128 >> (128 - size.bits())`.
…=oli-obk Reduces Code Repetitions like `!n >> amt` Fixes rust-lang#49937 . This PR contains defining a function which operates bit inversion and reducing bit operation like `!0u128 >> (128 - size.bits())`.
…=oli-obk Reduces Code Repetitions like `!n >> amt` Fixes rust-lang#49937 . This PR contains defining a function which operates bit inversion and reducing bit operation like `!0u128 >> (128 - size.bits())`.
@oli-obk Could you open this issue because codes which should be fixed still remain? |
Thanks! |
…=oli-obk Reduce a Code Repetition Related to Bit Operation This PR is related to [rust-lang#49937](rust-lang#49937). Should I do more commits about [`FIXME(49937)`](https://github.com/rust-lang/rust/search?q=FIXME%2849937%29&unscoped_q=FIXME%2849937%29) in this PR?
…=oli-obk Reduce a Code Repetition Related to Bit Operation This PR is related to [rust-lang#49937](rust-lang#49937). Should I do more commits about [`FIXME(49937)`](https://github.com/rust-lang/rust/search?q=FIXME%2849937%29&unscoped_q=FIXME%2849937%29) in this PR?
I think refactoring codes marked as |
Super! Thanks for all the work you put into cleaning up this issue! |
All of these should be deduplicated under a common set of functions that do sign extension or truncation of integers.
The functions should live somewhere in
librustc
, so probablylibrustc::mir::interpret
, because they are also needed inlibrustc::ty::layout
.The parts that need to be figured out:
The text was updated successfully, but these errors were encountered: