Hi,

Here is an "asm tidy" patch, that fixes some potentially
optimization-sensitive bugs, or gives better optimizations. Can someone
have a look before I commit?

Samuel
[gnumach]/Changelog
2006-08-26  Samuel Thibault <[EMAIL PROTECTED]>

        Asm tidy.

        * i386/i386/fpe_linkage.c (disable_fpe): Gather dependent asm
        statements.
        (fpe_exception_fixup): Drop bogus cast from input parameter of
        lcall asm statement.
        * i386/i386/proc_reg.h: (get_eflags, get_tr, get_ldt): Drop
        useless "volatile" from asm statement.
        (get_esp): Use direct asm register specification.
        * i386/include/mach/i386/cthreads.h: Likewise.
        * i386/i386/locore.S: Drop in[bwl] and out[bwl].
        * i386/i386/fpu.c: Include <i386/pio.h> for inline versions of
        in[bwl] and out[bwl].
        * i386/i386/pic.c: Likewise.
        * i386/i386/pit.c: Likewise.
        * i386/i386at/kd.c: Likewise.
        * i386/i386at/kd_event.c: Likewise.
        * i386/i386at/kd_mouse.c: Likewise.
        * i386/i386at/rtc.c: Likewise.

Index: i386/i386/fpe_linkage.c
===================================================================
RCS file: /sources/hurd/gnumach/i386/i386/fpe_linkage.c,v
retrieving revision 1.1.1.1.4.2
diff -u -p -r1.1.1.1.4.2 fpe_linkage.c
--- i386/i386/fpe_linkage.c     22 Jan 2005 05:35:10 -0000      1.1.1.1.4.2
+++ i386/i386/fpe_linkage.c     26 Aug 2006 11:28:20 -0000
@@ -252,9 +252,9 @@ disable_fpe()
         *      would reset fs & gs from the current user thread).
         */
 
-       asm volatile("xorl %eax, %eax");
-       asm volatile("movw %ax, %fs");
-       asm volatile("movw %ax, %gs");
+       asm volatile("xorw %ax, %ax\n\t"
+                    "movw %ax, %fs\n\t"
+                    "movw %ax, %gs\n\t":::"ax");
 
        gdt_desc_p(cpu_number(), USER_FPREGS)->access &= ~ACC_P;
 }
@@ -338,7 +338,7 @@ fpe_exception_fixup(exc, code, subcode)
            asm volatile("pushl %0; lcall %1; addl $4,%%esp"
                        :
                        : "r" (&tstate),
-                         "m" (*(char *)&fpe_recover_ptr) );
+                         "m" (fpe_recover_ptr) );
 
            (void) thread_setstatus(thread,
                                i386_REGS_SEGS_STATE,
Index: i386/i386/proc_reg.h
===================================================================
RCS file: /sources/hurd/gnumach/i386/i386/Attic/proc_reg.h,v
retrieving revision 1.1.1.1.4.1
diff -u -p -r1.1.1.1.4.1 proc_reg.h
--- i386/i386/proc_reg.h        14 Jan 2004 22:28:30 -0000      1.1.1.1.4.1
+++ i386/i386/proc_reg.h        26 Aug 2006 11:28:21 -0000
@@ -52,7 +52,7 @@ static inline unsigned
 get_eflags()
 {
        unsigned eflags;
-       asm volatile("pushfd; popl %0" : "=r" (eflags));
+       asm("pushfd; popl %0" : "=r" (eflags));
        return eflags;
 }
 
@@ -64,8 +64,7 @@ set_eflags(unsigned eflags)
 
 #define get_esp() \
     ({ \
-       register unsigned int _temp__; \
-       asm("mov %%esp, %0" : "=r" (_temp__)); \
+       register unsigned int _temp__ asm("esp"); \
        _temp__; \
     })
 
@@ -118,7 +117,7 @@ set_eflags(unsigned eflags)
 #define        get_tr() \
     ({ \
        unsigned short _seg__; \
-       asm volatile("str %0" : "=rm" (_seg__) ); \
+       asm("str %0" : "=rm" (_seg__) ); \
        _seg__; \
     })
 
@@ -128,7 +127,7 @@ set_eflags(unsigned eflags)
 #define        get_ldt() \
     ({ \
        unsigned short _seg__; \
-       asm volatile("sldt %0" : "=rm" (_seg__) ); \
+       asm("sldt %0" : "=rm" (_seg__) ); \
        _seg__; \
     })
 
Index: i386/include/mach/i386/cthreads.h
===================================================================
RCS file: /sources/hurd/gnumach/i386/include/mach/i386/cthreads.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 cthreads.h
--- i386/include/mach/i386/cthreads.h   25 Feb 1997 21:26:59 -0000      1.1.1.1
+++ i386/include/mach/i386/cthreads.h   26 Aug 2006 11:28:24 -0000
@@ -48,9 +48,7 @@ typedef volatile int spin_lock_t;
            _r__; }))
 
 #define        cthread_sp() \
