Annotation of gforth/sparc.h, revision 1.8
1.1 anton 1: /*
1.8 ! anton 2: $Id: sparc.h,v 1.4 1994/12/14 16:15:33 anton Exp $
1.1 anton 3: Copyright 1992 by the ANSI figForth Development Group
4:
1.3 anton 5: This is the machine-specific part for a SPARC
1.1 anton 6: */
1.5 anton 7:
8: #include "32bit.h"
1.4 anton 9:
10: #if !defined(USE_TOS) && !defined(USE_NO_TOS)
11: #define USE_TOS
12: #endif
1.1 anton 13:
1.3 anton 14: /* direct threading is probably faster on the SPARC, but has it been
15: tested? Therefore, DIRECT_THREADED is not defined */
1.1 anton 16:
17: #ifdef DIRECT_THREADED
1.7 anton 18: #ifndef WORDS_BIGENDIAN
19: #error Direct threading only supported for big-endian machines.
20: /* little endian SPARCs still store instructions in big-endian format,
21: so you would have to reverse the instructions stores in the following
22: */
23: #endif
24:
25: /* according to the SPARC V9 architecture manual, we have to use flush,
26: but as V2.20 does not recognize the opcode */
27: /* assuming size = 8 */
28: #define CACHE_FLUSH(addr,size) \
1.8 ! anton 29: asm("iflush %0; iflush %0+4"::"r"(addr))
1.7 anton 30:
1.1 anton 31: /* PFA gives the parameter field address corresponding to a cfa */
32: #define PFA(cfa) (((Cell *)cfa)+2)
33: /* PFA1 is a special version for use just after a NEXT1 */
34: /* the improvement here is that we may destroy cfa before using PFA1 */
1.6 anton 35: #define PFA1(cfa) PFA(cfa)
36: #ifdef undefined
1.1 anton 37: #define PFA1(cfa) /* PFA(cfa) */ \
1.6 anton 38: ({register Cell *pfa asm("%o7"); \
1.1 anton 39: pfa+2; })
1.6 anton 40: #endif
1.1 anton 41: /* CODE_ADDRESS is the address of the code jumped to through the code field */
1.6 anton 42: #define CODE_ADDRESS(cfa) ({unsigned _cfa = (unsigned)(cfa); \
43: (Label)(_cfa+((*(unsigned *)_cfa)<<2));})
1.1 anton 44: /* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
45: /* we use call, since 'branch always' only has 22 bits displacement */
46: #define MAKE_CF(cfa,ca) ({long *_cfa = (long *)(cfa); \
47: unsigned _ca = (unsigned)(ca); \
1.6 anton 48: _cfa[0] = 0x40000000|((_ca+4-(unsigned)_cfa)>>2); /* CALL ca */ \
1.1 anton 49: _cfa[1] = *(long *)_ca; /* delay slot */})
50:
51: /* this is the point where the does code starts if label points to the
52: * jump dodoes */
1.6 anton 53: #define DOES_CODE(label) ((Xt *)(CODE_ADDRESS(label)+DOES_HANDLER_SIZE))
1.1 anton 54:
55: /* this is a special version of DOES_CODE for use in dodoes */
1.6 anton 56: #define DOES_CODE1(label) DOES_CODE(label)
57: #ifdef undefined
58: #define DOES_CODE1(label) ({register Xt *_does_code asm("%o7"); \
1.1 anton 59: _does_code+2; })
1.6 anton 60: #endif
1.1 anton 61:
62: /* this stores a call dodoes at addr */
1.6 anton 63: #define MAKE_DOES_HANDLER(addr) MAKE_CF(addr,symbols[DODOES])
64:
65: #define DOES_HANDLER_SIZE 8
66:
67: #define MAKE_DOES_CF(addr,doesp) ({long *_addr = (long *)(addr); \
68: unsigned _doesp = (unsigned)(doesp); \
69: _addr[0] = 0x40000000|((_doesp-8-(unsigned)_addr)>>2); /* CALL doesp-8 */ \
70: _addr[1] = 0x01000000; /* nop */})
1.3 anton 71: #endif
1.6 anton 72:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>