-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Provide more atomic ops #48
Labels
C-enhancement
Category: A new feature or an improvement for an existing one
Comments
taiki-e
added
the
C-enhancement
Category: A new feature or an improvement for an existing one
label
Dec 4, 2022
bors bot
added a commit
that referenced
this issue
Dec 18, 2022
54: Add fetch_neg/neg/fetch_not/not r=taiki-e a=taiki-e Part of #48 - Add `AtomicI*::{fetch_neg,neg}` and `AtomicF*::fetch_neg` methods. `AtomicI*::neg` are equivalent to the corresponding `fetch_*` methods, but do not return the previous value. They are intended for optimization on platforms that have atomic instructions for the corresponding operation, such as x86's `lock neg`. Currently, optimizations by these methods (`neg`) are only guaranteed for x86. - Add `Atomic{I,U}*::{fetch_not,not}` methods. `Atomic{I,U}*::not` are equivalent to the corresponding `fetch_*` methods, but do not return the previous value. They are intended for optimization on platforms that have atomic instructions for the corresponding operation, such as x86's `lock not`, MSP430's `inv`. Currently, optimizations by these methods (`not`) are only guaranteed for x86 and MSP430. (Note: `AtomicBool` already has `fetch_not` and `not` methods.) Co-authored-by: Taiki Endo <[email protected]>
bors bot
added a commit
that referenced
this issue
Dec 18, 2022
54: Add fetch_neg/neg/fetch_not/not r=taiki-e a=taiki-e Part of #48 - Add `AtomicI*::{fetch_neg,neg}` and `AtomicF*::fetch_neg` methods. `AtomicI*::neg` are equivalent to the corresponding `fetch_*` methods, but do not return the previous value. They are intended for optimization on platforms that have atomic instructions for the corresponding operation, such as x86's `lock neg`. Currently, optimizations by these methods (`neg`) are only guaranteed for x86. - Add `Atomic{I,U}*::{fetch_not,not}` methods. `Atomic{I,U}*::not` are equivalent to the corresponding `fetch_*` methods, but do not return the previous value. They are intended for optimization on platforms that have atomic instructions for the corresponding operation, such as x86's `lock not`, MSP430's `inv`. Currently, optimizations by these methods (`not`) are only guaranteed for x86 and MSP430. (Note: `AtomicBool` already has `fetch_not` and `not` methods.) Co-authored-by: Taiki Endo <[email protected]>
Ok, I confirmed LLVM 16 generates
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following are the atomic operations supported by the x86 lock prefix.
We currently do not provide corresponding operations for BTC, BTR, BTS, NEG, and NOT. 1 2
NEG and NOT don't return the previous value, but can be provided in a way like #47.
Footnotes
To be exact, BTC, BTR, and BTS are available via other operations on Rust 1.65+, but
LLVM only generatesEDIT: see https://github.com/taiki-e/portable-atomic/issues/48#issuecomment-1453473831 ↩lock bt{s,r,c}
for immediate bit offsets (as of LLVM 15).As for NOT, an equivalent is available via
fetch_xor(-1i*)
/fetch_xor(u*::MAX)
, though, LLVM does not lower it tolock not
. ↩The text was updated successfully, but these errors were encountered: