Annotation of gforth/arch/386/machine.h, revision 1.47

1.1       anton       1: /*
                      2:   This is the machine-specific part for Intel 386 compatible processors
                      3: 
1.47    ! anton       4:   Copyright (C) 1995,1996,1997,1998,2000,2003,2004,2005,2006,2007,2008,2012 Free Software Foundation, Inc.
1.1       anton       5: 
                      6:   This file is part of Gforth.
                      7: 
                      8:   Gforth is free software; you can redistribute it and/or
                      9:   modify it under the terms of the GNU General Public License
1.39      anton      10:   as published by the Free Software Foundation, either version 3
1.1       anton      11:   of the License, or (at your option) any later version.
                     12: 
                     13:   This program is distributed in the hope that it will be useful,
                     14:   but WITHOUT ANY WARRANTY; without even the implied warranty of
                     15:   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     16:   GNU General Public License for more details.
                     17: 
                     18:   You should have received a copy of the GNU General Public License
1.39      anton      19:   along with this program; if not, see http://www.gnu.org/licenses/.
1.1       anton      20: */
                     21: 
1.4       pazsan     22: #ifdef HAVE_LIBKERNEL32
                     23: #ifdef i386
                     24: #define SYSCALL     __attribute__ ((stdcall))
                     25: #endif
                     26: #endif
                     27: 
1.35      anton      28: #if (((__GNUC__==2 && defined(__GNUC_MINOR__) && __GNUC_MINOR__>=95) || (__GNUC__==3))) && defined(FORCE_REG)
1.8       pazsan     29: #if !defined(USE_TOS) && !defined(USE_NO_TOS)
                     30: #define USE_TOS
1.9       pazsan     31: #endif
                     32: #endif
1.8       pazsan     33: #define MEMCMP_AS_SUBROUTINE 1
                     34: 
1.11      anton      35: #ifndef USE_FTOS
                     36: #ifndef USE_NO_FTOS
                     37: /* gcc can't keep TOS in a register on the 386, so don't try */
                     38: #define USE_NO_FTOS
                     39: #endif
                     40: #endif
                     41: 
1.33      anton      42: #define ASM_SM_SLASH_REM(d1lo, d1hi, n1, n2, n3) \
                     43:        asm("idivl %4": "=a"(n3),"=d"(n2) : "a"(d1lo),"d"(d1hi),"g"(n1):"cc");
1.29      anton      44: 
1.33      anton      45: #define ASM_UM_SLASH_MOD(d1lo, d1hi, n1, n2, n3) \
                     46:        asm("divl %4": "=a"(n3),"=d"(n2) : "a"(d1lo),"d"(d1hi),"g"(n1):"cc");
1.29      anton      47: 
1.44      anton      48: #if defined(USE_TOS)
1.46      pazsan     49: #define CLOBBER_TOS_WORKAROUND_START sp[0]=spTOS; __asm__ __volatile__ ("" ::: "memory");
1.44      anton      50: #define CLOBBER_TOS_WORKAROUND_END   spTOS=sp[0]
                     51: #endif
                     52: 
1.7       anton      53: #include "../generic/machine.h"
1.1       anton      54: 
                     55: /* 386 and below have no cache, 486 has a shared cache, and the
1.18      anton      56:    Pentium and later employ hardware cache consistency, so
1.1       anton      57:    flush-icache is a noop */
                     58: #define FLUSH_ICACHE(addr,size)
                     59: 
1.37      anton      60: /* code padding */
                     61: #define CODE_ALIGNMENT 16
                     62: #define CODE_PADDING {0x66, 0x66, 0x66, 0x90, 0x66, 0x66, 0x66, 0x90, \
                     63:                       0x66, 0x66, 0x66, 0x90, 0x66, 0x66, 0x66, 0x90}
                     64: #define MAX_PADDING 4
                     65: /* results for various maxpaddings:
                     66:    3GHz Xeon 5160                     2.2GHz Athlon 64 X2
                     67:    sieve bubble matrix  fib  padding sieve bubble matrix  fib 
                     68:     0.132 0.216  0.072 0.228    0     0.260 0.300  0.108 0.344
                     69:     0.132 0.216  0.072 0.228    1     0.268 0.300  0.112 0.344
                     70:     0.132 0.216  0.072 0.248    2     0.256 0.300  0.108 0.344
                     71:     0.136 0.216  0.072 0.248    3     0.252 0.300  0.108 0.344
                     72:     0.132 0.220  0.072 0.240    4     0.252 0.300  0.112 0.340
                     73:     0.136 0.216  0.072 0.248    5     0.252 0.300  0.108 0.344
                     74:     0.132 0.216  0.072 0.244    6     0.256 0.300  0.108 0.344
                     75:     0.132 0.216  0.072 0.244    7     0.264 0.300  0.108 0.344
                     76:     0.136 0.216  0.072 0.244    8     0.268 0.296  0.108 0.340
                     77: */
                     78: 
