@@ -1541,31 +1541,31 @@ class [[nodiscard]] APInt {
1541
1541
// / parsing the value in the string.
1542
1542
static unsigned getSufficientBitsNeeded (StringRef Str, uint8_t Radix);
1543
1543
1544
- // / The APInt version of the countLeadingZeros functions in
1545
- // / MathExtras.h.
1544
+ // / The APInt version of std::countl_zero.
1546
1545
// /
1547
1546
// / It counts the number of zeros from the most significant bit to the first
1548
1547
// / one bit.
1549
1548
// /
1550
1549
// / \returns BitWidth if the value is zero, otherwise returns the number of
1551
1550
// / zeros from the most significant bit to the first one bits.
1552
- unsigned countLeadingZeros () const {
1551
+ unsigned countl_zero () const {
1553
1552
if (isSingleWord ()) {
1554
1553
unsigned unusedBits = APINT_BITS_PER_WORD - BitWidth;
1555
1554
return llvm::countl_zero (U.VAL ) - unusedBits;
1556
1555
}
1557
1556
return countLeadingZerosSlowCase ();
1558
1557
}
1559
1558
1559
+ unsigned countLeadingZeros () const { return countl_zero (); }
1560
+
1560
1561
// / Count the number of leading one bits.
1561
1562
// /
1562
- // / This function is an APInt version of the countLeadingOnes
1563
- // / functions in MathExtras.h. It counts the number of ones from the most
1564
- // / significant bit to the first zero bit.
1563
+ // / This function is an APInt version of std::countl_one. It counts the number
1564
+ // / of ones from the most significant bit to the first zero bit.
1565
1565
// /
1566
1566
// / \returns 0 if the high order bit is not set, otherwise returns the number
1567
1567
// / of 1 bits from the most significant to the least
1568
- unsigned countLeadingOnes () const {
1568
+ unsigned countl_one () const {
1569
1569
if (isSingleWord ()) {
1570
1570
if (LLVM_UNLIKELY (BitWidth == 0 ))
1571
1571
return 0 ;
@@ -1574,6 +1574,8 @@ class [[nodiscard]] APInt {
1574
1574
return countLeadingOnesSlowCase ();
1575
1575
}
1576
1576
1577
+ unsigned countLeadingOnes () const { return countl_one (); }
1578
+
1577
1579
// / Computes the number of leading bits of this APInt that are equal to its
1578
1580
// / sign bit.
1579
1581
unsigned getNumSignBits () const {
@@ -1582,46 +1584,50 @@ class [[nodiscard]] APInt {
1582
1584
1583
1585
// / Count the number of trailing zero bits.
1584
1586
// /
1585
- // / This function is an APInt version of the countTrailingZeros
1586
- // / functions in MathExtras.h. It counts the number of zeros from the least
1587
- // / significant bit to the first set bit.
1587
+ // / This function is an APInt version of the countr_zero. It counts the number
1588
+ // / of zeros from the least significant bit to the first set bit.
1588
1589
// /
1589
1590
// / \returns BitWidth if the value is zero, otherwise returns the number of
1590
1591
// / zeros from the least significant bit to the first one bit.
1591
- unsigned countTrailingZeros () const {
1592
+ unsigned countr_zero () const {
1592
1593
if (isSingleWord ()) {
1593
1594
unsigned TrailingZeros = llvm::countr_zero (U.VAL );
1594
1595
return (TrailingZeros > BitWidth ? BitWidth : TrailingZeros);
1595
1596
}
1596
1597
return countTrailingZerosSlowCase ();
1597
1598
}
1598
1599
1600
+ unsigned countTrailingZeros () const { return countr_zero (); }
1601
+
1599
1602
// / Count the number of trailing one bits.
1600
1603
// /
1601
- // / This function is an APInt version of the countTrailingOnes
1602
- // / functions in MathExtras.h. It counts the number of ones from the least
1603
- // / significant bit to the first zero bit.
1604
+ // / This function is an APInt version of std::countr_one. It counts the number
1605
+ // / of ones from the least significant bit to the first zero bit.
1604
1606
// /
1605
1607
// / \returns BitWidth if the value is all ones, otherwise returns the number
1606
1608
// / of ones from the least significant bit to the first zero bit.
1607
- unsigned countTrailingOnes () const {
1609
+ unsigned countr_one () const {
1608
1610
if (isSingleWord ())
1609
1611
return llvm::countr_one (U.VAL );
1610
1612
return countTrailingOnesSlowCase ();
1611
1613
}
1612
1614
1615
+ unsigned countTrailingOnes () const { return countr_one (); }
1616
+
1613
1617
// / Count the number of bits set.
1614
1618
// /
1615
- // / This function is an APInt version of the countPopulation functions
1616
- // / in MathExtras.h. It counts the number of 1 bits in the APInt value.
1619
+ // / This function is an APInt version of std::popcount. It counts the number
1620
+ // / of 1 bits in the APInt value.
1617
1621
// /
1618
1622
// / \returns 0 if the value is zero, otherwise returns the number of set bits.
1619
- unsigned countPopulation () const {
1623
+ unsigned popcount () const {
1620
1624
if (isSingleWord ())
1621
1625
return llvm::popcount (U.VAL );
1622
1626
return countPopulationSlowCase ();
1623
1627
}
1624
1628
1629
+ unsigned countPopulation () const { return popcount (); }
1630
+
1625
1631
// / @}
1626
1632
// / \name Conversion Functions
1627
1633
// / @{
0 commit comments