]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
JIT: define USE_NEW_RTASM, 64-bit compilation fixes
authorFrode Solheim <frode@fs-uae.net>
Sun, 6 Sep 2015 21:53:49 +0000 (23:53 +0200)
committerFrode Solheim <frode@fs-uae.net>
Thu, 17 Sep 2015 17:18:09 +0000 (19:18 +0200)
jit/codegen_x86.cpp
jit/compemu_support.cpp
jit/exception_handler.cpp

index acec6cc258c72f8bcdc5a1a1d37d7a18bb6119e8..ae90930073739fd3096be8aff000a35a57e1e4f9 100644 (file)
@@ -167,7 +167,7 @@ static const uae_u8 need_to_preserve[]={1,1,1,1,0,1,1,1};
 #define CLOBBER_BSF  clobber_flags()
 
 /* The older code generator is now deprecated.  */
-#define USE_NEW_RTASM 0
+#define USE_NEW_RTASM 1
 
 #if USE_NEW_RTASM
 
@@ -3718,7 +3718,8 @@ LOWFUNC(NONE,WRITE,3,raw_fmovi_mrb,(MEMW m, FR r, double *bounds))
        /* Lower bound onto stack */
        emit_byte(0xdd);
        emit_byte(0x05);
-       emit_long((uae_u32)&bounds[0]); /* fld double from lower */
+/* FIXME: 32-bit address prefix needed? */
+       emit_long(uae_ptr32(&bounds[0])); /* fld double from lower */
 
        /* Clamp to lower */
        emit_byte(0xdb);
@@ -3731,7 +3732,8 @@ LOWFUNC(NONE,WRITE,3,raw_fmovi_mrb,(MEMW m, FR r, double *bounds))
        emit_byte(0xd8);        /* fstp st(0) */
        emit_byte(0xdd);
        emit_byte(0x05);
-       emit_long((uae_u32)&bounds[1]); /* fld double from upper */
+/* FIXME: 32-bit address prefix needed? */
+       emit_long(uae_ptr32(&bounds[1])); /* fld double from upper */
 
        /* Clamp to upper */
        emit_byte(0xdb);
@@ -4172,7 +4174,7 @@ LOWFUNC(NONE,NONE,2,raw_ftwotox_rr,(FW d, FR s))
        emit_byte(0xf0);    /* f2xm1 (2^frac(x))-1 */
        emit_byte(0xd8);
        emit_byte(0x05);
-       emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */
+       emit_long(uae_ptr32(&one)); /* fadd (2^frac(x))-1 + 1 */
        emit_byte(0xd9);
        emit_byte(0xfd);    /* fscale (2^frac(x))*2^int(x) */
        emit_byte(0xdd);
@@ -4208,7 +4210,7 @@ LOWFUNC(NONE,NONE,2,raw_fetox_rr,(FW d, FR s))
        emit_byte(0xf0);    /* f2xm1 (2^frac(x))-1 */
        emit_byte(0xd8);
        emit_byte(0x05);
-       emit_long((uae_u32)&one);  /* fadd (2^frac(x))-1 + 1 */
+       emit_long(uae_ptr32(&one));  /* fadd (2^frac(x))-1 + 1 */
        emit_byte(0xd9);
        emit_byte(0xfd);    /* fscale (2^frac(x))*2^int(x*log2(e)) */
        emit_byte(0xdd);
@@ -4279,7 +4281,7 @@ LOWFUNC(NONE,NONE,2,raw_ftentox_rr,(FW d, FR s))
        emit_byte(0xf0);    /* f2xm1 (2^frac(x))-1 */
        emit_byte(0xd8);
        emit_byte(0x05);
-       emit_long((uae_u32)&one);  /* fadd (2^frac(x))-1 + 1 */
+       emit_long(uae_ptr32(&one));  /* fadd (2^frac(x))-1 + 1 */
        emit_byte(0xd9);
        emit_byte(0xfd);    /* fscale (2^frac(x))*2^int(x*log2(10)) */
        emit_byte(0xdd);
@@ -4426,7 +4428,7 @@ LOWFUNC(NONE,NONE,2,raw_facos_rr,(FW d, FR s))
        emit_byte(0xf3);    /* fpatan atan(x/sqrt(1-(x^2))) & pop */
        emit_byte(0xdb);
        emit_byte(0x2d);
-       emit_long((uae_u32)&pihalf); /* fld load pi/2 from pihalf */
+       emit_long(uae_ptr32(&pihalf)); /* fld load pi/2 from pihalf */
        emit_byte(0xde);
        emit_byte(0xe1);    /* fsubrp pi/2 - asin(x) & pop */
        tos_make(d);        /* store y=acos(x) */
