Skip to content

Add bit_{set,clear,toggle} to Atomic{I,U}* and AtomicPtr#72

Merged
taiki-e merged 2 commits intomainfrom
bit-ops
Mar 3, 2023
Merged

Add bit_{set,clear,toggle} to Atomic{I,U}* and AtomicPtr#72
taiki-e merged 2 commits intomainfrom
bit-ops

Conversation

@taiki-e
Copy link
Copy Markdown
Owner

@taiki-e taiki-e commented Feb 8, 2023

They correspond to x86's lock bt{s,r,c}, and the implementation calls them on x86/x86_64.

LLVM 14 and older don't support generating lock bt{s,r,c}.
https://godbolt.org/z/G1TMKza97
LLVM 15 only supports generating lock bt{s,r,c} for immediate bit offsets.
https://godbolt.org/z/dzzhr81z6
LLVM 16 can generate lock bt{s,r,c} for both immediate and register bit offsets.
#48 (comment)
So, use fetch_* based implementations on LLVM 16+, otherwise use asm based implementations.

Closes #48

@taiki-e taiki-e added the O-x86 Target: x86/x64 processors label Feb 8, 2023
@taiki-e taiki-e mentioned this pull request Feb 8, 2023
5 tasks
@taiki-e taiki-e force-pushed the bit-ops branch 7 times, most recently from bc3c091 to 05ae878 Compare February 9, 2023 20:01
@taiki-e taiki-e force-pushed the bit-ops branch 7 times, most recently from 4ed4033 to 6d42701 Compare February 27, 2023 16:59
@taiki-e taiki-e force-pushed the bit-ops branch 2 times, most recently from b300ac9 to 2bb10d9 Compare March 3, 2023 03:15
@taiki-e taiki-e force-pushed the main branch 2 times, most recently from 7b11d7c to 8323808 Compare March 3, 2023 12:34
@taiki-e taiki-e force-pushed the bit-ops branch 4 times, most recently from 42883ef to 5be9097 Compare March 3, 2023 15:26
@taiki-e taiki-e merged commit 0f262d9 into main Mar 3, 2023
@taiki-e taiki-e deleted the bit-ops branch March 3, 2023 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-x86 Target: x86/x64 processors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide more atomic ops

1 participant