[llvm-commits] [llvm] r57124 - /llvm/trunk/utils/TableGen/CodeEmitterGen.cpp
Chris Lattner
clattner at apple.com
Sun Oct 5 14:52:17 PDT 2008
On Oct 5, 2008, at 2:16 PM, Daniel Dunbar wrote:
>
> - unsigned opMask = (1 << N) - 1;
> + unsigned opMask = ~0U >> (32-N);
>
> Would it be unreasonable to pull this until a utility header? I find
> something like
> --
> unsigned opMask = bits32::maxValueOfNBits(N);
> --
> more readable & easier to verify.
>
> Other things I put there are: truncateToNBits, isPowerOfTwo,
> withoutRightmostBit, isolateRightmostBit and indexOfSingleBit.
Sure, this could go into MathExtras.h. It would be nice to make the
MathExtras.h and APInt apis as similar as possible though (except that
MathExtras should have _32/_64 suffixes and always return int32/64 of
course)
-Chris
More information about the llvm-commits
mailing list