root / target-ppc / op_helper.h @ d63001d1
History | View | Annotate | Download (11.1 kB)
1 |
/*
|
---|---|
2 |
* PowerPC emulation helpers header for qemu.
|
3 |
*
|
4 |
* Copyright (c) 2003-2007 Jocelyn Mayer
|
5 |
*
|
6 |
* This library is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU Lesser General Public
|
8 |
* License as published by the Free Software Foundation; either
|
9 |
* version 2 of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This library is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
* Lesser General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU Lesser General Public
|
17 |
* License along with this library; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 |
*/
|
20 |
|
21 |
#if defined(MEMSUFFIX)
|
22 |
|
23 |
/* Memory load/store helpers */
|
24 |
void glue(do_lsw, MEMSUFFIX) (int dst); |
25 |
void glue(do_lsw_le, MEMSUFFIX) (int dst); |
26 |
void glue(do_stsw, MEMSUFFIX) (int src); |
27 |
void glue(do_stsw_le, MEMSUFFIX) (int src); |
28 |
void glue(do_lmw, MEMSUFFIX) (int dst); |
29 |
void glue(do_lmw_le, MEMSUFFIX) (int dst); |
30 |
void glue(do_stmw, MEMSUFFIX) (int src); |
31 |
void glue(do_stmw_le, MEMSUFFIX) (int src); |
32 |
void glue(do_icbi, MEMSUFFIX) (void); |
33 |
void glue(do_dcbz, MEMSUFFIX) (void); |
34 |
void glue(do_POWER_lscbx, MEMSUFFIX) (int dest, int ra, int rb); |
35 |
void glue(do_POWER2_lfq, MEMSUFFIX) (void); |
36 |
void glue(do_POWER2_lfq_le, MEMSUFFIX) (void); |
37 |
void glue(do_POWER2_stfq, MEMSUFFIX) (void); |
38 |
void glue(do_POWER2_stfq_le, MEMSUFFIX) (void); |
39 |
|
40 |
#if defined(TARGET_PPC64)
|
41 |
void glue(do_lsw_64, MEMSUFFIX) (int dst); |
42 |
void glue(do_lsw_le_64, MEMSUFFIX) (int dst); |
43 |
void glue(do_stsw_64, MEMSUFFIX) (int src); |
44 |
void glue(do_stsw_le_64, MEMSUFFIX) (int src); |
45 |
void glue(do_lmw_64, MEMSUFFIX) (int dst); |
46 |
void glue(do_lmw_le_64, MEMSUFFIX) (int dst); |
47 |
void glue(do_stmw_64, MEMSUFFIX) (int src); |
48 |
void glue(do_stmw_le_64, MEMSUFFIX) (int src); |
49 |
void glue(do_icbi_64, MEMSUFFIX) (void); |
50 |
void glue(do_dcbz_64, MEMSUFFIX) (void); |
51 |
#endif
|
52 |
|
53 |
#else
|
54 |
|
55 |
void do_print_mem_EA (target_ulong EA);
|
56 |
|
57 |
/* Registers load and stores */
|
58 |
void do_load_cr (void); |
59 |
void do_store_cr (uint32_t mask);
|
60 |
void do_load_xer (void); |
61 |
void do_store_xer (void); |
62 |
#if defined(TARGET_PPC64)
|
63 |
void do_store_pri (int prio); |
64 |
#endif
|
65 |
void do_load_fpscr (void); |
66 |
void do_store_fpscr (uint32_t mask);
|
67 |
target_ulong ppc_load_dump_spr (int sprn);
|
68 |
void ppc_store_dump_spr (int sprn, target_ulong val); |
69 |
|
70 |
/* Integer arithmetic helpers */
|
71 |
void do_adde (void); |
72 |
void do_addmeo (void); |
73 |
void do_divwo (void); |
74 |
void do_divwuo (void); |
75 |
void do_mullwo (void); |
76 |
void do_nego (void); |
77 |
void do_subfe (void); |
78 |
void do_subfmeo (void); |
79 |
void do_subfzeo (void); |
80 |
void do_sraw (void); |
81 |
#if defined(TARGET_PPC64)
|
82 |
void do_adde_64 (void); |
83 |
void do_addmeo_64 (void); |
84 |
void do_imul64 (uint64_t *tl, uint64_t *th);
|
85 |
void do_mul64 (uint64_t *tl, uint64_t *th);
|
86 |
void do_divdo (void); |
87 |
void do_divduo (void); |
88 |
void do_mulldo (void); |
89 |
void do_nego_64 (void); |
90 |
void do_subfe_64 (void); |
91 |
void do_subfmeo_64 (void); |
92 |
void do_subfzeo_64 (void); |
93 |
void do_srad (void); |
94 |
#endif
|
95 |
void do_popcntb (void); |
96 |
#if defined(TARGET_PPC64)
|
97 |
void do_popcntb_64 (void); |
98 |
#endif
|
99 |
|
100 |
/* Floating-point arithmetic helpers */
|
101 |
void do_fsqrt (void); |
102 |
void do_fre (void); |
103 |
void do_fres (void); |
104 |
void do_frsqrte (void); |
105 |
void do_fsel (void); |
106 |
#if USE_PRECISE_EMULATION
|
107 |
void do_fmadd (void); |
108 |
void do_fmsub (void); |
109 |
#endif
|
110 |
void do_fnmadd (void); |
111 |
void do_fnmsub (void); |
112 |
void do_fctiw (void); |
113 |
void do_fctiwz (void); |
114 |
#if defined(TARGET_PPC64)
|
115 |
void do_fcfid (void); |
116 |
void do_fctid (void); |
117 |
void do_fctidz (void); |
118 |
#endif
|
119 |
void do_frin (void); |
120 |
void do_friz (void); |
121 |
void do_frip (void); |
122 |
void do_frim (void); |
123 |
void do_fcmpu (void); |
124 |
void do_fcmpo (void); |
125 |
|
126 |
/* Misc */
|
127 |
void do_tw (int flags); |
128 |
#if defined(TARGET_PPC64)
|
129 |
void do_td (int flags); |
130 |
#endif
|
131 |
#if !defined(CONFIG_USER_ONLY)
|
132 |
void do_rfi (void); |
133 |
#if defined(TARGET_PPC64)
|
134 |
void do_rfid (void); |
135 |
#endif
|
136 |
#if defined(TARGET_PPC64H)
|
137 |
void do_hrfid (void); |
138 |
#endif
|
139 |
void do_load_6xx_tlb (int is_code); |
140 |
void do_load_74xx_tlb (int is_code); |
141 |
#endif
|
142 |
|
143 |
/* POWER / PowerPC 601 specific helpers */
|
144 |
void do_store_601_batu (int nr); |
145 |
void do_POWER_abso (void); |
146 |
void do_POWER_clcs (void); |
147 |
void do_POWER_div (void); |
148 |
void do_POWER_divo (void); |
149 |
void do_POWER_divs (void); |
150 |
void do_POWER_divso (void); |
151 |
void do_POWER_dozo (void); |
152 |
void do_POWER_maskg (void); |
153 |
void do_POWER_mulo (void); |
154 |
#if !defined(CONFIG_USER_ONLY)
|
155 |
void do_POWER_rac (void); |
156 |
void do_POWER_rfsvc (void); |
157 |
#endif
|
158 |
|
159 |
/* PowerPC 602 specific helper */
|
160 |
#if !defined(CONFIG_USER_ONLY)
|
161 |
void do_op_602_mfrom (void); |
162 |
#endif
|
163 |
|
164 |
/* PowerPC 440 specific helpers */
|
165 |
#if !defined(CONFIG_USER_ONLY)
|
166 |
void do_440_tlbre (int word); |
167 |
void do_440_tlbwe (int word); |
168 |
#endif
|
169 |
|
170 |
/* PowerPC 4xx specific helpers */
|
171 |
void do_405_check_ov (void); |
172 |
void do_405_check_sat (void); |
173 |
void do_load_dcr (void); |
174 |
void do_store_dcr (void); |
175 |
#if !defined(CONFIG_USER_ONLY)
|
176 |
void do_40x_rfci (void); |
177 |
void do_rfci (void); |
178 |
void do_rfdi (void); |
179 |
void do_rfmci (void); |
180 |
void do_4xx_tlbre_lo (void); |
181 |
void do_4xx_tlbre_hi (void); |
182 |
void do_4xx_tlbwe_lo (void); |
183 |
void do_4xx_tlbwe_hi (void); |
184 |
#endif
|
185 |
|
186 |
/* PowerPC 440 specific helpers */
|
187 |
void do_440_dlmzb (void); |
188 |
|
189 |
/* PowerPC 403 specific helpers */
|
190 |
#if !defined(CONFIG_USER_ONLY)
|
191 |
void do_load_403_pb (int num); |
192 |
void do_store_403_pb (int num); |
193 |
#endif
|
194 |
|
195 |
#if defined(TARGET_PPCEMB)
|
196 |
/* SPE extension helpers */
|
197 |
void do_brinc (void); |
198 |
/* Fixed-point vector helpers */
|
199 |
void do_evabs (void); |
200 |
void do_evaddw (void); |
201 |
void do_evcntlsw (void); |
202 |
void do_evcntlzw (void); |
203 |
void do_evneg (void); |
204 |
void do_evrlw (void); |
205 |
void do_evsel (void); |
206 |
void do_evrndw (void); |
207 |
void do_evslw (void); |
208 |
void do_evsrws (void); |
209 |
void do_evsrwu (void); |
210 |
void do_evsubfw (void); |
211 |
void do_evcmpeq (void); |
212 |
void do_evcmpgts (void); |
213 |
void do_evcmpgtu (void); |
214 |
void do_evcmplts (void); |
215 |
void do_evcmpltu (void); |
216 |
|
217 |
/* Single precision floating-point helpers */
|
218 |
void do_efscmplt (void); |
219 |
void do_efscmpgt (void); |
220 |
void do_efscmpeq (void); |
221 |
void do_efscfsf (void); |
222 |
void do_efscfuf (void); |
223 |
void do_efsctsf (void); |
224 |
void do_efsctuf (void); |
225 |
|
226 |
void do_efscfsi (void); |
227 |
void do_efscfui (void); |
228 |
void do_efsctsi (void); |
229 |
void do_efsctui (void); |
230 |
void do_efsctsiz (void); |
231 |
void do_efsctuiz (void); |
232 |
|
233 |
/* Double precision floating-point helpers */
|
234 |
void do_efdcmplt (void); |
235 |
void do_efdcmpgt (void); |
236 |
void do_efdcmpeq (void); |
237 |
void do_efdcfsf (void); |
238 |
void do_efdcfuf (void); |
239 |
void do_efdctsf (void); |
240 |
void do_efdctuf (void); |
241 |
|
242 |
void do_efdcfsi (void); |
243 |
void do_efdcfui (void); |
244 |
void do_efdctsi (void); |
245 |
void do_efdctui (void); |
246 |
void do_efdctsiz (void); |
247 |
void do_efdctuiz (void); |
248 |
|
249 |
void do_efdcfs (void); |
250 |
void do_efscfd (void); |
251 |
|
252 |
/* Floating-point vector helpers */
|
253 |
void do_evfsabs (void); |
254 |
void do_evfsnabs (void); |
255 |
void do_evfsneg (void); |
256 |
void do_evfsadd (void); |
257 |
void do_evfssub (void); |
258 |
void do_evfsmul (void); |
259 |
void do_evfsdiv (void); |
260 |
void do_evfscmplt (void); |
261 |
void do_evfscmpgt (void); |
262 |
void do_evfscmpeq (void); |
263 |
void do_evfststlt (void); |
264 |
void do_evfststgt (void); |
265 |
void do_evfststeq (void); |
266 |
void do_evfscfsi (void); |
267 |
void do_evfscfui (void); |
268 |
void do_evfscfsf (void); |
269 |
void do_evfscfuf (void); |
270 |
void do_evfsctsf (void); |
271 |
void do_evfsctuf (void); |
272 |
void do_evfsctsi (void); |
273 |
void do_evfsctui (void); |
274 |
void do_evfsctsiz (void); |
275 |
void do_evfsctuiz (void); |
276 |
#endif /* defined(TARGET_PPCEMB) */ |
277 |
|
278 |
/* Inlined helpers: used in micro-operation as well as helpers */
|
279 |
/* Generic fixed-point helpers */
|
280 |
static inline int _do_cntlzw (uint32_t val) |
281 |
{ |
282 |
int cnt = 0; |
283 |
if (!(val & 0xFFFF0000UL)) { |
284 |
cnt += 16;
|
285 |
val <<= 16;
|
286 |
} |
287 |
if (!(val & 0xFF000000UL)) { |
288 |
cnt += 8;
|
289 |
val <<= 8;
|
290 |
} |
291 |
if (!(val & 0xF0000000UL)) { |
292 |
cnt += 4;
|
293 |
val <<= 4;
|
294 |
} |
295 |
if (!(val & 0xC0000000UL)) { |
296 |
cnt += 2;
|
297 |
val <<= 2;
|
298 |
} |
299 |
if (!(val & 0x80000000UL)) { |
300 |
cnt++; |
301 |
val <<= 1;
|
302 |
} |
303 |
if (!(val & 0x80000000UL)) { |
304 |
cnt++; |
305 |
} |
306 |
return cnt;
|
307 |
} |
308 |
|
309 |
static inline int _do_cntlzd (uint64_t val) |
310 |
{ |
311 |
int cnt = 0; |
312 |
#if HOST_LONG_BITS == 64 |
313 |
if (!(val & 0xFFFFFFFF00000000ULL)) { |
314 |
cnt += 32;
|
315 |
val <<= 32;
|
316 |
} |
317 |
if (!(val & 0xFFFF000000000000ULL)) { |
318 |
cnt += 16;
|
319 |
val <<= 16;
|
320 |
} |
321 |
if (!(val & 0xFF00000000000000ULL)) { |
322 |
cnt += 8;
|
323 |
val <<= 8;
|
324 |
} |
325 |
if (!(val & 0xF000000000000000ULL)) { |
326 |
cnt += 4;
|
327 |
val <<= 4;
|
328 |
} |
329 |
if (!(val & 0xC000000000000000ULL)) { |
330 |
cnt += 2;
|
331 |
val <<= 2;
|
332 |
} |
333 |
if (!(val & 0x8000000000000000ULL)) { |
334 |
cnt++; |
335 |
val <<= 1;
|
336 |
} |
337 |
if (!(val & 0x8000000000000000ULL)) { |
338 |
cnt++; |
339 |
} |
340 |
#else
|
341 |
/* Make it easier on 32 bits host machines */
|
342 |
if (!(val >> 32)) |
343 |
cnt = _do_cntlzw(val) + 32;
|
344 |
else
|
345 |
cnt = _do_cntlzw(val >> 32);
|
346 |
#endif
|
347 |
return cnt;
|
348 |
} |
349 |
|
350 |
#if defined(TARGET_PPCEMB)
|
351 |
/* SPE extension */
|
352 |
/* Single precision floating-point helpers */
|
353 |
static inline uint32_t _do_efsabs (uint32_t val) |
354 |
{ |
355 |
return val & ~0x80000000; |
356 |
} |
357 |
static inline uint32_t _do_efsnabs (uint32_t val) |
358 |
{ |
359 |
return val | 0x80000000; |
360 |
} |
361 |
static inline uint32_t _do_efsneg (uint32_t val) |
362 |
{ |
363 |
return val ^ 0x80000000; |
364 |
} |
365 |
static inline uint32_t _do_efsadd (uint32_t op1, uint32_t op2) |
366 |
{ |
367 |
union {
|
368 |
uint32_t u; |
369 |
float32 f; |
370 |
} u1, u2; |
371 |
u1.u = op1; |
372 |
u2.u = op2; |
373 |
u1.f = float32_add(u1.f, u2.f, &env->spe_status); |
374 |
return u1.u;
|
375 |
} |
376 |
static inline uint32_t _do_efssub (uint32_t op1, uint32_t op2) |
377 |
{ |
378 |
union {
|
379 |
uint32_t u; |
380 |
float32 f; |
381 |
} u1, u2; |
382 |
u1.u = op1; |
383 |
u2.u = op2; |
384 |
u1.f = float32_sub(u1.f, u2.f, &env->spe_status); |
385 |
return u1.u;
|
386 |
} |
387 |
static inline uint32_t _do_efsmul (uint32_t op1, uint32_t op2) |
388 |
{ |
389 |
union {
|
390 |
uint32_t u; |
391 |
float32 f; |
392 |
} u1, u2; |
393 |
u1.u = op1; |
394 |
u2.u = op2; |
395 |
u1.f = float32_mul(u1.f, u2.f, &env->spe_status); |
396 |
return u1.u;
|
397 |
} |
398 |
static inline uint32_t _do_efsdiv (uint32_t op1, uint32_t op2) |
399 |
{ |
400 |
union {
|
401 |
uint32_t u; |
402 |
float32 f; |
403 |
} u1, u2; |
404 |
u1.u = op1; |
405 |
u2.u = op2; |
406 |
u1.f = float32_div(u1.f, u2.f, &env->spe_status); |
407 |
return u1.u;
|
408 |
} |
409 |
|
410 |
static inline int _do_efststlt (uint32_t op1, uint32_t op2) |
411 |
{ |
412 |
union {
|
413 |
uint32_t u; |
414 |
float32 f; |
415 |
} u1, u2; |
416 |
u1.u = op1; |
417 |
u2.u = op2; |
418 |
return float32_lt(u1.f, u2.f, &env->spe_status) ? 1 : 0; |
419 |
} |
420 |
static inline int _do_efststgt (uint32_t op1, uint32_t op2) |
421 |
{ |
422 |
union {
|
423 |
uint32_t u; |
424 |
float32 f; |
425 |
} u1, u2; |
426 |
u1.u = op1; |
427 |
u2.u = op2; |
428 |
return float32_le(u1.f, u2.f, &env->spe_status) ? 0 : 1; |
429 |
} |
430 |
static inline int _do_efststeq (uint32_t op1, uint32_t op2) |
431 |
{ |
432 |
union {
|
433 |
uint32_t u; |
434 |
float32 f; |
435 |
} u1, u2; |
436 |
u1.u = op1; |
437 |
u2.u = op2; |
438 |
return float32_eq(u1.f, u2.f, &env->spe_status) ? 1 : 0; |
439 |
} |
440 |
/* Double precision floating-point helpers */
|
441 |
static inline int _do_efdtstlt (uint64_t op1, uint64_t op2) |
442 |
{ |
443 |
union {
|
444 |
uint64_t u; |
445 |
float64 f; |
446 |
} u1, u2; |
447 |
u1.u = op1; |
448 |
u2.u = op2; |
449 |
return float64_lt(u1.f, u2.f, &env->spe_status) ? 1 : 0; |
450 |
} |
451 |
static inline int _do_efdtstgt (uint64_t op1, uint64_t op2) |
452 |
{ |
453 |
union {
|
454 |
uint64_t u; |
455 |
float64 f; |
456 |
} u1, u2; |
457 |
u1.u = op1; |
458 |
u2.u = op2; |
459 |
return float64_le(u1.f, u2.f, &env->spe_status) ? 0 : 1; |
460 |
} |
461 |
static inline int _do_efdtsteq (uint64_t op1, uint64_t op2) |
462 |
{ |
463 |
union {
|
464 |
uint64_t u; |
465 |
float64 f; |
466 |
} u1, u2; |
467 |
u1.u = op1; |
468 |
u2.u = op2; |
469 |
return float64_eq(u1.f, u2.f, &env->spe_status) ? 1 : 0; |
470 |
} |
471 |
#endif /* defined(TARGET_PPCEMB) */ |
472 |
#endif
|