File:  [gforth] / gforth / Attic / decstation.h
Revision 1.2: download - view: text, annotated - select for diffs
Thu May 5 15:46:41 1994 UTC (25 years, 1 month ago) by pazsan
Branches: MAIN
CVS tags: HEAD
Added direct threading for R3/4000. Still needs cache flush.
Added direct threading for R3/4000. Needs still cache flush.

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

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