1.26      anton      79: #if defined(FORCE_REG) && !defined(DOUBLY_INDIRECT) && !defined(VM_PROFILING)
1.36      pazsan     80: # if (__GNUC__==2 && defined(__GNUC_MINOR__) && __GNUC_MINOR__==5)
1.1       anton      81: /* i.e. gcc-2.5.x */
                     82: /* this works with 2.5.7; nothing works with 2.5.8 */
1.36      pazsan     83: #  define IPREG asm("%esi")
                     84: #  define SPREG asm("%edi")
                     85: #  if 0
                     86: #   ifdef USE_TOS
                     87: #    define CFAREG asm("%ecx")
                     88: #   else
                     89: #    define CFAREG asm("%edx")
                     90: #   endif
                     91: #  endif
                     92: # else /* !gcc-2.5.x */
1.1       anton      93: /* this works with 2.6.3 (and quite well, too) */
                     94: /* since this is not very demanding, it's the default for other gcc versions */
1.36      pazsan     95: #  if defined(USE_TOS) && !defined(CFA_NEXT)
                     96: #   if ((__GNUC__==2 && defined(__GNUC_MINOR__) && __GNUC_MINOR__>=95) || (__GNUC__==3))
1.8       pazsan     97:      /* gcc 2.95 has a better register allocater */
1.36      pazsan     98: #    define SPREG asm("%esi")
                     99: #    define RPREG asm("%edi")
                    100: #    ifdef NO_IP
                    101: #     define spbREG asm("%ebx")
                    102: #    else
                    103: #     define IPREG asm("%ebx")
                    104: #    endif
1.19      anton     105: /* ebp leads to broken code (gcc-3.0); eax, ecx, edx produce compile errors */
1.36      pazsan    106: #    define TOSREG asm("%ecx")
1.19      anton     107: /* ecx works only for TOS, and eax, edx don't work for anything (gcc-3.0) */
1.36      pazsan    108: #   else /* !(gcc-2.95 or gcc-3.x) */
                    109: #    if (__GNUC__==4 && defined(__GNUC_MINOR__) && __GNUC_MINOR__>=2)
1.40      pazsan    110: #     ifndef __APPLE__
1.42      pazsan    111: #      define IPREG asm("%ebx")
                    112: #      define SPREG asm("%esi")
                    113: #      define RPREG asm("%edi")
1.43      pazsan    114: #      define TOSREG asm("%ecx")
1.40      pazsan    115: #     else
1.42      pazsan    116: #      define IPREG asm("%edi")
                    117: #      define SPREG asm("%esi")
1.43      pazsan    118: #      define TOSREG asm("%ecx")
1.40      pazsan    119: #     endif
1.36      pazsan    120: #    endif /* (gcc-4.2 or later) */
                    121: #   endif /* !(gcc-2.95 or later) */
                    122: #  else /* !defined(USE_TOS) || defined(CFA_NEXT) */
                    123: #   if ((__GNUC__==2 && defined(__GNUC_MINOR__) && __GNUC_MINOR__>=95) || (__GNUC__>2))
                    124: #    define SPREG asm("%esi")
                    125: #    define RPREG asm("%edi")
                    126: #    ifdef NO_IP
                    127: #     define spbREG asm("%ebx")
                    128: #    else
                    129: #     define IPREG asm("%ebx")
                    130: #    endif
                    131: #   else /* !(gcc-2.95 or later) */
                    132: #    define SPREG asm("%ebx")
                    133: #   endif  /* !(gcc-2.95 or later) */
                    134: #  endif /* !defined(USE_TOS) || defined(CFA_NEXT) */
                    135: # endif /* !gcc-2.5.x */
1.26      anton     136: #endif /* defined(FORCE_REG) && !defined(DOUBLY_INDIRECT) && !defined(VM_PROFILING) */
1.2       pazsan    137: 
                    138: /* #define ALIGNMENT_CHECK 1 */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>