-
Notifications
You must be signed in to change notification settings - Fork 275
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
Remove all uses of #[rustc_args_required_const]
#1022
Comments
Question: Should we continue to accept all possible i32 values and simply use rather than the new static assert that is |
I think we should use |
I will start from avx512f then avx512bw.... |
i think the attribute makes rustc magically rewrite the 3 arg version to the const generic + 2 arg version. So callers can still continue to use the 3 arg version. |
I just tried it. It seems 3 arg one does not work. error[E0061]: this function takes 2 arguments but 3 arguments were supplied |
This is explained in point 6 above: the attribute rewrites the calls from other crates, not the current one where the tests are. The tests need to be rewritten to match the new signature with the const generic immediates. @minybot the most recent merged PRs have some other examples of changes to intrinsics and their tests, in case the OP and instructions are still unclear |
Thanks. This solution looks great. |
This comment has been minimized.
This comment has been minimized.
|
Yes. |
All uses of Many thanks to everyone involved who contributed to this! |
Wow that's amazing. :) Does that mean that we can remove EDIT: Oh, you said it is still used for some shuffle intrinsics. How is that "fine"? The attribute was not originally meant for any stable API, it was meant as a temporary hack (as far as I recall). |
It's used on Actually I'm not sure if it's even required any more. I'll have to try removing it to see if the tests still pass. |
Ah, that's good. :) Then I hope we can find some other, non-promotion-based, solution. |
I've removed the last uses in #1113. |
To solve #248 we are moving away from
#[rustc_args_required_const]
and switching to using the recently stabilized const generics instead. The goal is to massively reduce the binary size oflibcore.rlib
which is currently bloated due to the massivematch
statements needed to properly handle constant arguments for intrinsics.Instructions
Move constant arguments to const generics.
Change the
#[rustc_args_required_const(N)]
attribute to#[rustc_legacy_const_generics(N)]
. TheN
arguments to the attribute remains the same. This attribute allows legacy code to continue calling this function by passing constants as a parameter. The legacy support will likely be deprecated in Rust 2021.Use the
static_assert!
macro to perform bounds checking on the value. This is necessary because passing invalid value to intrinsics tends to trigger assert failures in LLVM if they reach codegen. Simply usingassert!
ormatch
is not enough since they don't prevent the intrinsic from reaching codegen.Eliminate unneeded
constify_*
/shuffle
macros and pass the constant directly to the underlying LLVM intrinsic.Update tests to call the function using const generics. Note that
#[rustc_legacy_const_generics]
does not work for functions defined in the same crate.Example
Before
After
The text was updated successfully, but these errors were encountered: