Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/vax/include Write kvtopte() and kvtophys() as inlin...



details:   https://anonhg.NetBSD.org/src/rev/6e7ec2933f99
branches:  trunk
changeset: 486719:6e7ec2933f99
user:      ragge <ragge%NetBSD.org@localhost>
date:      Sat May 27 21:17:06 2000 +0000

description:
Write kvtopte() and kvtophys() as inline assembler. GCC create quite bad
code for them, and they are only 2-3 instructions each if written by hand.

diffstat:

 sys/arch/vax/include/pte.h |  20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r c2b3dcb7d310 -r 6e7ec2933f99 sys/arch/vax/include/pte.h
--- a/sys/arch/vax/include/pte.h        Sat May 27 21:00:25 2000 +0000
+++ b/sys/arch/vax/include/pte.h        Sat May 27 21:17:06 2000 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: pte.h,v 1.13 1999/08/03 19:53:23 ragge Exp $      */
+/*      $NetBSD: pte.h,v 1.14 2000/05/27 21:17:06 ragge Exp $      */
 
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -80,11 +80,23 @@
  */
 #endif
 
-#define        kvtopte(va) (&Sysmap[PG_PFNUM(va)])
-#define        ptetokv(pt) \
-       ((((pt_entry_t *)(pt) - Sysmap) << VAX_PGSHIFT) + 0x80000000)
+#ifdef __GNUC__
+#define kvtopte(va) ({ \
+       struct pte *r; \
+       asm("extzv $9,$21,%1,%0;moval *_Sysmap[%0],%0" : "=r"(r) : "g"(va)); \
+       r; \
+})
+#define        kvtophys(va) ({ \
+       long r; \
+       asm("extzv $9,$21,%1,%0;ashl $9,*_Sysmap[%0],%0;insv %1,$0,$9,%0" \
+           : "&=r"(r) : "g"(va) : "cc"); \
+       r; \
+})
+#else /* __GNUC__ */
 #define        kvtophys(va) \
        (((kvtopte(va))->pg_pfn << VAX_PGSHIFT) | ((int)(va) & VAX_PGOFSET))
+#define        kvtopte(va) (&Sysmap[PG_PFNUM(va)])
+#endif /* __GNUC__ */
 #define        uvtopte(va, pcb) \
        (((unsigned)va < 0x40000000) ? \
        &((pcb->P0BR)[PG_PFNUM(va)]) : \



Home | Main Index | Thread Index | Old Index