Repository navigation
Use C++20 standard bit utilities and std::bit_cast. NFC - #2773
Merged
Merged
Conversation
sbc100
commented
Jun 23, 2026
Member
- Replace custom Clz, Ctz, and Popcount implementations in config.h.in with standard templates using std::countl_zero, std::countr_zero, and std::popcount from .
- Redefine wabt::Bitcast to use std::bit_cast.
- This removes a significant amount of compiler-specific boilerplate.
sbc100
force-pushed
the
cxx20-bitops
branch
2 times, most recently
from
June 23, 2026 20:17
2b083fc to
39f6b58
Compare
sbc100
enabled auto-merge (squash)
June 23, 2026 20:23
Collaborator
|
Question: it does not seem the general library needs these functions. Are these intrerpreter specific? If yes, we should move these to there. |
Member
Author
I had the same thought but it seems at least Clz is used in literal.cc. Maybe we could split them up be it seem like a good idea to keep them together. |
- Replace custom Clz, Ctz, and Popcount implementations in config.h.in with standard templates using std::countl_zero, std::countr_zero, and std::popcount from <bit>. - Redefine wabt::Bitcast to use std::bit_cast. This removes a significant amount of compiler-specific boilerplate.
Member
Author
|
OK, I ended up just inlining these calls.. since they were all operating on unsigned types anyway. |
sbc100
force-pushed
the
cxx20-bitops
branch
4 times, most recently
from
June 24, 2026 04:16
df00608 to
ac89a79
Compare
zherczeg
approved these changes
Jun 24, 2026
zherczeg
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. I like this code variant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.