version 1.1, 1994/12/12 17:10:47
|
version 1.7, 1996/07/26 15:28:29
|
Line 1
|
Line 1
|
/* |
/* This is the machine-specific part for MIPS R[2346810]000 processors |
Copyright 1992 by the ANSI figForth Development Group |
|
|
Copyright (C) 1995 Free Software Foundation, Inc. |
|
|
|
This file is part of Gforth. |
|
|
|
Gforth is free software; you can redistribute it and/or |
|
modify it under the terms of the GNU General Public License |
|
as published by the Free Software Foundation; either version 2 |
|
of the License, or (at your option) any later version. |
|
|
This is the machine-specific part for MIPS R[2346810]000 processors |
This program is distributed in the hope that it will be useful, |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
GNU General Public License for more details. |
|
|
|
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. |
*/ |
*/ |
|
|
|
#if !defined(USE_TOS) && !defined(USE_NO_TOS) |
|
/* on the mips this is a mixed blessing, since defining this spills |
|
the rp with some gcc versions. This machine has 31 regs, yet that's |
|
not enough for gcc-2.4.5 :-( */ |
|
#define USE_TOS |
|
#endif |
|
|
/* cache flush stuff */ |
/* cache flush stuff */ |
|
|
#ifndef INDIRECT_THREADED |
#ifndef INDIRECT_THREADED |
Line 12
|
Line 35
|
#endif |
#endif |
#endif |
#endif |
|
|
#ifdef DIRECT_THREADED |
#ifdef ultrix |
|
|
/* this works on Ultrix. Let's hope it works on others, too */ |
|
#include <mips/cachectl.h> |
#include <mips/cachectl.h> |
|
#else |
|
/* works on Irix */ |
|
#include <sys/cachectl.h> |
|
#endif |
|
|
#define CACHE_FLUSH(addr,size) \ |
#define FLUSH_ICACHE(addr,size) \ |
cacheflush((char *)(addr), (int)(size), BCACHE) |
cacheflush((char *)(addr), (int)(size), BCACHE) |
|
|
#endif |
|
|
|
#include "32bit.h" |
#include "32bit.h" |
|
|
#ifdef DIRECT_THREADED |
#ifdef DIRECT_THREADED |
Line 32
|
Line 55
|
/* this provides the first 4 bits of a jump address, i.e. it must be <16 */ |
/* this provides the first 4 bits of a jump address, i.e. it must be <16 */ |
#define SEGMENT_NUM 1 |
#define SEGMENT_NUM 1 |
|
|
|
#define JUMP(addr) (J_PATTERN|((((unsigned)(addr))&JUMP_MASK)>>2)) |
|
#define CALL(addr) (JAL_PATTERN|((((unsigned)(addr))&JUMP_MASK)>>2)) |
|
|
/* PFA gives the parameter field address corresponding to a cfa */ |
/* PFA gives the parameter field address corresponding to a cfa */ |
# define PFA(cfa) (((Cell *)cfa)+2) |
# define PFA(cfa) (((Cell *)cfa)+2) |
Line 41
|
Line 66
|
# define CODE_ADDRESS(cfa) ((Label)(((*(unsigned *)(cfa))^J_PATTERN^(SEGMENT_NUM<<26))<<2)) |
# define CODE_ADDRESS(cfa) ((Label)(((*(unsigned *)(cfa))^J_PATTERN^(SEGMENT_NUM<<26))<<2)) |
/* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */ |
/* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */ |
# define MAKE_CF(cfa,ca) ({long * _cfa = (long *)(cfa); \ |
# define MAKE_CF(cfa,ca) ({long * _cfa = (long *)(cfa); \ |
_cfa[0] = J_PATTERN|((((long)(ca))&JUMP_MASK)>>2); /* J ca */ \ |
_cfa[0] = JUMP(ca); \ |
_cfa[1] = 0; /* nop */}) |
_cfa[1] = 0; /* nop */}) |
# ifdef undefined |
# ifdef undefined |
/* the following version uses JAL to make PFA1 faster */ |
/* the following version uses JAL to make PFA1 faster */ |
Line 51
|
Line 76
|
# define CODE_ADDRESS(cfa) ((Label)(((*(unsigned *)(cfa))^JAL_PATTERN^(SEGMENT_NUM<<26))<<2)) |
# define CODE_ADDRESS(cfa) ((Label)(((*(unsigned *)(cfa))^JAL_PATTERN^(SEGMENT_NUM<<26))<<2)) |
# define MAKE_CF(cfa,ca) ({long *_cfa = (long *)(cfa); \ |
# define MAKE_CF(cfa,ca) ({long *_cfa = (long *)(cfa); \ |
long _ca = (long)(ca); \ |
long _ca = (long)(ca); \ |
_cfa[0] = JAL_PATTERN|(((((long)_ca)>>2))&JUMP_MASK); /* JAL ca+4 */ \ |
_cfa[0] = CALL(_ca); \ |
_cfa[1] = 0; /* *(long *)_ca; delay slot */}) |
_cfa[1] = 0; /* *(long *)_ca; delay slot */}) |
# endif /* undefined */ |
# endif /* undefined */ |
|
|
/* this is the point where the does code starts if label points to the |
/* this is the point where the does code starts if cfa points to a |
* jump dodoes */ |
code field of a does>-defined word */ |
# define DOES_CODE(cfa) ((Xt *)(((char *)CODE_ADDRESS(cfa))+8)) |
#define DOES_CODE(cfa) \ |
|
({ Xt _cfa=(Xt)(cfa); \ |
|
Label _ca=CODE_ADDRESS(_cfa); \ |
|
((*(unsigned *)_cfa)&(~JUMP_MASK)) == J_PATTERN && \ |
|
(*(unsigned *)_ca) == JUMP(symbols[DODOES]) \ |
|
? _ca+DOES_HANDLER_SIZE : 0; }) |
|
|
|
|
|
/* this is a special version of DOES_CODE for use in dodoes */ |
|
#define DOES_CODE1(cfa) ((Xt *)(((char *)CODE_ADDRESS(cfa))+DOES_HANDLER_SIZE)) |
|
|
/* this is a special version of DOES_CODE for use in dodoes */ |
|
# define DOES_CODE1(cfa) DOES_CODE(cfa) |
|
|
|
# define DOES_HANDLER_SIZE 8 |
# define DOES_HANDLER_SIZE 8 |
# define MAKE_DOES_CF(cfa,does_code) \ |
# define MAKE_DOES_CF(cfa,does_code) \ |
({long does_handlerp=((long)(does_code))-DOES_HANDLER_SIZE; \ |
({long does_handlerp=((long)(does_code))-DOES_HANDLER_SIZE; \ |
long *_cfa = (long*)(cfa); \ |
long *_cfa = (long*)(cfa); \ |
_cfa[0] = J_PATTERN|((does_handlerp&JUMP_MASK)>>2); /* J ca */ \ |
_cfa[0] = JUMP(does_handlerp); \ |
_cfa[1] = 0; /* nop */}) |
_cfa[1] = 0; /* nop */}) |
/* |
/* |
# define MAKE_DOES_CF(cfa, does_code) ({char *does_handlerp=((char *)does_code)-DOES_HANDLER_SIZE; \ |
# define MAKE_DOES_CF(cfa, does_code) ({char *does_handlerp=((char *)does_code)-DOES_HANDLER_SIZE; \ |
Line 85
|
Line 117
|
*/ |
*/ |
|
|
#define MAKE_DOESJUMP(addr) ({long * _addr = (long *)addr; \ |
#define MAKE_DOESJUMP(addr) ({long * _addr = (long *)addr; \ |
_addr[0] = J_PATTERN|(((((long)symbols[DODOES])>>2)+4)&JUMP_MASK), /* J dodoes+4 */ \ |
_addr[0] = JUMP(((unsigned)symbols[DODOES])+4); \ |
_addr[1] = *(long *)symbols[DODOES]; /* delay */}) |
_addr[1] = *(long *)symbols[DODOES]; /* delay */}) |
|
|
/* the following version uses JAL to make DOES_CODE1 faster */ |
/* the following version uses JAL to make DOES_CODE1 faster */ |
Line 96
|
Line 128
|
#define DOES_CODE1(cfa) ({register Code *_does_code asm("$31"); \ |
#define DOES_CODE1(cfa) ({register Code *_does_code asm("$31"); \ |
_does_code; }) |
_does_code; }) |
#define MAKE_DOESJUMP(addr) ({long * _addr = (long *)addr; \ |
#define MAKE_DOESJUMP(addr) ({long * _addr = (long *)addr; \ |
_addr[0] = JAL_PATTERN|(((((long)symbols[DODOES])>>2)+4)&JUMP_MASK), /* JAL dodoes+4 */ \ |
_addr[0] = CALL(((long)symbols[DODOES])+4); |
_addr[1] = *(long *)symbols[DODOES]; /* delay */}) |
_addr[1] = *(long *)symbols[DODOES]; /* delay */}) |
|
|
#endif |
#endif |