Commit 72a9747b79e2facf84a61248196d8fcf17665b35

Authored by blueswir1
1 parent 44e7757c

Convert save, restore, saved, restored, and flushw to TCG


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4092 c046a42c-6fe2-441c-8c8c-71466251a162
target-sparc/helper.h
@@ -8,6 +8,9 @@ target_ulong TCG_HELPER_PROTO helper_rdpsr(void); @@ -8,6 +8,9 @@ target_ulong TCG_HELPER_PROTO helper_rdpsr(void);
8 void TCG_HELPER_PROTO helper_wrpstate(target_ulong new_state); 8 void TCG_HELPER_PROTO helper_wrpstate(target_ulong new_state);
9 void TCG_HELPER_PROTO helper_done(void); 9 void TCG_HELPER_PROTO helper_done(void);
10 void TCG_HELPER_PROTO helper_retry(void); 10 void TCG_HELPER_PROTO helper_retry(void);
  11 +void TCG_HELPER_PROTO helper_flushw(void);
  12 +void TCG_HELPER_PROTO helper_saved(void);
  13 +void TCG_HELPER_PROTO helper_restored(void);
11 target_ulong TCG_HELPER_PROTO helper_rdccr(void); 14 target_ulong TCG_HELPER_PROTO helper_rdccr(void);
12 void TCG_HELPER_PROTO helper_wrccr(target_ulong new_ccr); 15 void TCG_HELPER_PROTO helper_wrccr(target_ulong new_ccr);
13 target_ulong TCG_HELPER_PROTO helper_rdcwp(void); 16 target_ulong TCG_HELPER_PROTO helper_rdcwp(void);
@@ -35,6 +38,8 @@ void TCG_HELPER_PROTO helper_trap(target_ulong nb_trap); @@ -35,6 +38,8 @@ void TCG_HELPER_PROTO helper_trap(target_ulong nb_trap);
35 void TCG_HELPER_PROTO helper_trapcc(target_ulong nb_trap, 38 void TCG_HELPER_PROTO helper_trapcc(target_ulong nb_trap,
36 target_ulong do_trap); 39 target_ulong do_trap);
37 void TCG_HELPER_PROTO helper_debug(void); 40 void TCG_HELPER_PROTO helper_debug(void);
  41 +void TCG_HELPER_PROTO helper_save(void);
  42 +void TCG_HELPER_PROTO helper_restore(void);