@@ -4530,7 +4532,7 @@ LOWFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s))
        emit_byte(0xf0);     /* f2xm1 (2^frac(x))-1 */
        emit_byte(0xd8);
        emit_byte(0x05);
-       emit_long((uae_u32)&one);  /* fadd (2^frac(x))-1 + 1 */
+       emit_long(uae_ptr32(&one));  /* fadd (2^frac(x))-1 + 1 */
        emit_byte(0xd9);
        emit_byte(0xfd);     /* fscale (2^frac(x))*2^int(x*log2(e)) */
        emit_byte(0xd9);
@@ -4547,7 +4549,7 @@ LOWFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s))
        emit_byte(0xf0);     /* f2xm1 (2^frac(x))-1 */
        emit_byte(0xd8);
        emit_byte(0x05);
-       emit_long((uae_u32)&one);  /* fadd (2^frac(x))-1 + 1 */
+       emit_long(uae_ptr32(&one));  /* fadd (2^frac(x))-1 + 1 */
        emit_byte(0xd9);
        emit_byte(0xfd);     /* fscale (2^frac(x))*2^int(x*log2(e)) */
        emit_byte(0xdd);
@@ -4625,7 +4627,7 @@ LOWFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s))
        emit_byte(0xf0);     /* f2xm1 (2^frac(x))-1 */
        emit_byte(0xd8);
        emit_byte(0x05);
-       emit_long((uae_u32)&one);  /* fadd (2^frac(x))-1 + 1 */
+       emit_long(uae_ptr32(&one));  /* fadd (2^frac(x))-1 + 1 */
        emit_byte(0xd9);
        emit_byte(0xfd);     /* fscale (2^frac(x))*2^int(x*log2(e)) */
        emit_byte(0xd9);
@@ -4642,7 +4644,7 @@ LOWFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s))
        emit_byte(0xf0);     /* f2xm1 (2^frac(x))-1 */
        emit_byte(0xd8);
        emit_byte(0x05);
-       emit_long((uae_u32)&one);  /* fadd (2^frac(x))-1 + 1 */
+       emit_long(uae_ptr32(&one));  /* fadd (2^frac(x))-1 + 1 */
        emit_byte(0xd9);
        emit_byte(0xfd);     /* fscale (2^frac(x))*2^int(x*log2(e)) */
        emit_byte(0xdd);
@@ -4716,7 +4718,7 @@ LOWFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s))
        emit_byte(0xf0);     /* f2xm1 (2^frac(x))-1 */
        emit_byte(0xd8);
        emit_byte(0x05);
-       emit_long((uae_u32)&one);  /* fadd (2^frac(x))-1 + 1 */
+       emit_long(uae_ptr32(&one));  /* fadd (2^frac(x))-1 + 1 */
        emit_byte(0xd9);
        emit_byte(0xfd);     /* fscale (2^frac(x))*2^int(x*log2(e)) */
        emit_byte(0xd9);
@@ -4733,7 +4735,7 @@ LOWFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s))
        emit_byte(0xf0);     /* f2xm1 (2^frac(x))-1 */
        emit_byte(0xd8);
        emit_byte(0x05);
-       emit_long((uae_u32)&one);  /* fadd (2^frac(x))-1 + 1 */
+       emit_long(uae_ptr32(&one));  /* fadd (2^frac(x))-1 + 1 */
        emit_byte(0xd9);
        emit_byte(0xfd);     /* fscale (2^frac(x))*2^int(x*log2(e)) */
        emit_byte(0xdd);
