Commit 9621339dcacc148a86d312d1e71623202c9df7db

Authored by bellard
1 parent ede28208

changed basic block exit generation


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@322 c046a42c-6fe2-441c-8c8c-71466251a162
dyngen-exec.h
... ... @@ -125,6 +125,8 @@ extern int printf(const char *, ...);
125 125  
126 126 #define xglue(x, y) x ## y
127 127 #define glue(x, y) xglue(x, y)
  128 +#define stringify(s) tostring(s)
  129 +#define tostring(s) #s
128 130  
129 131 #ifdef __alpha__
130 132 /* the symbols are considered non exported so a br immediate is generated */
... ... @@ -153,3 +155,27 @@ extern int __op_param1, __op_param2, __op_param3;
153 155 #endif
154 156  
155 157 extern int __op_jmp0, __op_jmp1;
  158 +
  159 +#ifdef __i386__
  160 +#define EXIT_TB() asm volatile ("ret")
  161 +#endif
  162 +#ifdef __powerpc__
  163 +#define EXIT_TB() asm volatile ("blr")
  164 +#endif
  165 +#ifdef __s390__
  166 +#define EXIT_TB() asm volatile ("br %r14")
  167 +#endif
  168 +#ifdef __alpha__
  169 +#define EXIT_TB() asm volatile ("ret")
  170 +#endif
  171 +#ifdef __ia64__
  172 +#define EXIT_TB() asm volatile ("br.ret.sptk.many b0;;")
  173 +#endif
  174 +#ifdef __sparc__
  175 +#define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0\n"
  176 + "nop")
  177 +#endif
  178 +#ifdef __arm__
  179 +#define EXIT_TB() asm volatile ("b exec_loop")
  180 +#endif
  181 +
... ...
dyngen.c
... ... @@ -1306,38 +1306,10 @@ fprintf(outfile,
1306 1306 " the_end:\n"
1307 1307 );
1308 1308  
1309   -/* generate epilogue */
1310   - switch(ELF_ARCH) {
1311   - case EM_386:
1312   - fprintf(outfile, "*gen_code_ptr++ = 0xc3; /* ret */\n");
1313   - break;
1314   - case EM_PPC:
1315   - fprintf(outfile, "*((uint32_t *)gen_code_ptr)++ = 0x4e800020; /* blr */\n");
1316   - break;
1317   - case EM_S390:
1318   - fprintf(outfile, "*((uint16_t *)gen_code_ptr)++ = 0x07fe; /* br %%r14 */\n");
1319   - break;
1320   - case EM_ALPHA:
1321   - fprintf(outfile, "*((uint32_t *)gen_code_ptr)++ = 0x6bfa8001; /* ret */\n");
1322   - break;
1323   - case EM_IA_64:
1324   - fprintf(outfile, "*((uint32_t *)gen_code_ptr)++ = 0x00840008; /* br.ret.sptk.many b0;; */\n");
1325   - break;
1326   - case EM_SPARC:
1327   - case EM_SPARC32PLUS:
1328   - fprintf(outfile, "*((uint32_t *)gen_code_ptr)++ = 0x81c62008; /* jmpl %%i0 + 8, %%g0 */\n");
1329   - fprintf(outfile, "*((uint32_t *)gen_code_ptr)++ = 0x01000000; /* nop */\n");
1330   - break;
1331   - case EM_SPARCV9:
1332   - fprintf(outfile, "*((uint32_t *)gen_code_ptr)++ = 0x81c7e008; /* ret */\n");
1333   - fprintf(outfile, "*((uint32_t *)gen_code_ptr)++ = 0x81e80000; /* restore */\n");
1334   - break;
1335   - case EM_ARM:
1336   - fprintf(outfile, "gen_code_ptr = arm_flush_ldr(gen_code_ptr, arm_ldr_table, arm_ldr_ptr, arm_data_table, arm_data_ptr, 0);\n");
1337   - break;
1338   - default:
1339   - error("unknown ELF architecture");
1340   - }
  1309 +/* generate some code patching */
  1310 +#ifdef HOST_ARM
  1311 +fprintf(outfile, "gen_code_ptr = arm_flush_ldr(gen_code_ptr, arm_ldr_table, arm_ldr_ptr, arm_data_table, arm_data_ptr, 0);\n");
  1312 +#endif
1341 1313 /* flush instruction cache */
1342 1314 fprintf(outfile, "flush_icache_range((unsigned long)gen_code_buf, (unsigned long)gen_code_ptr);\n");
1343 1315  
... ...
dyngen.h
... ... @@ -152,11 +152,7 @@ static uint8_t *arm_flush_ldr(uint8_t *gen_code_ptr,
152 152  
153 153 data_size = (uint8_t *)data_end - (uint8_t *)data_start;
154 154  
155   - if (!gen_jmp) {
156   - /* b exec_loop */
157   - arm_reloc_pc24((uint32_t *)gen_code_ptr, 0xeafffffe, (long)(&exec_loop));
158   - gen_code_ptr += 4;
159   - } else {
  155 + if (gen_jmp) {
160 156 /* generate branch to skip the data */
161 157 if (data_size == 0)
162 158 return gen_code_ptr;
... ...
... ... @@ -225,7 +225,7 @@ label ## n:\
225 225 T0 = (long)(tbparam) + (n);\
226 226 EIP = eip;\
227 227 dummy_label ## n:\
228   - return;\
  228 + EXIT_TB();\
229 229 } while (0)
230 230  
231 231 #endif
... ...
op-arm.c
... ... @@ -338,6 +338,11 @@ void OPPROTO op_jmp(void)
338 338 JUMP_TB(PARAM1, 1, PARAM2);
339 339 }
340 340  
  341 +void OPPROTO op_exit_tb(void)
  342 +{
  343 + EXIT_TB();
  344 +}
  345 +
341 346 void OPPROTO op_movl_T0_psr(void)
342 347 {
343 348 T0 = compute_cpsr();
... ...
op-i386.c
... ... @@ -566,6 +566,11 @@ void OPPROTO op_movl_T0_0(void)
566 566 T0 = 0;
567 567 }
568 568  
  569 +void OPPROTO op_exit_tb(void)
  570 +{
  571 + EXIT_TB();
  572 +}
  573 +
569 574 /* multiple size ops */
570 575  
571 576 #define ldul ldl
... ...
translate-arm.c
... ... @@ -828,6 +828,7 @@ static inline int gen_intermediate_code_internal(TranslationBlock *tb, int searc
828 828 case DISAS_JUMP:
829 829 /* indicate that the hash table must be used to find the next TB */
830 830 gen_op_movl_T0_0();
  831 + gen_op_exit_tb();
831 832 break;
832 833 case DISAS_TB_JUMP:
833 834 /* nothing more to generate */
... ...
translate-i386.c
... ... @@ -4163,6 +4163,7 @@ static inline int gen_intermediate_code_internal(TranslationBlock *tb, int searc
4163 4163 if (dc->is_jmp != DISAS_TB_JUMP) {
4164 4164 /* indicate that the hash table must be used to find the next TB */
4165 4165 gen_op_movl_T0_0();
  4166 + gen_op_exit_tb();
4166 4167 }
4167 4168 *gen_opc_ptr = INDEX_op_end;
4168 4169 /* we don't forget to fill the last values */
... ...