38 void TCG_HELPER_PROTO helper_flush(target_ulong addr); 43 void TCG_HELPER_PROTO helper_flush(target_ulong addr);
39 target_ulong TCG_HELPER_PROTO helper_udiv(target_ulong a, target_ulong b); 44 target_ulong TCG_HELPER_PROTO helper_udiv(target_ulong a, target_ulong b);
40 target_ulong TCG_HELPER_PROTO helper_sdiv(target_ulong a, target_ulong b); 45 target_ulong TCG_HELPER_PROTO helper_sdiv(target_ulong a, target_ulong b);
target-sparc/op.c
@@ -37,109 +37,11 @@ @@ -37,109 +37,11 @@
37 #endif 37 #endif
38 #endif 38 #endif
39 39
40 -#ifndef TARGET_SPARC64  
41 -/* XXX: use another pointer for %iN registers to avoid slow wrapping  
42 - handling ? */  
43 -void OPPROTO op_save(void)  
44 -{  
45 - uint32_t cwp;  
46 - cwp = (env->cwp - 1) & (NWINDOWS - 1);  
47 - if (env->wim & (1 << cwp)) {  
48 - raise_exception(TT_WIN_OVF);  
49 - }  
50 - set_cwp(cwp);  
51 - FORCE_RET();  
52 -}  
53 -  
54 -void OPPROTO op_restore(void)  
55 -{  
56 - uint32_t cwp;  
57 - cwp = (env->cwp + 1) & (NWINDOWS - 1);  
58 - if (env->wim & (1 << cwp)) {  
59 - raise_exception(TT_WIN_UNF);  
60 - }  
61 - set_cwp(cwp);  
62 - FORCE_RET();  
63 -}  
64 -#else  
65 -/* XXX: use another pointer for %iN registers to avoid slow wrapping  
66 - handling ? */  
67 -void OPPROTO op_save(void)  
68 -{  
69 - uint32_t cwp;  
70 - cwp = (env->cwp - 1) & (NWINDOWS - 1);  
71 - if (env->cansave == 0) {  
72 - raise_exception(TT_SPILL | (env->otherwin != 0 ?  
73 - (TT_WOTHER | ((env->wstate & 0x38) >> 1)):  
74 - ((env->wstate & 0x7) << 2)));  
75 - } else {  
76 - if (env->cleanwin - env->canrestore == 0) {  
77 - // XXX Clean windows without trap  
78 - raise_exception(TT_CLRWIN);  
79 - } else {  
80 - env->cansave--;  
81 - env->canrestore++;  
82 - set_cwp(cwp);  
83 - }  
84 - }  
85 - FORCE_RET();  
86 -}  
87 -  
88 -void OPPROTO op_restore(void)  
89 -{  
90 - uint32_t cwp;  
91 - cwp = (env->cwp + 1) & (NWINDOWS - 1);  
92 - if (env->canrestore == 0) {  
93 - raise_exception(TT_FILL | (env->otherwin != 0 ?  
94 - (TT_WOTHER | ((env->wstate & 0x38) >> 1)):  
95 - ((env->wstate & 0x7) << 2)));  
96 - } else {  
97 - env->cansave++;  
98 - env->canrestore--;  
99 - set_cwp(cwp);  
100 - }  
101 - FORCE_RET();  
102 -}  
103 -#endif  
104 -  
105 void OPPROTO op_jmp_label(void) 40 void OPPROTO op_jmp_label(void)
106 { 41 {
107 GOTO_LABEL_PARAM(1); 42 GOTO_LABEL_PARAM(1);
108 } 43 }
109 44
110 -#ifdef TARGET_SPARC64  
111 -void OPPROTO op_flushw(void)  
112 -{  
113 - if (env->cansave != NWINDOWS - 2) {  
114 - raise_exception(TT_SPILL | (env->otherwin != 0 ?  
115 - (TT_WOTHER | ((env->wstate & 0x38) >> 1)):  
116 - ((env->wstate & 0x7) << 2)));  
117 - }  
118 -}  
119 -  
120 -void OPPROTO op_saved(void)  
121 -{  
122 - env->cansave++;  
123 - if (env->otherwin == 0)  
124 - env->canrestore--;  
125 - else  
126 - env->otherwin--;  
127 - FORCE_RET();  
128 -}  
129 -  
130 -void OPPROTO op_restored(void)  
131 -{  
132 - env->canrestore++;  
133 - if (env->cleanwin < NWINDOWS - 1)  
134 - env->cleanwin++;  
135 - if (env->otherwin == 0)  
136 - env->cansave--;  
137 - else  
138 - env->otherwin--;  
139 - FORCE_RET();  
140 -}  
141 -#endif  
142 -  
143 #define CHECK_ALIGN_OP(align) \ 45 #define CHECK_ALIGN_OP(align) \
144 void OPPROTO op_check_align_T0_ ## align (void) \ 46 void OPPROTO op_check_align_T0_ ## align (void) \
145 { \ 47 { \
target-sparc/op_helper.c
@@ -2246,6 +2246,30 @@ void helper_debug(void) @@ -2246,6 +2246,30 @@ void helper_debug(void)
2246 } 2246 }
2247 2247
2248 #ifndef TARGET_SPARC64 2248 #ifndef TARGET_SPARC64
  2249 +/* XXX: use another pointer for %iN registers to avoid slow wrapping
  2250 + handling ? */
  2251 +void helper_save(void)
  2252 +{
  2253 + uint32_t cwp;
  2254 +
  2255 + cwp = (env->cwp - 1) & (NWINDOWS - 1);
  2256 + if (env->wim & (1 << cwp)) {
  2257 + raise_exception(TT_WIN_OVF);
  2258 + }
  2259 + set_cwp(cwp);
  2260 +}
  2261 +
  2262 +void helper_restore(void)
  2263 +{
  2264 + uint32_t cwp;
  2265 +
  2266 + cwp = (env->cwp + 1) & (NWINDOWS - 1);
  2267 + if (env->wim & (1 << cwp)) {
  2268 + raise_exception(TT_WIN_UNF);
  2269 + }
  2270 + set_cwp(cwp);
  2271 +}
  2272 +
