[llvm] b49b429 - [llvm] Deprecate PowerOf2Floor and ByteSwap_{16, 32, 64}
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 12 21:42:13 PST 2023
Author: Kazu Hirata
Date: 2023-02-12T21:42:07-08:00
New Revision: b49b429fde3a282664289d7a2155d994085eb232
URL: https://github.com/llvm/llvm-project/commit/b49b429fde3a282664289d7a2155d994085eb232
DIFF: https://github.com/llvm/llvm-project/commit/b49b429fde3a282664289d7a2155d994085eb232.diff
LOG: [llvm] Deprecate PowerOf2Floor and ByteSwap_{16,32,64}
llvm/include/llvm/ADT/bit.h now has equivalent functions
forward-ported from C++20.
Differential Revision: https://reviews.llvm.org/D143858
Added:
Modified:
llvm/include/llvm/Support/MathExtras.h
llvm/include/llvm/Support/SwapByteOrder.h
llvm/unittests/Support/MathExtrasTest.cpp
llvm/unittests/Support/SwapByteOrderTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
index 69ce1f91a6109..b009ba3fcea98 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/include/llvm/Support/MathExtras.h
@@ -455,6 +455,7 @@ constexpr inline uint64_t NextPowerOf2(uint64_t A) {
/// Returns the power of two which is less than or equal to the given value.
/// Essentially, it is a floor operation across the domain of powers of two.
+LLVM_DEPRECATED("use llvm::bit_floor instead", "llvm::bit_floor")
inline uint64_t PowerOf2Floor(uint64_t A) {
return llvm::bit_floor(A);
}
diff --git a/llvm/include/llvm/Support/SwapByteOrder.h b/llvm/include/llvm/Support/SwapByteOrder.h
index 9dd08665bd23e..ff4d0db66a6e8 100644
--- a/llvm/include/llvm/Support/SwapByteOrder.h
+++ b/llvm/include/llvm/Support/SwapByteOrder.h
@@ -48,12 +48,15 @@ namespace llvm {
/// ByteSwap_16 - This function returns a byte-swapped representation of
/// the 16-bit argument.
+LLVM_DEPRECATED("use llvm::byteswap instead", "llvm::byteswap")
inline uint16_t ByteSwap_16(uint16_t value) { return llvm::byteswap(value); }
/// This function returns a byte-swapped representation of the 32-bit argument.
+LLVM_DEPRECATED("use llvm::byteswap instead", "llvm::byteswap")
inline uint32_t ByteSwap_32(uint32_t value) { return llvm::byteswap(value); }
/// This function returns a byte-swapped representation of the 64-bit argument.
+LLVM_DEPRECATED("use llvm::byteswap instead", "llvm::byteswap")
inline uint64_t ByteSwap_64(uint64_t value) { return llvm::byteswap(value); }
namespace sys {
diff --git a/llvm/unittests/Support/MathExtrasTest.cpp b/llvm/unittests/Support/MathExtrasTest.cpp
index db667bfb28810..ca724d1c2b944 100644
--- a/llvm/unittests/Support/MathExtrasTest.cpp
+++ b/llvm/unittests/Support/MathExtrasTest.cpp
@@ -143,12 +143,6 @@ TEST(MathExtras, PowerOf2Ceil) {
EXPECT_EQ(8U, PowerOf2Ceil(7U));
}
-TEST(MathExtras, PowerOf2Floor) {
- EXPECT_EQ(0U, PowerOf2Floor(0U));
- EXPECT_EQ(8U, PowerOf2Floor(8U));
- EXPECT_EQ(4U, PowerOf2Floor(7U));
-}
-
TEST(MathExtras, CTLog2) {
EXPECT_EQ(CTLog2<1ULL << 0>(), 0U);
EXPECT_EQ(CTLog2<1ULL << 1>(), 1U);
diff --git a/llvm/unittests/Support/SwapByteOrderTest.cpp b/llvm/unittests/Support/SwapByteOrderTest.cpp
index 85392fad67e61..9581f070475e1 100644
--- a/llvm/unittests/Support/SwapByteOrderTest.cpp
+++ b/llvm/unittests/Support/SwapByteOrderTest.cpp
@@ -16,16 +16,6 @@ using namespace llvm;
namespace {
-TEST(ByteSwap, Swap_32) {
- EXPECT_EQ(0x44332211u, ByteSwap_32(0x11223344));
- EXPECT_EQ(0xDDCCBBAAu, ByteSwap_32(0xAABBCCDD));
-}
-
-TEST(ByteSwap, Swap_64) {
- EXPECT_EQ(0x8877665544332211ULL, ByteSwap_64(0x1122334455667788LL));
- EXPECT_EQ(0x1100FFEEDDCCBBAAULL, ByteSwap_64(0xAABBCCDDEEFF0011LL));
-}
-
// In these first two tests all of the original_uintx values are truncated
// except for 64. We could avoid this, but there's really no point.
More information about the llvm-commits
mailing list