--- gforth/Attic/hppa.h 1994/09/26 20:31:13 1.2 +++ gforth/Attic/hppa.h 1995/10/07 17:38:16 1.9 @@ -1,54 +1,34 @@ /* - $Id: hppa.h,v 1.2 1994/09/26 20:31:13 pazsan Exp $ + $Id: hppa.h,v 1.9 1995/10/07 17:38:16 anton Exp $ Copyright 1992 by the ANSI figForth Development Group This is the machine-specific part for a HPPA running HP-UX */ -/* cache flush stuff */ -#ifdef DIRECT_THREADED +#if !defined(USE_TOS) && !defined(USE_NO_TOS) +#define USE_TOS +#endif +#ifndef INDIRECT_THREADED +#ifndef DIRECT_THREADED +#define DIRECT_THREADED +#endif +#endif + +/* cache flush stuff */ extern void * cacheflush(void *, int, int); #ifdef DEBUG -# define CACHE_FLUSH(addr,size) \ +# define FLUSH_ICACHE(addr,size) \ ({ fprintf(stderr,"Flushing Cache at %08x:%08x\n",(int) addr, size); \ fflush(stderr); \ fprintf(stderr,"Cache flushed, final address: %08x\n", \ (int)cacheflush((void *)(addr), (int)(size), 32)); }) -# else -/* -# define CACHE_FLUSH(addr,size) \ - ({ fprintf(stderr,"Flushing Cache at %08x:%08x\n",(int) addr, size); \ - fflush(stderr); \ - fprintf(stderr,"Cache flushed, final address: %08x\n", \ - (int)cacheflush((void *)(addr), (int)(size), 32)); }) -*/ -# define CACHE_FLUSH(addr,size) \ +#else +# define FLUSH_ICACHE(addr,size) \ ({ (void)cacheflush((void *)(addr), (int)(size), 32); }) - -# endif #endif - -/* Cell and UCell must be the same size as a pointer */ -typedef long Cell; -typedef unsigned long UCell; - -/* DCell and UDCell must be twice as large as Cell */ -typedef long long DCell; -typedef unsigned long long UDCell; - -/* define this if IEEE singles and doubles are available as C data types */ -#define IEEE_FP - -/* the IEEE types are used only for loading and storing */ -/* the IEEE double precision type */ -typedef double DFloat; -/* the IEEE single precision type */ -typedef float SFloat; - -/* define this if the least-significant byte is at the largets address */ -#define BIG_ENDIAN +#include "32bit.h" #ifdef DIRECT_THREADED /* PFA gives the parameter field address corresponding to a cfa */ @@ -64,22 +44,13 @@ typedef float SFloat; /* we use ble and a register, since 'bl' only has 21 bits displacement */ #endif -#ifdef undefined -#define MAKE_CFA(cfa,ca) ({long *_cfa = (long *)(cfa); \ - unsigned _ca = (unsigned)(ca); \ - _cfa[0] = 0xE4A02000 | (((int)_ca+4-(int)symbols[0]) & 0x7FC)<<1 ; \ - _cfa[1] = *(long *)(_ca); \ - /* printf("%08x:%08x,%08x\n",_cfa,_cfa[0],_cfa[1]); */ \ - }) -#endif - #ifdef DIRECT_THREADED -#ifdef DEBUG -# define DOUT(a,b,c,d) fprintf(stderr,a,b,c,d) -#else -# define DOUT(a,b,c,d) -#endif +# ifdef DEBUG +# define DOUT(a,b,c,d) fprintf(stderr,a,b,c,d) +# else +# define DOUT(a,b,c,d) +# endif # define ASS17(n)(((((n) >> 13) & 0x1F) << 16)| /* first 5 bits */ \ ((((n) >> 2) & 0x3FF) << 3)| /* second 11 bits */ \ @@ -121,7 +92,7 @@ typedef float SFloat; # define MAKE_CF(cfa,ca) \ ({ \ long *_cfa = (long *)(cfa); \ - int _ca = (int)(ca); \ + int _ca = (int)(ca)+4; \ int _dp = _ca-(int)(_cfa+2); \ \ if(_ca < 0x40000) /* Branch absolute */ \ @@ -131,7 +102,7 @@ typedef float SFloat; ( 0 << 13) | /* space register */ \ ( 0 << 1))| /* if 1, don't execute delay slot */ \ ASS17(_ca); \ - _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \ + _cfa[1] = ((long *)(_ca))[-1]; /* or %r0,%r0,%r0 */; \ } \ else if(_dp < 0x40000 || _dp >= -0x40000) \ { \ @@ -140,10 +111,11 @@ typedef float SFloat; ( 0 << 13) | /* space register */ \ ( 0 << 1))| /* if 1, don't execute delay slot */ \ ASS17(_dp); \ - _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \ + _cfa[1] = ((long *)(_ca))[-1]; /* 0x08000240 or %r0,%r0,%r0 */; \ } \ else \ { \ + _ca -= 4; \ _cfa[0] = (0x08 << 26) | \ ((int)_ca<0) | \ (_ca & 0x00001800)<<1 | \ @@ -164,7 +136,7 @@ typedef float SFloat; /* this is the point where the does code starts if label points to the * jump dodoes */ -# define DOES_CODE(cfa) ((Xt *)(((char *)CODE_ADDRESS(cfa))+8)) +# define DOES_CODE(cfa) ((Xt *)(((long *)(cfa))[1])) /* this is a special version of DOES_CODE for use in dodoes */ # define DOES_CODE1(cfa) DOES_CODE(cfa) \ @@ -173,6 +145,8 @@ typedef float SFloat; /* HPPA uses register 2 for branch and link */ # define DOES_HANDLER_SIZE 8 +# define MAKE_DOES_HANDLER(cfa) ({ *(long *)(cfa)=DODOES; }) +#ifdef undefined # define MAKE_DOES_HANDLER(cfa) \ ({ \ long *_cfa = (long *)(cfa); \ @@ -215,54 +189,49 @@ typedef float SFloat; } \ DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \ }) +#endif # define MAKE_DOES_CF(cfa,ca) \ ({ \ long *_cfa = (long *)(cfa); \ - int _ca = (int)(ca)-DOES_HANDLER_SIZE; \ + int _ca = (int)symbols[DODOES]; \ int _dp = _ca-(int)(_cfa+2); \ \ - if(_dp < 0x40000 || _dp >= -0x40000) \ + if(_ca < 0x40000) /* Branch absolute */ \ { \ - _cfa[0] = (0x3A << 26) | /* major opcode */ \ + _cfa[0] =((0x38 << 26) | /* major opcode */ \ ( 0 << 21) | /* register */ \ ( 0 << 13) | /* space register */ \ - ( 0 << 1) | /* if 1, don't execute delay slot */ \ - ASS17(_dp); \ - _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \ + ( 1 << 1))| /* if 1, don't execute delay slot */ \ + ASS17(_ca); \ + _cfa[1] = (long)(ca); \ } \ - else if(_ca < 0x40000) /* Branch absolute */ \ + else if(_dp < 0x40000 || _dp >= -0x40000) \ { \ - _cfa[0] = (0x38 << 26) | /* major opcode */ \ + _cfa[0] =((0x3A << 26) | /* major opcode */ \ ( 0 << 21) | /* register */ \ ( 0 << 13) | /* space register */ \ - ( 0 << 1) | /* if 1, don't execute delay slot */ \ - ASS17(_ca); \ - _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \ + ( 1 << 1))| /* if 1, don't execute delay slot */ \ + ASS17(_dp); \ + _cfa[1] = (long)(ca); \ } \ else \ { \ - _cfa[0] = (0x08 << 26) | \ - ((int)_ca<0) | \ - (_ca & 0x00001800)<<1 | \ - (_ca & 0x0003E000)<<3 | \ - (_ca & 0x000C0000)>>4 | \ - (_ca & 0x7FF00000)>>19; \ - _ca &= 0x3FF; \ - _cfa[1] = (0x38 << 26) | /* major opcode */ \ - ( 1 << 21) | /* register */ \ - ( 0 << 13) | /* space register */ \ - ( 1 << 1) | /* if 1, don't execute delay slot */ \ - ASS17(_ca); \ + fprintf(stderr,"DOESCFA assignment failed, use ITC instead of DTC\n"); exit(1); \ } \ DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \ }) /* this stores a call dodoes at addr */ #endif -/* OS dependences */ - -#define SEEK_SET 0 -#define rint(x) floor((x)+0.5) - +#undef HAVE_LOG1P +#undef HAVE_RINT +#ifdef FORCE_REG +#define IPREG asm("%r10") +#define SPREG asm("%r9") +#define RPREG asm("%r8") +#define LPREG asm("%r7") +#define CFAREG asm("%r6") +#define TOSREG asm("%r11") +#endif /* FORCE_REG */