Annotation of gforth/sparc.h, revision 1.7

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

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