[PATCH] D142179: [ADT] Add bit_floor, bit_ceil, and bit_width to bit.h
Kazu Hirata via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 19 22:36:07 PST 2023
kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch adds C++20-style bit_floor, bit_ceil, and bit_width.
In a subsequent patch, I'm going to define PowerOf2Floor in
MathExtras.h in terms of bit_floor.
Unfortunately, PowerOf2Ceil isn't quite the same as bit_ceil because
PowerOf2Ceil(0) == 0, whereas bit_ceil(0) == 1.
MathExtras.h does not have a function directly corresponding to
bit_width, but Log2_32(X) + 1, which occurs in a few places, can be
replaced with bit_width(X).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142179
Files:
llvm/include/llvm/ADT/bit.h
llvm/unittests/ADT/BitTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142179.490722.patch
Type: text/x-patch
Size: 4763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230120/6c934f76/attachment.bin>
More information about the llvm-commits
mailing list