Commit dcc532c8098ffd347914ad036b8cf92a84171e3e

Authored by aurel32
1 parent ef0d51af

target-ppc: use ldl/ldub/stl/stub for load/store in op_helper.c

Should not give any performance penality given cpu_mmu_index() is
an inline function returning a value from env.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5837 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 11 additions and 130 deletions
target-ppc/op_helper.c
... ... @@ -107,88 +107,35 @@ static always_inline target_ulong get_addr(target_ulong addr)
107 107  
108 108 void helper_lmw (target_ulong addr, uint32_t reg)
109 109 {
110   -#ifdef CONFIG_USER_ONLY
111   -#define ldfun ldl_raw
112   -#else
113   - int (*ldfun)(target_ulong);
114   -
115   - switch (env->mmu_idx) {
116   - default:
117   - case 0: ldfun = ldl_user;
118   - break;
119   - case 1: ldfun = ldl_kernel;
120   - break;
121   - case 2: ldfun = ldl_hypv;
122   - break;
123   - }
124   -#endif
125 110 for (; reg < 32; reg++, addr += 4) {
126 111 if (msr_le)
127   - env->gpr[reg] = bswap32(ldfun(get_addr(addr)));
  112 + env->gpr[reg] = bswap32(ldl(get_addr(addr)));
128 113 else
129   - env->gpr[reg] = ldfun(get_addr(addr));
  114 + env->gpr[reg] = ldl(get_addr(addr));
130 115 }
131 116 }
132 117  
133 118 void helper_stmw (target_ulong addr, uint32_t reg)
134 119 {
135   -#ifdef CONFIG_USER_ONLY
136   -#define stfun stl_raw
137   -#else
138   - void (*stfun)(target_ulong, int);
139   -
140   - switch (env->mmu_idx) {
141   - default:
142   - case 0: stfun = stl_user;
143   - break;
144   - case 1: stfun = stl_kernel;
145   - break;
146   - case 2: stfun = stl_hypv;
147   - break;
148   - }
149   -#endif
150 120 for (; reg < 32; reg++, addr += 4) {
151 121 if (msr_le)
152   - stfun(get_addr(addr), bswap32((uint32_t)env->gpr[reg]));
  122 + stl(get_addr(addr), bswap32((uint32_t)env->gpr[reg]));
153 123 else
154   - stfun(get_addr(addr), (uint32_t)env->gpr[reg]);
  124 + stl(get_addr(addr), (uint32_t)env->gpr[reg]);
155 125 }
156 126 }
157 127  
158 128 void helper_lsw(target_ulong addr, uint32_t nb, uint32_t reg)
159 129 {
160 130 int sh;
161   -#ifdef CONFIG_USER_ONLY
162   -#define ldfunl ldl_raw
163   -#define ldfunb ldub_raw
164   -#else
165   - int (*ldfunl)(target_ulong);
166   - int (*ldfunb)(target_ulong);
167   -
168   - switch (env->mmu_idx) {
169   - default:
170   - case 0:
171   - ldfunl = ldl_user;
172   - ldfunb = ldub_user;
173   - break;
174   - case 1:
175   - ldfunl = ldl_kernel;
176   - ldfunb = ldub_kernel;
177   - break;
178   - case 2:
179   - ldfunl = ldl_hypv;
180   - ldfunb = ldub_hypv;
181   - break;
182   - }
183   -#endif
184 131 for (; nb > 3; nb -= 4, addr += 4) {
185   - env->gpr[reg] = ldfunl(get_addr(addr));
  132 + env->gpr[reg] = ldl(get_addr(addr));
186 133 reg = (reg + 1) % 32;
187 134 }
188 135 if (unlikely(nb > 0)) {
189 136 env->gpr[reg] = 0;
190 137 for (sh = 24; nb > 0; nb--, addr++, sh -= 8) {
191   - env->gpr[reg] |= ldfunb(get_addr(addr)) << sh;
  138 + env->gpr[reg] |= ldub(get_addr(addr)) << sh;
192 139 }
193 140 }
194 141 }
... ... @@ -214,37 +161,13 @@ void helper_lswx(target_ulong addr, uint32_t reg, uint32_t ra, uint32_t rb)
214 161 void helper_stsw(target_ulong addr, uint32_t nb, uint32_t reg)
215 162 {
216 163 int sh;
217   -#ifdef CONFIG_USER_ONLY
218   -#define stfunl stl_raw
219   -#define stfunb stb_raw
220   -#else
221   - void (*stfunl)(target_ulong, int);
222   - void (*stfunb)(target_ulong, int);
223   -
224   - switch (env->mmu_idx) {
225   - default:
226   - case 0:
227   - stfunl = stl_user;
228   - stfunb = stb_user;
229   - break;
230   - case 1:
231   - stfunl = stl_kernel;
232   - stfunb = stb_kernel;
233   - break;
234   - case 2:
235   - stfunl = stl_hypv;
236   - stfunb = stb_hypv;
237   - break;
238   - }
239   -#endif
240   -
241 164 for (; nb > 3; nb -= 4, addr += 4) {
242   - stfunl(get_addr(addr), env->gpr[reg]);
  165 + stl(get_addr(addr), env->gpr[reg]);
243 166 reg = (reg + 1) % 32;
244 167 }
245 168 if (unlikely(nb > 0)) {
246 169 for (sh = 24; nb > 0; nb--, addr++, sh -= 8)
247   - stfunb(get_addr(addr), (env->gpr[reg] >> sh) & 0xFF);
  170 + stb(get_addr(addr), (env->gpr[reg] >> sh) & 0xFF);
248 171 }
249 172 }
250 173  
... ... @@ -252,24 +175,9 @@ static void do_dcbz(target_ulong addr, int dcache_line_size)
252 175 {
253 176 target_long mask = get_addr(~(dcache_line_size - 1));
254 177 int i;
255   -#ifdef CONFIG_USER_ONLY
256   -#define stfun stl_raw
257   -#else
258   - void (*stfun)(target_ulong, int);
259   -
260   - switch (env->mmu_idx) {
261   - default:
262   - case 0: stfun = stl_user;
263   - break;
264   - case 1: stfun = stl_kernel;
265   - break;
266   - case 2: stfun = stl_hypv;
267   - break;
268   - }
269   -#endif
270 178 addr &= mask;
271 179 for (i = 0 ; i < dcache_line_size ; i += 4) {
272   - stfun(addr + i , 0);
  180 + stl(addr + i , 0);
273 181 }
274 182 if ((env->reserve & mask) == addr)
275 183 env->reserve = (target_ulong)-1ULL;
... ... @@ -298,19 +206,7 @@ void helper_icbi(target_ulong addr)
298 206 * (not a fetch) by the MMU. To be sure it will be so,
299 207 * do the load "by hand".
300 208 */
301   -#ifdef CONFIG_USER_ONLY
302   - tmp = ldl_raw(addr);
303   -#else
304   - switch (env->mmu_idx) {
305   - default:
306   - case 0: tmp = ldl_user(addr);
307   - break;
308   - case 1: tmp = ldl_kernel(addr);
309   - break;
310   - case 2: tmp = ldl_hypv(addr);
311   - break;
312   - }
313   -#endif
  209 + tmp = ldl(addr);
314 210 tb_invalidate_page_range(addr, addr + env->icache_line_size);
315 211 }
316 212  
... ... @@ -318,24 +214,9 @@ void helper_icbi(target_ulong addr)
318 214 target_ulong helper_lscbx (target_ulong addr, uint32_t reg, uint32_t ra, uint32_t rb)
319 215 {
320 216 int i, c, d;
321   -#ifdef CONFIG_USER_ONLY
322   -#define ldfun ldub_raw
323   -#else
324   - int (*ldfun)(target_ulong);
325   -
326   - switch (env->mmu_idx) {
327   - default:
328   - case 0: ldfun = ldub_user;
329   - break;
330   - case 1: ldfun = ldub_kernel;
331   - break;
332   - case 2: ldfun = ldub_hypv;
333   - break;
334   - }
335   -#endif
336 217 d = 24;
337 218 for (i = 0; i < xer_bc; i++) {
338   - c = ldfun((uint32_t)addr++);
  219 + c = ldub((uint32_t)addr++);
339 220 /* ra (if not 0) and rb are never modified */
340 221 if (likely(reg != rb && (ra == 0 || reg != ra))) {
341 222 env->gpr[reg] = (env->gpr[reg] & ~(0xFF << d)) | (c << d);
... ...