Add a macro for defining intrinsics with the Rust ABI#127885
Add a macro for defining intrinsics with the Rust ABI#127885tgross35 wants to merge 2 commits intorust-lang:masterfrom
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 |
| /// [`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.
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 |
workingjubilee
left a comment
There was a problem hiding this comment.
Something in the direction of oli's review seems correct to me. Basically "please make the macro less clever".
|
From the discussion on Zulip it sounds like we are heading toward what I was trying to achieve ( |
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