linux/arch/tile/include/asm/word-at-a-time.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2#ifndef _ASM_WORD_AT_A_TIME_H
   3#define _ASM_WORD_AT_A_TIME_H
   4
   5#include <asm/byteorder.h>
   6
   7struct word_at_a_time { /* unused */ };
   8#define WORD_AT_A_TIME_CONSTANTS {}
   9
  10/* Generate 0x01 byte values for zero bytes using a SIMD instruction. */
  11static inline unsigned long has_zero(unsigned long val, unsigned long *data,
  12                                     const struct word_at_a_time *c)
  13{
  14#ifdef __tilegx__
  15        unsigned long mask = __insn_v1cmpeqi(val, 0);
  16#else /* tilepro */
  17        unsigned long mask = __insn_seqib(val, 0);
  18#endif
  19        *data = mask;
  20        return mask;
  21}
  22
  23/* These operations are both nops. */
  24#define prep_zero_mask(val, data, c) (data)
  25#define create_zero_mask(data) (data)
  26
  27/* And this operation just depends on endianness. */
  28static inline long find_zero(unsigned long mask)
  29{
  30#ifdef __BIG_ENDIAN
  31        return __builtin_clzl(mask) >> 3;
  32#else
  33        return __builtin_ctzl(mask) >> 3;
  34#endif
  35}
  36
  37#ifdef __BIG_ENDIAN
  38#define zero_bytemask(mask) (~1ul << (63 - __builtin_clzl(mask)))
  39#else
  40#define zero_bytemask(mask) ((2ul << __builtin_ctzl(mask)) - 1)
  41#endif
  42
  43#endif /* _ASM_WORD_AT_A_TIME_H */
  44