Annotation of gforth/arch/sparc/machine.h, revision 1.7

1.1       anton       1: /* This is the machine-specific part for a SPARC
                      2: 
1.6       anton       3:   Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc.
1.1       anton       4: 
                      5:   This file is part of Gforth.
                      6: 
                      7:   Gforth is free software; you can redistribute it and/or
                      8:   modify it under the terms of the GNU General Public License
                      9:   as published by the Free Software Foundation; either version 2
                     10:   of the License, or (at your option) any later version.
                     11: 
                     12:   This program is distributed in the hope that it will be useful,
                     13:   but WITHOUT ANY WARRANTY; without even the implied warranty of
                     14:   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     15:   GNU General Public License for more details.
                     16: 
                     17:   You should have received a copy of the GNU General Public License
                     18:   along with this program; if not, write to the Free Software
1.7     ! anton      19:   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
1.1       anton      20: */
                     21: 
1.4       anton      22: #ifndef THREADING_SCHEME
                     23: #define THREADING_SCHEME 5
                     24: #endif
1.1       anton      25: 
                     26: #if !defined(USE_TOS) && !defined(USE_NO_TOS)
                     27: #define USE_TOS
                     28: #endif
                     29: 
                     30: #if !defined(INDIRECT_THREADED) && !defined(DIRECT_THREADED)
                     31: #define DIRECT_THREADED
                     32: #endif
1.4       anton      33: 
                     34: #include "../generic/machine.h"
1.1       anton      35: 
                     36: #define FLUSH_ICACHE(addr,size) \
                     37:   ({void *_addr=(addr); void *_end=_addr+((Cell)(size)); \
                     38:     for (_addr=((long)_addr)&~7; _addr<_end; _addr += 8) \
                     39:        asm("iflush %0+0"::"r"(_addr)); \
                     40:    })
                     41: /* the +0 in the iflush instruction is needed by gas */
                     42: 
                     43: #ifdef DIRECT_THREADED
                     44: #ifndef WORDS_BIGENDIAN
                     45: #error Direct threading only supported for big-endian SPARCs.
                     46: /* little endian SPARCs still store instructions in big-endian format,
                     47:    so you would have to reverse the instructions stores in the following
                     48: */
                     49: #endif
                     50: 
                     51: /* call to dest+4, because dest will reside in delay slot */
                     52: #define CALLD(dest,source) (0x40000000|((((unsigned)(dest))+4-(unsigned)(source))>>2))
                     53: 
                     54: /* PFA gives the parameter field address corresponding to a cfa */
                     55: #define PFA(cfa)       (((Cell *)cfa)+2)
                     56: /* PFA1 is a special version for use just after a NEXT1 */
                     57: /* the improvement here is that we may destroy cfa before using PFA1 */
                     58: #define PFA1(cfa)      PFA(cfa)
                     59: #ifdef undefined
                     60: #define PFA1(cfa)      /* PFA(cfa) */ \
                     61:                        ({register Cell *pfa asm("%o7"); \
                     62:                          pfa+2; })
                     63: #endif
                     64: /* CODE_ADDRESS is the address of the code jumped to through the code field */
1.5       anton      65: #define CODE_ADDRESS1(cfa)     ({unsigned _cfa = (unsigned)(cfa); \
1.1       anton      66:                                    (Label)(_cfa+((*(unsigned *)_cfa)<<2)-4);})
1.5       anton      67: #define CODE_ADDRESS(cfa)      ({ \
                     68:                  unsigned *__cfa = (unsigned *)(cfa); \
                     69:                  (((*__cfa)>>30)==1) ? CODE_ADDRESS1(__cfa) : (Label)__cfa; \
                     70:                })
                     71: 
1.1       anton      72: /* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
                     73: /* we use call, since 'branch always' only has 22 bits displacement */
                     74: #define MAKE_CF(cfa,ca)        ({long *_cfa        = (long *)(cfa); \
                     75:                          unsigned _ca = (unsigned)(ca); \
                     76:                          _cfa[0] = CALLD(_ca,_cfa); \
                     77:                          _cfa[1] = *(long *)_ca; /* delay slot */})
                     78: 
                     79: /* this is the point where the does code starts if cfa1 points to a
                     80:    code field of a does>-defined word */
                     81: /* the +4 is due to the fact, that the does_cf jumps directly to the
                     82:    code address, whereas CODE_ADDRESS expects a jump to
                     83:    code_address+4, and corrects for that (which is countercorrected by
                     84:    the +4) */
                     85: #define DOES_CODE(cfa1) \
                     86:      ({ Xt _cfa1=(Xt)(cfa1); \
1.5       anton      87:        unsigned _ca=((unsigned)CODE_ADDRESS(_cfa1))+4; \
                     88:        ((*(unsigned *)(_ca)) == CALLD(symbols[DODOES],_ca)) \
                     89:        ? _ca+DOES_HANDLER_SIZE : 0; \
                     90:      })
1.1       anton      91: 
                     92: /* this is a special version of DOES_CODE for use in dodoes */
1.5       anton      93: #define DOES_CODE1(label)      ((Xt *)(CODE_ADDRESS1(label)+4+DOES_HANDLER_SIZE))
1.1       anton      94: #ifdef undefined
                     95: #define DOES_CODE1(label)      ({register Xt *_does_code asm("%o7"); \
                     96:                                _does_code+2; })
                     97: #endif
                     98: 
                     99: /* this stores a call dodoes at addr */
                    100: #define MAKE_DOES_HANDLER(addr) MAKE_CF(addr,symbols[DODOES])
                    101: 
                    102: #define MAKE_DOES_CF(addr,doesp) ({long *_addr        = (long *)(addr); \
                    103:                          unsigned _doesp = (unsigned)(doesp); \
                    104:                          _addr[0] = 0x40000000|((_doesp-8-(unsigned)_addr)>>2); /* CALL doesp-8 */ \
                    105:                          _addr[1] = 0x01000000; /* nop */})
                    106: #endif
                    107: 

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