-       ({  int _sp__; \
-           __asm__("movl %%esp, %0" \
-             : "=g" (_sp__) ); \
+       ({  register unsigned long _sp__ __asm__("esp"); \
            _sp__; })
 
 #endif /* __GNUC__ */
Index: i386/i386/locore.S
===================================================================
RCS file: /sources/hurd/gnumach/i386/i386/locore.S,v
retrieving revision 1.6.2.2
diff -u -p -r1.6.2.2 locore.S
--- i386/i386/locore.S  26 Jan 2006 14:53:56 -0000      1.6.2.2
+++ i386/i386/locore.S  26 Aug 2006 11:28:21 -0000
@@ -1475,6 +1475,8 @@ ENTRY(_setts)
        movl    %eax,%cr0               /* set cr0 */
        ret
 
+#if 0
+/* these are not needed: macros from pio.h are much faster */
 /*
  * void outb(unsigned char *io_port,
  *          unsigned char byte)
@@ -1552,6 +1554,7 @@ ENTRY(inl)
        movl    S_ARG0,%edx             /* IO port address */
        inl     %dx,%eax                /* get the int */
        ret
+#endif
 
 /*
  * void loutb(unsigned byte *io_port,
Index: i386/i386/fpu.c
===================================================================
RCS file: /sources/hurd/gnumach/i386/i386/fpu.c,v
retrieving revision 1.2
diff -u -p -r1.2 fpu.c
--- i386/i386/fpu.c     24 May 1999 20:48:23 -0000      1.2
+++ i386/i386/fpu.c     26 Aug 2006 11:28:20 -0000
@@ -39,6 +39,7 @@
 #include <kern/thread.h>
 #include <kern/zalloc.h>
 
+#include <i386/pio.h>
 #include <i386/thread.h>
 #include <i386/fpu.h>
 #include "cpu_number.h"
Index: i386/i386/pic.c
===================================================================
RCS file: /sources/hurd/gnumach/i386/i386/pic.c,v
retrieving revision 1.2
diff -u -p -r1.2 pic.c
--- i386/i386/pic.c     5 Apr 2001 06:39:20 -0000       1.2
+++ i386/i386/pic.c     26 Aug 2006 11:28:21 -0000
@@ -52,6 +52,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFT
 #include <platforms.h>
 
 #include <sys/types.h>
+#include <i386/pio.h>
 #include <i386/ipl.h>
 #include <i386/pic.h>
 #include <i386/machspl.h>
Index: i386/i386/pit.c
===================================================================
RCS file: /sources/hurd/gnumach/i386/i386/pit.c,v
retrieving revision 1.3
diff -u -p -r1.3 pit.c
--- i386/i386/pit.c     1 Oct 2001 12:23:05 -0000       1.3
+++ i386/i386/pit.c     26 Aug 2006 11:28:21 -0000
@@ -51,6 +51,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFT
 
 #include <platforms.h>
 #include <kern/time_out.h>
+#include <i386/pio.h>
 #include <i386/ipl.h>
 #include <i386/pit.h>
 
Index: i386/i386at/iopl.c
===================================================================
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/iopl.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 iopl.c
--- i386/i386at/iopl.c  25 Feb 1997 21:27:17 -0000      1.1.1.1
+++ i386/i386at/iopl.c  26 Aug 2006 11:28:21 -0000
@@ -35,6 +35,7 @@
 
 #include <i386/io_port.h>
 #include <i386/pit.h>
+#include <i386/pio.h>
 
 /*
  * IOPL device.
Index: i386/i386at/kd.c
===================================================================
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/kd.c,v
retrieving revision 1.5.2.3
diff -u -p -r1.5.2.3 kd.c
--- i386/i386at/kd.c    20 Feb 2006 23:15:34 -0000      1.5.2.3
+++ i386/i386at/kd.c    26 Aug 2006 11:28:22 -0000
@@ -88,6 +88,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFT
 #include <vm/vm_kern.h>
 #include "vm_param.h"
 #include <i386/machspl.h>
+#include <i386/pio.h>
 #include <i386at/cram.h>
 #include <i386at/kd.h>
 #include <i386at/kdsoft.h>
Index: i386/i386at/kd_event.c
===================================================================
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/kd_event.c,v
retrieving revision 1.3.2.1
diff -u -p -r1.3.2.1 kd_event.c
--- i386/i386at/kd_event.c      2 Feb 2004 21:44:40 -0000       1.3.2.1
+++ i386/i386at/kd_event.c      26 Aug 2006 11:28:23 -0000
@@ -70,6 +70,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFT
 #include <sys/tty.h>
 #endif /* MACH_KERNEL */
 #include <i386/machspl.h>
+#include <i386/pio.h>
 #include <i386at/kd.h>
 #include <i386at/kd_queue.h>
 
Index: i386/i386at/kd_mouse.c
===================================================================
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/kd_mouse.c,v
retrieving revision 1.3.2.1
diff -u -p -r1.3.2.1 kd_mouse.c
--- i386/i386at/kd_mouse.c      30 Jun 2006 20:46:09 -0000      1.3.2.1
+++ i386/i386at/kd_mouse.c      26 Aug 2006 11:28:23 -0000
@@ -80,6 +80,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFT
 #include <sys/tty.h>
 #endif /* MACH_KERNEL */
 #include <i386/ipl.h>
+#include <i386/pio.h>
 #include <chips/busses.h>
 #include <i386at/kd.h>
 #include <i386at/kd_queue.h>
Index: i386/i386at/rtc.c
===================================================================
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/rtc.c,v
retrieving revision 1.2
diff -u -p -r1.2 rtc.c
--- i386/i386at/rtc.c   5 Apr 2001 06:39:21 -0000       1.2
+++ i386/i386at/rtc.c   26 Aug 2006 11:28:23 -0000
@@ -51,6 +51,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFT
 #include <kern/time_out.h>
 #include <i386/machspl.h>
 #include <i386at/rtc.h>
+#include <i386/pio.h>
 
 static unsigned char rtc[RTC_NREG];
 static int first_rtcopen_ever = 1;
_______________________________________________
Bug-hurd mailing list
Bug-hurd@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-hurd

Reply via email to