File:  [gforth] / gforth / Attic / decstation.h
Revision 1.3: download - view: text, annotated - select for diffs
Thu May 5 17:05:32 1994 UTC (25 years, 1 month ago) by pazsan
Branches: MAIN
CVS tags: HEAD
Got direct threading to work!

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

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