1 | #include "popcount.h" |
2 | |
3 | static const uint8_t PopCountLUT8Impl[1 << 8] = { |
4 | #define B2(n) n, n + 1, n + 1, n + 2 |
5 | #define B4(n) B2(n), B2(n + 1), B2(n + 1), B2(n + 2) |
6 | #define B6(n) B4(n), B4(n + 1), B4(n + 1), B4(n + 2) |
7 | B6(0), B6(1), B6(1), B6(2)}; |
8 | |
9 | uint8_t const* PopCountLUT8 = PopCountLUT8Impl; |
10 | |
11 | #if !defined(_MSC_VER) |
12 | //ICE here for msvc |
13 | |
14 | static const uint8_t PopCountLUT16Impl[1 << 16] = { |
15 | #define B2(n) n, n + 1, n + 1, n + 2 |
16 | #define B4(n) B2(n), B2(n + 1), B2(n + 1), B2(n + 2) |
17 | #define B6(n) B4(n), B4(n + 1), B4(n + 1), B4(n + 2) |
18 | #define B8(n) B6(n), B6(n + 1), B6(n + 1), B6(n + 2) |
19 | #define B10(n) B8(n), B8(n + 1), B8(n + 1), B8(n + 2) |
20 | #define B12(n) B10(n), B10(n + 1), B10(n + 1), B10(n + 2) |
21 | #define B14(n) B12(n), B12(n + 1), B12(n + 1), B12(n + 2) |
22 | B14(0), B14(1), B14(1), B14(2)}; |
23 | |
24 | uint8_t const* PopCountLUT16 = PopCountLUT16Impl; |
25 | #endif |
26 | |