[polly] 5e111eb - Migrate away from the soft-deprecated functions in APInt.h (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 20 00:58:34 PST 2023


Author: Kazu Hirata
Date: 2023-02-20T00:58:29-08:00
New Revision: 5e111eb275eee3bec1123b4b85606328017e5ee5

URL: https://github.com/llvm/llvm-project/commit/5e111eb275eee3bec1123b4b85606328017e5ee5
DIFF: https://github.com/llvm/llvm-project/commit/5e111eb275eee3bec1123b4b85606328017e5ee5.diff

LOG: Migrate away from the soft-deprecated functions in APInt.h (NFC)

Note that those functions on the left hand side are soft-deprecated in
favor of those on the right hand side:

  getMinSignedBits -> getSignificantBits
  getNullValue     -> getZero
  isNullValue      -> isZero
  isOneValue       -> isOne

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
    lldb/source/Utility/Scalar.cpp
    llvm/unittests/ADT/APIntTest.cpp
    llvm/unittests/IR/ConstantRangeTest.cpp
    polly/unittests/Isl/IslTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 717456698eb23..362ce2b200ae1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2707,7 +2707,7 @@ llvm::Expected<llvm::APInt> DWARFASTParserClang::ExtractIntFromFormValue(
   // For signed types, ask APInt how many bits are required to represent the
   // signed integer.
   const unsigned required_bits =
-      is_unsigned ? result.getActiveBits() : result.getMinSignedBits();
+      is_unsigned ? result.getActiveBits() : result.getSignificantBits();
 
   // If the input value doesn't fit into the integer type, return an error.
   if (required_bits > type_bits) {

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 19e00e111be52..4b80f6adca06a 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -145,7 +145,7 @@ bool Scalar::IsZero() const {
   case e_void:
     break;
   case e_int:
-    return m_integer.isNullValue();
+    return m_integer.isZero();
   case e_float:
     return m_float.isZero();
   }

diff  --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index ad0a280ae2a26..d8d7bfa27a3f3 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -166,7 +166,7 @@ TEST(APIntTest, i128_PositiveCount) {
   EXPECT_EQ(96u, s128.countl_zero());
   EXPECT_EQ(0u, s128.countl_one());
   EXPECT_EQ(32u, s128.getActiveBits());
-  EXPECT_EQ(33u, s128.getMinSignedBits());
+  EXPECT_EQ(33u, s128.getSignificantBits());
   EXPECT_EQ(1u, s128.countr_zero());
   EXPECT_EQ(0u, s128.countr_one());
   EXPECT_EQ(30u, s128.popcount());
@@ -176,7 +176,7 @@ TEST(APIntTest, i128_PositiveCount) {
   EXPECT_EQ(0u, s128.countl_zero());
   EXPECT_EQ(66u, s128.countl_one());
   EXPECT_EQ(128u, s128.getActiveBits());
-  EXPECT_EQ(63u, s128.getMinSignedBits());
+  EXPECT_EQ(63u, s128.getSignificantBits());
   EXPECT_EQ(1u, s128.countr_zero());
   EXPECT_EQ(0u, s128.countr_one());
   EXPECT_EQ(96u, s128.popcount());
@@ -200,7 +200,7 @@ TEST(APIntTest, i256) {
   EXPECT_EQ(190u, s256.countl_zero());
   EXPECT_EQ(0u, s256.countl_one());
   EXPECT_EQ(66u, s256.getActiveBits());
-  EXPECT_EQ(67u, s256.getMinSignedBits());
+  EXPECT_EQ(67u, s256.getSignificantBits());
   EXPECT_EQ(0u, s256.countr_zero());
   EXPECT_EQ(4u, s256.countr_one());
   EXPECT_EQ(8u, s256.popcount());
@@ -209,7 +209,7 @@ TEST(APIntTest, i256) {
   EXPECT_EQ(0u, s256.countl_zero());
   EXPECT_EQ(196u, s256.countl_one());
   EXPECT_EQ(256u, s256.getActiveBits());
-  EXPECT_EQ(61u, s256.getMinSignedBits());
+  EXPECT_EQ(61u, s256.getSignificantBits());
   EXPECT_EQ(0u, s256.countr_zero());
   EXPECT_EQ(4u, s256.countr_one());
   EXPECT_EQ(200u, s256.popcount());
@@ -2759,7 +2759,7 @@ TEST(APIntTest, RoundingSDiv) {
       APInt QuoTowardZero = A.sdiv(B);
       {
         APInt Quo = APIntOps::RoundingSDiv(A, B, APInt::Rounding::UP);
-        if (A.srem(B).isNullValue()) {
+        if (A.srem(B).isZero()) {
           EXPECT_EQ(QuoTowardZero, Quo);
         } else if (A.isNegative() !=
                    B.isNegative()) { // if the math quotient is negative.
@@ -2770,7 +2770,7 @@ TEST(APIntTest, RoundingSDiv) {
       }
       {
         APInt Quo = APIntOps::RoundingSDiv(A, B, APInt::Rounding::DOWN);
-        if (A.srem(B).isNullValue()) {
+        if (A.srem(B).isZero()) {
           EXPECT_EQ(QuoTowardZero, Quo);
         } else if (A.isNegative() !=
                    B.isNegative()) { // if the math quotient is negative.
@@ -2929,12 +2929,12 @@ TEST(APIntTest, MultiplicativeInverseExaustive) {
               .multiplicativeInverse(APInt::getSignedMinValue(BitWidth + 1))
               .trunc(BitWidth);
       APInt One = V * MulInv;
-      if (!V.isNullValue() && V.countr_zero() == 0) {
+      if (!V.isZero() && V.countr_zero() == 0) {
         // Multiplicative inverse exists for all odd numbers.
-        EXPECT_TRUE(One.isOneValue());
+        EXPECT_TRUE(One.isOne());
       } else {
         // Multiplicative inverse does not exist for even numbers (and 0).
-        EXPECT_TRUE(MulInv.isNullValue());
+        EXPECT_TRUE(MulInv.isZero());
       }
     }
   }
@@ -3120,8 +3120,8 @@ TEST(APIntTest, ScaleBitMask) {
 
   EXPECT_EQ(APIntOps::ScaleBitMask(APInt(8, 0x00), 8), APInt(8, 0x00));
 
-  EXPECT_EQ(APIntOps::ScaleBitMask(APInt::getNullValue(1024), 4096),
-            APInt::getNullValue(4096));
+  EXPECT_EQ(APIntOps::ScaleBitMask(APInt::getZero(1024), 4096),
+            APInt::getZero(4096));
   EXPECT_EQ(APIntOps::ScaleBitMask(APInt::getAllOnes(4096), 256),
             APInt::getAllOnes(256));
   EXPECT_EQ(APIntOps::ScaleBitMask(APInt::getOneBitSet(4096, 32), 256),

diff  --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp
index cb7d01759bee7..f4052838c434c 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -665,7 +665,7 @@ TEST_F(ConstantRangeTest, getMinSignedBits) {
   EnumerateInterestingConstantRanges([&](const ConstantRange &CR) {
     unsigned Exact = 0;
     ForeachNumInConstantRange(CR, [&](const APInt &N) {
-      Exact = std::max(Exact, N.getMinSignedBits());
+      Exact = std::max(Exact, N.getSignificantBits());
     });
 
     unsigned ResultCR = CR.getMinSignedBits();

diff  --git a/polly/unittests/Isl/IslTest.cpp b/polly/unittests/Isl/IslTest.cpp
index d3c64407d5da9..801758f5c8829 100644
--- a/polly/unittests/Isl/IslTest.cpp
+++ b/polly/unittests/Isl/IslTest.cpp
@@ -244,7 +244,7 @@ TEST(Isl, IslValToAPInt) {
     auto APLargePow2 = APIntFromVal(IslLargePow2);
     EXPECT_TRUE(APLargePow2.isPowerOf2());
     EXPECT_EQ(502u, APLargePow2.getBitWidth());
-    EXPECT_EQ(502u, APLargePow2.getMinSignedBits());
+    EXPECT_EQ(502u, APLargePow2.getSignificantBits());
   }
 
   {
@@ -252,7 +252,7 @@ TEST(Isl, IslValToAPInt) {
     auto IslLargeNPow2 = IslExp.pow2().neg();
     auto APLargeNPow2 = APIntFromVal(IslLargeNPow2);
     EXPECT_EQ(501u, APLargeNPow2.getBitWidth());
-    EXPECT_EQ(501u, APLargeNPow2.getMinSignedBits());
+    EXPECT_EQ(501u, APLargeNPow2.getSignificantBits());
     EXPECT_EQ(500, (-APLargeNPow2).exactLogBase2());
   }
 
@@ -262,7 +262,7 @@ TEST(Isl, IslValToAPInt) {
     auto APLargePow2 = APIntFromVal(IslLargePow2);
     EXPECT_TRUE(APLargePow2.isPowerOf2());
     EXPECT_EQ(514u, APLargePow2.getBitWidth());
-    EXPECT_EQ(514u, APLargePow2.getMinSignedBits());
+    EXPECT_EQ(514u, APLargePow2.getSignificantBits());
   }
 
   {
@@ -270,7 +270,7 @@ TEST(Isl, IslValToAPInt) {
     auto IslLargeNPow2 = IslExp.pow2().neg();
     auto APLargeNPow2 = APIntFromVal(IslLargeNPow2);
     EXPECT_EQ(513u, APLargeNPow2.getBitWidth());
-    EXPECT_EQ(513u, APLargeNPow2.getMinSignedBits());
+    EXPECT_EQ(513u, APLargeNPow2.getSignificantBits());
     EXPECT_EQ(512, (-APLargeNPow2).exactLogBase2());
   }
 


        


More information about the llvm-commits mailing list