Annotation of gforth/sparc.h, revision 1.10

1.1       anton       1: /*
1.10    ! anton       2:   $Id: sparc.h,v 1.9 1995/01/10 18:46:05 anton Exp $
1.1       anton       3:   Copyright 1992 by the ANSI figForth Development Group
                      4: 
1.3       anton       5:   This is the machine-specific part for a SPARC
1.1       anton       6: */
1.5       anton       7: 
                      8: #include "32bit.h"
1.4       anton       9: 
                     10: #if !defined(USE_TOS) && !defined(USE_NO_TOS)
                     11: #define USE_TOS
                     12: #endif
1.1       anton      13: 
1.9       anton      14: #if !defined(INDIRECT_THREADED) && !defined(DIRECT_THREADED)
                     15: #define DIRECT_THREADED
                     16: #endif
1.1       anton      17: 
                     18: #ifdef DIRECT_THREADED
1.7       anton      19: #ifndef WORDS_BIGENDIAN
1.10    ! anton      20: #error Direct threading only supported for big-endian SPARCs.
1.7       anton      21: /* little endian SPARCs still store instructions in big-endian format,
                     22:    so you would have to reverse the instructions stores in the following
                     23: */
                     24: #endif
                     25: 
                     26: /* assuming size = 8 */
                     27: #define CACHE_FLUSH(addr,size) \
1.8       anton      28:   asm("iflush %0; iflush %0+4"::"r"(addr))
1.7       anton      29: 
1.1       anton      30: /* PFA gives the parameter field address corresponding to a cfa */
                     31: #define PFA(cfa)       (((Cell *)cfa)+2)
                     32: /* PFA1 is a special version for use just after a NEXT1 */
                     33: /* the improvement here is that we may destroy cfa before using PFA1 */
1.6       anton      34: #define PFA1(cfa)      PFA(cfa)
                     35: #ifdef undefined
1.1       anton      36: #define PFA1(cfa)      /* PFA(cfa) */ \
1.6       anton      37:                        ({register Cell *pfa asm("%o7"); \
1.1       anton      38:                          pfa+2; })
1.6       anton      39: #endif
1.1       anton      40: /* CODE_ADDRESS is the address of the code jumped to through the code field */
1.6       anton      41: #define CODE_ADDRESS(cfa)      ({unsigned _cfa = (unsigned)(cfa); \
                     42:                                    (Label)(_cfa+((*(unsigned *)_cfa)<<2));})
1.1       anton      43: /* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
                     44: /* we use call, since 'branch always' only has 22 bits displacement */
                     45: #define MAKE_CF(cfa,ca)        ({long *_cfa        = (long *)(cfa); \
                     46:                          unsigned _ca = (unsigned)(ca); \
1.6       anton      47:                          _cfa[0] = 0x40000000|((_ca+4-(unsigned)_cfa)>>2); /* CALL ca */ \
1.1       anton      48:                          _cfa[1] = *(long *)_ca; /* delay slot */})
                     49: 
                     50: /* this is the point where the does code starts if label points to the
                     51:  * jump dodoes */
1.6       anton      52: #define DOES_CODE(label)       ((Xt *)(CODE_ADDRESS(label)+DOES_HANDLER_SIZE))
1.1       anton      53: 
                     54: /* this is a special version of DOES_CODE for use in dodoes */
1.6       anton      55: #define DOES_CODE1(label)      DOES_CODE(label)
                     56: #ifdef undefined
                     57: #define DOES_CODE1(label)      ({register Xt *_does_code asm("%o7"); \
1.1       anton      58:                                _does_code+2; })
1.6       anton      59: #endif
1.1       anton      60: 
                     61: /* this stores a call dodoes at addr */
1.6       anton      62: #define MAKE_DOES_HANDLER(addr) MAKE_CF(addr,symbols[DODOES])
                     63: 
                     64: #define DOES_HANDLER_SIZE       8
                     65: 
                     66: #define MAKE_DOES_CF(addr,doesp) ({long *_addr        = (long *)(addr); \
                     67:                          unsigned _doesp = (unsigned)(doesp); \
                     68:                          _addr[0] = 0x40000000|((_doesp-8-(unsigned)_addr)>>2); /* CALL doesp-8 */ \
                     69:                          _addr[1] = 0x01000000; /* nop */})
1.3       anton      70: #endif
1.6       anton      71: 

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