From 197d20aa966dfdb19dcf53e389b919d7d41796b0 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 20 Nov 2006 13:00:29 +0000 Subject: [PATCH] fix x86-64 builds git-archimport-id: bonzini@gnu.org--2004b/lightning--stable--1.2--patch-39 --- ChangeLog | 14 ++++++++++++++ lightning/asm-common.h | 9 ++++++--- lightning/i386/asm-64.h | 7 +++++++ lightning/i386/asm-i386.h | 2 ++ lightning/i386/core-32.h | 9 +++++++-- lightning/i386/core-64.h | 24 +++++++++++++++--------- lightning/i386/core-i386.h | 9 --------- lightning/i386/funcs.h | 2 +- tests/funcfp.c | 8 ++++++++ tests/rpnfp.c | 8 ++++++++ tests/run-test | 4 ++++ tests/testfp.c | 8 ++++++++ 12 files changed, 80 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 287cdda64..c99af4666 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-11-20 Paolo Bonzini + + * lightning/asm-common.h: Make 64-bit safe. + * lightning/i386/funcs.h: Make 64-bit safe. + + * lightning/i386/asm-64.h: More merge from mzscheme. + * lightning/i386/asm-i386.h: More merge from mzscheme. + * lightning/i386/core-32.h: More merge from mzscheme. + * lightning/i386/core-64.h: More merge from mzscheme. + * lightning/i386/core-i386.h: More merge from mzscheme. + + * tests/rpnfp.c, tests/testfp.c, tests/funcfp.c: Skip if no floating-point + support. + 2006-11-04 Paolo Bonzini * tests/rpn.c: Remove pushr/popr. diff --git a/lightning/asm-common.h b/lightning/asm-common.h index 6f61521e2..58e89b457 100644 --- a/lightning/asm-common.h +++ b/lightning/asm-common.h @@ -95,11 +95,13 @@ typedef unsigned long _ul; #define _jit_UC(X) ((_uc )(X)) #define _jit_US(X) ((_us )(X)) #define _jit_UI(X) ((_ui )(X)) +#define _jit_SI(X) ((int )(X)) #define _jit_SL(X) ((_sl )(X)) #define _jit_UL(X) ((_ul )(X)) # define _PUC(X) ((_uc *)(X)) # define _PUS(X) ((_us *)(X)) # define _PUI(X) ((_ui *)(X)) +# define _PSI(X) ((int *)(X)) # define _PSL(X) ((_sl *)(X)) # define _PUL(X) ((_ul *)(X)) @@ -109,9 +111,9 @@ typedef unsigned long _ul; #define _jit_L(L) _jit_UL(((*_jit.x.ul_pc++)= _jit_UL((L) ))) #define _jit_I_noinc(I) _jit_UL(((*_jit.x.ui_pc)= _jit_UI((I) ))) -#define _MASK(N) ((unsigned)((1<<(N)))-1) -#define _siP(N,I) (!((((unsigned)(I))^(((unsigned)(I))<<1))&~_MASK(N))) -#define _uiP(N,I) (!(((unsigned)(I))&~_MASK(N))) +#define _MASK(N) ((unsigned long)((1L<<(N)))-1L) +#define _siP(N,I) (!((((unsigned long)(I))^(((unsigned long)(I))<<1))&~_MASK(N))) +#define _uiP(N,I) (!(((unsigned long)(I))&~_MASK(N))) #define _suiP(N,I) (_siP(N,I) | _uiP(N,I)) #ifndef _ASM_SAFETY @@ -131,6 +133,7 @@ typedef unsigned long _ul; #define _s16P(I) _siP(16,I) #define _u8P(I) _uiP(8,I) #define _u16P(I) _uiP(16,I) +#define _u32P(I) _uiP(32,I) #define _su8(I) _ck_su(8,I) #define _su16(I) _ck_su(16,I) diff --git a/lightning/i386/asm-64.h b/lightning/i386/asm-64.h index f44f20367..5079d0ac3 100644 --- a/lightning/i386/asm-64.h +++ b/lightning/i386/asm-64.h @@ -57,6 +57,13 @@ #define _qO( OP, R,X,B ) ( _REX(R,X,B), _jit_B( OP ) ) #define _qOr( OP,R ) ( _REX(0,0,R), _jit_B( (OP)|_r(R&0x7)) ) #define _qOs( OP, B, R, M ) ( _REX(0, M, R), _Os(OP, B) ) +#define _qOr_Q( OP,R ,Q ) ( _qOr ( OP,R) ,_jit_L(Q) ) +#define _qO_Mrm( OP ,MO,R,M ) ( _qO ( OP,R,0,M),_qMrm(MO,R,M ) ) +#define _qO_Mrm_L( OP ,MO,R,M ,L ) ( _qO ( OP,R,0,M),_qMrm(MO,R,M ) ,_jit_I(L) ) +#define _qOs_Mrm_sL(OP ,MO,R,M ,L ) ( _qOs ( OP,L,R,M),_qMrm(MO,R,M ),_sL(L) ) +#define _qO_r_X( OP ,R ,MD,MB,MI,MS ) ( _qO ( OP,R,0,MS),_qr_X(R,MD,MB,MI,MS) ) +#define _qO_r_XB( OP ,R ,MD,MB,MI,MS ) ( _qO ( OP,R,0,MB),_qr_X(R,MD,MB,MI,MS) ) + #define ADDQrr(RS, RD) _qO_Mrm (0x01 ,_b11,_r8(RS),_r8(RD) ) #define ADDQir(IM, RD) _qOs_Mrm_sL (0x81 ,_b11,_b000 ,_r8(RD) ,IM ) diff --git a/lightning/i386/asm-i386.h b/lightning/i386/asm-i386.h index 9bcf4ce1f..6169bb44a 100644 --- a/lightning/i386/asm-i386.h +++ b/lightning/i386/asm-i386.h @@ -111,6 +111,8 @@ typedef _uc jit_insn; #define _r4(R) ((_rS(R)==4) ? _rN(R) : JITFAIL("32-bit register required")) #endif +#define _r8(R) _r4(R) + /*** ASSEMBLER ***/ #define _OFF4(D) (_jit_UL(D) - _jit_UL(_jit.x.pc)) diff --git a/lightning/i386/core-32.h b/lightning/i386/core-32.h index 805af0397..87ebc802a 100644 --- a/lightning/i386/core-32.h +++ b/lightning/i386/core-32.h @@ -34,9 +34,10 @@ #ifndef __lightning_core_h #define __lightning_core_h -#include "core-i386.h" - #define JIT_CAN_16 1 +#define JIT_AP _EBP + +#include "core-i386.h" struct jit_local_state { int framesize; @@ -61,6 +62,10 @@ struct jit_local_state { _jitl.alloca_slack -= (amount), \ _jitl.alloca_offset -= (amount)) +/* Stack */ +#define jit_pushr_i(rs) PUSHLr(rs) +#define jit_popr_i(rs) POPLr(rs) + /* The += in argssize allows for stack pollution */ #ifdef __APPLE__ diff --git a/lightning/i386/core-64.h b/lightning/i386/core-64.h index 420fbcffe..0f974760e 100644 --- a/lightning/i386/core-64.h +++ b/lightning/i386/core-64.h @@ -34,6 +34,9 @@ #ifndef __lightning_core_h #define __lightning_core_h +/* Used to implement ldc, stc, ... */ +#define JIT_CAN_16 0 + #include "core-i386.h" struct jit_local_state { @@ -77,9 +80,6 @@ struct jit_local_state { #define jit_bra_l0(rs, is, op, op0) \ ( (is) == 0 ? (TESTQrr(rs, rs), op0, _jit.x.pc) : jit_bra_l(rs, is, op)) -/* Used to implement ldc, stc, ... */ -#define JIT_CAN_16 0 - #define jit_reduceQ(op, is, rs) \ (_u8P(is) && jit_check8(rs) ? jit_reduce_(op##Bir(is, jit_reg8(rs))) : \ jit_reduce_(op##Qir(is, rs)) ) @@ -106,8 +106,8 @@ struct jit_local_state { #define jit_rshr_ul(d, r1, r2) jit_replace((r1), (r2), _ECX, jit_qop_ ((d), (r1), SHRQrr(_CL, (d)) )) /* Stack */ -#define jit_pushr_l(rs) PUSHQr(rs) -#define jit_popr_l(rs) POPQr(rs) +#define jit_pushr_i(rs) PUSHQr(rs) +#define jit_popr_i(rs) POPQr(rs) #define jit_base_prolog() (PUSHQr(_EBP), MOVQrr(_ESP, _EBP), PUSHQr(_EBX), PUSHQr(_R12), PUSHQr(_R13)) #define jit_prolog(n) (_jitl.nextarg_geti = 0, _jitl.alloca_offset = -24, jit_base_prolog()) @@ -140,10 +140,16 @@ struct jit_local_state { (MOVQrr(_R12, _ESI), MOVQrr(_R13, _EDI)) #define jit_retval_l(rd) ((void)jit_movr_l ((rd), _EAX)) -#define jit_arg_i() (_jitl.nextarg_geti++) -#define jit_arg_l() (_jitl.nextarg_geti++) -#define jit_arg_p() (_jitl.nextarg_geti++) -#define jit_arg_reg(p) (jit_arg_reg_order[p]) +#define jit_arg_c() (jit_arg_reg_order[_jitl.nextarg_geti++]) +#define jit_arg_uc() (jit_arg_reg_order[_jitl.nextarg_geti++]) +#define jit_arg_s() (jit_arg_reg_order[_jitl.nextarg_geti++]) +#define jit_arg_us() (jit_arg_reg_order[_jitl.nextarg_geti++]) +#define jit_arg_i() (jit_arg_reg_order[_jitl.nextarg_geti++]) +#define jit_arg_ui() (jit_arg_reg_order[_jitl.nextarg_geti++]) +#define jit_arg_l() (jit_arg_reg_order[_jitl.nextarg_geti++]) +#define jit_arg_ul() (jit_arg_reg_order[_jitl.nextarg_geti++]) +#define jit_arg_p() (jit_arg_reg_order[_jitl.nextarg_geti++]) +#define jit_arg_up() (jit_arg_reg_order[_jitl.nextarg_geti++]) static int jit_arg_reg_order[] = { _EDI, _ESI, _EDX, _ECX }; #define jit_negr_l(d, rs) jit_opi_((d), (rs), NEGQr(d), (XORQrr((d), (d)), SUBQrr((rs), (d))) ) diff --git a/lightning/i386/core-i386.h b/lightning/i386/core-i386.h index 0e3e97b59..3f06c0e54 100644 --- a/lightning/i386/core-i386.h +++ b/lightning/i386/core-i386.h @@ -34,7 +34,6 @@ #ifndef __lightning_core_i386_h #define __lightning_core_i386_h -#define JIT_AP _EBP #define JIT_FP _EBP #define JIT_SP _ESP #define JIT_RET _EAX @@ -107,11 +106,6 @@ : jit_replace(_EBX, rs, _EAX, MOVBrm(_AL, dd, db, di, ds))) /* Reduce arguments of XOR/OR/TEST */ -#ifdef JIT_X86_64 -# define JIT_CAN_16 0 -#else -# define JIT_CAN_16 1 -#endif #define jit_reduce_(op) op #define jit_reduce(op, is, rs) \ (_u8P(is) && jit_check8(rs) ? jit_reduce_(op##Bir(is, jit_reg8(rs))) : \ @@ -261,9 +255,6 @@ #define jit_rshr_ui(d, r1, r2) jit_replace((r1), (r2), _ECX, jit_op_ ((d), (r1), SHRLrr(_CL, (d)) )) /* Stack */ -#define jit_pushr_i(rs) PUSHLr(rs) -#define jit_popr_i(rs) POPLr(rs) - #define jit_prepare_f(nf) (_jitl.argssize += (nf)) #define jit_prepare_d(nd) (_jitl.argssize += 2 * (nd)) #define jit_retval_i(rd) ((void)jit_movr_i ((rd), _EAX)) diff --git a/lightning/i386/funcs.h b/lightning/i386/funcs.h index 4daaf4875..77171ece1 100644 --- a/lightning/i386/funcs.h +++ b/lightning/i386/funcs.h @@ -53,7 +53,7 @@ jit_flush_code(void *dest, void *end) jit_flush_code as an mprotect. */ #ifdef __linux__ static unsigned long prev_page = 0, prev_length = 0; - int page, length; + long page, length; #ifdef PAGESIZE const int page_size = PAGESIZE; #else diff --git a/tests/funcfp.c b/tests/funcfp.c index 8e8b5656e..7858c4c2f 100644 --- a/tests/funcfp.c +++ b/tests/funcfp.c @@ -37,6 +37,7 @@ #include #include "lightning.h" +#ifdef JIT_FPR static jit_insn codeBuffer[300]; typedef int (*intFunc) (int, int); @@ -175,3 +176,10 @@ main (int argc, char *argv[]) return 0; } +#else +int +main() +{ + return (77); +} +#endif diff --git a/tests/rpnfp.c b/tests/rpnfp.c index 2c7193f6e..a3b322cae 100644 --- a/tests/rpnfp.c +++ b/tests/rpnfp.c @@ -38,6 +38,7 @@ #include #include "lightning.h" +#ifdef JIT_FPR static jit_insn codeBuffer[1024]; typedef double (*pdfd) (double); /* Pointer to Double Function of Double */ @@ -136,3 +137,10 @@ main () #endif return 0; } +#else +int +main() +{ + return (77); +} +#endif diff --git a/tests/run-test b/tests/run-test index ae3dfc7e6..83b3270f1 100755 --- a/tests/run-test +++ b/tests/run-test @@ -1,6 +1,10 @@ #! /bin/sh ./$1 > $1.log +if test $? = 77; then + exit 77 +fi + if cmp -s $srcdir/$1.ok $1.log; then rm $1.log else diff --git a/tests/testfp.c b/tests/testfp.c index 1de858b61..dc7574d1e 100644 --- a/tests/testfp.c +++ b/tests/testfp.c @@ -37,6 +37,7 @@ #include #include "lightning.h" +#ifdef JIT_FPR static jit_insn codeBuffer[300]; static double a; @@ -215,3 +216,10 @@ main() return (0); } +#else +int +main() +{ + return (77); +} +#endif