2249 void helper_wrpsr(target_ulong new_psr) 2273 void helper_wrpsr(target_ulong new_psr)
2250 { 2274 {
2251 if ((new_psr & PSR_CWP) >= NWINDOWS) 2275 if ((new_psr & PSR_CWP) >= NWINDOWS)
@@ -2260,6 +2284,74 @@ target_ulong helper_rdpsr(void) @@ -2260,6 +2284,74 @@ target_ulong helper_rdpsr(void)
2260 } 2284 }
2261 2285
2262 #else 2286 #else
  2287 +/* XXX: use another pointer for %iN registers to avoid slow wrapping
  2288 + handling ? */
  2289 +void helper_save(void)
  2290 +{
  2291 + uint32_t cwp;
  2292 +
  2293 + cwp = (env->cwp - 1) & (NWINDOWS - 1);
  2294 + if (env->cansave == 0) {
  2295 + raise_exception(TT_SPILL | (env->otherwin != 0 ?
  2296 + (TT_WOTHER | ((env->wstate & 0x38) >> 1)):
  2297 + ((env->wstate & 0x7) << 2)));
  2298 + } else {
  2299 + if (env->cleanwin - env->canrestore == 0) {
  2300 + // XXX Clean windows without trap
  2301 + raise_exception(TT_CLRWIN);
  2302 + } else {
  2303 + env->cansave--;
  2304 + env->canrestore++;
  2305 + set_cwp(cwp);
  2306 + }
  2307 + }
  2308 +}
  2309 +
  2310 +void helper_restore(void)
  2311 +{
  2312 + uint32_t cwp;
  2313 +
  2314 + cwp = (env->cwp + 1) & (NWINDOWS - 1);
  2315 + if (env->canrestore == 0) {
  2316 + raise_exception(TT_FILL | (env->otherwin != 0 ?
  2317 + (TT_WOTHER | ((env->wstate & 0x38) >> 1)):
  2318 + ((env->wstate & 0x7) << 2)));
  2319 + } else {
  2320 + env->cansave++;
  2321 + env->canrestore--;
  2322 + set_cwp(cwp);
  2323 + }
  2324 +}
  2325 +
  2326 +void helper_flushw(void)
  2327 +{
  2328 + if (env->cansave != NWINDOWS - 2) {
  2329 + raise_exception(TT_SPILL | (env->otherwin != 0 ?
  2330 + (TT_WOTHER | ((env->wstate & 0x38) >> 1)):
  2331 + ((env->wstate & 0x7) << 2)));
  2332 + }
  2333 +}
  2334 +
  2335 +void helper_saved(void)
  2336 +{
  2337 + env->cansave++;
  2338 + if (env->otherwin == 0)
  2339 + env->canrestore--;
  2340 + else
  2341 + env->otherwin--;
  2342 +}
  2343 +
  2344 +void helper_restored(void)
  2345 +{
  2346 + env->canrestore++;
  2347 + if (env->cleanwin < NWINDOWS - 1)
  2348 + env->cleanwin++;
  2349 + if (env->otherwin == 0)
  2350 + env->cansave--;
  2351 + else
  2352 + env->otherwin--;
  2353 +}
  2354 +
