From 170ef2e15216164022f374a2019f527ac6cab055 Mon Sep 17 00:00:00 2001 From: Frode Solheim Date: Sun, 6 Sep 2015 23:42:14 +0200 Subject: [PATCH] JIT: Added factor argument to mov_*_indexed functions --- jit/codegen_x86.cpp | 162 +++++++++++++++++++++++++----------- jit/compemu_midfunc_x86.cpp | 40 ++++----- jit/compemu_midfunc_x86.h | 12 +-- jit/compemu_support.cpp | 12 +-- 4 files changed, 146 insertions(+), 80 deletions(-) diff --git a/jit/codegen_x86.cpp b/jit/codegen_x86.cpp index bacc8ef6..04ef388d 100644 --- a/jit/codegen_x86.cpp +++ b/jit/codegen_x86.cpp @@ -1856,77 +1856,141 @@ LOWFUNC(NONE,NONE,2,raw_mov_w_rr,(W2 d, R2 s)) } LENDFUNC(NONE,NONE,2,raw_mov_w_rr,(W2 d, R2 s)) -LOWFUNC(NONE,READ,3,raw_mov_l_rrm_indexed,(W4 d, R4 baser, R4 index)) +LOWFUNC(NONE,READ,4,raw_mov_l_rrm_indexed,(W4 d,R4 baser, R4 index, IMM factor)) { - emit_byte(0x8b); - if (baser==5) { - emit_byte(0x44+8*d); - emit_byte(8*index+baser); - emit_byte(0); - return; + int isebp=(baser==5)?0x40:0; + int fi; + + switch(factor) { + case 1: fi=0; break; + case 2: fi=1; break; + case 4: fi=2; break; + case 8: fi=3; break; + default: abort(); } - emit_byte(0x04+8*d); - emit_byte(8*index+baser); + + + emit_byte(0x8b); + emit_byte(0x04+8*d+isebp); + emit_byte(baser+8*index+0x40*fi); + if (isebp) + emit_byte(0x00); } -LENDFUNC(NONE,READ,3,raw_mov_l_rrm_indexed,(W4 d, R4 baser, R4 index)) +LENDFUNC(NONE,READ,4,raw_mov_l_rrm_indexed,(W4 d,R4 baser, R4 index, IMM factor)) -LOWFUNC(NONE,READ,3,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index)) +LOWFUNC(NONE,READ,4,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index, IMM factor)) { + int fi; + int isebp; + + switch(factor) { + case 1: fi=0; break; + case 2: fi=1; break; + case 4: fi=2; break; + case 8: fi=3; break; + default: abort(); + } + isebp=(baser==5)?0x40:0; + emit_byte(0x66); emit_byte(0x8b); - if (baser==5) { - emit_byte(0x44+8*d); - emit_byte(8*index+baser); - emit_byte(0); - return; + emit_byte(0x04+8*d+isebp); + emit_byte(baser+8*index+0x40*fi); + if (isebp) + emit_byte(0x00); } - emit_byte(0x04+8*d); - emit_byte(8*index+baser); -} -LENDFUNC(NONE,READ,3,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index)) +LENDFUNC(NONE,READ,4,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index, IMM factor)) -LOWFUNC(NONE,READ,3,raw_mov_b_rrm_indexed,(W1 d, R4 baser, R4 index)) +LOWFUNC(NONE,READ,4,raw_mov_b_rrm_indexed,(W1 d, R4 baser, R4 index, IMM factor)) { - emit_byte(0x8a); - if (baser==5) { - emit_byte(0x44+8*d); - emit_byte(8*index+baser); - emit_byte(0); - return; + int fi; + int isebp; + + switch(factor) { + case 1: fi=0; break; + case 2: fi=1; break; + case 4: fi=2; break; + case 8: fi=3; break; + default: abort(); } - emit_byte(0x04+8*d); - emit_byte(8*index+baser); + isebp=(baser==5)?0x40:0; + + emit_byte(0x8a); + emit_byte(0x04+8*d+isebp); + emit_byte(baser+8*index+0x40*fi); + if (isebp) + emit_byte(0x00); } -LENDFUNC(NONE,READ,3,raw_mov_b_rrm_indexed,(W1 d, R4 baser, R4 index)) +LENDFUNC(NONE,READ,4,raw_mov_b_rrm_indexed,(W1 d, R4 baser, R4 index, IMM factor)) -LOWFUNC(NONE,WRITE,3,raw_mov_l_mrr_indexed,(R4 baser, R4 index, R4 s)) +LOWFUNC(NONE,WRITE,4,raw_mov_l_mrr_indexed,(R4 baser, R4 index, IMM factor, R4 s)) { - emit_byte(0x89); - if (baser==5) { - emit_byte(0x44+8*s); - emit_byte(8*index+baser); - emit_byte(0); - return; + int fi; + int isebp; + + switch(factor) { + case 1: fi=0; break; + case 2: fi=1; break; + case 4: fi=2; break; + case 8: fi=3; break; + default: abort(); } - emit_byte(0x04+8*s); - emit_byte(8*index+baser); + + + isebp=(baser==5)?0x40:0; + + emit_byte(0x89); + emit_byte(0x04+8*s+isebp); + emit_byte(baser+8*index+0x40*fi); + if (isebp) + emit_byte(0x00); } -LENDFUNC(NONE,WRITE,3,raw_mov_l_mrr_indexed,(R4 baser, R4 index, R4 s)) +LENDFUNC(NONE,WRITE,4,raw_mov_l_mrr_indexed,(R4 baser, R4 index, IMM factor, R4 s)) -LOWFUNC(NONE,WRITE,3,raw_mov_w_mrr_indexed,(R4 baser, R4 index, R2 s)) +LOWFUNC(NONE,WRITE,4,raw_mov_w_mrr_indexed,(R4 baser, R4 index, IMM factor, R2 s)) { + int fi; + int isebp; + + switch(factor) { + case 1: fi=0; break; + case 2: fi=1; break; + case 4: fi=2; break; + case 8: fi=3; break; + default: abort(); + } + isebp=(baser==5)?0x40:0; + emit_byte(0x66); emit_byte(0x89); - if (baser==5) { - emit_byte(0x44+8*s); - emit_byte(8*index+baser); - emit_byte(0); - return; + emit_byte(0x04+8*s+isebp); + emit_byte(baser+8*index+0x40*fi); + if (isebp) + emit_byte(0x00); +} +LENDFUNC(NONE,WRITE,4,raw_mov_w_mrr_indexed,(R4 baser, R4 index, IMM factor, R2 s)) + +LOWFUNC(NONE,WRITE,4,raw_mov_b_mrr_indexed,(R4 baser, R4 index, IMM factor, R1 s)) +{ + int fi; + int isebp; + + switch(factor) { + case 1: fi=0; break; + case 2: fi=1; break; + case 4: fi=2; break; + case 8: fi=3; break; + default: abort(); } - emit_byte(0x04+8*s); - emit_byte(8*index+baser); + isebp=(baser==5)?0x40:0; + + emit_byte(0x88); + emit_byte(0x04+8*s+isebp); + emit_byte(baser+8*index+0x40*fi); + if (isebp) + emit_byte(0x00); } -LENDFUNC(NONE,WRITE,3,raw_mov_w_mrr_indexed,(R4 baser, R4 index, R2 s)) +LENDFUNC(NONE,WRITE,4,raw_mov_b_mrr_indexed,(R4 baser, R4 index, IMM factor, R1 s)) LOWFUNC(NONE,WRITE,3,raw_mov_b_mrr_indexed,(R4 baser, R4 index, R1 s)) { diff --git a/jit/compemu_midfunc_x86.cpp b/jit/compemu_midfunc_x86.cpp index d4fd2a7a..b36df907 100644 --- a/jit/compemu_midfunc_x86.cpp +++ b/jit/compemu_midfunc_x86.cpp @@ -1061,50 +1061,51 @@ MIDFUNC(2,mov_w_rr,(W2 d, RR2 s)) } MENDFUNC(2,mov_w_rr,(W2 d, RR2 s)) -MIDFUNC(3,mov_l_rrm_indexed,(W4 d,RR4 baser, RR4 index)) +MIDFUNC(4,mov_l_rrm_indexed,(W4 d,RR4 baser, RR4 index, IMM factor)) { CLOBBER_MOV; baser=readreg(baser,4); index=readreg(index,4); d=writereg(d,4); - raw_mov_l_rrm_indexed(d,baser,index); + raw_mov_l_rrm_indexed(d,baser,index,factor); unlock2(d); unlock2(baser); unlock2(index); } -MENDFUNC(3,mov_l_rrm_indexed,(W4 d,RR4 baser, RR4 index)) +MENDFUNC(4,mov_l_rrm_indexed,(W4 d,RR4 baser, RR4 index, IMM factor)) -MIDFUNC(3,mov_w_rrm_indexed,(W2 d, RR4 baser, RR4 index)) +MIDFUNC(4,mov_w_rrm_indexed,(W2 d, RR4 baser, RR4 index, IMM factor)) { CLOBBER_MOV; baser=readreg(baser,4); index=readreg(index,4); d=writereg(d,2); - raw_mov_w_rrm_indexed(d,baser,index); + raw_mov_w_rrm_indexed(d,baser,index,factor); unlock2(d); unlock2(baser); unlock2(index); } -MENDFUNC(3,mov_w_rrm_indexed,(W2 d, RR4 baser, RR4 index)) +MENDFUNC(4,mov_w_rrm_indexed,(W2 d, RR4 baser, RR4 index, IMM factor)) -MIDFUNC(3,mov_b_rrm_indexed,(W1 d, RR4 baser, RR4 index)) +MIDFUNC(4,mov_b_rrm_indexed,(W1 d, RR4 baser, RR4 index, IMM factor)) { CLOBBER_MOV; baser=readreg(baser,4); index=readreg(index,4); d=writereg(d,1); - raw_mov_b_rrm_indexed(d,baser,index); + raw_mov_b_rrm_indexed(d,baser,index,factor); unlock2(d); unlock2(baser); unlock2(index); } -MENDFUNC(3,mov_b_rrm_indexed,(W1 d, RR4 baser, RR4 index)) +MENDFUNC(4,mov_b_rrm_indexed,(W1 d, RR4 baser, RR4 index, IMM factor)) -MIDFUNC(3,mov_l_mrr_indexed,(RR4 baser, RR4 index, RR4 s)) + +MIDFUNC(4,mov_l_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR4 s)) { CLOBBER_MOV; baser=readreg(baser,4); @@ -1112,42 +1113,43 @@ MIDFUNC(3,mov_l_mrr_indexed,(RR4 baser, RR4 index, RR4 s)) s=readreg(s,4); Dif (baser==s || index==s) - jit_abort (_T("mov_l_mrr_indexed")); + jit_abort("mov_l_mrr_indexed"); + - raw_mov_l_mrr_indexed(baser,index,s); + raw_mov_l_mrr_indexed(baser,index,factor,s); unlock2(s); unlock2(baser); unlock2(index); } -MENDFUNC(3,mov_l_mrr_indexed,(RR4 baser, RR4 index, RR4 s)) +MENDFUNC(4,mov_l_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR4 s)) -MIDFUNC(3,mov_w_mrr_indexed,(RR4 baser, RR4 index, RR2 s)) +MIDFUNC(4,mov_w_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR2 s)) { CLOBBER_MOV; baser=readreg(baser,4); index=readreg(index,4); s=readreg(s,2); - raw_mov_w_mrr_indexed(baser,index,s); + raw_mov_w_mrr_indexed(baser,index,factor,s); unlock2(s); unlock2(baser); unlock2(index); } -MENDFUNC(3,mov_w_mrr_indexed,(RR4 baser, RR4 index, RR2 s)) +MENDFUNC(4,mov_w_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR2 s)) -MIDFUNC(3,mov_b_mrr_indexed,(RR4 baser, RR4 index, RR1 s)) +MIDFUNC(4,mov_b_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR1 s)) { CLOBBER_MOV; s=readreg(s,1); baser=readreg(baser,4); index=readreg(index,4); - raw_mov_b_mrr_indexed(baser,index,s); + raw_mov_b_mrr_indexed(baser,index,factor,s); unlock2(s); unlock2(baser); unlock2(index); } -MENDFUNC(3,mov_b_mrr_indexed,(RR4 baser, RR4 index, RR1 s)) +MENDFUNC(4,mov_b_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR1 s)) #ifdef UAE diff --git a/jit/compemu_midfunc_x86.h b/jit/compemu_midfunc_x86.h index 549c3b73..6ea19a10 100644 --- a/jit/compemu_midfunc_x86.h +++ b/jit/compemu_midfunc_x86.h @@ -101,12 +101,12 @@ DECLARE_MIDFUNC(imul_32_32(RW4 d, RR4 s)); DECLARE_MIDFUNC(mul_32_32(RW4 d, RR4 s)); DECLARE_MIDFUNC(mov_b_rr(W1 d, RR1 s)); DECLARE_MIDFUNC(mov_w_rr(W2 d, RR2 s)); -DECLARE_MIDFUNC(mov_l_rrm_indexed(W4 d, RR4 baser, RR4 index)); -DECLARE_MIDFUNC(mov_w_rrm_indexed(W2 d, RR4 baser, RR4 index)); -DECLARE_MIDFUNC(mov_b_rrm_indexed(W1 d, RR4 baser, RR4 index)); -DECLARE_MIDFUNC(mov_l_mrr_indexed(RR4 baser, RR4 index, RR4 s)); -DECLARE_MIDFUNC(mov_w_mrr_indexed(RR4 baser, RR4 index, RR2 s)); -DECLARE_MIDFUNC(mov_b_mrr_indexed(RR4 baser, RR4 index, RR1 s)); +DECLARE_MIDFUNC(mov_l_rrm_indexed(W4 d,RR4 baser, RR4 index, IMM factor)); +DECLARE_MIDFUNC(mov_w_rrm_indexed(W2 d, RR4 baser, RR4 index, IMM factor)); +DECLARE_MIDFUNC(mov_b_rrm_indexed(W1 d, RR4 baser, RR4 index, IMM factor)); +DECLARE_MIDFUNC(mov_l_mrr_indexed(RR4 baser, RR4 index, IMM factor, RR4 s)); +DECLARE_MIDFUNC(mov_w_mrr_indexed(RR4 baser, RR4 index, IMM factor, RR2 s)); +DECLARE_MIDFUNC(mov_b_mrr_indexed(RR4 baser, RR4 index, IMM factor, RR1 s)); DECLARE_MIDFUNC(mov_l_rm_indexed(W4 d, IMM base, RR4 index)); DECLARE_MIDFUNC(mov_l_rR(W4 d, RR4 s, IMM offset)); DECLARE_MIDFUNC(mov_w_rR(W2 d, RR4 s, IMM offset)); diff --git a/jit/compemu_support.cpp b/jit/compemu_support.cpp index e5fcf282..f2c19eb8 100644 --- a/jit/compemu_support.cpp +++ b/jit/compemu_support.cpp @@ -2884,10 +2884,10 @@ static void writemem_real(int address, int source, int size, int tmp, int clobbe } } switch (size) { /* f now holds the offset */ - case 1: mov_b_mrr_indexed(address,f,source); break; - case 2: mid_bswap_16(source); mov_w_mrr_indexed(address,f,source); + case 1: mov_b_mrr_indexed(address,f,1,source); break; + case 2: mid_bswap_16(source); mov_w_mrr_indexed(address,f,1,source); mid_bswap_16(source); break; /* base, index, source */ - case 4: mid_bswap_32(source); mov_l_mrr_indexed(address,f,source); + case 4: mid_bswap_32(source); mov_l_mrr_indexed(address,f,1,source); mid_bswap_32(source); break; } } @@ -2984,9 +2984,9 @@ static void readmem_real(int address, int dest, int size, int tmp) /* f now holds the offset */ switch(size) { - case 1: mov_b_rrm_indexed(dest,address,f); break; - case 2: mov_w_rrm_indexed(dest,address,f); mid_bswap_16(dest); break; - case 4: mov_l_rrm_indexed(dest,address,f); mid_bswap_32(dest); break; + case 1: mov_b_rrm_indexed(dest,address,f,1); break; + case 2: mov_w_rrm_indexed(dest,address,f,1); mid_bswap_16(dest); break; + case 4: mov_l_rrm_indexed(dest,address,f,1); mid_bswap_32(dest); break; } forget_about(tmp); } -- 2.47.3