--- gforth/arch/alpha/machine.h 1998/12/08 22:02:54 1.3 +++ gforth/arch/alpha/machine.h 2000/09/23 15:47:02 1.9 @@ -1,6 +1,6 @@ -/* preliminary machine file for DEC Alpha +/* DEC Alpha - Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc. + Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc. This file is part of Gforth. @@ -16,11 +16,14 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. */ /* Be careful: long long on Alpha are 64 bit :-(( */ -#define LONG_LATENCY + +#ifndef THREADING_SCHEME +#define THREADING_SCHEME 5 +#endif #if !defined(USE_TOS) && !defined(USE_NO_TOS) #define USE_TOS @@ -97,7 +100,10 @@ typedef short Int16; code gcc produces for the cpu_dep routine. */ -#define CPU_DEP2 register Label _alpha_docol asm("$9")=&&docol; \ +/* if you change this, also change _DOCOL_LABEL below */ +#define DO_BASE (&&docol) + +#define CPU_DEP2 register Label _alpha_docol asm("$9")=DO_BASE; \ register Label _alpha_ca; #define CPU_DEP3 cpu_dep: asm("lda %0, 500(%1)":"=r"(_alpha_ca):"r"(_alpha_docol)); goto *_alpha_ca; @@ -106,31 +112,35 @@ typedef short Int16; /* CODE_ADDRESS is the address of the code jumped to through the code field */ -#define CODE_ADDRESS(wa) ({Int32 *_wa=(Int32 *)(wa); \ - (_wa[0]&0xfc000000)==0x68000000 ? /*JMP?*/\ - &&docol : \ - &&docol+((Int16 *)_wa)[0]; }) +#define CODE_ADDRESS(wa) ({ \ + Int32 *_wa=(Int32 *)(wa); \ + (_wa[0]&0xfc000000)==0x68000000 ? /*JMP?*/\ + DO_BASE : \ + ((((_wa[0]^((Int32 *)_CPU_DEP_LABEL)[0]) & 0xffff0000)==0 && \ + ((_wa[1]^((Int32 *)_CPU_DEP_LABEL)[1]) & 0xffffc000)==0 ) ? \ + (DO_BASE+((Int16 *)_wa)[0]) : \ + (Label)_wa); }) #define _CPU_DEP_LABEL (symbols[DOESJUMP]) #define _DOCOL_LABEL (symbols[DOCOL]) /* MAKE_CF creates an appropriate code field at the wa; ca is the code address. For the Alpha, this is a lda followed by a jmp (or just a - jmp, if ca==&&docol). We patch the jmp with a good hint (on the + jmp, if ca==DO_BASE). We patch the jmp with a good hint (on the 21064A this saves 5 cycles!) */ #define MAKE_CF(wa,ca) ({ \ - Int32 *_wa=(Int32 *)(wa); \ - Label _ca=(Label)(ca); \ - if (_ca==_DOCOL_LABEL) \ - _wa[0]=(((0x1a<<26)|(31<<21)|(9<<16))| \ - (((((Cell)_ca)-((Cell)_wa)-4) & 0xffff)>>2)); \ - else { \ - _wa[0]=((((Int32 *)_CPU_DEP_LABEL)[0] & 0xffff0000)| \ - ((((Cell)_ca)-((Cell)_DOCOL_LABEL)) & 0xffff)); \ - _wa[1]=((((Int32 *)_CPU_DEP_LABEL)[1] & 0xffffc000)| \ - (((((Cell)_ca)-((Cell)_wa)-8) & 0xffff)>>2)); \ - } \ - }) + Int32 *_wa=(Int32 *)(wa); \ + Label _ca=(Label)(ca); \ + if (_ca==_DOCOL_LABEL) \ + _wa[0]=(((0x1a<<26)|(31<<21)|(9<<16))| \ + (((((Cell)_ca)-((Cell)_wa)-4) & 0xffff)>>2)); \ + else { \ + _wa[0]=((((Int32 *)_CPU_DEP_LABEL)[0] & 0xffff0000)| \ + ((((Cell)_ca)-((Cell)_DOCOL_LABEL)) & 0xffff)); \ + _wa[1]=((((Int32 *)_CPU_DEP_LABEL)[1] & 0xffffc000)| \ + (((((Cell)_ca)-((Cell)_wa)-8) & 0xffff)>>2)); \ + } \ + }) /* this is the point where the does code for the word with the xt cfa starts. Because the jump to the code field takes only one cell on @@ -139,7 +149,7 @@ typedef short Int16; #define DOES_CODE(cfa) \ ({ Int32 *_wa=(cfa); \ (_wa[0] == ((((Int32 *)_CPU_DEP_LABEL)[0] & 0xffff0000)| \ - ((((Cell)&&dodoes)-((Cell)&&docol)) & 0xffff)) && \ + ((((Cell)&&dodoes)-((Cell)DO_BASE)) & 0xffff)) && \ (_wa[1]&0xffffc000) == (((Int32 *)_CPU_DEP_LABEL)[1] & 0xffffc000)) \ ? DOES_CODE1(_wa) : 0; }) @@ -149,7 +159,7 @@ typedef short Int16; /* the does handler resides between DOES> and the following Forth code. Since the code-field jumps directly to dodoes, the does-handler is not needed for the Alpha architecture */ -#define MAKE_DOES_HANDLER(addr) 0 +#define MAKE_DOES_HANDLER(addr) ((void)0) /* This makes a code field for a does-defined word. doesp is the address of the does-code. On the Alpha, the code field consists of @@ -159,3 +169,13 @@ typedef short Int16; _cfa[1] = (doesp); }) #endif +#ifdef FORCE_REG +/* $9-$14 are callee-saved, $1-$8 and $22-$25 are caller-saved */ +#define IPREG asm("$10") +#define SPREG asm("$11") +#define RPREG asm("$12") +#define LPREG asm("$13") +#define TOSREG asm("$14") +/* #define CFAREG asm("$22") egcs-1.0.3 crashes with any caller-saved + register decl */ +#endif /* FORCE_REG */