2 * Copyright 2004-2009 Analog Devices Inc.
4 * Licensed under the ADI BSD license or the GPL-2 (or later)
7 #include <linux/linkage.h>
9 /* int memcmp(const void *s1, const void *s2, size_t n);
10 * R0 = First Address (s1)
11 * R1 = Second Address (s2)
14 * Favours word aligned data.
23 P0 = R0; /* P0 = s1 address */
24 P3 = R1; /* P3 = s2 Address */
25 P2 = R2 ; /* P2 = count */
27 IF CC JUMP .Ltoo_small;
29 R1 = R1 | R0; /* OR addresses together */
30 R1 <<= 30; /* check bottom two bits */
31 CC = AZ; /* AZ set if zero. */
32 IF !CC JUMP .Lbytes ; /* Jump if addrs not aligned. */
34 P1 = P2 >> 2; /* count = n/4 */
36 R2 = R2 & R3; /* remainder */
37 P2 = R2; /* set remainder */
39 LSETUP (.Lquad_loop_s, .Lquad_loop_e) LC0=P1;
45 MNOP || R0 = [P0++] || R1 = [I0++];
48 IF !CC JUMP .Lquad_different;
54 CC = P2 == 0; /* Check zero count*/
55 IF CC JUMP .Lfinished; /* very unlikely*/
58 LSETUP (.Lbyte_loop_s, .Lbyte_loop_e) LC0=P2;
60 R1 = B[P3++](Z); /* *s2 */
61 R0 = B[P0++](Z); /* *s1 */
63 IF !CC JUMP .Ldifferent;
73 /* We've read two quads which don't match.
74 * Can't just compare them, because we're
75 * a little-endian machine, so the MSBs of
76 * the regs occur at later addresses in the
78 * Arrange to re-read those two quads again,
81 P0 += -4; /* back up to the start of the */
82 P3 = I0; /* quads, and increase the*/
83 P2 += 4; /* remainder count*/