-
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
Add a macro for defining intrinsics with the Rust ABI #127885
base: master
Are you sure you want to change the base?
Conversation
Migrating intrinsics at this time seems to come with a lot of boilerplate in the form of attributes and empty bodies (see <rust-lang#127337> for an example). Add a macro that simplifies this, and makes the transition from `extern "rust-intrinsic"` intrinsics much cleaner.
There are a couple unfortunate things here:
This isn't 100% complete, e.g. generics with |
|
||
/// Raises an `f16` to an integer power. | ||
/// | ||
/// The stabilized version of this intrinsic is | ||
/// [`f16::powi`](../../std/primitive.f16.html#method.powi) | ||
#[rustc_nounwind] | ||
pub fn powif16(a: f16, x: i32) -> f16; | ||
pub unsafe fn powif16(_a: f16, _x: i32) -> f16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these float intrinsics could probably just be safe if there are no preconditions, not as part of this PR though.
The macro could probably also be tweaked to allow specifying the fallback body |
☔ The latest upstream changes (presumably #127865) made this pull request unmergeable. Please resolve the merge conflicts. |
the point was to have a meaningful body that emulates the behaviour with potentially more expensive operations. |
I am not sure about this change. I would prefer to just use |
If
As in, foo();
bar(); ? Unfortunately macro parsing is pretty insistent that the I might be able to improve something here, just need to fight with the macro system a bit. |
the macro can just add the |
r? libs I'm going on leave for 4 months |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something in the direction of oli's review seems correct to me. Basically "please make the macro less clever".
Migrating intrinsics at this time seems to come with a lot of boilerplate in the form of attributes and empty bodies (see #127337 for an example). Add a macro that simplifies this, and makes the transition from
extern "rust-intrinsic"
intrinsics much cleaner, and then make use of it.Cc #93145
r? @oli-obk