hint-less mode updated for SVP, state load callback, etc
[picodrive.git] / Pico / carthw / svp / gen_arm.c
index 87e8368..909433a 100644 (file)
        EMIT(((cond)<<28) | 0x05000000 | ((u)<<23) | ((b)<<22) | ((l)<<20) | ((rn)<<16) | ((rd)<<12) | (offset_12))
 
 /* addressing mode 3 */
-#define EOP_C_AM3_IMM(cond,u,l,rn,rd,s,h,offset_8) \
-       EMIT(((cond)<<28) | 0x01400090 | ((u)<<23) | ((l)<<20) | ((rn)<<16) | ((rd)<<12) | (((offset_8)&0xf0)<<4) | \
-                       ((s)<<6) | ((h)<<5) | ((offset_8)&0xf))
+#define EOP_C_AM3(cond,u,r,l,rn,rd,s,h,immed_reg) \
+       EMIT(((cond)<<28) | 0x01000090 | ((u)<<23) | ((r)<<22) | ((l)<<20) | ((rn)<<16) | ((rd)<<12) | \
+                       ((s)<<6) | ((h)<<5) | (immed_reg))
+
+#define EOP_C_AM3_IMM(cond,u,l,rn,rd,s,h,offset_8) EOP_C_AM3(cond,u,1,l,rn,rd,s,h,(((offset_8)&0xf0)<<4)|((offset_8)&0xf))
+
+#define EOP_C_AM3_REG(cond,u,l,rn,rd,s,h,rm)       EOP_C_AM3(cond,u,0,l,rn,rd,s,h,rm)
 
 /* ldr and str */
 #define EOP_LDR_IMM(   rd,rn,offset_12) EOP_C_AM2_IMM(A_COND_AL,1,0,1,rn,rd,offset_12)
 
 #define EOP_LDRH_IMM(   rd,rn,offset_8)  EOP_C_AM3_IMM(A_COND_AL,1,1,rn,rd,0,1,offset_8)
 #define EOP_LDRH_SIMPLE(rd,rn)           EOP_C_AM3_IMM(A_COND_AL,1,1,rn,rd,0,1,0)
+#define EOP_LDRH_REG(   rd,rn,rm)        EOP_C_AM3_REG(A_COND_AL,1,1,rn,rd,0,1,rm)
 #define EOP_STRH_IMM(   rd,rn,offset_8)  EOP_C_AM3_IMM(A_COND_AL,1,0,rn,rd,0,1,offset_8)
 #define EOP_STRH_SIMPLE(rd,rn)           EOP_C_AM3_IMM(A_COND_AL,1,0,rn,rd,0,1,0)
+#define EOP_STRH_REG(   rd,rn,rm)        EOP_C_AM3_REG(A_COND_AL,1,0,rn,rd,0,1,rm)
 
 /* ldm and stm */
 #define EOP_XXM(cond,p,u,s,w,l,rn,list) \
@@ -191,19 +197,16 @@ static void emit_call(void *target)
 
 static void emit_block_prologue(void)
 {
-       // stack regs
-       EOP_STMFD_ST(A_R4M|A_R5M|A_R6M|A_R7M|A_R8M|A_R9M|A_R10M|A_R11M|A_R14M); // stmfd r13!, {r4-r11,lr}
-       emit_call(regfile_load);
-       EOP_MOV_IMM(11, 0, 0);                  // mov r11, #0
+       // nothing
 }
 
-static void emit_block_epilogue(int icount)
+static void emit_block_epilogue(int cycles)
 {
-       if (icount > 0xff) { printf("large icount: %i\n", icount); icount = 0xff; }
-       emit_call(regfile_store);
-       EOP_ADD_IMM(0,11,0,icount);             // add r0, r11, #icount
-       EOP_LDMFD_ST(A_R4M|A_R5M|A_R6M|A_R7M|A_R8M|A_R9M|A_R10M|A_R11M|A_R14M); // ldmfd r13!, {r4-r11,lr}
-       EOP_BX(14);                             // bx r14
+       if (cycles > 0xff) { printf("large cycle count: %i\n", cycles); cycles = 0xff; }
+       EOP_SUB_IMM(11,11,0,cycles);            // sub r11, r11, #cycles
+#ifdef ARM
+       emit_call(ssp_drc_next);
+#endif
 }
 
 static void emit_pc_dump(int pc)