summaryrefslogtreecommitdiffstats
path: root/arch/tile/include/asm/word-at-a-time.h
blob: 9e5ce0d7b292160d5f544fcda08c00ea6c04f168 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef _ASM_WORD_AT_A_TIME_H
#define _ASM_WORD_AT_A_TIME_H

#include <asm/byteorder.h>

struct word_at_a_time { /* unused */ };
#define WORD_AT_A_TIME_CONSTANTS {}

/* Generate 0x01 byte values for non-zero bytes using a SIMD instruction. */
static inline unsigned long has_zero(unsigned long val, unsigned long *data,
				     const struct word_at_a_time *c)
{
#ifdef __tilegx__
	unsigned long mask = __insn_v1cmpeqi(val, 0);
#else /* tilepro */
	unsigned long mask = __insn_seqib(val, 0);
#endif
	*data = mask;
	return mask;
}

/* These operations are both nops. */
#define prep_zero_mask(val, data, c) (data)
#define create_zero_mask(data) (data)

/* And this operation just depends on endianness. */
static inline long find_zero(unsigned long mask)
{
#ifdef __BIG_ENDIAN
	return __builtin_clzl(mask) >> 3;
#else
	return __builtin_ctzl(mask) >> 3;
#endif
}

#endif /* _ASM_WORD_AT_A_TIME_H */