[llvm-commits] [llvm] r57124 - /llvm/trunk/utils/TableGen/CodeEmitterGen.cpp

Daniel Dunbar daniel at zuster.org
Sun Oct 5 14:16:23 PDT 2008


> -            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.

 - Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20081005/dd43caf1/attachment.html>


More information about the llvm-commits mailing list