diff options
author | Chris Lattner <clattner@nondot.org> | 2021-09-08 22:13:13 -0700 |
---|---|---|
committer | Chris Lattner <clattner@nondot.org> | 2021-09-09 09:50:24 -0700 |
commit | 735f46715d90fd0ff48dd44d1007302640ab4d11 (patch) | |
tree | b6e83d6168f4c6e7b3427791fe17581f210015ec /llvm/unittests/IR/ConstantRangeTest.cpp | |
parent | 6355234660551e7562e2ace512ccaefacbbb9065 (diff) | |
download | llvm-735f46715d90fd0ff48dd44d1007302640ab4d11.zip llvm-735f46715d90fd0ff48dd44d1007302640ab4d11.tar.gz llvm-735f46715d90fd0ff48dd44d1007302640ab4d11.tar.bz2 |
[APInt] Normalize naming on keep constructors / predicate methods.
This renames the primary methods for creating a zero value to `getZero`
instead of `getNullValue` and renames predicates like `isAllOnesValue`
to simply `isAllOnes`. This achieves two things:
1) This starts standardizing predicates across the LLVM codebase,
following (in this case) ConstantInt. The word "Value" doesn't
convey anything of merit, and is missing in some of the other things.
2) Calling an integer "null" doesn't make any sense. The original sin
here is mine and I've regretted it for years. This moves us to calling
it "zero" instead, which is correct!
APInt is widely used and I don't think anyone is keen to take massive source
breakage on anything so core, at least not all in one go. As such, this
doesn't actually delete any entrypoints, it "soft deprecates" them with a
comment.
Included in this patch are changes to a bunch of the codebase, but there are
more. We should normalize SelectionDAG and other APIs as well, which would
make the API change more mechanical.
Differential Revision: https://reviews.llvm.org/D109483
Diffstat (limited to 'llvm/unittests/IR/ConstantRangeTest.cpp')
-rw-r--r-- | llvm/unittests/IR/ConstantRangeTest.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp index 8eca261..5fde024 100644 --- a/llvm/unittests/IR/ConstantRangeTest.cpp +++ b/llvm/unittests/IR/ConstantRangeTest.cpp @@ -1969,7 +1969,7 @@ TEST_F(ConstantRangeTest, UnsignedAddOverflow) { EXPECT_MAY_OVERFLOW(Empty.unsignedAddMayOverflow(Some)); // Never overflow despite one full/wrap set. - ConstantRange Zero(APInt::getNullValue(16)); + ConstantRange Zero(APInt::getZero(16)); EXPECT_NEVER_OVERFLOWS(Full.unsignedAddMayOverflow(Zero)); EXPECT_NEVER_OVERFLOWS(Wrap.unsignedAddMayOverflow(Zero)); EXPECT_NEVER_OVERFLOWS(Zero.unsignedAddMayOverflow(Full)); @@ -2003,8 +2003,8 @@ TEST_F(ConstantRangeTest, UnsignedSubOverflow) { EXPECT_MAY_OVERFLOW(Empty.unsignedSubMayOverflow(Some)); // Never overflow despite one full/wrap set. - ConstantRange Zero(APInt::getNullValue(16)); - ConstantRange Max(APInt::getAllOnesValue(16)); + ConstantRange Zero(APInt::getZero(16)); + ConstantRange Max(APInt::getAllOnes(16)); EXPECT_NEVER_OVERFLOWS(Full.unsignedSubMayOverflow(Zero)); EXPECT_NEVER_OVERFLOWS(Wrap.unsignedSubMayOverflow(Zero)); EXPECT_NEVER_OVERFLOWS(Max.unsignedSubMayOverflow(Full)); @@ -2038,7 +2038,7 @@ TEST_F(ConstantRangeTest, SignedAddOverflow) { EXPECT_MAY_OVERFLOW(Empty.signedAddMayOverflow(Some)); // Never overflow despite one full/wrap set. - ConstantRange Zero(APInt::getNullValue(16)); + ConstantRange Zero(APInt::getZero(16)); EXPECT_NEVER_OVERFLOWS(Full.signedAddMayOverflow(Zero)); EXPECT_NEVER_OVERFLOWS(Wrap.signedAddMayOverflow(Zero)); EXPECT_NEVER_OVERFLOWS(Zero.signedAddMayOverflow(Full)); @@ -2090,7 +2090,7 @@ TEST_F(ConstantRangeTest, SignedSubOverflow) { EXPECT_MAY_OVERFLOW(Empty.signedSubMayOverflow(Some)); // Never overflow despite one full/wrap set. - ConstantRange Zero(APInt::getNullValue(16)); + ConstantRange Zero(APInt::getZero(16)); EXPECT_NEVER_OVERFLOWS(Full.signedSubMayOverflow(Zero)); EXPECT_NEVER_OVERFLOWS(Wrap.signedSubMayOverflow(Zero)); @@ -2474,18 +2474,14 @@ TEST_F(ConstantRangeTest, binaryNot) { PreferSmallest); TestUnaryOpExhaustive( [](const ConstantRange &CR) { - return CR.binaryXor( - ConstantRange(APInt::getAllOnesValue(CR.getBitWidth()))); + return CR.binaryXor(ConstantRange(APInt::getAllOnes(CR.getBitWidth()))); }, - [](const APInt &N) { return ~N; }, - PreferSmallest); + [](const APInt &N) { return ~N; }, PreferSmallest); TestUnaryOpExhaustive( [](const ConstantRange &CR) { - return ConstantRange(APInt::getAllOnesValue(CR.getBitWidth())) - .binaryXor(CR); + return ConstantRange(APInt::getAllOnes(CR.getBitWidth())).binaryXor(CR); }, - [](const APInt &N) { return ~N; }, - PreferSmallest); + [](const APInt &N) { return ~N; }, PreferSmallest); } } // anonymous namespace |