/*
 * include/asm-alpha/xor.h
 *
 * Optimized RAID-5 checksumming functions for alpha EV5 and EV6
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * You should have received a copy of the GNU General Public License
 * (for example /usr/src/linux/COPYING); if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

extern void xor_alpha_2(unsigned long, unsigned long *, unsigned long *);
extern void xor_alpha_3(unsigned long, unsigned long *, unsigned long *,
		        unsigned long *);
extern void xor_alpha_4(unsigned long, unsigned long *, unsigned long *,
		        unsigned long *, unsigned long *);
extern void xor_alpha_5(unsigned long, unsigned long *, unsigned long *,
		        unsigned long *, unsigned long *, unsigned long *);

extern void xor_alpha_prefetch_2(unsigned long, unsigned long *,
				 unsigned long *);
extern void xor_alpha_prefetch_3(unsigned long, unsigned long *,
				 unsigned long *, unsigned long *);
extern void xor_alpha_prefetch_4(unsigned long, unsigned long *,
				 unsigned long *, unsigned long *,
				 unsigned long *);
extern void xor_alpha_prefetch_5(unsigned long, unsigned long *,
				 unsigned long *, unsigned long *,
				 unsigned long *, unsigned long *);

asm("								\n\
	.text							\n\
	.align 3						\n\
	.ent xor_alpha_2					\n\
xor_alpha_2:							\n\
	.prologue 0						\n\
	srl $16, 6, $16						\n\
	.align 4						\n\
2:								\n\
	ldq $0,0($17)						\n\
	ldq $1,0($18)						\n\
	ldq $2,8($17)						\n\
	ldq $3,8($18)						\n\
								\n\
	ldq $4,16($17)						\n\
	ldq $5,16($18)						\n\
	ldq $6,24($17)						\n\
	ldq $7,24($18)						\n\
								\n\
	ldq $19,32($17)						\n\
	ldq $20,32($18)						\n\
	ldq $21,40($17)						\n\
	ldq $22,40($18)						\n\
								\n\
	ldq $23,48($17)						\n\
	ldq $24,48($18)						\n\
	ldq $25,56($17)						\n\
	xor $0,$1,$0		# 7 cycles from $1 load		\n\
								\n\
	ldq $27,56($18)						\n\
	xor $2,$3,$2						\n\
	stq $0,0($17)						\n\
	xor $4,$5,$4						\n\
								\n\
	stq $2,8($17)						\n\
	xor $6,$7,$6						\n\
	stq $4,16($17)						\n\
	xor $19,$20,$19						\n\
								\n\
	stq $6,24($17)						\n\
	xor $21,$22,$21						\n\
	stq $19,32($17)						\n\
	xor $23,$24,$23						\n\
								\n\
	stq $21,40($17)						\n\
	xor $25,$27,$25						\n\
	stq $23,48($17)						\n\
	subq $16,1,$16						\n\
								\n\
	stq $25,56($17)						\n\
	addq $17,64,$17						\n\
	addq $18,64,$18						\n\
	bgt $16,2b						\n\
								\n\
	ret							\n\
	.end xor_alpha_2					\n\
								\n\
	.align 3						\n\
	.ent xor_alpha_3					\n\
xor_alpha_3:							\n\
	.prologue 0						\n\
	srl $16, 6, $16						\n\
	.align 4						\n\
3:								\n\
	ldq $0,0($17)						\n\
	ldq $1,0($18)						\n\
	ldq $2,0($19)						\n\
	ldq $3,8($17)						\n\
								\n\
	ldq $4,8($18)						\n\
	ldq $6,16($17)						\n\
	ldq $7,16($18)						\n\
	ldq $21,24($17)						\n\
								\n\
	ldq $22,24($18)						\n\
	ldq $24,32($17)						\n\
	ldq $25,32($18)						\n\
	ldq $5,8($19)						\n\
								\n\
	ldq $20,16($19)						\n\
	ldq $23,24($19)						\n\
	ldq $27,32($19)						\n\
	nop							\n\
								\n\
	xor $0,$1,$1		# 8 cycles from $0 load		\n\
	xor $3,$4,$4		# 6 cycles from $4 load		\n\
	xor $6,$7,$7		# 6 cycles from $7 load		\n\
	xor $21,$22,$22		# 5 cycles from $22 load	\n\
								\n\
	xor $1,$2,$2		# 9 cycles from $2 load		\n\
	xor $24,$25,$25		# 5 cycles from $25 load	\n\
	stq $2,0($17)						\n\
	xor $4,$5,$5		# 6 cycles from $5 load		\n\
								\n\
	stq $5,8($17)						\n\
	xor $7,$20,$20		# 7 cycles from $20 load	\n\
	stq $20,16($17)						\n\
	xor $22,$23,$23		# 7 cycles from $23 load	\n\
								\n\
	stq $23,24($17)						\n\
	xor $25,$27,$27		# 7 cycles from $27 load	\n\
	stq $27,32($17)						\n\
	nop							\n\
								\n\
	ldq $0,40($17)						\n\
	ldq $1,40($18)						\n\
	ldq $3,48($17)						\n\
	ldq $4,48($18)						\n\
								\n\
	ldq $6,56($17)						\n\
	ldq $7,56($18)						\n\
	ldq $2,40($19)						\n\
	ldq $5,48($19)						\n\
								\n\
	ldq $20,56($19)						\n\
	xor $0,$1,$1		# 4 cycles from $1 load		\n\
	xor $3,$4,$4		# 5 cycles from $4 load		\n\
	xor $6,$7,$7		# 5 cycles from $7 load		\n\
