Annotation of gforth/hppa.h, revision 1.8
1.1 anton 1: /*
1.7 pazsan 2: $Id: hppa.h,v 1.6 1994/12/14 16:15:28 anton Exp $
1.1 anton 3: Copyright 1992 by the ANSI figForth Development Group
4:
5: This is the machine-specific part for a HPPA running HP-UX
6: */
1.6 anton 7:
8: #if !defined(USE_TOS) && !defined(USE_NO_TOS)
9: #define USE_TOS
10: #endif
1.5 anton 11:
12: #ifndef INDIRECT_THREADED
13: #ifndef DIRECT_THREADED
14: #define DIRECT_THREADED
15: #endif
16: #endif
17:
1.2 pazsan 18: /* cache flush stuff */
19: #ifdef DIRECT_THREADED
20:
21: extern void * cacheflush(void *, int, int);
22: #ifdef DEBUG
23: # define CACHE_FLUSH(addr,size) \
24: ({ fprintf(stderr,"Flushing Cache at %08x:%08x\n",(int) addr, size); \
25: fflush(stderr); \
26: fprintf(stderr,"Cache flushed, final address: %08x\n", \
27: (int)cacheflush((void *)(addr), (int)(size), 32)); })
1.3 pazsan 28: #else
1.2 pazsan 29: # define CACHE_FLUSH(addr,size) \
30: ({ (void)cacheflush((void *)(addr), (int)(size), 32); })
31: # endif
32: #endif
1.1 anton 33:
1.5 anton 34: #include "32bit.h"
1.2 pazsan 35:
1.1 anton 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: /* the improvement here is that we may destroy cfa before using PFA1 */
1.2 pazsan 41: # define PFA1(cfa) PFA(cfa)
1.1 anton 42: /* HPPA uses register 2 for branch and link */
43:
44: /* CODE_ADDRESS is the address of the code jumped to through the code field */
1.2 pazsan 45:
1.1 anton 46: /* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
47: /* we use ble and a register, since 'bl' only has 21 bits displacement */
48: #endif
1.2 pazsan 49:
1.1 anton 50: #ifdef DIRECT_THREADED
1.2 pazsan 51:
1.3 pazsan 52: # ifdef DEBUG
53: # define DOUT(a,b,c,d) fprintf(stderr,a,b,c,d)
54: # else
55: # define DOUT(a,b,c,d)
56: # endif
1.2 pazsan 57:
58: # define ASS17(n)(((((n) >> 13) & 0x1F) << 16)| /* first 5 bits */ \
59: ((((n) >> 2) & 0x3FF) << 3)| /* second 11 bits */ \
60: ((((n) >> 12) & 0x1) << 2) | /* lo sign (arg!) */ \
61: (((n) < 0) << 0)) /* sign bit */
62:
63: # define DIS17(n)(((((n) >> 16) & 0x1F) << 13)| /* first 5 bits */ \
64: ((((n) >> 3) & 0x3FF) << 2)| /* second 11 bits */ \
65: ((((n) >> 2) & 0x1) << 12) | /* lo sign (arg!) */ \
66: (-((n) & 1) << 18)) /* sign bit */
67:
68: # define CODE_ADDRESS(cfa) ((Label)({ \
69: unsigned int *_cfa=(unsigned int *)(cfa); unsigned _ca; \
70: if((_cfa[0] & 0xFFE0E002) == 0xE8000000) /* relative branch */ \
71: { \
72: _ca = _cfa[0]; \
73: _ca = DIS17(_ca); \
74: _ca += (int) (_cfa + 2); \
75: } \
76: else if((_cfa[0] & 0xFFE0E002) == 0xE0000000) /* absolute branch */ \
77: { \
78: _ca = _cfa[0]; \
79: _ca = DIS17(_ca); \
80: } \
81: else \
82: { \
83: _ca = _cfa[0]; \
84: _ca = (_ca<<31) | \
85: ((_ca>>1 ) & 0x00001800) | \
86: ((_ca>>3 ) & 0x0003E000) | \
87: ((_ca<<4 ) & 0x000C0000) | \
88: ((_ca<<19) & 0x7FF00000) | \
89: ((_cfa[1]>>1) & 0xFFC); \
90: } \
91: /* printf("code-address at %08x: %08x\n",_ca,_cfa); */ \
92: _ca; \
93: }))
94:
95: # define MAKE_CF(cfa,ca) \
96: ({ \
97: long *_cfa = (long *)(cfa); \
1.3 pazsan 98: int _ca = (int)(ca)+4; \
1.2 pazsan 99: int _dp = _ca-(int)(_cfa+2); \
100: \
101: if(_ca < 0x40000) /* Branch absolute */ \
102: { \
103: _cfa[0] =((0x38 << 26) | /* major opcode */ \
104: ( 0 << 21) | /* register */ \
105: ( 0 << 13) | /* space register */ \
106: ( 0 << 1))| /* if 1, don't execute delay slot */ \
107: ASS17(_ca); \
1.3 pazsan 108: _cfa[1] = ((long *)(_ca))[-1]; /* or %r0,%r0,%r0 */; \
1.2 pazsan 109: } \
110: else if(_dp < 0x40000 || _dp >= -0x40000) \
111: { \
112: _cfa[0] =((0x3A << 26) | /* major opcode */ \
113: ( 0 << 21) | /* register */ \
114: ( 0 << 13) | /* space register */ \
115: ( 0 << 1))| /* if 1, don't execute delay slot */ \
116: ASS17(_dp); \
1.3 pazsan 117: _cfa[1] = ((long *)(_ca))[-1]; /* 0x08000240 or %r0,%r0,%r0 */; \
1.2 pazsan 118: } \
119: else \
120: { \
1.3 pazsan 121: _ca -= 4; \
1.2 pazsan 122: _cfa[0] = (0x08 << 26) | \
123: ((int)_ca<0) | \
124: (_ca & 0x00001800)<<1 | \
125: (_ca & 0x0003E000)<<3 | \
126: (_ca & 0x000C0000)>>4 | \
127: (_ca & 0x7FF00000)>>19; \
128: _ca &= 0x3FF; \
129: _cfa[1] =((0x38 << 26) | /* major opcode */ \
130: ( 1 << 21) | /* register */ \
131: ( 0 << 13) | /* space register */ \
132: ( 1 << 1))| /* if 1, don't execute delay slot */ \
133: ASS17(_ca); \
134: } \
135: DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \
136: })
1.1 anton 137: /* HP wins the price for the most obfuscated binary opcode */
138:
139: /* this is the point where the does code starts if label points to the
140: * jump dodoes */
141:
1.3 pazsan 142: # define DOES_CODE(cfa) ((Xt *)(((long *)(cfa))[1]))
1.1 anton 143:
144: /* this is a special version of DOES_CODE for use in dodoes */
1.2 pazsan 145: # define DOES_CODE1(cfa) DOES_CODE(cfa) \
146: /* ({register Xt * _ret asm("%r31"); _ret;}) */
147:
1.1 anton 148: /* HPPA uses register 2 for branch and link */
149:
1.2 pazsan 150: # define DOES_HANDLER_SIZE 8
1.3 pazsan 151: # define MAKE_DOES_HANDLER(cfa) ({ *(long *)(cfa)=DODOES; })
152: #ifdef undefined
1.2 pazsan 153: # define MAKE_DOES_HANDLER(cfa) \
154: ({ \
155: long *_cfa = (long *)(cfa); \
156: int _ca = (int)symbols[DODOES]; \
157: int _dp = _ca-(int)(_cfa+2); \
158: \
159: if(_ca < 0x40000) /* Branch absolute */ \
160: { \
161: _cfa[0] =((0x38 << 26) | /* major opcode */ \
162: ( 0 << 21) | /* register */ \
163: ( 0 << 13) | /* space register */ \
164: ( 0 << 1))| /* if 1, don't execute delay slot */ \
165: ASS17(_ca); \
166: _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \
167: } \
168: else if(_dp < 0x40000 || _dp >= -0x40000) \
169: { \
170: _cfa[0] =((0x3A << 26) | /* major opcode */ \
171: ( 0 << 21) | /* register */ \
172: ( 0 << 13) | /* space register */ \
173: ( 0 << 1))| /* if 1, don't execute delay slot */ \
174: ASS17(_dp); \
175: _cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \
176: } \
177: else \
178: { \
179: fprintf(stderr,"DOESHANDLER assignment failed, use ITC instead of DTC\n"); exit(1); \
180: _cfa[0] = (0x08 << 26) | \
181: ((int)_ca<0) | \
182: (_ca & 0x00001800)<<1 | \
183: (_ca & 0x0003E000)<<3 | \
184: (_ca & 0x000C0000)>>4 | \
185: (_ca & 0x7FF00000)>>19; \
186: _ca &= 0x3FF; \
187: _cfa[1] =((0x38 << 26) | /* major opcode */ \
188: ( 1 << 21) | /* register */ \
189: ( 0 << 13) | /* space register */ \
190: ( 1 << 1))| /* if 1, don't execute delay slot */ \
191: ASS17(_ca); \
192: } \
193: DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \
194: })
1.3 pazsan 195: #endif
1.2 pazsan 196:
197: # define MAKE_DOES_CF(cfa,ca) \
198: ({ \
199: long *_cfa = (long *)(cfa); \
1.3 pazsan 200: int _ca = (int)symbols[DODOES]; \
1.2 pazsan 201: int _dp = _ca-(int)(_cfa+2); \
202: \
1.3 pazsan 203: if(_ca < 0x40000) /* Branch absolute */ \
1.2 pazsan 204: { \
1.3 pazsan 205: _cfa[0] =((0x38 << 26) | /* major opcode */ \
1.2 pazsan 206: ( 0 << 21) | /* register */ \
207: ( 0 << 13) | /* space register */ \
1.3 pazsan 208: ( 1 << 1))| /* if 1, don't execute delay slot */ \
209: ASS17(_ca); \
210: _cfa[1] = (long)(ca); \
1.2 pazsan 211: } \
1.3 pazsan 212: else if(_dp < 0x40000 || _dp >= -0x40000) \
1.2 pazsan 213: { \
1.3 pazsan 214: _cfa[0] =((0x3A << 26) | /* major opcode */ \
1.2 pazsan 215: ( 0 << 21) | /* register */ \
216: ( 0 << 13) | /* space register */ \
1.3 pazsan 217: ( 1 << 1))| /* if 1, don't execute delay slot */ \
218: ASS17(_dp); \
219: _cfa[1] = (long)(ca); \
1.2 pazsan 220: } \
221: else \
222: { \
1.3 pazsan 223: fprintf(stderr,"DOESCFA assignment failed, use ITC instead of DTC\n"); exit(1); \
1.2 pazsan 224: } \
225: DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \
226: })
1.1 anton 227: /* this stores a call dodoes at addr */
228: #endif
1.2 pazsan 229:
1.7 pazsan 230: #undef HAVE_LOG1P
231: #undef HAVE_RINT
232:
233: #ifdef FORCE_REG
234: #define IPREG asm("%r10")
235: #define SPREG asm("%r9")
236: #define RPREG asm("%r8")
237: #define LPREG asm("%r7")
238: #define CFAREG asm("%r6")
239: #define TOSREG asm("%r11")
240: #endif /* FORCE_REG */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>