1 | #if SIMDJSON_IMPLEMENTATION_ARM64 || SIMDJSON_IMPLEMENTATION_ICELAKE || SIMDJSON_IMPLEMENTATION_HASWELL || SIMDJSON_IMPLEMENTATION_WESTMERE || SIMDJSON_IMPLEMENTATION_PPC64 |
2 | |
3 | #include <cstdint> |
4 | |
5 | namespace simdjson { // table modified and copied from |
6 | namespace internal { // http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetTable |
7 | SIMDJSON_DLLIMPORTEXPORT const unsigned char BitsSetTable256mul2[256] = { |
8 | 0, 2, 2, 4, 2, 4, 4, 6, 2, 4, 4, 6, 4, 6, 6, 8, 2, 4, 4, |
9 | 6, 4, 6, 6, 8, 4, 6, 6, 8, 6, 8, 8, 10, 2, 4, 4, 6, 4, 6, |
10 | 6, 8, 4, 6, 6, 8, 6, 8, 8, 10, 4, 6, 6, 8, 6, 8, 8, 10, 6, |
11 | 8, 8, 10, 8, 10, 10, 12, 2, 4, 4, 6, 4, 6, 6, 8, 4, 6, 6, 8, |
12 | 6, 8, 8, 10, 4, 6, 6, 8, 6, 8, 8, 10, 6, 8, 8, 10, 8, 10, 10, |
13 | 12, 4, 6, 6, 8, 6, 8, 8, 10, 6, 8, 8, 10, 8, 10, 10, 12, 6, 8, |
14 | 8, 10, 8, 10, 10, 12, 8, 10, 10, 12, 10, 12, 12, 14, 2, 4, 4, 6, 4, |
15 | 6, 6, 8, 4, 6, 6, 8, 6, 8, 8, 10, 4, 6, 6, 8, 6, 8, 8, 10, |
16 | 6, 8, 8, 10, 8, 10, 10, 12, 4, 6, 6, 8, 6, 8, 8, 10, 6, 8, 8, |
17 | 10, 8, 10, 10, 12, 6, 8, 8, 10, 8, 10, 10, 12, 8, 10, 10, 12, 10, 12, |
18 | 12, 14, 4, 6, 6, 8, 6, 8, 8, 10, 6, 8, 8, 10, 8, 10, 10, 12, 6, |
19 | 8, 8, 10, 8, 10, 10, 12, 8, 10, 10, 12, 10, 12, 12, 14, 6, 8, 8, 10, |
20 | 8, 10, 10, 12, 8, 10, 10, 12, 10, 12, 12, 14, 8, 10, 10, 12, 10, 12, 12, |
21 | 14, 10, 12, 12, 14, 12, 14, 14, 16}; |
22 | |
23 | SIMDJSON_DLLIMPORTEXPORT const uint8_t pshufb_combine_table[272] = { |
24 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, |
25 | 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x08, |
26 | 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0xff, 0x00, 0x01, 0x02, 0x03, |
27 | 0x04, 0x05, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0xff, 0xff, |
28 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
29 | 0x0f, 0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0a, 0x0b, |
30 | 0x0c, 0x0d, 0x0e, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x08, |
31 | 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, |
32 | 0x00, 0x01, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0xff, 0xff, |
33 | 0xff, 0xff, 0xff, 0xff, 0x00, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
34 | 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x08, 0x09, 0x0a, 0x0b, |
35 | 0x0c, 0x0d, 0x0e, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, |
36 | }; |
37 | |
38 | // 256 * 8 bytes = 2kB, easily fits in cache. |
39 | SIMDJSON_DLLIMPORTEXPORT const uint64_t thintable_epi8[256] = { |
40 | 0x0706050403020100, 0x0007060504030201, 0x0007060504030200, |
41 | 0x0000070605040302, 0x0007060504030100, 0x0000070605040301, |
42 | 0x0000070605040300, 0x0000000706050403, 0x0007060504020100, |
43 | 0x0000070605040201, 0x0000070605040200, 0x0000000706050402, |
44 | 0x0000070605040100, 0x0000000706050401, 0x0000000706050400, |
45 | 0x0000000007060504, 0x0007060503020100, 0x0000070605030201, |
46 | 0x0000070605030200, 0x0000000706050302, 0x0000070605030100, |
47 | 0x0000000706050301, 0x0000000706050300, 0x0000000007060503, |
48 | 0x0000070605020100, 0x0000000706050201, 0x0000000706050200, |
49 | 0x0000000007060502, 0x0000000706050100, 0x0000000007060501, |
50 | 0x0000000007060500, 0x0000000000070605, 0x0007060403020100, |
51 | 0x0000070604030201, 0x0000070604030200, 0x0000000706040302, |
52 | 0x0000070604030100, 0x0000000706040301, 0x0000000706040300, |
53 | 0x0000000007060403, 0x0000070604020100, 0x0000000706040201, |
54 | 0x0000000706040200, 0x0000000007060402, 0x0000000706040100, |
55 | 0x0000000007060401, 0x0000000007060400, 0x0000000000070604, |
56 | 0x0000070603020100, 0x0000000706030201, 0x0000000706030200, |
57 | 0x0000000007060302, 0x0000000706030100, 0x0000000007060301, |
58 | 0x0000000007060300, 0x0000000000070603, 0x0000000706020100, |
59 | 0x0000000007060201, 0x0000000007060200, 0x0000000000070602, |
60 | 0x0000000007060100, 0x0000000000070601, 0x0000000000070600, |
61 | 0x0000000000000706, 0x0007050403020100, 0x0000070504030201, |
62 | 0x0000070504030200, 0x0000000705040302, 0x0000070504030100, |
63 | 0x0000000705040301, 0x0000000705040300, 0x0000000007050403, |
64 | 0x0000070504020100, 0x0000000705040201, 0x0000000705040200, |
65 | 0x0000000007050402, 0x0000000705040100, 0x0000000007050401, |
66 | 0x0000000007050400, 0x0000000000070504, 0x0000070503020100, |
67 | 0x0000000705030201, 0x0000000705030200, 0x0000000007050302, |
68 | 0x0000000705030100, 0x0000000007050301, 0x0000000007050300, |
69 | 0x0000000000070503, 0x0000000705020100, 0x0000000007050201, |
70 | 0x0000000007050200, 0x0000000000070502, 0x0000000007050100, |
71 | 0x0000000000070501, 0x0000000000070500, 0x0000000000000705, |
72 | 0x0000070403020100, 0x0000000704030201, 0x0000000704030200, |
73 | 0x0000000007040302, 0x0000000704030100, 0x0000000007040301, |
74 | 0x0000000007040300, 0x0000000000070403, 0x0000000704020100, |
75 | 0x0000000007040201, 0x0000000007040200, 0x0000000000070402, |
76 | 0x0000000007040100, 0x0000000000070401, 0x0000000000070400, |
77 | 0x0000000000000704, 0x0000000703020100, 0x0000000007030201, |
78 | 0x0000000007030200, 0x0000000000070302, 0x0000000007030100, |
79 | 0x0000000000070301, 0x0000000000070300, 0x0000000000000703, |
80 | 0x0000000007020100, 0x0000000000070201, 0x0000000000070200, |
81 | 0x0000000000000702, 0x0000000000070100, 0x0000000000000701, |
82 | 0x0000000000000700, 0x0000000000000007, 0x0006050403020100, |
83 | 0x0000060504030201, 0x0000060504030200, 0x0000000605040302, |
84 | 0x0000060504030100, 0x0000000605040301, 0x0000000605040300, |
85 | 0x0000000006050403, 0x0000060504020100, 0x0000000605040201, |
86 | 0x0000000605040200, 0x0000000006050402, 0x0000000605040100, |
87 | 0x0000000006050401, 0x0000000006050400, 0x0000000000060504, |
88 | 0x0000060503020100, 0x0000000605030201, 0x0000000605030200, |
89 | 0x0000000006050302, 0x0000000605030100, 0x0000000006050301, |
90 | 0x0000000006050300, 0x0000000000060503, 0x0000000605020100, |
91 | 0x0000000006050201, 0x0000000006050200, 0x0000000000060502, |
92 | 0x0000000006050100, 0x0000000000060501, 0x0000000000060500, |
93 | 0x0000000000000605, 0x0000060403020100, 0x0000000604030201, |
94 | 0x0000000604030200, 0x0000000006040302, 0x0000000604030100, |
95 | 0x0000000006040301, 0x0000000006040300, 0x0000000000060403, |
96 | 0x0000000604020100, 0x0000000006040201, 0x0000000006040200, |
97 | 0x0000000000060402, 0x0000000006040100, 0x0000000000060401, |
98 | 0x0000000000060400, 0x0000000000000604, 0x0000000603020100, |
99 | 0x0000000006030201, 0x0000000006030200, 0x0000000000060302, |
100 | 0x0000000006030100, 0x0000000000060301, 0x0000000000060300, |
101 | 0x0000000000000603, 0x0000000006020100, 0x0000000000060201, |
102 | 0x0000000000060200, 0x0000000000000602, 0x0000000000060100, |
103 | 0x0000000000000601, 0x0000000000000600, 0x0000000000000006, |
104 | 0x0000050403020100, 0x0000000504030201, 0x0000000504030200, |
105 | 0x0000000005040302, 0x0000000504030100, 0x0000000005040301, |
106 | 0x0000000005040300, 0x0000000000050403, 0x0000000504020100, |
107 | 0x0000000005040201, 0x0000000005040200, 0x0000000000050402, |
108 | 0x0000000005040100, 0x0000000000050401, 0x0000000000050400, |
109 | 0x0000000000000504, 0x0000000503020100, 0x0000000005030201, |
110 | 0x0000000005030200, 0x0000000000050302, 0x0000000005030100, |
111 | 0x0000000000050301, 0x0000000000050300, 0x0000000000000503, |
112 | 0x0000000005020100, 0x0000000000050201, 0x0000000000050200, |
113 | 0x0000000000000502, 0x0000000000050100, 0x0000000000000501, |
114 | 0x0000000000000500, 0x0000000000000005, 0x0000000403020100, |
115 | 0x0000000004030201, 0x0000000004030200, 0x0000000000040302, |
116 | 0x0000000004030100, 0x0000000000040301, 0x0000000000040300, |
117 | 0x0000000000000403, 0x0000000004020100, 0x0000000000040201, |
118 | 0x0000000000040200, 0x0000000000000402, 0x0000000000040100, |
119 | 0x0000000000000401, 0x0000000000000400, 0x0000000000000004, |
120 | 0x0000000003020100, 0x0000000000030201, 0x0000000000030200, |
121 | 0x0000000000000302, 0x0000000000030100, 0x0000000000000301, |
122 | 0x0000000000000300, 0x0000000000000003, 0x0000000000020100, |
123 | 0x0000000000000201, 0x0000000000000200, 0x0000000000000002, |
124 | 0x0000000000000100, 0x0000000000000001, 0x0000000000000000, |
125 | 0x0000000000000000, |
126 | }; //static uint64_t thintable_epi8[256] |
127 | |
128 | } // namespace internal |
129 | } // namespace simdjson |
130 | |
131 | #endif // SIMDJSON_IMPLEMENTATION_ARM64 || SIMDJSON_IMPLEMENTATION_ICELAKE || SIMDJSON_IMPLEMENTATION_HASWELL || SIMDJSON_IMPLEMENTATION_WESTMERE || SIMDJSON_IMPLEMENTATION_PPC64 |
132 | |