4 #include <asm/bitsperlong.h>
5 #include <linux/types.h>
6 #include <linux/compiler.h>
8 #define __SWAB_64_THRU_32__
10 static inline __attribute_const__ __u16
__arch_swab16(__u16 x
)
12 __asm__("dep %0, 15, 8, %0\n\t" /* deposit 00ab -> 0bab */
13 "shd %%r0, %0, 8, %0" /* shift 000000ab -> 00ba */
18 #define __arch_swab16 __arch_swab16
20 static inline __attribute_const__ __u32
__arch_swab24(__u32 x
)
22 __asm__("shd %0, %0, 8, %0\n\t" /* shift xabcxabc -> cxab */
23 "dep %0, 15, 8, %0\n\t" /* deposit cxab -> cbab */
24 "shd %%r0, %0, 8, %0" /* shift 0000cbab -> 0cba */
30 static inline __attribute_const__ __u32
__arch_swab32(__u32 x
)
33 __asm__("shd %0, %0, 16, %1\n\t" /* shift abcdabcd -> cdab */
34 "dep %1, 15, 8, %1\n\t" /* deposit cdab -> cbab */
35 "shd %0, %1, 8, %0" /* shift abcdcbab -> dcba */
36 : "=r" (x
), "=&r" (temp
)
40 #define __arch_swab32 __arch_swab32
42 #if __BITS_PER_LONG > 32
44 ** From "PA-RISC 2.0 Architecture", HP Professional Books.
45 ** See Appendix I page 8 , "Endian Byte Swapping".
47 ** Pretty cool algorithm: (* == zero'd bits)
48 ** PERMH 01234567 -> 67452301 into %0
49 ** HSHL 67452301 -> 7*5*3*1* into %1
50 ** HSHR 67452301 -> *6*4*2*0 into %0
51 ** OR %0 | %1 -> 76543210 into %0 (all done!)
53 static inline __attribute_const__ __u64
__arch_swab64(__u64 x
)
56 __asm__("permh,3210 %0, %0\n\t"
58 "hshr,u %0, 8, %0\n\t"
60 : "=r" (x
), "=&r" (temp
)
64 #define __arch_swab64 __arch_swab64
65 #endif /* __BITS_PER_LONG > 32 */
67 #endif /* _PARISC_SWAB_H */