[PATCH] D69032: [APInt] add wrapping support for APInt::setBits
ChenZheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 01:03:46 PST 2019
shchenz marked an inline comment as done.
shchenz added inline comments.
================
Comment at: llvm/include/llvm/ADT/APInt.h:606-613
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit) {
APInt Res(numBits, 0);
- Res.setBits(loBit, hiBit);
+ if (loBit <= hiBit)
+ Res.setBits(loBit, hiBit);
+ else
+ Res.setBitsWithWrap(loBit, hiBit);
return Res;
----------------
lebedev.ri wrote:
> lebedev.ri wrote:
> > These changes are still there
> To reword, the suggestion is to
>
> ```
> static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit) {
> APInt Res(numBits, 0);
> Res.setBits(loBit, hiBit);
> return Res;
> }
>
> static APInt getBitsSetWithWrap(unsigned numBits, unsigned loBit, unsigned hiBit) {
> APInt Res(numBits, 0);
> Res.setBitsWithWrap(loBit, hiBit);
> return Res;
> }
> ```
I think if we want to avoid recursion in `setBits`, we just need to split `setBits` for wrap and non-wrap. I am not sure the benifit of spliting `getBitsSet`, could you point it out to me?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69032/new/
https://reviews.llvm.org/D69032
More information about the llvm-commits
mailing list