40 #define DOT0(n) X(n ## _dot) { instr(n)(cpu,ic); \ 41 update_cr0(cpu, reg(ic->arg[0])); } 42 #define DOT1(n) X(n ## _dot) { instr(n)(cpu,ic); \ 43 update_cr0(cpu, reg(ic->arg[1])); } 44 #define DOT2(n) X(n ## _dot) { instr(n)(cpu,ic); \ 45 update_cr0(cpu, reg(ic->arg[2])); } 47 #ifndef CHECK_FOR_FPU_EXCEPTION 48 #define CHECK_FOR_FPU_EXCEPTION { if (!(cpu->cd.ppc.msr & PPC_MSR_FP)) { \ 50 uint64_t low_pc = ((size_t)ic - \ 51 (size_t)cpu->cd.ppc.cur_ic_page) \ 52 / sizeof(struct ppc_instr_call); \ 53 cpu->pc = (cpu->pc & ~((PPC_IC_ENTRIES_PER_PAGE-1) << \ 54 PPC_INSTR_ALIGNMENT_SHIFT)) + (low_pc << \ 55 PPC_INSTR_ALIGNMENT_SHIFT); \ 56 ppc_exception(cpu, PPC_EXCEPTION_FPU); \ 75 fatal(
"PPC: invalid(): INTERNAL ERROR\n");
93 reg(
ic->arg[2]) = (int32_t)
ic->arg[1];
111 reg(
ic->arg[2]) = tmp;
126 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
129 tmp2 += (uint32_t)
ic->arg[1];
130 if ((tmp2 >> 32) != (tmp >> 32))
132 reg(
ic->arg[2]) = (uint32_t)tmp2;
147 if (tmp >=
reg(
ic->arg[0]))
163 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
166 tmp2 += (uint32_t)
ic->arg[1];
167 if ((tmp2 >> 32) != (tmp >> 32))
169 reg(
ic->arg[2]) = (uint32_t)tmp2;
183 unsigned int bo =
ic->arg[0], bi31m =
ic->arg[1];
185 uint64_t old_pc =
cpu->
pc;
189 ctr_ok = (bo >> 2) & 1;
191 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
192 cond_ok = (bo >> 4) & 1;
193 cond_ok |= ( ((bo >> 3) & 1) == ((
cpu->
cd.
ppc.
cr >> bi31m) & 1) );
194 if (ctr_ok && cond_ok) {
195 uint64_t mask_within_page =
202 if ((old_pc & ~mask_within_page) ==
203 (
cpu->
pc & ~mask_within_page)) {
206 ((
cpu->
pc & mask_within_page) >>
221 uint64_t low_pc, old_pc =
cpu->
pc;
222 unsigned int bo =
ic->arg[0], bi31m =
ic->arg[1] ;
227 ctr_ok = (bo >> 2) & 1;
229 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
230 cond_ok = (bo >> 4) & 1;
231 cond_ok |= ( ((bo >> 3) & 1) == ((
cpu->
cd.
ppc.
cr >> bi31m) & 1) );
234 low_pc = ((size_t)
ic - (
size_t)
235 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call) + 1;
240 if (ctr_ok && cond_ok) {
241 uint64_t mask_within_page =
250 if ((old_pc & ~mask_within_page) ==
251 (
cpu->
pc & ~mask_within_page)) {
254 ((
cpu->
pc & mask_within_page) >>
273 unsigned int bo =
ic->arg[0], bi31m =
ic->arg[1];
274 uint64_t old_pc =
cpu->
pc;
276 int cond_ok = (bo >> 4) & 1;
277 cond_ok |= ( ((bo >> 3) & 1) == ((
cpu->
cd.
ppc.
cr >> bi31m) & 1) );
279 uint64_t mask_within_page =
286 if ((old_pc & ~mask_within_page) ==
287 (
cpu->
pc & ~mask_within_page)) {
290 ((
cpu->
pc & mask_within_page) >>
300 uint64_t low_pc, old_pc =
cpu->
pc;
301 unsigned int bo =
ic->arg[0], bi31m =
ic->arg[1] ;
303 int cond_ok = (bo >> 4) & 1;
304 cond_ok |= ( ((bo >> 3) & 1) == ((
cpu->
cd.
ppc.
cr >> bi31m) & 1) );
307 low_pc = ((size_t)
ic - (
size_t)
308 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call) + 1;
314 uint64_t mask_within_page =
321 if ((old_pc & ~mask_within_page) ==
322 (
cpu->
pc & ~mask_within_page)) {
325 ((
cpu->
pc & mask_within_page) >>
343 cpu->
pc += (int32_t)
ic->arg[0];
365 unsigned int ctr_ok, cond_ok, bi31m =
ic->arg[2], bo =
ic->arg[1];
368 ctr_ok = (bo >> 2) & 1;
370 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
371 cond_ok = (bo >> 4) & 1;
372 cond_ok |= ( ((bo >> 3) & 1) ==
374 if (ctr_ok && cond_ok)
380 unsigned int ctr_ok, cond_ok, bi31m =
ic->arg[2], bo =
ic->arg[1];
384 low_pc = ((size_t)
ic - (
size_t)
385 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call) + 1;
392 ctr_ok = (bo >> 2) & 1;
394 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
395 cond_ok = (bo >> 4) & 1;
396 cond_ok |= ( ((bo >> 3) & 1) ==
398 if (ctr_ok && cond_ok)
410 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
424 unsigned int ctr_ok, cond_ok, bi31m =
ic->arg[2], bo =
ic->arg[1];
427 ctr_ok = (bo >> 2) & 1;
429 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
430 cond_ok = (bo >> 4) & 1;
431 cond_ok |= ( ((bo >> 3) & 1) ==
433 if (ctr_ok && cond_ok)
434 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
436 X(bc_samepage_simple0)
438 int bi31m =
ic->arg[2];
440 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
442 X(bc_samepage_simple1)
444 int bi31m =
ic->arg[2];
446 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
451 unsigned int ctr_ok, cond_ok, bi31m =
ic->arg[2], bo =
ic->arg[1];
455 low_pc = ((size_t)
ic - (
size_t)
456 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call) + 1;
463 ctr_ok = (bo >> 2) & 1;
465 ctr_ok |= ( (tmp == 0) == ((bo >> 1) & 1) );
466 cond_ok = (bo >> 4) & 1;
467 cond_ok |= ( ((bo >> 3) & 1) ==
469 if (ctr_ok && cond_ok)
470 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
485 cpu->
pc += (int32_t)
ic->arg[0];
515 cpu->
pc += (int32_t)
ic->arg[0];
546 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
564 cpu->
cd.
ppc.next_ic = (
struct ppc_instr_call *)
ic->arg[0];
567 low_pc = ((size_t)
cpu->
cd.
ppc.next_ic - (
size_t)
568 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call);
583 uint32_t tmp =
reg(
ic->arg[0]);
585 for (i=0; i<32; i++) {
586 if (tmp & 0x80000000)
603 int64_t tmp =
reg(
ic->arg[0]), tmp2 =
reg(
ic->arg[1]);
604 int bf_shift =
ic->arg[2], c;
627 uint64_t tmp =
reg(
ic->arg[0]), tmp2 =
reg(
ic->arg[1]);
628 int bf_shift =
ic->arg[2], c;
651 int64_t tmp =
reg(
ic->arg[0]), imm = (int32_t)
ic->arg[1];
652 int bf_shift =
ic->arg[2], c;
675 uint64_t tmp =
reg(
ic->arg[0]), imm = (uint32_t)
ic->arg[1];
676 int bf_shift =
ic->arg[2], c;
699 int32_t tmp =
reg(
ic->arg[0]), tmp2 =
reg(
ic->arg[1]);
700 int bf_shift =
ic->arg[2], c;
715 int32_t tmp =
reg(
ic->arg[0]), tmp2 =
reg(
ic->arg[1]);
736 uint32_t tmp =
reg(
ic->arg[0]), tmp2 =
reg(
ic->arg[1]);
737 int bf_shift =
ic->arg[2], c;
760 int32_t tmp =
reg(
ic->arg[0]), imm =
ic->arg[1];
761 int bf_shift =
ic->arg[2], c;
776 int32_t tmp =
reg(
ic->arg[0]), imm =
ic->arg[1];
797 uint32_t tmp =
reg(
ic->arg[0]), imm =
ic->arg[1];
798 int bf_shift =
ic->arg[2], c;
821 unsigned char cacheline[128];
828 addr &= ~(cacheline_size - 1);
829 memset(cacheline, 0,
sizeof(cacheline));
831 while (cleared < cacheline_size) {
832 int to_clear = cacheline_size <
sizeof(cacheline)?
833 cacheline_size :
sizeof(cacheline);
835 unsigned char *
page =
cpu->
cd.
ppc.host_store[addr >> 12];
837 memset(page + (addr & 0xfff), 0, to_clear);
892 *(uint64_t *)
ic->arg[1] = *(uint64_t *)
ic->arg[0];
906 v = *(uint64_t *)
ic->arg[0];
907 *(uint64_t *)
ic->arg[1] = v & 0x7fffffffffffffffULL;
921 v = *(uint64_t *)
ic->arg[0];
922 *(uint64_t *)
ic->arg[1] = v ^ 0x8000000000000000ULL;
936 int bf_shift =
ic->arg[0], c = 0;
947 else if (fra.
f > frb.
f)
989 (*(uint64_t *)
ic->arg[1]) =
1009 if (frb.
f >= 2147483647.0)
1011 else if (frb.
f <= -2147483648.0)
1014 res = (int32_t) frb.
f;
1017 *(uint64_t *)
ic->arg[1] = (uint32_t)res;
1032 double result = 0.0;
1042 result = fra.
f * frc.
f;
1048 else if (result > 0.0)
1057 (*(uint64_t *)
ic->arg[0]) =
1076 uint32_t iw =
ic->arg[2];
1077 int b = (iw >> 11) & 31, c = (iw >> 6) & 31;
1081 double result = 0.0;
1092 result = fra.
f * frc.
f + frb.
f;
1098 else if (result > 0.0)
1107 (*(uint64_t *)
ic->arg[0]) =
1121 uint32_t iw =
ic->arg[2];
1122 int b = (iw >> 11) & 31, c = (iw >> 6) & 31;
1126 double result = 0.0;
1137 result = fra.
f * frc.
f - frb.
f;
1143 else if (result > 0.0)
1152 (*(uint64_t *)
ic->arg[0]) =
1168 double result = 0.0;
1178 result = fra.
f + frb.
f;
1184 else if (result > 0.0)
1193 (*(uint64_t *)
ic->arg[2]) =
1205 double result = 0.0;
1215 result = fra.
f - frb.
f;
1221 else if (result > 0.0)
1230 (*(uint64_t *)
ic->arg[2]) =
1242 double result = 0.0;
1249 if (fra.
nan || frb.
nan || frb.
f == 0)
1252 result = fra.
f / frb.
f;
1258 else if (result > 0.0)
1267 (*(uint64_t *)
ic->arg[2]) =
1284 int iw =
ic->arg[0], len = 4,
load = 0, xo = (iw >> 1) & 1023;
1285 int i, rc = iw & 1, rt, ra, rb;
1286 uint64_t
addr = 0, value;
1301 rt = (iw >> 21) & 31;
1302 ra = (iw >> 16) & 31;
1303 rb = (iw >> 11) & 31;
1311 fatal(
"ll: rc-bit set?\n");
1316 fatal(
"ll: error: TODO\n");
1321 for (i=0; i<len; i++) {
1326 value |= d[len - 1 - i];
1335 fatal(
"sc: rc-bit not set?\n");
1353 for (i=0; i<len; i++) {
1355 d[len - 1 - i] = value >> (8*i);
1357 d[i] = value >> (8*i);
1362 fatal(
"sc: error: TODO\n");
1388 int sr_num =
ic->arg[0];
1398 int sr_num =
reg(
ic->arg[0]) >> 28;
1422 uint32_t sr_num =
reg(
ic->arg[0]) >> 28;
1434 int rs = (
ic->arg[0] >> 21) & 31;
1435 int ra = (
ic->arg[0] >> 16) & 31;
1436 int sh = ((
ic->arg[0] >> 11) & 31) | ((
ic->arg[0] & 2) << 4);
1437 int mb = ((
ic->arg[0] >> 6) & 31) | (
ic->arg[0] & 0x20);
1438 int rc =
ic->arg[0] & 1;
1442 int b = (tmp >> 63) & 1;
1443 tmp = (tmp << 1) | b;
1447 tmp |= ((uint64_t)1 << (63-mb));
1463 int rs = (
ic->arg[0] >> 21) & 31;
1464 int ra = (
ic->arg[0] >> 16) & 31;
1465 int sh = ((
ic->arg[0] >> 11) & 31) | ((
ic->arg[0] & 2) << 4);
1466 int me = ((
ic->arg[0] >> 6) & 31) | (
ic->arg[0] & 0x20);
1467 int rc =
ic->arg[0] & 1;
1471 int b = (tmp >> 63) & 1;
1472 tmp = (tmp << 1) | b;
1475 tmp &= ~((uint64_t)1 << (63-me));
1489 uint32_t iw =
ic->arg[0];
1490 int rs = (iw >> 21) & 31, ra = (iw >> 16) & 31;
1491 int sh = ((iw >> 11) & 31) | ((iw & 2) << 4);
1492 int mb = ((iw >> 6) & 31) | (iw & 0x20);
1493 int rc =
ic->arg[0] & 1;
1498 int b = (s >> 63) & 1;
1503 tmp |= ((uint64_t)1 << (63-m));
1505 }
while (m != 63 - sh);
1522 uint32_t tmp, iword =
ic->arg[2];
1523 int rs = (iword >> 21) & 31;
1524 int rb = (iword >> 11) & 31;
1527 tmp = (tmp << sh) | (tmp >> (32-sh));
1528 tmp &= (uint32_t)
ic->arg[1];
1529 reg(
ic->arg[0]) = tmp;
1543 uint32_t tmp, iword =
ic->arg[2];
1544 int rs = (iword >> 21) & 31;
1545 int sh = (iword >> 11) & 31;
1547 tmp = (tmp << sh) | (tmp >> (32-sh));
1548 tmp &= (uint32_t)
ic->arg[1];
1549 reg(
ic->arg[0]) = tmp;
1564 uint32_t iword =
ic->arg[2];
1565 int sh = (iword >> 11) & 31;
1566 int mb = (iword >> 6) & 31;
1567 int me = (iword >> 1) & 31;
1570 tmp = (tmp << sh) | (tmp >> (32-sh));
1574 mask = (uint64_t)1 << (31-mb);
1583 reg(
ic->arg[1]) = ra;
1598 uint32_t tmp =
reg(
ic->arg[0]);
1599 int i = 0, j = 0, sh =
ic->arg[2];
1602 if (tmp & 0x80000000)
1608 if (tmp & 0x40000000)
1613 reg(
ic->arg[1]) = (int64_t)(int32_t)tmp;
1625 int bf_shift =
ic->arg[0], bfa_shift =
ic->arg[1];
1626 uint32_t tmp = (
cpu->
cd.
ppc.
cr >> bfa_shift) & 0xf;
1638 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1639 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1647 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1648 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1656 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1657 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1665 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1666 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1674 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1675 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1683 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1684 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1692 uint32_t iword =
ic->arg[0];
int bt = (iword >> 21) & 31;
1693 int ba = (iword >> 16) & 31, bb = (iword >> 11) & 31;
1775 uint64_t tmp, mask = 0x800000000000ff73ULL;
1821 uint64_t x =
reg(
ic->arg[0]);
1832 x = (y & 0xffffffff00000000ULL) | (x & 0xffffffffULL);
1861 x = (x & ~0x8000) |
ic->arg[0];
1887 reg(
ic->arg[2]) = (uint32_t)(
reg(
ic->arg[0]) * (int32_t)
ic->arg[1]);
1901 int rs =
ic->arg[0];
1903 int low_pc = ((
size_t)
ic - (size_t)
cpu->
cd.
ppc.cur_ic_page)
1904 /
sizeof(
struct ppc_instr_call);
1918 + (d[2] << 8) + d[3];
1921 + (d[1] << 8) + d[0];
1924 addr +=
sizeof(uint32_t);
1930 int rs =
ic->arg[0];
1932 int low_pc = ((
size_t)
ic - (size_t)
cpu->
cd.
ppc.cur_ic_page)
1933 /
sizeof(
struct ppc_instr_call);
1941 d[3] = tmp; d[2] = tmp >> 8;
1942 d[1] = tmp >> 16; d[0] = tmp >> 24;
1944 d[0] = tmp; d[1] = tmp >> 8;
1945 d[2] = tmp >> 16; d[3] = tmp >> 24;
1954 addr +=
sizeof(uint32_t);
1969 int rt =
ic->arg[0], nb =
ic->arg[2];
1972 int low_pc = ((size_t)
ic - (
size_t)
cpu->
cd.
ppc.cur_ic_page)
1973 /
sizeof(
struct ppc_instr_call);
2002 int rs =
ic->arg[0], nb =
ic->arg[2];
2006 int low_pc = ((size_t)
ic - (
size_t)
cpu->
cd.
ppc.cur_ic_page)
2007 /
sizeof(
struct ppc_instr_call);
2013 unsigned char d = cur >> 24;
2041 reg(
ic->arg[2]) = (int32_t)(int8_t)
reg(
ic->arg[0]);
2043 reg(
ic->arg[2]) = (int64_t)(int8_t)
reg(
ic->arg[0]);
2049 reg(
ic->arg[2]) = (int32_t)(int16_t)
reg(
ic->arg[0]);
2051 reg(
ic->arg[2]) = (int64_t)(int16_t)
reg(
ic->arg[0]);
2057 fatal(
"TODO: extsw: invalid instruction\n");
2059 reg(
ic->arg[2]) = (int64_t)(int32_t)
reg(
ic->arg[0]);
2064 << (
reg(
ic->arg[1]) & 31); }
2067 if (sa >= 64)
reg(
ic->arg[2]) = 0;
2068 else reg(
ic->arg[2]) = (uint64_t)
reg(
ic->arg[0]) << (sa & 63); }
2072 uint32_t tmp =
reg(
ic->arg[0]);
2073 int i = 0, j = 0, sh =
reg(
ic->arg[1]) & 31;
2076 if (tmp & 0x80000000)
2082 if (tmp & 0x40000000)
2087 reg(
ic->arg[2]) = (int64_t)(int32_t)tmp;
2091 >> (
reg(
ic->arg[1]) & 31); }
2131 int32_t sum = (int32_t)
reg(
ic->arg[0]) * (int32_t)
reg(
ic->arg[1]);
2132 reg(
ic->arg[2]) = (int32_t)sum;
2138 sum = (int64_t)(int32_t)
reg(
ic->arg[0])
2139 * (int64_t)(int32_t)
reg(
ic->arg[1]);
2140 reg(
ic->arg[2]) = sum >> 32;
2146 sum = (uint64_t)(uint32_t)
reg(
ic->arg[0])
2147 * (uint64_t)(uint32_t)
reg(
ic->arg[1]);
2148 reg(
ic->arg[2]) = sum >> 32;
2153 int32_t a =
reg(
ic->arg[0]), b =
reg(
ic->arg[1]);
2159 reg(
ic->arg[2]) = (uint32_t)sum;
2164 uint32_t a =
reg(
ic->arg[0]), b =
reg(
ic->arg[1]);
2170 reg(
ic->arg[2]) = sum;
2196 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
2197 uint64_t tmp2 = tmp;
2199 tmp += (uint32_t)
reg(
ic->arg[1]);
2200 if ((tmp >> 32) != (tmp2 >> 32))
2202 reg(
ic->arg[2]) = (uint32_t)tmp;
2217 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
2218 uint64_t tmp2 = tmp;
2220 tmp += (uint32_t)
reg(
ic->arg[1]);
2223 if ((tmp >> 32) != (tmp2 >> 32))
2225 reg(
ic->arg[2]) = (uint32_t)tmp;
2232 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
2233 uint64_t tmp2 = tmp;
2237 tmp += 0xffffffffULL;
2238 if ((tmp >> 32) != (tmp2 >> 32))
2240 reg(
ic->arg[2]) = (uint32_t)tmp;
2247 uint64_t tmp = (uint32_t)
reg(
ic->arg[0]);
2248 uint64_t tmp2 = tmp;
2252 if ((tmp >> 32) != (tmp2 >> 32))
2254 reg(
ic->arg[2]) = (uint32_t)tmp;
2286 }
else if (
reg(
ic->arg[1]) >=
reg(
ic->arg[0]))
2294 reg(
ic->arg[2]) =
reg(
ic->arg[1]) -
reg(
ic->arg[0]) - (old_ca? 0 : 1);
2300 uint64_t tmp = (uint32_t)(~
reg(
ic->arg[0]));
2301 tmp += 0xffffffffULL;
2305 if ((tmp >> 32) != 0)
2307 reg(
ic->arg[2]) = (uint32_t)tmp;
2313 uint64_t tmp = (uint32_t)(~
reg(
ic->arg[0]));
2314 uint64_t tmp2 = tmp;
2318 if ((tmp >> 32) != (tmp2 >> 32))
2320 reg(
ic->arg[2]) = (uint32_t)tmp;
2345 uint64_t old_pc, low_pc = ((size_t)
ic - (
size_t)
2346 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call);
2360 [2 + 4 + 8](
cpu,
ic);
2362 if (old_pc == cpu->pc) {
2365 (*(uint64_t *)
ic->arg[0]) &= 0xffffffff;
2368 (*(uint64_t *)
ic->arg[0]) =
2375 uint64_t old_pc, low_pc = ((size_t)
ic - (
size_t)
2376 cpu->
cd.
ppc.cur_ic_page) /
sizeof(
struct ppc_instr_call);
2386 ppc32_loadstore_indexed
2390 [2 + 4 + 8](
cpu,
ic);
2392 if (old_pc == cpu->pc) {
2395 (*(uint64_t *)
ic->arg[0]) &= 0xffffffff;
2398 (*(uint64_t *)
ic->arg[0]) =
2412 [3 + 4 + 8](
cpu,
ic);
2420 ppc32_loadstore_indexed
2424 [3 + 4 + 8](
cpu,
ic);
2428 uint64_t *old_arg0 = (uint64_t *)
ic->arg[0];
2437 ic->arg[0] = (size_t)&tmp_val;
2447 ic->arg[0] = (size_t)old_arg0;
2451 uint64_t *old_arg0 = (uint64_t *)
ic->arg[0];
2460 ic->arg[0] = (size_t)&tmp_val;
2464 ppc32_loadstore_indexed
2470 ic->arg[0] = (size_t)old_arg0;
2490 ppc32_loadstore_indexed
2510 int rs =
ic->arg[0];
2518 hi = ((uint64_t)data[0] << 56) +
2519 ((uint64_t)data[1] << 48) +
2520 ((uint64_t)data[2] << 40) +
2521 ((uint64_t)data[3] << 32) +
2522 ((uint64_t)data[4] << 24) +
2523 ((uint64_t)data[5] << 16) +
2524 ((uint64_t)data[6] << 8) +
2525 ((uint64_t)data[7]);
2526 lo = ((uint64_t)data[8] << 56) +
2527 ((uint64_t)data[9] << 48) +
2528 ((uint64_t)data[10] << 40) +
2529 ((uint64_t)data[11] << 32) +
2530 ((uint64_t)data[12] << 24) +
2531 ((uint64_t)data[13] << 16) +
2532 ((uint64_t)data[14] << 8) +
2533 ((uint64_t)data[15]);
2541 int rs =
ic->arg[0];
2554 data[10] = lo >> 40;
2555 data[11] = lo >> 32;
2556 data[12] = lo >> 24;
2557 data[13] = lo >> 16;
2587 fatal(
"[ tlbia ]\n");
2626 cpu->
cd.
ppc.next_ic = ¬hing_call;
2703 uint64_t
addr, low_pc, tmp_addr;
2704 uint32_t iword, mask;
2705 unsigned char *
page;
2706 unsigned char ib[4];
2707 int main_opcode, rt, rs, ra, rb, rc, aa_bit, l_bit, lk_bit, spr, sh,
2708 xo, imm,
load, size, update, zero, bf, bo, bi, bh, oe_bit, n64=0,
2709 bfa, fp, byterev, nb, mb, me;
2710 void (*samepage_function)(
struct cpu *,
struct ppc_instr_call *);
2711 void (*rc_f)(
struct cpu *,
struct ppc_instr_call *);
2714 low_pc = ((size_t)
ic - (
size_t)
cpu->
cd.
ppc.cur_ic_page)
2715 /
sizeof(
struct ppc_instr_call);
2724 page =
cpu->
cd.
ppc.host_load[((uint32_t)addr) >> 12];
2736 page = l3->host_load[x3];
2742 memcpy(ib, page + (addr & 0xfff),
sizeof(ib));
2747 fatal(
"PPC to_be_translated(): " 2748 "read failed: TODO\n");
2755 uint32_t *p = (uint32_t *) ib;
2760 #define DYNTRANS_TO_BE_TRANSLATED_HEAD 2762 #undef DYNTRANS_TO_BE_TRANSLATED_HEAD 2769 main_opcode = iword >> 26;
2771 switch (main_opcode) {
2774 if (iword == 0x12739cc4) {
2782 fatal(
"[ TODO: Unimplemented ALTIVEC, iword" 2783 " = 0x%08" PRIx32
"x ]\n", iword);
2789 rt = (iword >> 21) & 31;
2790 ra = (iword >> 16) & 31;
2791 imm = (int16_t)(iword & 0xffff);
2794 ic->arg[1] = (ssize_t)imm;
2799 rt = (iword >> 21) & 31;
2800 ra = (iword >> 16) & 31;
2801 imm = (int16_t)(iword & 0xffff);
2804 ic->arg[1] = (ssize_t)imm;
2810 bf = (iword >> 23) & 7;
2811 l_bit = (iword >> 21) & 1;
2812 ra = (iword >> 16) & 31;
2814 imm = iword & 0xffff;
2820 imm = (int16_t)(iword & 0xffff);
2831 ic->arg[1] = (ssize_t)imm;
2832 ic->arg[2] = 28 - 4 * bf;
2839 fatal(
"addic for 64-bit: TODO\n");
2842 rt = (iword >> 21) & 31;
2843 ra = (iword >> 16) & 31;
2844 imm = (int16_t)(iword & 0xffff);
2856 rt = (iword >> 21) & 31; ra = (iword >> 16) & 31;
2862 ic->arg[1] = (int16_t)(iword & 0xffff);
2865 if (ra == 0 &&
ic->arg[1] == 0)
2872 rs = (iword >> 21) & 31; ra = (iword >> 16) & 31;
2875 ic->arg[1] = iword & 0xffff;
2885 rs = (iword >> 21) & 31; ra = (iword >> 16) & 31;
2892 ic->arg[1] = iword & 0xffff;
2919 rs = (iword >> 21) & 31;
2920 ra = (iword >> 16) & 31;
2921 imm = (int16_t)iword;
2922 load = 0; zero = 1; size = 0; update = 0; fp = 0;
2924 switch (main_opcode) {
2928 case PPC_HI6_LHAU: load=1; size=1; zero=0; update=1;
break;
2946 if (
ic->f == NULL) {
2953 [size + 4*zero + 8*load + (imm==0? 16 : 0)
2956 if (ra == 0 && update) {
2958 fatal(
"TODO: ra=0 && update?\n");
2969 ic->arg[2] = (ssize_t)imm;
2973 aa_bit = (iword >> 1) & 1;
2975 bo = (iword >> 21) & 31;
2976 bi = (iword >> 16) & 31;
2977 tmp_addr = (int64_t)(int16_t)(iword & 0xfffc);
2980 fatal(
"aa_bit: NOT YET\n");
2985 samepage_function =
instr(bcl_samepage);
2988 if ((bo & 0x14) == 0x04) {
2989 samepage_function = bo & 8?
2990 instr(bc_samepage_simple1) :
2991 instr(bc_samepage_simple0);
2993 samepage_function =
instr(bc_samepage);
2995 ic->arg[0] = (ssize_t)(tmp_addr + (addr & 0xffc));
3001 uint64_t mask_within_page =
3003 uint64_t old_pc =
addr;
3004 uint64_t new_pc = old_pc + (int32_t)tmp_addr;
3005 if ((old_pc & ~mask_within_page) ==
3006 (new_pc & ~mask_within_page)) {
3007 ic->f = samepage_function;
3008 ic->arg[0] = (size_t) (
3010 ((new_pc & mask_within_page) >> 2));
3016 ic->arg[0] = (iword >> 5) & 0x7f;
3017 ic->arg[1] = (addr & 0xfff) + 4;
3018 if (iword == 0x44ee0002) {
3026 aa_bit = (iword & 2) >> 1;
3028 tmp_addr = (int64_t)(int32_t)((iword & 0x03fffffc) << 6);
3029 tmp_addr = (int64_t)tmp_addr >> 6;
3033 samepage_function =
instr(bl_samepage_trace);
3036 samepage_function =
instr(bl_samepage);
3040 samepage_function =
instr(b_samepage);
3042 ic->arg[0] = (ssize_t)(tmp_addr + (addr & 0xffc));
3043 ic->arg[1] = (addr & 0xffc) + 4;
3047 uint64_t mask_within_page =
3049 uint64_t old_pc =
addr;
3050 uint64_t new_pc = old_pc + (int32_t)tmp_addr;
3051 if ((old_pc & ~mask_within_page) ==
3052 (new_pc & ~mask_within_page)) {
3053 ic->f = samepage_function;
3054 ic->arg[0] = (size_t) (
3056 ((new_pc & mask_within_page) >> 2));
3069 ic->arg[0] = (ssize_t)tmp_addr;
3074 xo = (iword >> 1) & 1023;
3079 bo = (iword >> 21) & 31;
3080 bi = (iword >> 16) & 31;
3081 bh = (iword >> 11) & 3;
3089 (bo & 0x14) == 0x14)
3095 fatal(
"TODO: bclr/bcctr " 3096 "bo bit 2 clear!\n");
3105 ic->arg[1] = 31 - bi;
3123 bf = (iword >> 23) & 7;
3124 bfa = (iword >> 18) & 7;
3125 ic->arg[0] = 28 - 4*bf;
3126 ic->arg[1] = 28 - 4*bfa;
3155 ra = (iword >> 16) & 31;
3156 mb = (iword >> 6) & 31;
3157 me = (iword >> 1) & 31;
3161 mask |= ((uint32_t)0x80000000 >> mb);
3166 switch (main_opcode) {
3174 ic->arg[2] = (uint32_t)iword;
3178 rs = (iword >> 21) & 31;
3179 ra = (iword >> 16) & 31;
3183 ic->arg[2] = (uint32_t)iword;
3189 rs = (iword >> 21) & 31;
3190 ra = (iword >> 16) & 31;
3196 ic->arg[2] = (int32_t)(int16_t)iword;
3197 switch (main_opcode) {
3208 xo = (iword >> 2) & 7;
3222 fatal(
"TODO: rld* in 32-bit mode?\n");
3232 xo = (iword >> 1) & 1023;
3237 bf = (iword >> 23) & 7;
3238 l_bit = (iword >> 21) & 1;
3239 ra = (iword >> 16) & 31;
3240 rb = (iword >> 11) & 31;
3258 ic->arg[2] = 28 - 4*bf;
3262 rs = (iword >> 21) & 31;
3263 ra = (iword >> 16) & 31;
3267 fatal(
"TODO: rc\n");
3276 rt = (iword >> 21) & 31;
3277 spr = ((iword >> 6) & 0x3e0) + ((iword >> 16) & 31);
3278 debug_spr_usage(
cpu->
pc, spr);
3286 default:
ic->f =
instr(mfspr);
3291 rs = (iword >> 21) & 31;
3292 spr = ((iword >> 6) & 0x3e0) + ((iword >> 16) & 31);
3293 debug_spr_usage(
cpu->
pc, spr);
3311 rt = (iword >> 21) & 31;
3317 rt = (iword >> 21) & 31;
3324 rs = (iword >> 21) & 31;
3325 l_bit = (iword >> 16) & 1;
3328 fatal(
"TODO: mtmsr l-bit\n");
3332 ic->arg[1] = (addr & 0xfff) + 4;
3338 rs = (iword >> 21) & 31;
3340 int i, fxm = (iword >> 12) & 255;
3342 for (i=0; i<8; i++, fxm <<= 1) {
3347 ic->arg[1] = (uint32_t)tmp;
3355 rt = (iword >> 21) & 31;
3356 rb = (iword >> 11) & 31;
3365 fatal(
"Not yet for 64-bit mode\n");
3372 rt = (iword >> 21) & 31;
3373 ic->arg[0] = (iword >> 16) & 15;
3381 fatal(
"Not yet for 64-bit mode\n");
3387 rs = (iword >> 21) & 31;
3388 ra = (iword >> 16) & 31;
3389 sh = (iword >> 11) & 31;
3412 ra = (iword >> 16) & 31;
3413 rb = (iword >> 11) & 31;
3419 ic->arg[2] = addr & 0xfff;
3437 rb = (iword >> 11) & 31;
3443 rb = (iword >> 11) & 31;
3449 rb = (iword >> 11) & 31;
3460 rt = (iword >> 21) & 31;
3461 spr = ((iword >> 6) & 0x3e0) + ((iword >> 16) & 31);
3464 case 268:
ic->f =
instr(mftb);
break;
3465 case 269:
ic->f =
instr(mftbu);
break;
3467 fatal(
"mftb spr=%i?\n", spr);
3473 rt = (iword >> 21) & 31;
3474 ra = (iword >> 16) & 31;
3494 rs = (iword >> 21) & 31;
3495 ra = (iword >> 16) & 31;
3496 nb = (iword >> 11) & 31;
3502 ic->arg[2] = nb == 0? 32 : nb;
3510 ic->arg[0] = iword & 0x8000;
3515 fatal(
"[ mtdcr: TODO ]\n");
3543 rs = (iword >> 21) & 31;
3544 ra = (iword >> 16) & 31;
3545 rb = (iword >> 11) & 31;
3551 load = 0; zero = 1; size = 0; update = 0;
3552 byterev = 0; fp = 0;
3558 case PPC_31_LHAUX: size=1; load=update=1; zero=0;
break;
3592 if (!byterev &&
ic->f == NULL) {
3595 ppc32_loadstore_indexed
3599 [size + 4*zero + 8*load + 16*update];
3601 if (ra == 0 && update) {
3603 fatal(
"TODO: ra=0 && update?\n");
3623 rs = (iword >> 21) & 31;
3624 ra = (iword >> 16) & 31;
3625 rb = (iword >> 11) & 31;
3630 rc_f =
instr(extsb_dot);
break;
3632 rc_f =
instr(extsh_dot);
break;
3634 rc_f =
instr(extsw_dot);
break;
3636 rc_f =
instr(slw_dot);
break;
3638 rc_f =
instr(sld_dot);
break;
3640 rc_f =
instr(sraw_dot);
break;
3642 rc_f =
instr(srw_dot);
break;
3644 rc_f =
instr(and_dot);
break;
3646 rc_f =
instr(nand_dot);
break;
3648 rc_f =
instr(andc_dot);
break;
3650 rc_f =
instr(nor_dot);
break;
3653 rc_f =
instr(or_dot);
break;
3655 rc_f =
instr(orc_dot);
break;
3657 rc_f =
instr(xor_dot);
break;
3659 rc_f =
instr(eqv_dot);
break;
3683 rt = (iword >> 21) & 31;
3684 ra = (iword >> 16) & 31;
3685 rb = (iword >> 11) & 31;
3686 oe_bit = (iword >> 10) & 1;
3690 fatal(
"oe_bit not yet implemented\n");
3713 ic->f =
instr(add_dot);
break;
3715 ic->f =
instr(adde_dot);
break;
3717 ic->f =
instr(addme_dot);
break;
3719 ic->f =
instr(addze_dot);
break;
3721 ic->f =
instr(divw_dot);
break;
3723 ic->f =
instr(divwu_dot);
break;
3725 ic->f =
instr(mullw_dot);
break;
3727 ic->f =
instr(mulhw_dot);
break;
3729 ic->f =
instr(mulhwu_dot);
break;
3731 ic->f =
instr(subf_dot);
break;
3733 ic->f =
instr(subfc_dot);
break;
3735 ic->f =
instr(subfe_dot);
break;
3737 ic->f =
instr(subfme_dot);
break;
3739 ic->f =
instr(subfze_dot);
break;
3741 fatal(
"RC bit not yet " 3751 fatal(
"Not yet for 64-bit mode\n");
3766 rs = (iword >> 21) & 31;
3767 ra = (iword >> 16) & 31;
3768 rb = (iword >> 11) & 31;
3783 xo = (iword >> 1) & 1023;
3784 rt = (iword >> 21) & 31;
3785 ra = (iword >> 16) & 31;
3786 rb = (iword >> 11) & 31;
3787 rs = (iword >> 6) & 31;
3792 fatal(
"Floating point (59) " 3793 "with rc bit! TODO\n");
3826 xo = (iword >> 1) & 1023;
3827 rt = (iword >> 21) & 31;
3828 ra = (iword >> 16) & 31;
3829 rb = (iword >> 11) & 31;
3830 rs = (iword >> 6) & 31;
3835 fatal(
"Floating point (63) " 3836 "with rc bit! TODO\n");
3875 ic->arg[0] = 28 - 4*(rt >> 2);
3902 for (bi=7; bi>=0; bi--) {
3904 if (iword & (1 << (17+bi)))
3917 #define DYNTRANS_TO_BE_TRANSLATED_TAIL 3919 #undef DYNTRANS_TO_BE_TRANSLATED_TAIL
void(* ppc_loadstore[64])(struct cpu *, struct ppc_instr_call *)
void fatal(const char *fmt,...)
void(* ppc_loadstore_indexed[32])(struct cpu *, struct ppc_instr_call *)
void COMBINE() nop(struct cpu *cpu, struct mips_instr_call *ic, int low_addr)
struct arm_instr_call * ic
#define PPC_FPSCR_FPCC_SHIFT
#define DYNTRANS_L2_64_TABLE
void ieee_interpret_float_value(uint64_t x, struct ieee_float_value *fvp, int fmt)
void COMBINE() ori(struct cpu *cpu, struct mips_instr_call *ic, int low_addr)
void reg_access_msr(struct cpu *cpu, uint64_t *valuep, int writeflag, int check_for_interrupts)
int debugger_n_steps_left_before_interaction
int translation_readahead
#define quick_pc_to_pointers(cpu)
int(* memory_rw)(struct cpu *cpu, struct memory *mem, uint64_t vaddr, unsigned char *data, size_t len, int writeflag, int cache_flags)
int of_emul(struct cpu *cpu)
#define PPC_HI6_ADDIC_DOT
void cpu_functioncall_trace(struct cpu *cpu, uint64_t f)
#define PPC_IC_ENTRIES_PER_PAGE
void cpu_functioncall_trace_return(struct cpu *cpu)
void ppc_exception(struct cpu *cpu, int exception_nr)
#define CACHE_INSTRUCTION
void load(FILE *fh, unsigned char *ptr, unsigned long sz)
uint64_t ieee_store_float_value(double nf, int fmt, int nan)
#define PPC_HI6_ANDIS_DOT
#define PPC_INSTR_ALIGNMENT_SHIFT
#define PPC_EXCEPTION_FPU
#define CHECK_FOR_FPU_EXCEPTION
void update_cr0(struct cpu *cpu, uint64_t value)
addr & if(addr >=0x24 &&page !=NULL)
#define DYNTRANS_L3_64_TABLE
struct ppc_cpu_type_def cpu_type
#define INVALIDATE_VADDR_UPPER4
void(* invalidate_translation_caches)(struct cpu *, uint64_t paddr, int flags)