index bd586a089bbe58ecd36b01db300b82014304fd25..225d809351488daeae590cd6ea291df92286f1c2 100644 (file)
        uae_log("JIT: " format "\n", __func__, ##__VA_ARGS__);
 #define jit_log2(format, ...)
 
-#define MEMBaseDiff ((uae_u32)NATMEM_OFFSET)
+#define MEMBaseDiff uae_ptr32(NATMEM_OFFSET)
 
 #ifdef NATMEM_OFFSET
 #define FIXED_ADDRESSING 1
@@ -1544,7 +1544,7 @@ static  int alloc_reg_hinted(int r, int size, int willclobber, int hint)
                                else if (r==FLAGX)
                                        raw_load_flagx(bestreg,r);
                                else {
-                                       raw_mov_l_rm(bestreg,(uae_u32)live.state[r].mem);
+                                       raw_mov_l_rm(bestreg,uae_ptr32(live.state[r].mem));
                                }
                                live.state[r].dirtysize=0;
                                set_status(r,CLEAN);
@@ -2758,8 +2758,8 @@ static void align_target(uae_u32 a)
 static inline int isinrom(uintptr addr)
 {
 #ifdef UAE
-       return (addr>=(uae_u32)kickmem_bank.baseaddr &&
-               addr<(uae_u32)kickmem_bank.baseaddr+8*65536);
+       return (addr >= uae_ptr32(kickmem_bank.baseaddr) &&
+                       addr < uae_ptr32(kickmem_bank.baseaddr + 8 * 65536));
 #else
        return ((addr >= (uintptr)ROMBaseHost) && (addr < (uintptr)ROMBaseHost + ROMSize));
 #endif
@@ -2870,7 +2870,7 @@ static void writemem_real(int address, int source, int size, int tmp, int clobbe
 
        mov_l_rr(f,address);
        shrl_l_ri(f,16);  /* The index into the baseaddr table */
-       mov_l_rm_indexed(f,(uae_u32)(baseaddr),f);
+       mov_l_rm_indexed(f,uae_ptr32(baseaddr),f);
 
        if (address==source) { /* IBrowse does this! */
                if (size > 1) {
@@ -2898,7 +2898,7 @@ static inline void writemem(int address, int source, int offset, int size, int t
 
        mov_l_rr(f,address);
        shrl_l_ri(f,16);   /* The index into the mem bank table */
-       mov_l_rm_indexed(f,(uae_u32)mem_banks,f);
+       mov_l_rm_indexed(f,uae_ptr32(mem_banks),f);
        /* Now f holds a pointer to the actual membank */
        mov_l_rR(f,f,offset);
        /* Now f holds the address of the b/w/lput function */
@@ -2980,7 +2980,7 @@ static void readmem_real(int address, int dest, int size, int tmp)
 
        mov_l_rr(f,address);
        shrl_l_ri(f,16);   /* The index into the baseaddr table */
-       mov_l_rm_indexed(f,(uae_u32)baseaddr,f);
+       mov_l_rm_indexed(f,uae_ptr32(baseaddr),f);
        /* f now holds the offset */
 
        switch(size) {
@@ -2999,7 +2999,7 @@ static inline void readmem(int address, int dest, int offset, int size, int tmp)
 
        mov_l_rr(f,address);
        shrl_l_ri(f,16);   /* The index into the mem bank table */
-       mov_l_rm_indexed(f,(uae_u32)mem_banks,f);
+       mov_l_rm_indexed(f,uae_ptr32(mem_banks),f);
        /* Now f holds a pointer to the actual membank */
        mov_l_rR(f,f,offset);
        /* Now f holds the address of the b/w/lget function */
@@ -3062,7 +3062,7 @@ static inline void get_n_addr_real(int address, int dest, int tmp)
        mov_l_rr(f,address);
        mov_l_rr(dest,address); // gb-- nop if dest==address
        shrl_l_ri(f,16);
-       mov_l_rm_indexed(f,(uae_u32)baseaddr,f);
+       mov_l_rm_indexed(f,uae_ptr32(baseaddr),f);
        add_l(dest,f);
        forget_about(tmp);
 }
@@ -3093,7 +3093,7 @@ void get_n_addr_jmp(int address, int dest, int tmp)
                f=dest;
        mov_l_rr(f,address);
        shrl_l_ri(f,16);   /* The index into the baseaddr bank table */
-       mov_l_rm_indexed(dest,(uae_u32)baseaddr,f);
+       mov_l_rm_indexed(dest,uae_ptr32(baseaddr),f);
        add_l(dest,address);
        and_l_ri (dest, ~1);
        forget_about(tmp);
@@ -4206,8 +4206,8 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
 
                bi->handler=
                        bi->handler_to_use=(cpuop_func*)get_target();
-               raw_cmp_l_mi((uae_u32)&regs.pc_p,(uae_u32)pc_hist[0].location);
-               raw_jnz((uae_u32)popall_cache_miss);
+               raw_cmp_l_mi(uae_ptr32(&regs.pc_p),uae_ptr32(pc_hist[0].location));
+               raw_jnz(uae_ptr32(popall_cache_miss));
                /* This was 16 bytes on the x86, so now aligned on (n+1)*32 */
 
                was_comp=0;
@@ -4296,7 +4296,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
                                                        was_comp=0;
                                                }
                                                raw_mov_l_ri(REG_PAR1,(uae_u32)opcode);
-                                               raw_mov_l_ri(REG_PAR2,(uae_u32)&regs);
+                                               raw_mov_l_ri(REG_PAR2,uae_ptr32(&regs));
 #if USE_NORMAL_CALLING_CONVENTION
                                                raw_push_l_r(REG_PAR2);
                                                raw_push_l_r(REG_PAR1);
@@ -4317,7 +4317,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
                                                        raw_jz_b_oponly();
                                                        branchadd=(uae_s8*)get_target();
                                                        emit_byte(0);
-                                                       raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                                                       raw_sub_l_mi(uae_ptr32(&countdown),scaled_cycles(totcycles));
                                                        raw_jmp((uintptr)popall_do_nothing);
                                                        *branchadd=(uintptr)get_target()-(uintptr)branchadd-1;
                                                }
@@ -4378,7 +4378,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
                                /* predicted outcome */
                                tbi=get_blockinfo_addr_new((void*)t1,1);
                                match_states(tbi);
-                               raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                               raw_sub_l_mi(uae_ptr32(&countdown),scaled_cycles(totcycles));
                                raw_jcc_l_oponly(9);
                                tba=(uae_u32*)get_target();
                                emit_jmp_target(get_handler(t1));
@@ -4394,7 +4394,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
                                match_states(tbi);
 
                                //flush(1); /* Can only get here if was_comp==1 */
-                               raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                               raw_sub_l_mi(uae_ptr32(&countdown),scaled_cycles(totcycles));
                                raw_jcc_l_oponly(9);
                                tba=(uae_u32*)get_target();
                                emit_jmp_target(get_handler(t2));
@@ -4414,7 +4414,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
                                        raw_and_l_ri(r,TAGMASK);
                                        int r2 = (r==0) ? 1 : 0;
                                        raw_mov_l_ri(r2,(uintptr)popall_do_nothing);
-                                       raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                                       raw_sub_l_mi(uae_ptr32(&countdown),scaled_cycles(totcycles));
 #if USE_NEW_RTASM
                                        raw_cmov_l_rm_indexed(r2,(uintptr)cache_tags,r,SIZEOF_VOID_P,9);
 #else
@@ -4430,7 +4430,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
                                        tbi=get_blockinfo_addr_new((void*)(uintptr)v,1);
                                        match_states(tbi);
 
-                                       raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                                       raw_sub_l_mi(uae_ptr32(&countdown),scaled_cycles(totcycles));
                                        raw_jcc_l_oponly(9);
                                        tba=(uae_u32*)get_target();
                                        emit_jmp_target(get_handler(v));
@@ -4444,7 +4444,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
                                        raw_and_l_ri(r,TAGMASK);
                                        int r2 = (r==0) ? 1 : 0;
                                        raw_mov_l_ri(r2,(uintptr)popall_do_nothing);
-                                       raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+                                       raw_sub_l_mi(uae_ptr32(&countdown),scaled_cycles(totcycles));
 #if USE_NEW_RTASM
                                        raw_cmov_l_rm_indexed(r2,(uintptr)cache_tags,r,SIZEOF_VOID_P,9);
 #else
index 5505522ccd6921d03d6371135134c7c4a4a2f841..4b4eeb144e000135f2c7e1ffc501e6c469edb4e9 100644 (file)
@@ -48,9 +48,19 @@ typedef LPEXCEPTION_POINTERS CONTEXT_T;
 
 #elif HAVE_STRUCT_UCONTEXT_UC_MCONTEXT_GREGS
 
+#ifdef CPU_x86_64
+#define CONTEXT_RIP(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_RIP])
+#define CONTEXT_RAX(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_RAX])
+#define CONTEXT_RCX(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_RCX])
+#define CONTEXT_RDX(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_RDX])
+#define CONTEXT_RBX(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_RBX])
+#define CONTEXT_RSP(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_RSP])
+#define CONTEXT_RBP(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_RBP])
+#define CONTEXT_RSI(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_RSI])
+#define CONTEXT_RDI(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_RDI])
+#else
 typedef void *CONTEXT_T;
 #define HAVE_CONTEXT_T 1
-
 #define CONTEXT_EIP(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_EIP])
 #define CONTEXT_EAX(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_EAX])
 #define CONTEXT_ECX(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_ECX])
@@ -60,8 +70,8 @@ typedef void *CONTEXT_T;
 #define CONTEXT_EBP(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_EBP])
 #define CONTEXT_ESI(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_ESI])
 #define CONTEXT_EDI(context) (((struct ucontext *) context)->uc_mcontext.gregs[REG_EDI])
-
 #define CONTEXT_CR2(context) (((struct ucontext *) context)->uc_mcontext.cr2)
+#endif
 
 #endif