From 415df89e22abe3defa06cbc901a173e5a6791f8d Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Mon, 14 Oct 2019 09:04:15 +0000 Subject: [Alignment][NFC] Support compile time constants Summary: This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68936 llvm-svn: 374758 --- llvm/unittests/Support/MathExtrasTest.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'llvm/unittests/Support/MathExtrasTest.cpp') diff --git a/llvm/unittests/Support/MathExtrasTest.cpp b/llvm/unittests/Support/MathExtrasTest.cpp index 01c83c9e14d..e910d83b626 100644 --- a/llvm/unittests/Support/MathExtrasTest.cpp +++ b/llvm/unittests/Support/MathExtrasTest.cpp @@ -203,6 +203,25 @@ TEST(MathExtras, PowerOf2Floor) { EXPECT_EQ(4U, PowerOf2Floor(7U)); } +TEST(MathExtras, CTLog2) { + EXPECT_EQ(CTLog2<1ULL << 0>(), 0U); + EXPECT_EQ(CTLog2<1ULL << 1>(), 1U); + EXPECT_EQ(CTLog2<1ULL << 2>(), 2U); + EXPECT_EQ(CTLog2<1ULL << 3>(), 3U); + EXPECT_EQ(CTLog2<1ULL << 4>(), 4U); + EXPECT_EQ(CTLog2<1ULL << 5>(), 5U); + EXPECT_EQ(CTLog2<1ULL << 6>(), 6U); + EXPECT_EQ(CTLog2<1ULL << 7>(), 7U); + EXPECT_EQ(CTLog2<1ULL << 8>(), 8U); + EXPECT_EQ(CTLog2<1ULL << 9>(), 9U); + EXPECT_EQ(CTLog2<1ULL << 10>(), 10U); + EXPECT_EQ(CTLog2<1ULL << 11>(), 11U); + EXPECT_EQ(CTLog2<1ULL << 12>(), 12U); + EXPECT_EQ(CTLog2<1ULL << 13>(), 13U); + EXPECT_EQ(CTLog2<1ULL << 14>(), 14U); + EXPECT_EQ(CTLog2<1ULL << 15>(), 15U); +} + TEST(MathExtras, ByteSwap_32) { EXPECT_EQ(0x44332211u, ByteSwap_32(0x11223344)); EXPECT_EQ(0xDDCCBBAAu, ByteSwap_32(0xAABBCCDD)); -- cgit v1.2.3