Home | History | Annotate | Download | only in qemu

Lines Matching refs:val

52 static inline int clz32(uint32_t val)
55 if (val)
56 return __builtin_clz(val);
62 if (!(val & 0xFFFF0000U)) {
64 val <<= 16;
66 if (!(val & 0xFF000000U)) {
68 val <<= 8;
70 if (!(val & 0xF0000000U)) {
72 val <<= 4;
74 if (!(val & 0xC0000000U)) {
76 val <<= 2;
78 if (!(val & 0x80000000U)) {
80 val <<= 1;
82 if (!(val & 0x80000000U)) {
89 static inline int clo32(uint32_t val)
91 return clz32(~val);
94 static inline int clz64(uint64_t val)
97 if (val)
98 return __builtin_clzll(val);
104 if (!(val >> 32)) {
107 val >>= 32;
110 return cnt + clz32(val);
114 static inline int clo64(uint64_t val)
116 return clz64(~val);
119 static inline int ctz32(uint32_t val)
122 if (val)
123 return __builtin_ctz(val);
130 if (!(val & 0x0000FFFFUL)) {
132 val >>= 16;
134 if (!(val & 0x000000FFUL)) {
136 val >>= 8;
138 if (!(val & 0x0000000FUL)) {
140 val >>= 4;
142 if (!(val & 0x00000003UL)) {
144 val >>= 2;
146 if (!(val & 0x00000001UL)) {
148 val >>= 1;
150 if (!(val & 0x00000001UL)) {
158 static inline int cto32(uint32_t val)
160 return ctz32(~val);
163 static inline int ctz64(uint64_t val)
166 if (val)
167 return __builtin_ctzll(val);
174 if (!((uint32_t)val)) {
176 val >>= 32;
179 return cnt + ctz32(val);
183 static inline int cto64(uint64_t val)
185 return ctz64(~val);
188 static inline int ctpop8(uint8_t val)
190 val = (val & 0x55) + ((val >> 1) & 0x55);
191 val = (val & 0x33) + ((val >> 2) & 0x33);
192 val = (val & 0x0f) + ((val >> 4) & 0x0f);
194 return val;
197 static inline int ctpop16(uint16_t val)
199 val = (val & 0x5555) + ((val >> 1) & 0x5555);
200 val = (val & 0x3333) + ((val >> 2) & 0x3333);
201 val = (val & 0x0f0f) + ((val >> 4) & 0x0f0f);
202 val = (val & 0x00ff) + ((val >> 8) & 0x00ff);
204 return val;
207 static inline int ctpop32(uint32_t val)
210 return __builtin_popcount(val);
212 val = (val & 0x55555555) + ((val >> 1) & 0x55555555);
213 val = (val & 0x33333333) + ((val >> 2) & 0x33333333);
214 val = (val & 0x0f0f0f0f) + ((val >> 4) & 0x0f0f0f0f);
215 val = (val & 0x00ff00ff) + ((val >> 8) & 0x00ff00ff);
216 val = (val & 0x0000ffff) + ((val >> 16) & 0x0000ffff);
218 return val;
222 static inline int ctpop64(uint64_t val)
225 return __builtin_popcountll(val);
227 val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL);
228 val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL);
229 val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & 0x0f0f0f0f0f0f0f0fULL);
230 val = (val & 0x00ff00ff00ff00ffULL) + ((val >> 8) & 0x00ff00ff00ff00ffULL);
231 val = (val & 0x0000ffff0000ffffULL) + ((val >> 16) & 0x0000ffff0000ffffULL);
232 val = (val & 0x00000000ffffffffULL) + ((val >> 32) & 0x00000000ffffffffULL);
234 return val;