--- hatari/src/cpu/jit/gencomp.c 2019/04/09 08:49:24 1.1.1.1 +++ hatari/src/cpu/jit/gencomp.c 2019/04/09 08:55:31 1.1.1.2 @@ -262,7 +262,7 @@ gen_nextibyte (void) static void sync_m68k_pc (void) { - comprintf("\t if (m68k_pc_offset>100) sync_m68k_pc();\n"); + comprintf("\t if (m68k_pc_offset>JIT_M68K_PC_SYNC) sync_m68k_pc();\n"); } @@ -714,58 +714,61 @@ genmovemel (uae_u16 opcode) comprintf ("\tint i;\n"); comprintf ("\tint offset=0;\n"); genamode (table68k[opcode].dmode, "dstreg", table68k[opcode].size, "src", 2, 1); - comprintf("\tif (1 && !special_mem) {\n"); + if (table68k[opcode].size == sz_long) + comprintf("\tif (1 && !special_mem) {\n"); + else + comprintf("\tif (1 && !special_mem) {\n"); /* Fast but unsafe... */ - comprintf("\tget_n_addr(srca,native,scratchie);\n"); + comprintf("\t\tget_n_addr(srca,native,scratchie);\n"); - comprintf("\tfor (i=0;i<16;i++) {\n" - "\t\tif ((mask>>i)&1) {\n"); + comprintf("\t\tfor (i=0;i<16;i++) {\n" + "\t\t\tif ((mask>>i)&1) {\n"); switch(table68k[opcode].size) { case sz_long: - comprintf("\t\t\tmov_l_rR(i,native,offset);\n" - "\t\t\tgen_bswap_32(i);\n" - "\t\t\toffset+=4;\n"); + comprintf("\t\t\t\tmov_l_rR(i,native,offset);\n" + "\t\t\t\tgen_bswap_32(i);\n" + "\t\t\t\toffset+=4;\n"); break; case sz_word: - comprintf("\t\t\tmov_w_rR(i,native,offset);\n" - "\t\t\tgen_bswap_16(i);\n" - "\t\t\tsign_extend_16_rr(i,i);\n" - "\t\t\toffset+=2;\n"); + comprintf("\t\t\t\tmov_w_rR(i,native,offset);\n" + "\t\t\t\tgen_bswap_16(i);\n" + "\t\t\t\tsign_extend_16_rr(i,i);\n" + "\t\t\t\toffset+=2;\n"); break; default: abort(); } - comprintf("\t\t}\n" - "\t}"); + comprintf("\t\t\t}\n" + "\t\t}\n"); if (table68k[opcode].dmode == Aipi) { - comprintf("\t\t\tlea_l_brr(8+dstreg,srca,offset);\n"); + comprintf("\t\tlea_l_brr(8+dstreg,srca,offset);\n"); } /* End fast but unsafe. */ comprintf("\t} else {\n"); - comprintf ("\tint tmp=scratchie++;\n"); + comprintf ("\t\tint tmp=scratchie++;\n"); - comprintf("\tmov_l_rr(tmp,srca);\n"); - comprintf("\tfor (i=0;i<16;i++) {\n" - "\t\tif ((mask>>i)&1) {\n"); + comprintf("\t\tmov_l_rr(tmp,srca);\n"); + comprintf("\t\tfor (i=0;i<16;i++) {\n" + "\t\t\tif ((mask>>i)&1) {\n"); switch(table68k[opcode].size) { case sz_long: - comprintf("\t\t\treadlong(tmp,i,scratchie);\n" - "\t\t\tadd_l_ri(tmp,4);\n"); + comprintf("\t\t\t\treadlong(tmp,i,scratchie);\n" + "\t\t\t\tadd_l_ri(tmp,4);\n"); break; case sz_word: - comprintf("\t\t\treadword(tmp,i,scratchie);\n" - "\t\t\tadd_l_ri(tmp,2);\n"); + comprintf("\t\t\t\treadword(tmp,i,scratchie);\n" + "\t\t\t\tadd_l_ri(tmp,2);\n"); break; default: abort(); } - comprintf("\t\t}\n" - "\t}"); + comprintf("\t\t\t}\n" + "\t\t}\n"); if (table68k[opcode].dmode == Aipi) { - comprintf("\t\t\tmov_l_rr(8+dstreg,tmp);\n"); + comprintf("\t\tmov_l_rr(8+dstreg,tmp);\n"); } comprintf("\t}\n"); @@ -787,7 +790,10 @@ genmovemle (uae_u16 opcode) on her, but unfortunately, gfx mem isn't "real" mem, and thus that act of cleverness means that movmle must pay attention to special_mem, or Genetic Species is a rather boring-looking game ;-) */ - comprintf("\tif (1 && !special_mem) {\n"); + if (table68k[opcode].size == sz_long) + comprintf("\tif (1 && !special_mem) {\n"); + else + comprintf("\tif (1 && !special_mem) {\n"); comprintf("\tget_n_addr(srca,native,scratchie);\n"); if (table68k[opcode].dmode!=Apdi) { @@ -2883,6 +2889,114 @@ generate_includes (FILE * f, int bigger) static int postfix; + +static char *decodeEA (amodes mode, wordsizes size) +{ + static char buffer[80]; + + buffer[0] = 0; + switch (mode){ + case Dreg: + strcpy (buffer,"Dn"); + break; + case Areg: + strcpy (buffer,"An"); + break; + case Aind: + strcpy (buffer,"(An)"); + break; + case Aipi: + strcpy (buffer,"(An)+"); + break; + case Apdi: + strcpy (buffer,"-(An)"); + break; + case Ad16: + strcpy (buffer,"(d16,An)"); + break; + case Ad8r: + strcpy (buffer,"(d8,An,Xn)"); + break; + case PC16: + strcpy (buffer,"(d16,PC)"); + break; + case PC8r: + strcpy (buffer,"(d8,PC,Xn)"); + break; + case absw: + strcpy (buffer,"(xxx).W"); + break; + case absl: + strcpy (buffer,"(xxx).L"); + break; + case imm: + switch (size){ + case sz_byte: + strcpy (buffer,"#.B"); + break; + case sz_word: + strcpy (buffer,"#.W"); + break; + case sz_long: + strcpy (buffer,"#.L"); + break; + default: + break; + } + break; + case imm0: + strcpy (buffer,"#.B"); + break; + case imm1: + strcpy (buffer,"#.W"); + break; + case imm2: + strcpy (buffer,"#.L"); + break; + case immi: + strcpy (buffer,"#"); + break; + + default: + break; + } + return buffer; +} + +static char *outopcode (int opcode) +{ + static char out[100]; + struct instr *ins; + int i; + + ins = &table68k[opcode]; + for (i = 0; lookuptab[i].name[0]; i++) { + if (ins->mnemo == lookuptab[i].mnemo) + break; + } + { + char *s = ua (lookuptab[i].name); + strcpy (out, s); + xfree (s); + } + if (ins->smode == immi) + strcat (out, "Q"); + if (ins->size == sz_byte) + strcat (out,".B"); + if (ins->size == sz_word) + strcat (out,".W"); + if (ins->size == sz_long) + strcat (out,".L"); + strcat (out," "); + if (ins->suse) + strcat (out, decodeEA (ins->smode, ins->size)); + if (ins->duse) { + if (ins->suse) strcat (out,","); + strcat (out, decodeEA (ins->dmode, ins->size)); + } + return out; +} + static void generate_one_opcode (int rp, int noflags) { @@ -3011,25 +3125,24 @@ generate_one_opcode (int rp, int noflags comprintf ("return 0;\n"); comprintf ("}\n"); - char name[100] = { 0 }; - for (int k = 0; lookuptab[i].name[k]; k++) - name[k] = lookuptab[i].name[k]; - + char *name = ua (lookuptab[i].name); if (aborted) { fprintf (stblfile, "{ NULL, %ld, 0x%08x }, /* %s */\n", opcode, flags, name); com_discard(); } else { - if (noflags) { + printf ("/* %s */\n", outopcode (opcode)); + if (noflags) { fprintf (stblfile, "{ op_%lx_%d_comp_nf, %ld, 0x%08x }, /* %s */\n", opcode, postfix, opcode, flags, name); fprintf (headerfile, "extern compop_func op_%lx_%d_comp_nf;\n", opcode, postfix); - printf ("unsigned long REGPARAM2 op_%lx_%d_comp_nf(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, name); + printf ("uae_u32 REGPARAM2 op_%lx_%d_comp_nf(uae_u32 opcode)\n{\n", opcode, postfix); } else { fprintf (stblfile, "{ op_%lx_%d_comp_ff, %ld, 0x%08x }, /* %s */\n", opcode, postfix, opcode, flags, name); fprintf (headerfile, "extern compop_func op_%lx_%d_comp_ff;\n", opcode, postfix); - printf ("unsigned long REGPARAM2 op_%lx_%d_comp_ff(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, name); + printf ("uae_u32 REGPARAM2 op_%lx_%d_comp_ff(uae_u32 opcode)\n{\n", opcode, postfix); } com_flush(); } + xfree (name); } opcode_next_clev[rp] = next_cpu_level; opcode_last_postfix[rp] = postfix; @@ -3074,6 +3187,8 @@ generate_func (int noflags) "extern void comp_fscc_opp();\n" "extern void comp_fbcc_opp();\n\n"); + printf ("#define JIT_M68K_PC_SYNC 100\n\n"); + rp = 0; for (j = 1; j <= 8; ++j) { @@ -3142,3 +3257,7 @@ main (int argc, char **argv) free (table68k); return 0; } + +void write_log (const TCHAR *format,...) +{ +}