diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-12-13 20:47:34 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-12-13 20:47:34 +0000 |
commit | 5bb504f4ea73fc46b4fb64d4ba970aafde1381b7 (patch) | |
tree | c5418a0810049b6e5e2b9d6a2fc3276992088bc8 /unittests | |
parent | a23bd2e761f528e91e2b4d14cc495b7afde3b4f2 (diff) | |
download | llvm-5bb504f4ea73fc46b4fb64d4ba970aafde1381b7.tar.gz llvm-5bb504f4ea73fc46b4fb64d4ba970aafde1381b7.tar.bz2 llvm-5bb504f4ea73fc46b4fb64d4ba970aafde1381b7.tar.xz |
[block-freq] Add the APInt method extractBit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197271 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/ADT/APIntTest.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/unittests/ADT/APIntTest.cpp b/unittests/ADT/APIntTest.cpp index 3c0dfe1440..1d330f0d36 100644 --- a/unittests/ADT/APIntTest.cpp +++ b/unittests/ADT/APIntTest.cpp @@ -597,4 +597,30 @@ TEST(APIntTest, tcDecrement) { EXPECT_EQ(APInt::tcCompare(test, expected, 4), 0); } } + +TEST(APIntTest, extractBit) { + // Single word check. + uint64_t E1 = 0x2CA7F46BF6569915ULL; + APInt A1(64, E1); + for (unsigned i = 0, e = 64; i < e; ++i) { + EXPECT_EQ(bool(E1 & (1ULL << i)), + A1.extractBit(i)); + } + + // Multiword check. + integerPart E2[4] = { + 0xeb6eb136591cba21ULL, + 0x7b9358bd6a33f10aULL, + 0x7e7ffa5eadd8846ULL, + 0x305f341ca00b613dULL + }; + APInt A2(integerPartWidth*4, ArrayRef<integerPart>(E2, 4)); + for (unsigned i = 0; i < 4; ++i) { + for (unsigned j = 0; j < integerPartWidth; ++j) { + EXPECT_EQ(bool(E2[i] & (1ULL << j)), + A2.extractBit(i*integerPartWidth + j)); + } + } +} + } |