[gforth] / gforth / Attic / sparc.h  

gforth: gforth/Attic/sparc.h


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

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help