2263 target_ulong helper_rdccr(void) 2355 target_ulong helper_rdccr(void)
2264 { 2356 {
2265 return GET_CCR(env); 2357 return GET_CCR(env);
target-sparc/translate.c
@@ -2280,7 +2280,7 @@ static void disas_sparc_insn(DisasContext * dc) @@ -2280,7 +2280,7 @@ static void disas_sparc_insn(DisasContext * dc)
2280 break; 2280 break;
2281 } else if (xop == 0x2b) { /* rdtbr / V9 flushw */ 2281 } else if (xop == 0x2b) { /* rdtbr / V9 flushw */
2282 #ifdef TARGET_SPARC64 2282 #ifdef TARGET_SPARC64
2283 - gen_op_flushw(); 2283 + tcg_gen_helper_0_0(helper_flushw);
2284 #else 2284 #else
2285 if (!supervisor(dc)) 2285 if (!supervisor(dc))
2286 goto priv_insn; 2286 goto priv_insn;
@@ -3251,10 +3251,10 @@ static void disas_sparc_insn(DisasContext * dc) @@ -3251,10 +3251,10 @@ static void disas_sparc_insn(DisasContext * dc)
3251 #ifdef TARGET_SPARC64 3251 #ifdef TARGET_SPARC64
3252 switch (rd) { 3252 switch (rd) {
3253 case 0: 3253 case 0:
3254 - gen_op_saved(); 3254 + tcg_gen_helper_0_0(helper_saved);
3255 break; 3255 break;
3256 case 1: 3256 case 1:
3257 - gen_op_restored(); 3257 + tcg_gen_helper_0_0(helper_restored);
3258 break; 3258 break;
3259 case 2: /* UA2005 allclean */ 3259 case 2: /* UA2005 allclean */
3260 case 3: /* UA2005 otherw */ 3260 case 3: /* UA2005 otherw */
@@ -3954,7 +3954,7 @@ static void disas_sparc_insn(DisasContext * dc) @@ -3954,7 +3954,7 @@ static void disas_sparc_insn(DisasContext * dc)
3954 } 3954 }
3955 #endif 3955 #endif
3956 } 3956 }
3957 - gen_op_restore(); 3957 + tcg_gen_helper_0_0(helper_restore);
3958 gen_mov_pc_npc(dc); 3958 gen_mov_pc_npc(dc);
3959 gen_op_check_align_T0_3(); 3959 gen_op_check_align_T0_3();
3960 tcg_gen_mov_tl(cpu_npc, cpu_T[0]); 3960 tcg_gen_mov_tl(cpu_npc, cpu_T[0]);
@@ -4009,12 +4009,12 @@ static void disas_sparc_insn(DisasContext * dc) @@ -4009,12 +4009,12 @@ static void disas_sparc_insn(DisasContext * dc)
4009 break; 4009 break;
4010 case 0x3c: /* save */ 4010 case 0x3c: /* save */
4011 save_state(dc); 4011 save_state(dc);
4012 - gen_op_save(); 4012 + tcg_gen_helper_0_0(helper_save);
4013 gen_movl_T0_reg(rd); 4013 gen_movl_T0_reg(rd);
4014 break; 4014 break;
4015 case 0x3d: /* restore */ 4015 case 0x3d: /* restore */
4016 save_state(dc); 4016 save_state(dc);
4017 - gen_op_restore(); 4017 + tcg_gen_helper_0_0(helper_restore);
4018 gen_movl_T0_reg(rd); 4018 gen_movl_T0_reg(rd);
4019 break; 4019 break;
4020 #if !defined(CONFIG_USER_ONLY) && defined(TARGET_SPARC64) 4020 #if !defined(CONFIG_USER_ONLY) && defined(TARGET_SPARC64)