Diff for /gforth/Attic/hppa.h between versions 1.2 and 1.14

version 1.2, 1994/09/26 20:31:13 version 1.14, 1995/11/07 18:06:45
Line 1 Line 1
 /*  /* This is the machine-specific part for a HPPA running HP-UX
   $Id$  
   Copyright 1992 by the ANSI figForth Development Group  
   
   This is the machine-specific part for a HPPA running HP-UX    Copyright (C) 1995 Free Software Foundation, Inc.
 */  
 /* cache flush stuff */  
   
 #ifdef DIRECT_THREADED    This file is part of Gforth.
   
 extern void * cacheflush(void *, int, int);    Gforth is free software; you can redistribute it and/or
 #ifdef DEBUG    modify it under the terms of the GNU General Public License
 #  define CACHE_FLUSH(addr,size) \    as published by the Free Software Foundation; either version 2
         ({      fprintf(stderr,"Flushing Cache at %08x:%08x\n",(int) addr, size); \    of the License, or (at your option) any later version.
                 fflush(stderr); \  
                 fprintf(stderr,"Cache flushed, final address: %08x\n", \    This program is distributed in the hope that it will be useful,
                         (int)cacheflush((void *)(addr), (int)(size), 32)); })    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #  else    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 /*    GNU General Public License for more details.
 #  define CACHE_FLUSH(addr,size) \  
         ({      fprintf(stderr,"Flushing Cache at %08x:%08x\n",(int) addr, size); \    You should have received a copy of the GNU General Public License
                 fflush(stderr); \    along with this program; if not, write to the Free Software
                 fprintf(stderr,"Cache flushed, final address: %08x\n", \    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
                         (int)cacheflush((void *)(addr), (int)(size), 32)); })  
 */  */
 #  define CACHE_FLUSH(addr,size) \  
                 ({ (void)cacheflush((void *)(addr), (int)(size), 32); })  
   
 #  endif  #if !defined(USE_TOS) && !defined(USE_NO_TOS)
   #define USE_TOS
   #endif
   
   #ifndef INDIRECT_THREADED
   #ifndef DIRECT_THREADED
   #define DIRECT_THREADED
   #endif
 #endif  #endif
   
   #define LONG_LATENCY
   
 /* Cell and UCell must be the same size as a pointer */  /* cache flush stuff */
 typedef long Cell;  extern void cacheflush(void *, int, int);
 typedef unsigned long UCell;  #ifdef DEBUG
   #  define FLUSH_ICACHE(addr,size) \
 /* DCell and UDCell must be twice as large as Cell */  ({ \
 typedef long long DCell;     fprintf(stderr,"Flushing Cache at %08x:%08x\n",(int) addr, size); \
 typedef unsigned long long UDCell;     fflush(stderr); \
      cacheflush((void *)(addr), (int)(size), 32); \
 /* define this if IEEE singles and doubles are available as C data types */     fprintf(stderr,"Cache flushed\n");  })
 #define IEEE_FP  #else
   #  define FLUSH_ICACHE(addr,size) \
 /* the IEEE types are used only for loading and storing */       cacheflush((void *)(addr), (int)(size), 32)
 /* the IEEE double precision type */  #endif
 typedef double DFloat;  
 /* the IEEE single precision type */  
 typedef float SFloat;  
   
 /* define this if the least-significant byte is at the largets address */  #include "32bit.h"
 #define BIG_ENDIAN  
   
 #ifdef DIRECT_THREADED  #ifdef DIRECT_THREADED
         /* PFA gives the parameter field address corresponding to a cfa */     /* PFA gives the parameter field address corresponding to a cfa */
 #       define PFA(cfa) (((Cell *)cfa)+2)  #  define PFA(cfa)      (((Cell *)cfa)+2)
         /* PFA1 is a special version for use just after a NEXT1 */     /* PFA1 is a special version for use just after a NEXT1 */
         /* the improvement here is that we may destroy cfa before using PFA1 */     /* the improvement here is that we may destroy cfa before using PFA1 */
 #       define PFA1(cfa)       PFA(cfa)  #  define PFA1(cfa)       PFA(cfa)
         /* HPPA uses register 2 for branch and link */     /* HPPA uses register 2 for branch and link */
   
         /* CODE_ADDRESS is the address of the code jumped to through the code field */     /* CODE_ADDRESS is the address of the code jumped to through the code field */
   
         /* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */     /* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
         /* we use ble and a register, since 'bl' only has 21 bits displacement */     /* 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  #endif
   
 #ifdef DIRECT_THREADED  #ifdef DIRECT_THREADED
   
 #ifdef DEBUG  #  ifdef DEBUG
 #       define DOUT(a,b,c,d)  fprintf(stderr,a,b,c,d)  #         define DOUT(a,b,c,d)  fprintf(stderr,a,b,c,d)
 #else  #  else
 #       define DOUT(a,b,c,d)  #    define DOUT(a,b,c,d)
 #endif  #  endif
   
 #  define ASS17(n)(((((n) >> 13) & 0x1F) << 16)| /* first 5 bits */ \  #  define ASS17(n)(((((n) >> 13) & 0x1F) << 16)| /* first 5 bits */ \
                                        ((((n) >>  2) & 0x3FF) << 3)| /* second 11 bits */ \                     ((((n) >>  2) & 0x3FF) << 3)| /* second 11 bits */ \
                                        ((((n) >> 12) & 0x1) << 2)  | /* lo sign (arg!) */ \                     ((((n) >> 12) & 0x1) << 2)  | /* lo sign (aaarg!) */ \
                                        (((n) < 0) << 0)) /* sign bit */                     (((n) < 0) << 0)) /* sign bit */
   
 #  define DIS17(n)(((((n) >> 16) & 0x1F) << 13)| /* first 5 bits */ \  #  define DIS17(n)(((((n) >> 16) & 0x1F) << 13)| /* first 5 bits */ \
                                        ((((n) >>  3) & 0x3FF) << 2)| /* second 11 bits */ \                     ((((n) >>  3) & 0x3FF) << 2)| /* second 11 bits */ \
                                        ((((n) >>  2) & 0x1) << 12) | /* lo sign (arg!) */ \                     ((((n) >>  2) & 0x1) << 12) | /* lo sign (aaarg!) */ \
                                        (-((n) & 1) << 18)) /* sign bit */                     (-((n) & 1) << 18)) /* sign bit */
   
 #       define CODE_ADDRESS(cfa) ((Label)({ \  #  define CODE_ADDRESS(cfa)\
                 unsigned int *_cfa=(unsigned int *)(cfa); unsigned _ca; \  ((Label)({ \
                 if((_cfa[0] & 0xFFE0E002) == 0xE8000000) /* relative branch */ \               unsigned int *_cfa=(unsigned int *)(cfa); unsigned _ca; \
                         { \               if((_cfa[0] & 0xFFE0E002) == 0xE8000000) /* relative branch */ \
                                 _ca = _cfa[0]; \               { \
                                 _ca = DIS17(_ca); \                   _ca = _cfa[0]; \
                                 _ca += (int) (_cfa + 2); \                   _ca = DIS17(_ca); \
                         } \                   _ca += (int) (_cfa + 1); \
                 else if((_cfa[0] & 0xFFE0E002) == 0xE0000000) /* absolute branch */ \               } \
                         { \               else if((_cfa[0] & 0xFFE0E002) == 0xE0000000) /* absolute branch */ \
                                 _ca = _cfa[0]; \               { \
                                 _ca = DIS17(_ca); \                   _ca = _cfa[0]; \
                         } \                   _ca = DIS17(_ca)-4; \
                 else \               } \
                         { \               else \
                                 _ca = _cfa[0]; \               { \
                                 _ca = (_ca<<31) | \                   _ca = _cfa[0]; \
                                       ((_ca>>1 ) & 0x00001800) | \                   _ca = (_ca<<31) | \
                                       ((_ca>>3 ) & 0x0003E000) | \                   ((_ca>>1 ) & 0x00001800) | \
                                       ((_ca<<4 ) & 0x000C0000) | \                   ((_ca>>3 ) & 0x0003E000) | \
                                       ((_ca<<19) & 0x7FF00000) |  \                   ((_ca<<4 ) & 0x000C0000) | \
                                       ((_cfa[1]>>1) & 0xFFC); \                   ((_ca<<19) & 0x7FF00000) |  \
                         } \                   ((_cfa[1]>>1) & 0xFFC); \
                 /* printf("code-address at %08x: %08x\n",_ca,_cfa); */ \               } \
                 _ca; \               /* printf("code-address at %08x: %08x\n",_ca,_cfa); */ \
         }))               _ca; \
            }))
 #       define MAKE_CF(cfa,ca) \  
         ({ \  #  define MAKE_CF(cfa,ca) \
                 long *_cfa   = (long *)(cfa); \  ({ \
                 int _ca      = (int)(ca); \       long *_cfa   = (long *)(cfa); \
                 int _dp      = _ca-(int)(_cfa+2); \       int _ca      = (int)(ca)+4; \
                 \       int _dp      = _ca-(int)(_cfa+2); \
                 if(_ca < 0x40000) /* Branch absolute */ \       \
                         { \       if(_ca < 0x40000) /* Branch absolute */ \
                                 _cfa[0] =((0x38 << 26) | /* major opcode */ \       { \
                                           (   0 << 21) | /* register */ \           _cfa[0] =((0x38 << 26) | /* major opcode */ \
                                           (   0 << 13) | /* space register */ \                     (   0 << 21) | /* register */ \
                                           (   0 <<  1))| /* if 1, don't execute delay slot */ \                     (   0 << 13) | /* space register */ \
                       ASS17(_ca); \                     (   0 <<  1) | /* if 1, don't execute delay slot */ \
                                 _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \                     ASS17(_ca)); \
                         } \           _cfa[1] = ((long *)(_ca))[-1]; /* or %r0,%r0,%r0 */; \
                 else if(_dp < 0x40000 || _dp >= -0x40000) \       } \
                         { \       else if(_dp < 0x40000 || _dp >= -0x40000) \
                                 _cfa[0] =((0x3A << 26) | /* major opcode */ \       { \
                                           (   0 << 21) | /* register */ \           _cfa[0] =((0x3A << 26) | /* major opcode */ \
                                           (   0 << 13) | /* space register */ \                     (   0 << 21) | /* register */ \
                                           (   0 <<  1))| /* if 1, don't execute delay slot */ \                     (   0 << 13) | /* space register */ \
                                           ASS17(_dp); \                     (   0 <<  1) | /* if 1, don't execute delay slot */ \
                                 _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \                     ASS17(_dp)); \
                         } \           _cfa[1] = ((long *)(_ca))[-1]; /* 0x08000240 or %r0,%r0,%r0 */; \
                 else \       } \
                         { \       else \
                                 _cfa[0] = (0x08 << 26) | \       { \
                                           ((int)_ca<0) | \           _ca -= 4; \
                                           (_ca & 0x00001800)<<1 | \           _cfa[0] = (0x08 << 26) | \
                                           (_ca & 0x0003E000)<<3 | \           ((int)_ca<0) | \
                                           (_ca & 0x000C0000)>>4 | \           (_ca & 0x00001800)<<1 | \
                                           (_ca & 0x7FF00000)>>19; \           (_ca & 0x0003E000)<<3 | \
             _ca &= 0x3FF; \           (_ca & 0x000C0000)>>4 | \
                                 _cfa[1] =((0x38 << 26) | /* major opcode */ \           (_ca & 0x7FF00000)>>19; \
                                           (   1 << 21) | /* register */ \           _ca &= 0x3FF; \
                                           (   0 << 13) | /* space register */ \           _cfa[1] =((0x38 << 26) | /* major opcode */ \
                                           (   1 <<  1))| /* if 1, don't execute delay slot */ \                     (   1 << 21) | /* register */ \
                                           ASS17(_ca); \                     (   0 << 13) | /* space register */ \
                         } \                     (   1 <<  1) | /* if 1, don't execute delay slot */ \
                         DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \                     ASS17(_ca)); \
         })       } \
         /* HP wins the price for the most obfuscated binary opcode */       DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \
    })
   /* HP wins the price for the most obfuscated binary opcode */
   
         /* this is the point where the does code starts if label points to the  /* this is the point where the does code starts if label points to the
          * jump dodoes */   * 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 */  /* this is a special version of DOES_CODE for use in dodoes */
 #       define DOES_CODE1(cfa)  DOES_CODE(cfa) \  #  define DOES_CODE1(cfa)  DOES_CODE(cfa) \
 /*      ({register Xt * _ret asm("%r31"); _ret;}) */  /*      ({register Xt * _ret asm("%r31"); _ret;}) */
   
         /* HPPA uses register 2 for branch and link */  /* HPPA uses register 2 for branch and link */
   
 #       define DOES_HANDLER_SIZE 8  #  define DOES_HANDLER_SIZE 8
 #       define MAKE_DOES_HANDLER(cfa) \  #  define MAKE_DOES_HANDLER(cfa)  ({ *(long *)(cfa)=DODOES; })
         ({ \  #ifdef undefined
                 long *_cfa   = (long *)(cfa); \  #  define MAKE_DOES_HANDLER(cfa) \
                 int _ca      = (int)symbols[DODOES]; \  ({ \
                 int _dp      = _ca-(int)(_cfa+2); \       long *_cfa   = (long *)(cfa); \
                 \       int _ca      = (int)symbols[DODOES]; \
                 if(_ca < 0x40000) /* Branch absolute */ \       int _dp      = _ca-(int)(_cfa+2); \
                         { \       \
                                 _cfa[0] =((0x38 << 26) | /* major opcode */ \       if(_ca < 0x40000) /* Branch absolute */ \
                                           (   0 << 21) | /* register */ \       { \
                                           (   0 << 13) | /* space register */ \           _cfa[0] =((0x38 << 26) | /* major opcode */ \
                                           (   0 <<  1))| /* if 1, don't execute delay slot */ \                     (   0 << 21) | /* register */ \
                                           ASS17(_ca); \                     (   0 << 13) | /* space register */ \
                                 _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \                     (   0 <<  1) | /* if 1, don't execute delay slot */ \
                         } \                     ASS17(_ca)); \
                 else if(_dp < 0x40000 || _dp >= -0x40000) \           _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \
                         { \       } \
                                 _cfa[0] =((0x3A << 26) | /* major opcode */ \       else if(_dp < 0x40000 || _dp >= -0x40000) \
                                           (   0 << 21) | /* register */ \       { \
                                           (   0 << 13) | /* space register */ \           _cfa[0] =((0x3A << 26) | /* major opcode */ \
                                           (   0 <<  1))| /* if 1, don't execute delay slot */ \                     (   0 << 21) | /* register */ \
                                           ASS17(_dp); \                     (   0 << 13) | /* space register */ \
                                 _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \                     (   0 <<  1) | /* if 1, don't execute delay slot */ \
                         } \                     ASS17(_dp)); \
                 else \           _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \
                         { \       } \
                                 fprintf(stderr,"DOESHANDLER assignment failed, use ITC instead of DTC\n"); exit(1); \       else \
                                 _cfa[0] = (0x08 << 26) | \       { \
                                           ((int)_ca<0) | \           fprintf(stderr,"DOESHANDLER assignment failed, use ITC instead of DTC\n"); exit(1); \
                                           (_ca & 0x00001800)<<1 | \           _cfa[0] = ((0x08 << 26) | \
                                           (_ca & 0x0003E000)<<3 | \                      ((int)_ca<0) | \
                                           (_ca & 0x000C0000)>>4 | \                      (_ca & 0x00001800)<<1 | \
                                           (_ca & 0x7FF00000)>>19; \                      (_ca & 0x0003E000)<<3 | \
             _ca &= 0x3FF; \                      (_ca & 0x000C0000)>>4 | \
                                 _cfa[1] =((0x38 << 26) | /* major opcode */ \                      (_ca & 0x7FF00000)>>19); \
                                           (   1 << 21) | /* register */ \           _ca &= 0x3FF; \
                                           (   0 << 13) | /* space register */ \           _cfa[1] =((0x38 << 26) | /* major opcode */ \
                                           (   1 <<  1))| /* if 1, don't execute delay slot */ \                     (   1 << 21) | /* register */ \
                                           ASS17(_ca); \                     (   0 << 13) | /* space register */ \
                         } \                     (   1 <<  1) | /* if 1, don't execute delay slot */ \
                         DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \                     ASS17(_ca)); \
         })       } \
        DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \
 #       define MAKE_DOES_CF(cfa,ca) \   })
         ({ \  
                 long *_cfa   = (long *)(cfa); \  
                 int _ca      = (int)(ca)-DOES_HANDLER_SIZE; \  
                 int _dp      = _ca-(int)(_cfa+2); \  
                 \  
                 if(_dp < 0x40000 || _dp >= -0x40000) \  
                         { \  
                                 _cfa[0] = (0x3A << 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 */; \  
                         } \  
                 else if(_ca < 0x40000) /* Branch absolute */ \  
                         { \  
                                 _cfa[0] = (0x38 << 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 */; \  
                         } \  
                 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); \  
                         } \  
                         DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \  
         })  
         /* this stores a call dodoes at addr */  
 #endif  #endif
   
 /* OS dependences */  #  define MAKE_DOES_CF(cfa,ca) \
   ({ \
 #define SEEK_SET 0       long *_cfa   = (long *)(cfa); \
 #define rint(x) floor((x)+0.5)       int _ca      = (int)symbols[DODOES]; \
        int _dp      = _ca-(int)(_cfa+2); \
        \
        if(_ca < 0x40000) /* Branch absolute */ \
        { \
            _cfa[0] =((0x38 << 26) | /* major opcode */ \
                      (   0 << 21) | /* register */ \
                      (   0 << 13) | /* space register */ \
                      (   1 <<  1) | /* if 1, don't execute delay slot */ \
                      ASS17(_ca)); \
            _cfa[1] = (long)(ca); \
        } \
        else if(_dp < 0x40000 || _dp >= -0x40000) \
        { \
            _cfa[0] =((0x3A << 26) | /* major opcode */ \
                      (   0 << 21) | /* register */ \
                      (   0 << 13) | /* space register */ \
                      (   1 <<  1) | /* if 1, don't execute delay slot */ \
                      ASS17(_dp)); \
            _cfa[1] = (long)(ca); \
        } \
        else \
        { \
            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
   
   #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 */

Removed from v.1.2  
changed lines
  Added in v.1.14


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