Annotation of gforth/hppa.h, revision 1.16
1.14 anton 1: /* This is the machine-specific part for a HPPA running HP-UX
1.1 anton 2:
1.14 anton 3: Copyright (C) 1995 Free Software Foundation, Inc.
4:
5: This file is part of Gforth.
6:
7: Gforth is free software; you can redistribute it and/or
8: modify it under the terms of the GNU General Public License
9: as published by the Free Software Foundation; either version 2
10: of the License, or (at your option) any later version.
11:
12: This program is distributed in the hope that it will be useful,
13: but WITHOUT ANY WARRANTY; without even the implied warranty of
14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: GNU General Public License for more details.
16:
17: You should have received a copy of the GNU General Public License
18: along with this program; if not, write to the Free Software
19: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1.1 anton 20: */
1.6 anton 21:
22: #if !defined(USE_TOS) && !defined(USE_NO_TOS)
23: #define USE_TOS
24: #endif
1.5 anton 25:
26: #ifndef INDIRECT_THREADED
27: #ifndef DIRECT_THREADED
28: #define DIRECT_THREADED
29: #endif
30: #endif
31:
1.13 pazsan 32: #define LONG_LATENCY
33:
1.2 pazsan 34: /* cache flush stuff */
1.10 pazsan 35: extern void cacheflush(void *, int, int);
1.2 pazsan 36: #ifdef DEBUG
1.9 anton 37: # define FLUSH_ICACHE(addr,size) \
1.10 pazsan 38: ({ \
39: fprintf(stderr,"Flushing Cache at %08x:%08x\n",(int) addr, size); \
40: fflush(stderr); \
1.11 pazsan 41: cacheflush((void *)(addr), (int)(size), 32); \
42: fprintf(stderr,"Cache flushed\n"); })
1.3 pazsan 43: #else
1.9 anton 44: # define FLUSH_ICACHE(addr,size) \
1.10 pazsan 45: cacheflush((void *)(addr), (int)(size), 32)
1.2 pazsan 46: #endif
1.1 anton 47:
1.5 anton 48: #include "32bit.h"
1.2 pazsan 49:
1.1 anton 50: #ifdef DIRECT_THREADED
1.10 pazsan 51: /* PFA gives the parameter field address corresponding to a cfa */
52: # define PFA(cfa) (((Cell *)cfa)+2)
53: /* PFA1 is a special version for use just after a NEXT1 */
54: /* the improvement here is that we may destroy cfa before using PFA1 */
55: # define PFA1(cfa) PFA(cfa)
56: /* HPPA uses register 2 for branch and link */
1.1 anton 57:
1.10 pazsan 58: /* CODE_ADDRESS is the address of the code jumped to through the code field */
1.2 pazsan 59:
1.10 pazsan 60: /* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
61: /* we use ble and a register, since 'bl' only has 21 bits displacement */
1.1 anton 62: #endif
1.2 pazsan 63:
1.1 anton 64: #ifdef DIRECT_THREADED
1.2 pazsan 65:
1.3 pazsan 66: # ifdef DEBUG
67: # define DOUT(a,b,c,d) fprintf(stderr,a,b,c,d)
68: # else
1.10 pazsan 69: # define DOUT(a,b,c,d)
1.3 pazsan 70: # endif
1.2 pazsan 71:
72: # define ASS17(n)(((((n) >> 13) & 0x1F) << 16)| /* first 5 bits */ \
1.10 pazsan 73: ((((n) >> 2) & 0x3FF) << 3)| /* second 11 bits */ \
1.16 ! pazsan 74: ((((n) >> 12) & 0x1) << 2) | /* intermediate bit */ \
! 75: (((n) < 0) << 0)) /* low sign bit (aaarg!) */
1.2 pazsan 76:
77: # define DIS17(n)(((((n) >> 16) & 0x1F) << 13)| /* first 5 bits */ \
1.10 pazsan 78: ((((n) >> 3) & 0x3FF) << 2)| /* second 11 bits */ \
1.16 ! pazsan 79: ((((n) >> 2) & 0x1) << 12) | /* intermediate bit */ \
! 80: (-((n) & 1) << 18)) /* low sign bit (aaarg!) */
1.10 pazsan 81:
82: # define CODE_ADDRESS(cfa)\
83: ((Label)({ \
1.16 ! pazsan 84: unsigned int *_cfa=(unsigned int *)(cfa); \
! 85: unsigned int _ca = DIS17(_cfa[0]); \
! 86: if((_cfa[0] & 0xFFE0E000) == 0xE8000000) /* relative branch */ \
1.10 pazsan 87: { \
88: _ca += (int) (_cfa + 1); \
89: } \
1.16 ! pazsan 90: else if((_cfa[0] & 0xFFE0E000) == 0xE0000000) /* absolute branch */ \
1.10 pazsan 91: { \
1.16 ! pazsan 92: _ca = _ca-4; \
1.10 pazsan 93: } \
94: else \
95: { \
1.16 ! pazsan 96: _ca = (int)_cfa; \
1.10 pazsan 97: } \
98: /* printf("code-address at %08x: %08x\n",_ca,_cfa); */ \
1.16 ! pazsan 99: _ca + ((_cfa[0] & 2) << 1); \
1.10 pazsan 100: }))
101:
102: # define MAKE_CF(cfa,ca) \
103: ({ \
104: long *_cfa = (long *)(cfa); \
105: int _ca = (int)(ca)+4; \
106: int _dp = _ca-(int)(_cfa+2); \
107: \
108: if(_ca < 0x40000) /* Branch absolute */ \
109: { \
110: _cfa[0] =((0x38 << 26) | /* major opcode */ \
111: ( 0 << 21) | /* register */ \
112: ( 0 << 13) | /* space register */ \
1.12 pazsan 113: ( 0 << 1) | /* if 1, don't execute delay slot */ \
114: ASS17(_ca)); \
1.16 ! pazsan 115: _cfa[1] = ((long *)(_ca))[-1]; /* fill delay slot with first inst */ \
1.10 pazsan 116: } \
117: else if(_dp < 0x40000 || _dp >= -0x40000) \
118: { \
119: _cfa[0] =((0x3A << 26) | /* major opcode */ \
120: ( 0 << 21) | /* register */ \
121: ( 0 << 13) | /* space register */ \
1.12 pazsan 122: ( 0 << 1) | /* if 1, don't execute delay slot */ \
123: ASS17(_dp)); \
1.16 ! pazsan 124: _cfa[1] = ((long *)(_ca))[-1]; /* fill delay slot with first inst */ \
1.10 pazsan 125: } \
126: else \
127: { \
1.16 ! pazsan 128: fprintf(stderr,"CODE FIELD assignment failed, use ITC instead of DTC\n"); exit(1); \
1.10 pazsan 129: } \
130: DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \
131: })
132: /* HP wins the price for the most obfuscated binary opcode */
1.1 anton 133:
1.10 pazsan 134: /* this is the point where the does code starts if label points to the
135: * jump dodoes */
1.1 anton 136:
1.15 pazsan 137: /* this is a special version of DOES_CODE for use in dodoes */
138: # define DOES_CODE1(cfa) ((Xt *)(((long *)(cfa))[1]))
139:
140: # define DOES_CODE(cfa) \
1.16 ! pazsan 141: (((((*(long *)(cfa)) & 0xF7E0E002) == 0xE0000002) && \
! 142: ((long)(CODE_ADDRESS(cfa)) == (long)symbols[DODOES])) ? \
1.15 pazsan 143: DOES_CODE1(cfa) : 0L)
1.1 anton 144:
1.2 pazsan 145: /* ({register Xt * _ret asm("%r31"); _ret;}) */
146:
1.10 pazsan 147: /* HPPA uses register 2 for branch and link */
1.1 anton 148:
1.10 pazsan 149: # define DOES_HANDLER_SIZE 8
1.16 ! pazsan 150: # define MAKE_DOES_HANDLER(cfa)
1.10 pazsan 151:
152: # define MAKE_DOES_CF(cfa,ca) \
153: ({ \
154: long *_cfa = (long *)(cfa); \
155: int _ca = (int)symbols[DODOES]; \
156: int _dp = _ca-(int)(_cfa+2); \
157: \
158: if(_ca < 0x40000) /* Branch absolute */ \
159: { \
160: _cfa[0] =((0x38 << 26) | /* major opcode */ \
161: ( 0 << 21) | /* register */ \
162: ( 0 << 13) | /* space register */ \
1.12 pazsan 163: ( 1 << 1) | /* if 1, don't execute delay slot */ \
164: ASS17(_ca)); \
1.10 pazsan 165: _cfa[1] = (long)(ca); \
166: } \
167: else if(_dp < 0x40000 || _dp >= -0x40000) \
168: { \
169: _cfa[0] =((0x3A << 26) | /* major opcode */ \
170: ( 0 << 21) | /* register */ \
171: ( 0 << 13) | /* space register */ \
1.12 pazsan 172: ( 1 << 1) | /* if 1, don't execute delay slot */ \
173: ASS17(_dp)); \
1.10 pazsan 174: _cfa[1] = (long)(ca); \
175: } \
176: else \
177: { \
178: fprintf(stderr,"DOESCFA assignment failed, use ITC instead of DTC\n"); exit(1); \
179: } \
180: DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \
181: })
182: /* this stores a call dodoes at addr */
1.1 anton 183: #endif
1.2 pazsan 184:
1.7 pazsan 185: #undef HAVE_LOG1P
186: #undef HAVE_RINT
187:
188: #ifdef FORCE_REG
189: #define IPREG asm("%r10")
190: #define SPREG asm("%r9")
191: #define RPREG asm("%r8")
192: #define LPREG asm("%r7")
193: #define CFAREG asm("%r6")
194: #define TOSREG asm("%r11")
195: #endif /* FORCE_REG */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>