[llvm-commits] [llvm] r121851 - in /llvm/trunk: include/llvm/Support/MathExtras.h lib/MC/MCStreamer.cpp
Bill Wendling
wendling at apple.com
Wed Dec 15 13:15:34 PST 2010
On Dec 14, 2010, at 11:12 PM, Rafael Espindola wrote:
> Author: rafael
> Date: Wed Dec 15 01:12:24 2010
> New Revision: 121851
>
> URL: http://llvm.org/viewvc/llvm-project?rev=121851&view=rev
> Log:
> Generalize an assert.
>
> Modified:
> llvm/trunk/include/llvm/Support/MathExtras.h
> llvm/trunk/lib/MC/MCStreamer.cpp
>
> Modified: llvm/trunk/include/llvm/Support/MathExtras.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=121851&r1=121850&r2=121851&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/MathExtras.h (original)
> +++ llvm/trunk/include/llvm/Support/MathExtras.h Wed Dec 15 01:12:24 2010
> @@ -76,6 +76,12 @@
> return x == (x & (~0ULL >> (64 - N)));
> }
>
> +/// isIIntN - Checks if an signed integer fits into the given (dynamic)
"isIIntN" is a typo.
-bw
> +/// bit width.
> +inline bool isIntN(unsigned N, int64_t x) {
> + return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1)));
> +}
> +
> /// isMask_32 - This function returns true if the argument is a sequence of ones
> /// starting at the least significant bit with the remainder zero (32 bit
> /// version). Ex. isMask_32(0x0000FFFFU) == true.
>
> Modified: llvm/trunk/lib/MC/MCStreamer.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=121851&r1=121850&r2=121851&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCStreamer.cpp (original)
> +++ llvm/trunk/lib/MC/MCStreamer.cpp Wed Dec 15 01:12:24 2010
> @@ -48,7 +48,8 @@
> void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size,
> unsigned AddrSpace) {
> assert(Size <= 8 && "Invalid size");
> - assert(!(Size == 1 && (signed)Value > 255) && "Invalid size");
> + unsigned Bits = 8 * Size;
> + assert((isUIntN(Bits, Value) || isIntN(Bits, Value)) && "Invalid size");
> char buf[8];
> // FIXME: Endianness assumption.
> for (unsigned i = 0; i != Size; ++i)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101215/4ec28c0d/attachment.html>
More information about the llvm-commits
mailing list