File:  [gforth] / gforth / Attic / sparc.h
Revision 1.7: download - view: text, annotated - select for diffs
Thu Jan 5 22:33:19 1995 UTC (29 years, 2 months ago) by anton
Branches: MAIN
CVS tags: HEAD
Tried to add cache flushing to the sparc (but had to comment it out)
direct threading now gives a compile-time error for little-endian sparcs

    1: /*
    2:   Copyright 1992 by the ANSI figForth Development Group
    3: 
    4:   This is the machine-specific part for a SPARC
    5: */
    6: 
    7: #include "32bit.h"
    8: 
    9: #if !defined(USE_TOS) && !defined(USE_NO_TOS)
   10: #define USE_TOS
   11: #endif
   12: 
   13: /* direct threading is probably faster on the SPARC, but has it been
   14:    tested? Therefore, DIRECT_THREADED is not defined */
   15: 
   16: #ifdef DIRECT_THREADED
   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: 
   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 */
   36: #define PFA1(cfa)	PFA(cfa)
   37: #ifdef undefined
   38: #define PFA1(cfa)	/* PFA(cfa) */ \
   39: 			({register Cell *pfa asm("%o7"); \
   40: 			  pfa+2; })
   41: #endif
   42: /* CODE_ADDRESS is the address of the code jumped to through the code field */
   43: #define CODE_ADDRESS(cfa)	({unsigned _cfa = (unsigned)(cfa); \
   44: 				    (Label)(_cfa+((*(unsigned *)_cfa)<<2));})
   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); \
   49: 			  _cfa[0] = 0x40000000|((_ca+4-(unsigned)_cfa)>>2); /* CALL ca */ \
   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 */
   54: #define DOES_CODE(label)	((Xt *)(CODE_ADDRESS(label)+DOES_HANDLER_SIZE))
   55: 
   56: /* this is a special version of DOES_CODE for use in dodoes */
   57: #define DOES_CODE1(label)	DOES_CODE(label)
   58: #ifdef undefined
   59: #define DOES_CODE1(label)	({register Xt *_does_code asm("%o7"); \
   60: 			  	_does_code+2; })
   61: #endif
   62: 
   63: /* this stores a call dodoes at addr */
   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 */})
   72: #endif
   73: 

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