1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_WORD_AT_A_TIME_H
3 #define _ASM_WORD_AT_A_TIME_H
5 #include <asm/byteorder.h>
7 struct word_at_a_time
{ /* unused */ };
8 #define WORD_AT_A_TIME_CONSTANTS {}
10 /* Generate 0x01 byte values for zero bytes using a SIMD instruction. */
11 static inline unsigned long has_zero(unsigned long val
, unsigned long *data
,
12 const struct word_at_a_time
*c
)
15 unsigned long mask
= __insn_v1cmpeqi(val
, 0);
17 unsigned long mask
= __insn_seqib(val
, 0);
23 /* These operations are both nops. */
24 #define prep_zero_mask(val, data, c) (data)
25 #define create_zero_mask(data) (data)
27 /* And this operation just depends on endianness. */
28 static inline long find_zero(unsigned long mask
)
31 return __builtin_clzl(mask
) >> 3;
33 return __builtin_ctzl(mask
) >> 3;
38 #define zero_bytemask(mask) (~1ul << (63 - __builtin_clzl(mask)))
40 #define zero_bytemask(mask) ((2ul << __builtin_ctzl(mask)) - 1)
43 #endif /* _ASM_WORD_AT_A_TIME_H */