filename | src/sh4/sh4x86.in |
changeset | 409:549e00835448 |
prev | 408:af496b734734 |
next | 416:714df603c869 |
author | nkeynes |
date | Sat Sep 29 05:33:02 2007 +0000 (13 years ago) |
permissions | -rw-r--r-- |
last change | Modify termination again to allow early exit (eg on end-of-page), as well as allowing follow through on conditional branches if desired. |
file | annotate | diff | log | raw |
1.1 --- a/src/sh4/sh4x86.in Fri Sep 28 07:27:20 2007 +00001.2 +++ b/src/sh4/sh4x86.in Sat Sep 29 05:33:02 2007 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: sh4x86.in,v 1.16 2007-09-28 07:27:20 nkeynes Exp $1.6 + * $Id: sh4x86.in,v 1.17 2007-09-29 05:33:02 nkeynes Exp $1.7 *1.8 * SH4 => x86 translation. This version does no real optimization, it just1.9 * outputs straight-line x86 code - it mainly exists to provide a baseline1.10 @@ -42,6 +42,7 @@1.11 gboolean in_delay_slot;1.12 gboolean priv_checked; /* true if we've already checked the cpu mode. */1.13 gboolean fpuen_checked; /* true if we've already checked fpu enabled. */1.14 + gboolean branch_taken; /* true if we branched unconditionally */1.15 uint32_t block_start_pc;1.17 /* Allocated memory for the (block-wide) back-patch list */1.18 @@ -371,6 +372,7 @@1.19 sh4_x86.in_delay_slot = FALSE;1.20 sh4_x86.priv_checked = FALSE;1.21 sh4_x86.fpuen_checked = FALSE;1.22 + sh4_x86.branch_taken = FALSE;1.23 sh4_x86.backpatch_posn = 0;1.24 sh4_x86.block_start_pc = pc;1.25 }1.26 @@ -410,6 +412,10 @@1.27 * Write the block trailer (exception handling block)1.28 */1.29 void sh4_translate_end_block( sh4addr_t pc ) {1.30 + if( sh4_x86.branch_taken == FALSE ) {1.31 + // Didn't exit unconditionally already, so write the termination here1.32 + exit_block( pc, pc );1.33 + }1.34 if( sh4_x86.backpatch_posn != 0 ) {1.35 uint8_t *end_ptr = xlat_output;1.36 // Exception termination. Jump block for various exception codes:1.37 @@ -1282,7 +1288,6 @@1.38 JNE_rel8( 30, nottaken );1.39 exit_block( disp + pc + 4, pc+2 );1.40 JMP_TARGET(nottaken);1.41 - exit_block( pc + 2, pc + 2 );1.42 return 2;1.43 }1.44 :}1.45 @@ -1298,7 +1303,6 @@1.46 // not taken1.47 *patch = (xlat_output - ((uint8_t *)patch)) - 4;1.48 sh4_x86_translate_instruction(pc+2);1.49 - exit_block( pc + 4, pc+4 );1.50 return 4;1.51 }1.52 :}1.53 @@ -1309,6 +1313,7 @@1.54 sh4_x86.in_delay_slot = TRUE;1.55 sh4_x86_translate_instruction( pc + 2 );1.56 exit_block( disp + pc + 4, pc+4 );1.57 + sh4_x86.branch_taken = TRUE;1.58 return 4;1.59 }1.60 :}1.61 @@ -1322,6 +1327,7 @@1.62 sh4_x86.in_delay_slot = TRUE;1.63 sh4_x86_translate_instruction( pc + 2 );1.64 exit_block_pcset(pc+2);1.65 + sh4_x86.branch_taken = TRUE;1.66 return 4;1.67 }1.68 :}1.69 @@ -1334,6 +1340,7 @@1.70 sh4_x86.in_delay_slot = TRUE;1.71 sh4_x86_translate_instruction( pc + 2 );1.72 exit_block( disp + pc + 4, pc+4 );1.73 + sh4_x86.branch_taken = TRUE;1.74 return 4;1.75 }1.76 :}1.77 @@ -1348,6 +1355,7 @@1.78 sh4_x86.in_delay_slot = TRUE;1.79 sh4_x86_translate_instruction( pc + 2 );1.80 exit_block_pcset(pc+2);1.81 + sh4_x86.branch_taken = TRUE;1.82 return 4;1.83 }1.84 :}1.85 @@ -1359,7 +1367,6 @@1.86 JE_rel8( 30, nottaken );1.87 exit_block( disp + pc + 4, pc+2 );1.88 JMP_TARGET(nottaken);1.89 - exit_block( pc + 2, pc+2 );1.90 return 2;1.91 }1.92 :}1.93 @@ -1375,7 +1382,6 @@1.94 // not taken1.95 *patch = (xlat_output - ((uint8_t *)patch)) - 4;1.96 sh4_x86_translate_instruction(pc+2);1.97 - exit_block( pc + 4, pc+4 );1.98 return 4;1.99 }1.100 :}1.101 @@ -1388,6 +1394,7 @@1.102 sh4_x86.in_delay_slot = TRUE;1.103 sh4_x86_translate_instruction(pc+2);1.104 exit_block_pcset(pc+2);1.105 + sh4_x86.branch_taken = TRUE;1.106 return 4;1.107 }1.108 :}1.109 @@ -1402,6 +1409,7 @@1.110 sh4_x86.in_delay_slot = TRUE;1.111 sh4_x86_translate_instruction(pc+2);1.112 exit_block_pcset(pc+2);1.113 + sh4_x86.branch_taken = TRUE;1.114 return 4;1.115 }1.116 :}1.117 @@ -1419,6 +1427,7 @@1.118 sh4_x86.fpuen_checked = FALSE;1.119 sh4_x86_translate_instruction(pc+2);1.120 exit_block_pcset(pc+2);1.121 + sh4_x86.branch_taken = TRUE;1.122 return 4;1.123 }1.124 :}1.125 @@ -1431,6 +1440,7 @@1.126 sh4_x86.in_delay_slot = TRUE;1.127 sh4_x86_translate_instruction(pc+2);1.128 exit_block_pcset(pc+2);1.129 + sh4_x86.branch_taken = TRUE;1.130 return 4;1.131 }1.132 :}1.133 @@ -1442,6 +1452,7 @@1.134 call_func0( sh4_raise_trap );1.135 ADD_imm8s_r32( 4, R_ESP );1.136 exit_block_pcset(pc);1.137 + sh4_x86.branch_taken = TRUE;1.138 return 2;1.139 }1.140 :}1.141 @@ -2283,7 +2294,6 @@1.142 call_func0( sh4_sleep );1.143 sh4_x86.in_delay_slot = FALSE;1.144 INC_r32(R_ESI);1.145 - exit_block(pc+2, pc+2);1.146 return 2;1.147 :}1.148 STC SR, Rn {:
.