diff options
| -rw-r--r-- | include/asm-frv/bitops.h | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h index 97fb746f76c7..591eecc1f8cd 100644 --- a/include/asm-frv/bitops.h +++ b/include/asm-frv/bitops.h | |||
| @@ -186,7 +186,47 @@ static inline int __test_bit(int nr, const volatile void * addr) | |||
| 186 | bit; \ | 186 | bit; \ |
| 187 | }) | 187 | }) |
| 188 | 188 | ||
| 189 | #include <asm-generic/bitops/fls64.h> | 189 | /** |
| 190 | * fls64 - find last bit set in a 64-bit value | ||
| 191 | * @n: the value to search | ||
| 192 | * | ||
| 193 | * This is defined the same way as ffs: | ||
| 194 | * - return 64..1 to indicate bit 63..0 most significant bit set | ||
| 195 | * - return 0 to indicate no bits set | ||
| 196 | */ | ||
| 197 | static inline __attribute__((const)) | ||
| 198 | int fls64(u64 n) | ||
| 199 | { | ||
| 200 | union { | ||
| 201 | u64 ll; | ||
| 202 | struct { u32 h, l; }; | ||
| 203 | } _; | ||
| 204 | int bit, x, y; | ||
| 205 | |||
| 206 | _.ll = n; | ||
| 207 | |||
| 208 | asm(" subcc.p %3,gr0,gr0,icc0 \n" | ||
| 209 | " subcc %4,gr0,gr0,icc1 \n" | ||
| 210 | " ckne icc0,cc4 \n" | ||
| 211 | " ckne icc1,cc5 \n" | ||
| 212 | " norcr cc4,cc5,cc6 \n" | ||
| 213 | " csub.p %0,%0,%0 ,cc6,1 \n" | ||
| 214 | " orcr cc5,cc4,cc4 \n" | ||
| 215 | " andcr cc4,cc5,cc4 \n" | ||
| 216 | " cscan.p %3,gr0,%0 ,cc4,0 \n" | ||
| 217 | " setlos #64,%1 \n" | ||
| 218 | " cscan.p %4,gr0,%0 ,cc4,1 \n" | ||
| 219 | " setlos #32,%2 \n" | ||
| 220 | " csub.p %1,%0,%0 ,cc4,0 \n" | ||
| 221 | " csub %2,%0,%0 ,cc4,1 \n" | ||
| 222 | : "=&r"(bit), "=r"(x), "=r"(y) | ||
| 223 | : "0r"(_.h), "r"(_.l) | ||
| 224 | : "icc0", "icc1", "cc4", "cc5", "cc6" | ||
| 225 | ); | ||
| 226 | return bit; | ||
| 227 | |||
| 228 | } | ||
| 229 | |||
| 190 | #include <asm-generic/bitops/sched.h> | 230 | #include <asm-generic/bitops/sched.h> |
| 191 | #include <asm-generic/bitops/hweight.h> | 231 | #include <asm-generic/bitops/hweight.h> |
| 192 | 232 | ||
