version 1.1, 1994/02/11 16:30:46
|
version 1.2, 1994/09/26 20:31:13
|
Line 4
|
Line 4
|
|
|
This is the machine-specific part for a HPPA running HP-UX |
This is the machine-specific part for a HPPA running HP-UX |
*/ |
*/ |
|
/* cache flush stuff */ |
|
|
|
#ifdef DIRECT_THREADED |
|
|
|
extern void * cacheflush(void *, int, int); |
|
#ifdef DEBUG |
|
# define CACHE_FLUSH(addr,size) \ |
|
({ fprintf(stderr,"Flushing Cache at %08x:%08x\n",(int) addr, size); \ |
|
fflush(stderr); \ |
|
fprintf(stderr,"Cache flushed, final address: %08x\n", \ |
|
(int)cacheflush((void *)(addr), (int)(size), 32)); }) |
|
# else |
|
/* |
|
# define CACHE_FLUSH(addr,size) \ |
|
({ fprintf(stderr,"Flushing Cache at %08x:%08x\n",(int) addr, size); \ |
|
fflush(stderr); \ |
|
fprintf(stderr,"Cache flushed, final address: %08x\n", \ |
|
(int)cacheflush((void *)(addr), (int)(size), 32)); }) |
|
*/ |
|
# define CACHE_FLUSH(addr,size) \ |
|
({ (void)cacheflush((void *)(addr), (int)(size), 32); }) |
|
|
|
# endif |
|
#endif |
|
|
|
|
/* Cell and UCell must be the same size as a pointer */ |
/* Cell and UCell must be the same size as a pointer */ |
Line 31 typedef float SFloat;
|
Line 55 typedef float SFloat;
|
# define PFA(cfa) (((Cell *)cfa)+2) |
# define PFA(cfa) (((Cell *)cfa)+2) |
/* PFA1 is a special version for use just after a NEXT1 */ |
/* PFA1 is a special version for use just after a NEXT1 */ |
/* the improvement here is that we may destroy cfa before using PFA1 */ |
/* the improvement here is that we may destroy cfa before using PFA1 */ |
# define PFA1(cfa) /* PFA(cfa) */ \ |
# define PFA1(cfa) PFA(cfa) |
({register volatile Cell *pfa asm("%31"); \ |
|
((int)pfa & (-4)); }) |
|
/* HPPA uses register 2 for branch and link */ |
/* HPPA uses register 2 for branch and link */ |
|
|
/* CODE_ADDRESS is the address of the code jumped to through the code field */ |
/* CODE_ADDRESS is the address of the code jumped to through the code field */ |
# define CODE_ADDRESS(cfa) ((Label)((*(unsigned *)(cfa))/* <<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 */ |
/* we use ble and a register, since 'bl' only has 21 bits displacement */ |
/* we use ble and a register, since 'bl' only has 21 bits displacement */ |
#endif |
#endif |
|
|
|
#ifdef undefined |
#define MAKE_CFA(cfa,ca) ({long *_cfa = (long *)(cfa); \ |
#define MAKE_CFA(cfa,ca) ({long *_cfa = (long *)(cfa); \ |
unsigned _ca = (unsigned)(ca); \ |
unsigned _ca = (unsigned)(ca); \ |
_cfa[0] = 0xE4A02000 | ((_ca+4-symbols[0]) & 0x7FC)<<1 ; \ |
_cfa[0] = 0xE4A02000 | (((int)_ca+4-(int)symbols[0]) & 0x7FC)<<1 ; \ |
_cfa[1] = *(long *)(_ca); \ |
_cfa[1] = *(long *)(_ca); \ |
/* printf("%08x:%08x,%08x\n",_cfa,_cfa[0],_cfa[1]); */ \ |
/* printf("%08x:%08x,%08x\n",_cfa,_cfa[0],_cfa[1]); */ \ |
}) |
}) |
|
#endif |
|
|
#ifdef DIRECT_THREADED |
#ifdef DIRECT_THREADED |
# define MAKE_CF(cfa,ca) MAKE_CFA(cfa,ca) |
|
/* |
#ifdef DEBUG |
#define MAKE_CF(cfa,ca) ({long *_cfa = (long *)(cfa); \ |
# define DOUT(a,b,c,d) fprintf(stderr,a,b,c,d) |
unsigned _ca = (unsigned)(ca); \ |
#else |
if((_ca-(int)(_cfa+1)>=-0x40000)||(_ca-(int)(_cfa+1)<0x40000)) \ |
# define DOUT(a,b,c,d) |
{ \ |
#endif |
_cfa[1] = *(long *)(_ca); \ |
|
_ca = _ca-(int)(_cfa+1); \ |
# define ASS17(n)(((((n) >> 13) & 0x1F) << 16)| /* first 5 bits */ \ |
_cfa[0] = 0xEBE00000 | \ |
((((n) >> 2) & 0x3FF) << 3)| /* second 11 bits */ \ |
((int)_ca<0) | \ |
((((n) >> 12) & 0x1) << 2) | /* lo sign (arg!) */ \ |
(_ca & 0x00FFC)<<1 | \ |
(((n) < 0) << 0)) /* sign bit */ |
(_ca & 0x01000)>>10 | \ |
|
(_ca & 0x3E000)<<3; \ |
# define DIS17(n)(((((n) >> 16) & 0x1F) << 13)| /* first 5 bits */ \ |
} \ |
((((n) >> 3) & 0x3FF) << 2)| /* second 11 bits */ \ |
else \ |
((((n) >> 2) & 0x1) << 12) | /* lo sign (arg!) */ \ |
{ \ |
(-((n) & 1) << 18)) /* sign bit */ |
_cfa[0] = 0x20200000 | \ |
|
((int)_ca<0) | \ |
# define CODE_ADDRESS(cfa) ((Label)({ \ |
(_ca & 0x00001800)<<1 | \ |
unsigned int *_cfa=(unsigned int *)(cfa); unsigned _ca; \ |
(_ca & 0x0003E000)<<3 | \ |
if((_cfa[0] & 0xFFE0E002) == 0xE8000000) /* relative branch */ \ |
(_ca & 0x000C0000)>>4 | \ |
{ \ |
(_ca & 0x7FF00000)>>19 \ |
_ca = _cfa[0]; \ |
_cfa[1] = 0xE4202002 | (_ca & 0x7FC)<<1 ; \ |
_ca = DIS17(_ca); \ |
}}) |
_ca += (int) (_cfa + 2); \ |
*/ |
} \ |
|
else if((_cfa[0] & 0xFFE0E002) == 0xE0000000) /* absolute branch */ \ |
|
{ \ |
|
_ca = _cfa[0]; \ |
|
_ca = DIS17(_ca); \ |
|
} \ |
|
else \ |
|
{ \ |
|
_ca = _cfa[0]; \ |
|
_ca = (_ca<<31) | \ |
|
((_ca>>1 ) & 0x00001800) | \ |
|
((_ca>>3 ) & 0x0003E000) | \ |
|
((_ca<<4 ) & 0x000C0000) | \ |
|
((_ca<<19) & 0x7FF00000) | \ |
|
((_cfa[1]>>1) & 0xFFC); \ |
|
} \ |
|
/* printf("code-address at %08x: %08x\n",_ca,_cfa); */ \ |
|
_ca; \ |
|
})) |
|
|
|
# define MAKE_CF(cfa,ca) \ |
|
({ \ |
|
long *_cfa = (long *)(cfa); \ |
|
int _ca = (int)(ca); \ |
|
int _dp = _ca-(int)(_cfa+2); \ |
|
\ |
|
if(_ca < 0x40000) /* Branch absolute */ \ |
|
{ \ |
|
_cfa[0] =((0x38 << 26) | /* major opcode */ \ |
|
( 0 << 21) | /* register */ \ |
|
( 0 << 13) | /* space register */ \ |
|
( 0 << 1))| /* if 1, don't execute delay slot */ \ |
|
ASS17(_ca); \ |
|
_cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \ |
|
} \ |
|
else if(_dp < 0x40000 || _dp >= -0x40000) \ |
|
{ \ |
|
_cfa[0] =((0x3A << 26) | /* major opcode */ \ |
|
( 0 << 21) | /* register */ \ |
|
( 0 << 13) | /* space register */ \ |
|
( 0 << 1))| /* if 1, don't execute delay slot */ \ |
|
ASS17(_dp); \ |
|
_cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \ |
|
} \ |
|
else \ |
|
{ \ |
|
_cfa[0] = (0x08 << 26) | \ |
|
((int)_ca<0) | \ |
|
(_ca & 0x00001800)<<1 | \ |
|
(_ca & 0x0003E000)<<3 | \ |
|
(_ca & 0x000C0000)>>4 | \ |
|
(_ca & 0x7FF00000)>>19; \ |
|
_ca &= 0x3FF; \ |
|
_cfa[1] =((0x38 << 26) | /* major opcode */ \ |
|
( 1 << 21) | /* register */ \ |
|
( 0 << 13) | /* space register */ \ |
|
( 1 << 1))| /* if 1, don't execute delay slot */ \ |
|
ASS17(_ca); \ |
|
} \ |
|
DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \ |
|
}) |
/* HP wins the price for the most obfuscated binary opcode */ |
/* HP wins the price for the most obfuscated binary opcode */ |
|
|
/* this is the point where the does code starts if label points to the |
/* this is the point where the does code starts if label points to the |
* jump dodoes */ |
* jump dodoes */ |
|
|
# define DOES_CODE(label) (((Xt *)(label))+2) |
# define DOES_CODE(cfa) ((Xt *)(((char *)CODE_ADDRESS(cfa))+8)) |
|
|
/* this is a special version of DOES_CODE for use in dodoes */ |
/* this is a special version of DOES_CODE for use in dodoes */ |
# define DOES_CODE1(label) ({register volatile Xt *_does_code asm("%31"); \ |
# define DOES_CODE1(cfa) DOES_CODE(cfa) \ |
(Xt *)((int)_does_code & (-4)); }) |
/* ({register Xt * _ret asm("%r31"); _ret;}) */ |
|
|
/* HPPA uses register 2 for branch and link */ |
/* HPPA uses register 2 for branch and link */ |
|
|
|
# define DOES_HANDLER_SIZE 8 |
|
# define MAKE_DOES_HANDLER(cfa) \ |
|
({ \ |
|
long *_cfa = (long *)(cfa); \ |
|
int _ca = (int)symbols[DODOES]; \ |
|
int _dp = _ca-(int)(_cfa+2); \ |
|
\ |
|
if(_ca < 0x40000) /* Branch absolute */ \ |
|
{ \ |
|
_cfa[0] =((0x38 << 26) | /* major opcode */ \ |
|
( 0 << 21) | /* register */ \ |
|
( 0 << 13) | /* space register */ \ |
|
( 0 << 1))| /* if 1, don't execute delay slot */ \ |
|
ASS17(_ca); \ |
|
_cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \ |
|
} \ |
|
else if(_dp < 0x40000 || _dp >= -0x40000) \ |
|
{ \ |
|
_cfa[0] =((0x3A << 26) | /* major opcode */ \ |
|
( 0 << 21) | /* register */ \ |
|
( 0 << 13) | /* space register */ \ |
|
( 0 << 1))| /* if 1, don't execute delay slot */ \ |
|
ASS17(_dp); \ |
|
_cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \ |
|
} \ |
|
else \ |
|
{ \ |
|
fprintf(stderr,"DOESHANDLER assignment failed, use ITC instead of DTC\n"); exit(1); \ |
|
_cfa[0] = (0x08 << 26) | \ |
|
((int)_ca<0) | \ |
|
(_ca & 0x00001800)<<1 | \ |
|
(_ca & 0x0003E000)<<3 | \ |
|
(_ca & 0x000C0000)>>4 | \ |
|
(_ca & 0x7FF00000)>>19; \ |
|
_ca &= 0x3FF; \ |
|
_cfa[1] =((0x38 << 26) | /* major opcode */ \ |
|
( 1 << 21) | /* register */ \ |
|
( 0 << 13) | /* space register */ \ |
|
( 1 << 1))| /* if 1, don't execute delay slot */ \ |
|
ASS17(_ca); \ |
|
} \ |
|
DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \ |
|
}) |
|
|
|
# define MAKE_DOES_CF(cfa,ca) \ |
|
({ \ |
|
long *_cfa = (long *)(cfa); \ |
|
int _ca = (int)(ca)-DOES_HANDLER_SIZE; \ |
|
int _dp = _ca-(int)(_cfa+2); \ |
|
\ |
|
if(_dp < 0x40000 || _dp >= -0x40000) \ |
|
{ \ |
|
_cfa[0] = (0x3A << 26) | /* major opcode */ \ |
|
( 0 << 21) | /* register */ \ |
|
( 0 << 13) | /* space register */ \ |
|
( 0 << 1) | /* if 1, don't execute delay slot */ \ |
|
ASS17(_dp); \ |
|
_cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \ |
|
} \ |
|
else if(_ca < 0x40000) /* Branch absolute */ \ |
|
{ \ |
|
_cfa[0] = (0x38 << 26) | /* major opcode */ \ |
|
( 0 << 21) | /* register */ \ |
|
( 0 << 13) | /* space register */ \ |
|
( 0 << 1) | /* if 1, don't execute delay slot */ \ |
|
ASS17(_ca); \ |
|
_cfa[1] = 0x08000240 /* or %r0,%r0,%r0 */; \ |
|
} \ |
|
else \ |
|
{ \ |
|
_cfa[0] = (0x08 << 26) | \ |
|
((int)_ca<0) | \ |
|
(_ca & 0x00001800)<<1 | \ |
|
(_ca & 0x0003E000)<<3 | \ |
|
(_ca & 0x000C0000)>>4 | \ |
|
(_ca & 0x7FF00000)>>19; \ |
|
_ca &= 0x3FF; \ |
|
_cfa[1] = (0x38 << 26) | /* major opcode */ \ |
|
( 1 << 21) | /* register */ \ |
|
( 0 << 13) | /* space register */ \ |
|
( 1 << 1) | /* if 1, don't execute delay slot */ \ |
|
ASS17(_ca); \ |
|
} \ |
|
DOUT("%08x: %08x,%08x\n",(int)_cfa,_cfa[0],_cfa[1]); \ |
|
}) |
/* this stores a call dodoes at addr */ |
/* this stores a call dodoes at addr */ |
# define MAKE_DOESJUMP(addr) MAKE_CFA((addr),symbols[3]) |
|
#endif |
#endif |
|
|
/* OS dependences */ |
/* OS dependences */ |
Line 95 typedef float SFloat;
|
Line 265 typedef float SFloat;
|
#define SEEK_SET 0 |
#define SEEK_SET 0 |
#define rint(x) floor((x)+0.5) |
#define rint(x) floor((x)+0.5) |
|
|
#ifdef DIRECT_THREADED |
|
# define CPU_DEP register Label branchto asm("%5")=symbols[0]; |
|
# define CPU_DEP2 &&deadcode |
|
# define CPU_DEP3 deadcode: return((Label *)branchto); |
|
#endif |
|