[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h
Reid Spencer
reid at x10sys.com
Sat Mar 24 16:37:06 PDT 2007
On Sat, 2007-03-24 at 16:31 -0700, Chris Lattner wrote:
> > /// @param loBit the index of the lowest bit set.
> > /// @returns An APInt value with the requested bits set.
> > /// @brief Get a value with a block of bits set.
> > - static APInt getBitsSet(uint32_t numBits, uint32_t hiBit,
> > uint32_t loBit = 0);
> > + static APInt getBitsSet(uint32_t numBits, uint32_t hiBit,
> > uint32_t loBit = 0){
> > + assert(hiBit < numBits && "hiBit out of range");
> > + assert(loBit < numBits && "loBit out of range");
> > + if (hiBit < loBit)
>
> Hrm? Why would you allow hiBit < loBit? This seems like something
> that should be asserted against.
Read the definition of the function in the documentation. It allows you
to construct things like:
0xFF0000FF with getBitsSet(32, 8, 24);
>
> > + return getLowBitsSet(numBits, hiBit+1) |
> > + getHighBitsSet(numBits, numBits-loBit+1);
> > + else if (loBit == 0)
> > + return getLowBitsSet(numBits, hiBit+1);
>
> Do you need this special case for correctness?
No, I was trying to saves a rather expensive shl for a common case.
However, I decided that before I wrote getLowBitsSet (which is the
equivalent). I'll remove that case and the default parameter.
>
> -Chris
>
> > + return getLowBitsSet(numBits, hiBit-loBit+1).shl(loBit);
> > + }
> >
> > /// Constructs an APInt value that has the top hiBitsSet bits set.
> > /// @param numBits the bitwidth of the result
> >
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20070324/deae638b/attachment.sig>
More information about the llvm-commits
mailing list