drc: something works on arm64
[pcsx_rearmed.git] / libpcsxcore / new_dynarec / patches / trace_drc_chk
CommitLineData
a151a8d8 1diff --git a/libpcsxcore/new_dynarec/linkage_arm.S b/libpcsxcore/new_dynarec/linkage_arm.S
3968e69e 2index bbc52c3..83c5b08 100644
a151a8d8 3--- a/libpcsxcore/new_dynarec/linkage_arm.S
4+++ b/libpcsxcore/new_dynarec/linkage_arm.S
3968e69e 5@@ -437,7 +437,7 @@ FUNCTION(cc_interrupt):
a151a8d8 6 str r1, [fp, #LO_pending_exception]
7 and r2, r2, r10, lsr #17
8 add r3, fp, #LO_restore_candidate
9- str r10, [fp, #LO_cycle] /* PCSX cycles */
10+@@@ str r10, [fp, #LO_cycle] /* PCSX cycles */
11 @@ str r10, [fp, #LO_reg_cop0+36] /* Count */
12 ldr r4, [r2, r3]
13 mov r10, lr
3968e69e 14@@ -527,7 +527,7 @@ FUNCTION(new_dyna_leave):
a151a8d8 15 ldr r0, [fp, #LO_last_count]
16 add r12, fp, #28
17 add r10, r0, r10
18- str r10, [fp, #LO_cycle]
19+@@@ str r10, [fp, #LO_cycle]
20 ldmfd sp!, {r4, r5, r6, r7, r8, r9, sl, fp, ip, pc}
21 .size new_dyna_leave, .-new_dyna_leave
22
3968e69e 23@@ -644,7 +644,7 @@ FUNCTION(new_dyna_start):
a151a8d8 24 \readop r0, [r1, r3, lsl #\tab_shift]
25 .endif
26 movcc pc, lr
27- str r2, [fp, #LO_cycle]
28+@@@ str r2, [fp, #LO_cycle]
29 bx r1
30 .endm
31
3968e69e 32@@ -679,7 +679,7 @@ FUNCTION(jump_handler_read32):
a151a8d8 33 mov r0, r1
34 add r2, r2, r12
35 push {r2, lr}
36- str r2, [fp, #LO_cycle]
37+@@@ str r2, [fp, #LO_cycle]
38 blx r3
39
40 ldr r0, [fp, #LO_next_interupt]
3968e69e 41@@ -707,7 +707,7 @@ FUNCTION(jump_handler_write_h):
a151a8d8 42 add r2, r2, r12
43 mov r0, r1
44 push {r2, lr}
45- str r2, [fp, #LO_cycle]
46+@@@ str r2, [fp, #LO_cycle]
47 blx r3
48
49 ldr r0, [fp, #LO_next_interupt]
d1e4ebd9 50diff --git a/libpcsxcore/new_dynarec/linkage_arm64.S b/libpcsxcore/new_dynarec/linkage_arm64.S
3968e69e 51index 698bd78..798abea 100644
d1e4ebd9 52--- a/libpcsxcore/new_dynarec/linkage_arm64.S
53+++ b/libpcsxcore/new_dynarec/linkage_arm64.S
3968e69e 54@@ -119,7 +119,7 @@ FUNCTION(cc_interrupt):
d1e4ebd9 55 str wzr, [rFP, #LO_pending_exception]
56 and w2, w2, rCC, lsr #17
57 add x3, rFP, #LO_restore_candidate
58- str rCC, [rFP, #LO_cycle] /* PCSX cycles */
59+## str rCC, [rFP, #LO_cycle] /* PCSX cycles */
60 # str rCC, [rFP, #LO_reg_cop0+36] /* Count */
61 ldr w19, [x3, w2, uxtw]
62 mov x21, lr
3968e69e 63@@ -227,7 +227,7 @@ FUNCTION(new_dyna_start):
d1e4ebd9 64 FUNCTION(new_dyna_leave):
65 ldr w0, [rFP, #LO_last_count]
66 add rCC, rCC, w0
67- str rCC, [rFP, #LO_cycle]
68+## str rCC, [rFP, #LO_cycle]
69 ldp x19, x20, [sp, #16*1]
70 ldp x21, x22, [sp, #16*2]
71 ldp x23, x24, [sp, #16*3]
3968e69e 72@@ -245,7 +245,7 @@ FUNCTION(new_dyna_leave):
d1e4ebd9 73 /* w0 = adddr/data, x1 = rhandler, w2 = cycles, x3 = whandler */
74 ldr w4, [rFP, #LO_last_count]
75 add w4, w4, w2
76- str w4, [rFP, #LO_cycle]
77+## str w4, [rFP, #LO_cycle]
78 .endm
79
80 .macro memhandler_post
a151a8d8 81diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c
3968e69e 82index 1452db3..8200e44 100644
a151a8d8 83--- a/libpcsxcore/new_dynarec/new_dynarec.c
84+++ b/libpcsxcore/new_dynarec/new_dynarec.c
3968e69e 85@@ -44,10 +44,10 @@ static int sceBlock;
d1e4ebd9 86 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
87 #endif
a151a8d8 88
89-//#define DISASM
90-//#define assem_debug printf
91+#define DISASM
92+#define assem_debug printf
93 //#define inv_debug printf
94-#define assem_debug(...)
95+//#define assem_debug(...)
96 #define inv_debug(...)
97
98 #ifdef __i386__
3968e69e 99@@ -423,6 +423,9 @@ static int doesnt_expire_soon(void *tcaddr)
a151a8d8 100 // This is called from the recompiled JR/JALR instructions
d1e4ebd9 101 void noinline *get_addr(u_int vaddr)
a151a8d8 102 {
103+#ifdef DRC_DBG
104+printf("get_addr %08x, pc=%08x\n", vaddr, psxRegs.pc);
105+#endif
106 u_int page=get_page(vaddr);
107 u_int vpage=get_vpage(vaddr);
108 struct ll_entry *head;
3968e69e 109@@ -4393,13 +4396,15 @@ void do_cc(int i,signed char i_regmap[],int *adj,int addr,int taken,int invert)
a151a8d8 110 }
111 emit_addimm_and_set_flags(cycles,HOST_CCREG);
d1e4ebd9 112 jaddr=out;
a151a8d8 113- emit_jns(0);
d1e4ebd9 114+ //emit_jns(0);
115+ emit_jmp(0);
a151a8d8 116 }
117 else
118 {
119 emit_cmpimm(HOST_CCREG,-CLOCK_ADJUST(count+2));
d1e4ebd9 120 jaddr=out;
a151a8d8 121- emit_jns(0);
d1e4ebd9 122+ //emit_jns(0);
123+ emit_jmp(0);
a151a8d8 124 }
d1e4ebd9 125 add_stub(CC_STUB,jaddr,idle?idle:out,(*adj==0||invert||idle)?0:(count+2),i,addr,taken,0);
a151a8d8 126 }
3968e69e 127@@ -4807,7 +4812,8 @@ static void rjump_assemble(int i,struct regstat *i_regs)
a151a8d8 128 // special case for RFE
129 emit_jmp(0);
130 else
131- emit_jns(0);
132+ //emit_jns(0);
d1e4ebd9 133+ emit_jmp(0);
134 //load_regs_bt(branch_regs[i].regmap,branch_regs[i].dirty,-1);
a151a8d8 135 #ifdef USE_MINI_HT
136 if(rs1[i]==31) {
3968e69e 137@@ -4912,7 +4918,8 @@ static void cjump_assemble(int i,struct regstat *i_regs)
a151a8d8 138 else if(nop) {
139 emit_addimm_and_set_flags(CLOCK_ADJUST(ccadj[i]+2),cc);
d1e4ebd9 140 void *jaddr=out;
a151a8d8 141- emit_jns(0);
d1e4ebd9 142+ //emit_jns(0);
143+ emit_jmp(0);
144 add_stub(CC_STUB,jaddr,out,0,i,start+i*4+8,NOTTAKEN,0);
a151a8d8 145 }
146 else {
3968e69e 147@@ -5099,7 +5106,8 @@ static void cjump_assemble(int i,struct regstat *i_regs)
a151a8d8 148 emit_loadreg(CCREG,HOST_CCREG);
149 emit_addimm_and_set_flags(CLOCK_ADJUST(ccadj[i]+2),HOST_CCREG);
d1e4ebd9 150 void *jaddr=out;
a151a8d8 151- emit_jns(0);
d1e4ebd9 152+ //emit_jns(0);
153+ emit_jmp(0);
154 add_stub(CC_STUB,jaddr,out,0,i,start+i*4+8,NOTTAKEN,0);
a151a8d8 155 emit_storereg(CCREG,HOST_CCREG);
156 }
3968e69e 157@@ -5108,7 +5116,8 @@ static void cjump_assemble(int i,struct regstat *i_regs)
a151a8d8 158 assert(cc==HOST_CCREG);
159 emit_addimm_and_set_flags(CLOCK_ADJUST(ccadj[i]+2),cc);
d1e4ebd9 160 void *jaddr=out;
a151a8d8 161- emit_jns(0);
d1e4ebd9 162+ //emit_jns(0);
163+ emit_jmp(0);
164 add_stub(CC_STUB,jaddr,out,0,i,start+i*4+8,likely[i]?NULLDS:NOTTAKEN,0);
a151a8d8 165 }
166 }
3968e69e 167@@ -5210,7 +5219,8 @@ static void sjump_assemble(int i,struct regstat *i_regs)
a151a8d8 168 else if(nevertaken) {
169 emit_addimm_and_set_flags(CLOCK_ADJUST(ccadj[i]+2),cc);
d1e4ebd9 170 void *jaddr=out;
a151a8d8 171- emit_jns(0);
d1e4ebd9 172+ //emit_jns(0);
173+ emit_jmp(0);
174 add_stub(CC_STUB,jaddr,out,0,i,start+i*4+8,NOTTAKEN,0);
a151a8d8 175 }
176 else {
3968e69e 177@@ -5366,7 +5376,8 @@ static void sjump_assemble(int i,struct regstat *i_regs)
a151a8d8 178 emit_loadreg(CCREG,HOST_CCREG);
179 emit_addimm_and_set_flags(CLOCK_ADJUST(ccadj[i]+2),HOST_CCREG);
d1e4ebd9 180 void *jaddr=out;
a151a8d8 181- emit_jns(0);
d1e4ebd9 182+ //emit_jns(0);
183+ emit_jmp(0);
184 add_stub(CC_STUB,jaddr,out,0,i,start+i*4+8,NOTTAKEN,0);
a151a8d8 185 emit_storereg(CCREG,HOST_CCREG);
186 }
3968e69e 187@@ -5375,7 +5386,8 @@ static void sjump_assemble(int i,struct regstat *i_regs)
a151a8d8 188 assert(cc==HOST_CCREG);
189 emit_addimm_and_set_flags(CLOCK_ADJUST(ccadj[i]+2),cc);
d1e4ebd9 190 void *jaddr=out;
a151a8d8 191- emit_jns(0);
d1e4ebd9 192+ //emit_jns(0);
193+ emit_jmp(0);
194 add_stub(CC_STUB,jaddr,out,0,i,start+i*4+8,likely[i]?NULLDS:NOTTAKEN,0);
a151a8d8 195 }
196 }
3968e69e 197@@ -5863,7 +5875,7 @@ void unneeded_registers(int istart,int iend,int r)
a151a8d8 198 // R0 is always unneeded
d1e4ebd9 199 u|=1;
a151a8d8 200 // Save it
201- unneeded_reg[i]=u;
202+ unneeded_reg[i]=1;//u;
a151a8d8 203 gte_unneeded[i]=gte_u;
204 /*
d1e4ebd9 205 printf("ur (%d,%d) %x: ",istart,iend,start+i*4);
3968e69e 206@@ -8387,6 +8399,7 @@ int new_recompile_block(int addr)
a151a8d8 207
208 // This allocates registers (if possible) one instruction prior
209 // to use, which can avoid a load-use penalty on certain CPUs.
210+#if 0
211 for(i=0;i<slen-1;i++)
212 {
d1e4ebd9 213 if(!i||(itype[i-1]!=UJUMP&&itype[i-1]!=CJUMP&&itype[i-1]!=SJUMP&&itype[i-1]!=RJUMP))
3968e69e 214@@ -8543,6 +8556,7 @@ int new_recompile_block(int addr)
a151a8d8 215 }
216 }
217 }
218+#endif
219
220 /* Pass 6 - Optimize clean/dirty state */
221 clean_registers(0,slen-1,1);
3968e69e 222@@ -8842,6 +8856,11 @@ int new_recompile_block(int addr)
a151a8d8 223 case SPAN:
224 pagespan_assemble(i,&regs[i]);break;
225 }
226+
227+#ifdef DRC_DBG
228+ if(itype[i]!=UJUMP&&itype[i]!=CJUMP&&itype[i]!=SJUMP&&itype[i]!=RJUMP)
d1e4ebd9 229+ wb_dirtys(regs[i].regmap,regs[i].dirty);
a151a8d8 230+#endif
231 if(itype[i]==UJUMP||itype[i]==RJUMP||(source[i]>>16)==0x1000)
232 literal_pool(1024);
233 else
3968e69e 234@@ -8950,7 +8969,7 @@ int new_recompile_block(int addr)
a151a8d8 235 }
236 }
237 // External Branch Targets (jump_in)
238- if(copy+slen*4>(void *)shadow+sizeof(shadow)) copy=shadow;
239+ if(copy+slen*4>(void *)shadow+sizeof(shadow)) {copy=shadow;printf("shadow overflow\n");}
240 for(i=0;i<slen;i++)
241 {
242 if(bt[i]||i==0)
3968e69e 243@@ -9065,6 +9084,10 @@ int new_recompile_block(int addr)
a151a8d8 244 }
245 expirep=(expirep+1)&65535;
246 }
247+#ifdef DRC_DBG
248+printf("new_recompile_block done\n");
249+fflush(stdout);
250+#endif
251 return 0;
252 }
253