File:  [gforth] / gforth / Attic / decstation.h
Revision 1.5: download - view: text, annotated - select for diffs
Wed Nov 30 17:46:04 1994 UTC (26 years, 11 months ago) by anton
Branches: MAIN
CVS tags: HEAD
Added FORCE_REG stuff to decstation.h
added man page

    1: /*
    2:   Copyright 1992 by the ANSI figForth Development Group
    3: 
    4:   This is the machine-specific part for a Decstation running Ultrix
    5: */
    6: /* cache flush stuff */
    7: 
    8: #ifdef DIRECT_THREADED
    9: 
   10: #include <mips/cachectl.h>
   11: 
   12: #define CACHE_FLUSH(addr,size) \
   13: 				cacheflush((char *)(addr), (int)(size), BCACHE)
   14: 
   15: #endif
   16: 
   17: /* Cell and UCell must be the same size as a pointer */
   18: typedef long Cell;
   19: typedef unsigned long UCell;
   20: 
   21: /* DCell and UDCell must be twice as large as Cell */
   22: typedef long long DCell;
   23: typedef unsigned long long UDCell;
   24: 
   25: /* define this if IEEE singles and doubles are available as C data types */
   26: #define IEEE_FP
   27: 
   28: /* the IEEE types are used only for loading and storing */
   29: /* the IEEE double precision type */
   30: typedef double DFloat;
   31: /* the IEEE single precision type */
   32: typedef float SFloat;
   33: 
   34: /* define this if the least-significant byte is at the largets address */
   35: /* #define BIG_ENDIAN */
   36: 
   37: /* some definitions for composing opcodes */
   38: #define JUMP_MASK	0x03ffffff
   39: #define J_PATTERN	0x08000000
   40: #define JAL_PATTERN	0x0c000000
   41: /* this provides the first 4 bits of a jump address, i.e. it must be <16 */
   42: #define SEGMENT_NUM	1
   43: 
   44: #ifdef DIRECT_THREADED
   45: 	/* PFA gives the parameter field address corresponding to a cfa */
   46: #	define PFA(cfa)	(((Cell *)cfa)+2)
   47: 	/* PFA1 is a special version for use just after a NEXT1 */
   48: #	define PFA1(cfa)	PFA(cfa)
   49: 	/* CODE_ADDRESS is the address of the code jumped to through the code field */
   50: #	define CODE_ADDRESS(cfa)	((Label)(((*(unsigned *)(cfa))^J_PATTERN^(SEGMENT_NUM<<26))<<2))
   51: 	/* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
   52: #	define MAKE_CF(cfa,ca)	({long * _cfa = (long *)(cfa); \
   53: 					  _cfa[0] = J_PATTERN|((((long)(ca))&JUMP_MASK)>>2); /* J ca */ \
   54: 					  _cfa[1] = 0; /* nop */})
   55: #	ifdef undefined
   56: 		/* the following version uses JAL to make PFA1 faster */
   57: #		define PFA1(label)	({register Cell *pfa asm("$31"); \
   58: 						pfa; })
   59: 		/* CODE_ADDRESS is the address of the code jumped to through the code field */
   60: #		define CODE_ADDRESS(cfa)	((Label)(((*(unsigned *)(cfa))^JAL_PATTERN^(SEGMENT_NUM<<26))<<2))
   61: #		define MAKE_CF(cfa,ca)	({long *_cfa = (long *)(cfa); \
   62: 					  long _ca = (long)(ca); \
   63: 						  _cfa[0] = JAL_PATTERN|(((((long)_ca)>>2))&JUMP_MASK); /* JAL ca+4 */ \
   64: 						  _cfa[1] = 0; /* *(long *)_ca; delay slot */})
   65: #	endif /* undefined */
   66: 
   67: 	/* this is the point where the does code starts if label points to the
   68: 	 * jump dodoes */
   69: #	define DOES_CODE(cfa)	((Xt *)(((char *)CODE_ADDRESS(cfa))+8))
   70: 
   71: 	/* this is a special version of DOES_CODE for use in dodoes */
   72: #	define DOES_CODE1(cfa)	DOES_CODE(cfa)
   73: 
   74: #	define DOES_HANDLER_SIZE	8
   75: #	define MAKE_DOES_CF(cfa,does_code) \
   76: 			({long does_handlerp=((long)(does_code))-DOES_HANDLER_SIZE; \
   77: 			  long *_cfa = (long*)(cfa); \
   78: 			  _cfa[0] = J_PATTERN|((does_handlerp&JUMP_MASK)>>2); /* J ca */ \
   79: 			  _cfa[1] = 0; /* nop */})
   80: /*
   81: #	define MAKE_DOES_CF(cfa, does_code)	({char *does_handlerp=((char *)does_code)-DOES_HANDLER_SIZE;	\
   82: 						  MAKE_CF(cfa,does_handlerp);	\
   83: 						  MAKE_DOES_HANDLER(does_handlerp) ;})
   84: */
   85: 	/* this stores a jump dodoes at addr */
   86: #	define MAKE_DOES_HANDLER(addr)	MAKE_CF(addr,symbols[DODOES])
   87: 
   88: #endif
   89: #ifdef undefined
   90: /* and here are some more efficient versions that can be tried later */
   91: 
   92: /* the first version saves one cycle by doing something useful in the
   93:    delay slot. !! check that the instruction in the delay slot is legal
   94: */
   95: 
   96: #define MAKE_DOESJUMP(addr)	({long * _addr = (long *)addr; \
   97: 				  _addr[0] = J_PATTERN|(((((long)symbols[DODOES])>>2)+4)&JUMP_MASK), /* J dodoes+4 */ \
   98: 				  _addr[1] = *(long *)symbols[DODOES]; /* delay */})
   99: 
  100: /* the following version uses JAL to make DOES_CODE1 faster */
  101: /* !! does the declaration clear the register ? */
  102: /* it's ok to use the same reg as in PFA1:
  103:    dodoes is the only potential problem and I have taken care of it */
  104: 
  105: #define DOES_CODE1(cfa)	({register Code *_does_code asm("$31"); \
  106: 				    _does_code; })
  107: #define MAKE_DOESJUMP(addr)	({long * _addr = (long *)addr; \
  108: 				  _addr[0] = JAL_PATTERN|(((((long)symbols[DODOES])>>2)+4)&JUMP_MASK), /* JAL dodoes+4 */ \
  109: 				  _addr[1] = *(long *)symbols[DODOES]; /* delay */})
  110: 
  111: #endif
  112: 
  113: #ifdef FORCE_REG
  114: #define IPREG asm("$16")
  115: #define SPREG asm("$17")
  116: #define RPREG asm("$18")
  117: #define LPREG asm("$19")
  118: #define CFAREG asm("$20")
  119: #define TOSREG asm("$21")
  120: #endif /* FORCE_REG */

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