More 32-bit cleanup.

This commit is contained in:
eeh 2002-01-21 18:50:36 +00:00
parent f2c19708a2
commit 40f4f638ed
2 changed files with 28 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: in4_cksum.c,v 1.1 2001/08/10 20:53:11 eeh Exp $ */
/* $NetBSD: in4_cksum.c,v 1.2 2002/01/21 18:50:36 eeh Exp $ */
/*
* Copyright (c) 2001 Eduardo Horvath.
@ -80,19 +80,38 @@ in4_cksum(m, nxt, off, len)
ipov.ih_dst = mtod(m, struct ip *)->ip_dst;
w = (u_char *)&ipov;
/* assumes sizeof(ipov) == 20 */
#ifdef __arch64__
__asm __volatile(" lduw [%5 + 0], %1; "
" lduw [%5 + 4], %2; "
" lduw [%5 + 8], %3; add %0, %1, %0; "
" lduw [%5 + 12], %1; add %0, %2, %0; "
" lduw [%5 + 16], %2; add %0, %3, %0; "
" mov -1, %3; "
" add %0, %1, %0; "
" srl %3, 0, %3; "
" add %0, %2, %0; "
" mov -1, %3; add %0, %1, %0; "
" srl %3, 0, %3; add %0, %2, %0; "
" srlx %0, 32, %2; and %0, %3, %1; "
" add %0, %2, %0; "
: "=r" (sum), "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3)
: "0" (sum), "r" (w));
#else
/*
* Can't use upper 32-bits of the registers, so this needs to
* be recoded. So instead of accumulating the carry in the
* upper 32-bits of the registers, we use addxcc which cannot
* be grouped with any other instructions.
*/
__asm __volatile(" lduw [%5 + 0], %1; "
" lduw [%5 + 4], %2; "
" lduw [%5 + 8], %3; addcc %0, %1, %0; "
" lduw [%5 + 12], %1; "
" addxcc %0, %2, %0; "
" lduw [%5 + 16], %2; "
" addxcc %0, %3, %0; "
" addxcc %0, %1, %0; "
" addxcc %0, %2, %0; "
" addxcc %0, 0, %0; "
: "=r" (sum), "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3)
: "0" (sum), "r" (w));
#endif
}
/* skip unnecessary part */
@ -102,6 +121,5 @@ in4_cksum(m, nxt, off, len)
off -= m->m_len;
m = m->m_next;
}
return (in_cksum_internal(m, len, off, sum));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_cksum.S,v 1.4 2002/01/16 18:49:22 eeh Exp $ */
/* $NetBSD: in_cksum.S,v 1.5 2002/01/21 18:50:37 eeh Exp $ */
/*
* Copyright (c) 2001 Eduardo Horvath
@ -54,11 +54,13 @@
*/
#define IALIGN .align 32
IALIGN
ENTRY(in_cksum)
clr %o3 ! sum = 0;
clr %o2
_ENTRY(_C_LABEL(in_cksum_internal))
srl %o3, 0, %o3 ! Make sure this is a 32-bit value going in
brz %o0, Lfinish ! for (; m && len > 0; m->m_next) {
clr %g1 ! swapped = 0;
brlez %o1, Lfinish