aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/bitops.cpp
blob: cee2667f4b47ff9c98527b44f106735872c0bc85 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include "bitops.h"
 
namespace NBitOps { 
    namespace NPrivate { 
        const ui64 WORD_MASK[] = { 
            0x0000000000000000ULL, 
            0x0000000000000001ULL, 
            0x0000000000000003ULL, 
            0x0000000000000007ULL, 
            0x000000000000000FULL, 
            0x000000000000001FULL, 
            0x000000000000003FULL, 
            0x000000000000007FULL, 
            0x00000000000000FFULL, 
            0x00000000000001FFULL, 
            0x00000000000003FFULL, 
            0x00000000000007FFULL, 
            0x0000000000000FFFULL, 
            0x0000000000001FFFULL, 
            0x0000000000003FFFULL, 
            0x0000000000007FFFULL, 
            0x000000000000FFFFULL, 
            0x000000000001FFFFULL, 
            0x000000000003FFFFULL, 
            0x000000000007FFFFULL, 
            0x00000000000FFFFFULL, 
            0x00000000001FFFFFULL, 
            0x00000000003FFFFFULL, 
            0x00000000007FFFFFULL, 
            0x0000000000FFFFFFULL, 
            0x0000000001FFFFFFULL, 
            0x0000000003FFFFFFULL, 
            0x0000000007FFFFFFULL, 
            0x000000000FFFFFFFULL, 
            0x000000001FFFFFFFULL, 
            0x000000003FFFFFFFULL, 
            0x000000007FFFFFFFULL, 
            0x00000000FFFFFFFFULL, 
            0x00000001FFFFFFFFULL, 
            0x00000003FFFFFFFFULL, 
            0x00000007FFFFFFFFULL, 
            0x0000000FFFFFFFFFULL, 
            0x0000001FFFFFFFFFULL, 
            0x0000003FFFFFFFFFULL, 
            0x0000007FFFFFFFFFULL, 
            0x000000FFFFFFFFFFULL, 
            0x000001FFFFFFFFFFULL, 
            0x000003FFFFFFFFFFULL, 
            0x000007FFFFFFFFFFULL, 
            0x00000FFFFFFFFFFFULL, 
            0x00001FFFFFFFFFFFULL, 
            0x00003FFFFFFFFFFFULL, 
            0x00007FFFFFFFFFFFULL, 
            0x0000FFFFFFFFFFFFULL, 
            0x0001FFFFFFFFFFFFULL, 
            0x0003FFFFFFFFFFFFULL, 
            0x0007FFFFFFFFFFFFULL, 
            0x000FFFFFFFFFFFFFULL, 
            0x001FFFFFFFFFFFFFULL, 
            0x003FFFFFFFFFFFFFULL, 
            0x007FFFFFFFFFFFFFULL, 
            0x00FFFFFFFFFFFFFFULL, 
            0x01FFFFFFFFFFFFFFULL, 
            0x03FFFFFFFFFFFFFFULL, 
            0x07FFFFFFFFFFFFFFULL, 
            0x0FFFFFFFFFFFFFFFULL, 
            0x1FFFFFFFFFFFFFFFULL, 
            0x3FFFFFFFFFFFFFFFULL, 
            0x7FFFFFFFFFFFFFFFULL, 
            0xFFFFFFFFFFFFFFFFULL, 
        }; 
 
        const ui64 INVERSE_WORD_MASK[] = { 
            ~0x0000000000000000ULL, 
            ~0x0000000000000001ULL, 
            ~0x0000000000000003ULL, 
            ~0x0000000000000007ULL, 
            ~0x000000000000000FULL, 
            ~0x000000000000001FULL, 
            ~0x000000000000003FULL, 
            ~0x000000000000007FULL, 
            ~0x00000000000000FFULL, 
            ~0x00000000000001FFULL, 
            ~0x00000000000003FFULL, 
            ~0x00000000000007FFULL, 
            ~0x0000000000000FFFULL, 
            ~0x0000000000001FFFULL, 
            ~0x0000000000003FFFULL, 
            ~0x0000000000007FFFULL, 
            ~0x000000000000FFFFULL, 
            ~0x000000000001FFFFULL, 
            ~0x000000000003FFFFULL, 
            ~0x000000000007FFFFULL, 
            ~0x00000000000FFFFFULL, 
            ~0x00000000001FFFFFULL, 
            ~0x00000000003FFFFFULL, 
            ~0x00000000007FFFFFULL, 
            ~0x0000000000FFFFFFULL, 
            ~0x0000000001FFFFFFULL, 
            ~0x0000000003FFFFFFULL, 
            ~0x0000000007FFFFFFULL, 
            ~0x000000000FFFFFFFULL, 
            ~0x000000001FFFFFFFULL, 
            ~0x000000003FFFFFFFULL, 
            ~0x000000007FFFFFFFULL, 
            ~0x00000000FFFFFFFFULL, 
            ~0x00000001FFFFFFFFULL, 
            ~0x00000003FFFFFFFFULL, 
            ~0x00000007FFFFFFFFULL, 
            ~0x0000000FFFFFFFFFULL, 
            ~0x0000001FFFFFFFFFULL, 
            ~0x0000003FFFFFFFFFULL, 
            ~0x0000007FFFFFFFFFULL, 
            ~0x000000FFFFFFFFFFULL, 
            ~0x000001FFFFFFFFFFULL, 
            ~0x000003FFFFFFFFFFULL, 
            ~0x000007FFFFFFFFFFULL, 
            ~0x00000FFFFFFFFFFFULL, 
            ~0x00001FFFFFFFFFFFULL, 
            ~0x00003FFFFFFFFFFFULL, 
            ~0x00007FFFFFFFFFFFULL, 
            ~0x0000FFFFFFFFFFFFULL, 
            ~0x0001FFFFFFFFFFFFULL, 
            ~0x0003FFFFFFFFFFFFULL, 
            ~0x0007FFFFFFFFFFFFULL, 
            ~0x000FFFFFFFFFFFFFULL, 
            ~0x001FFFFFFFFFFFFFULL, 
            ~0x003FFFFFFFFFFFFFULL, 
            ~0x007FFFFFFFFFFFFFULL, 
            ~0x00FFFFFFFFFFFFFFULL, 
            ~0x01FFFFFFFFFFFFFFULL, 
            ~0x03FFFFFFFFFFFFFFULL, 
            ~0x07FFFFFFFFFFFFFFULL, 
            ~0x0FFFFFFFFFFFFFFFULL, 
            ~0x1FFFFFFFFFFFFFFFULL, 
            ~0x3FFFFFFFFFFFFFFFULL, 
            ~0x7FFFFFFFFFFFFFFFULL, 
            ~0xFFFFFFFFFFFFFFFFULL, 
        }; 
    }
}