Revision a7812ae4 target-cris/translate.c
b/target-cris/translate.c | ||
---|---|---|
39 | 39 |
#include "crisv32-decode.h" |
40 | 40 |
#include "qemu-common.h" |
41 | 41 |
|
42 |
#define GEN_HELPER 1 |
|
43 |
#include "helper.h" |
|
44 |
|
|
42 | 45 |
#define DISAS_CRIS 0 |
43 | 46 |
#if DISAS_CRIS |
44 | 47 |
#define DIS(x) if (loglevel & CPU_LOG_TB_IN_ASM) x |
... | ... | |
61 | 64 |
#define CC_MASK_NZVC 0xf |
62 | 65 |
#define CC_MASK_RNZV 0x10e |
63 | 66 |
|
64 |
static TCGv cpu_env; |
|
67 |
static TCGv_ptr cpu_env;
|
|
65 | 68 |
static TCGv cpu_R[16]; |
66 | 69 |
static TCGv cpu_PR[16]; |
67 | 70 |
static TCGv cc_x; |
... | ... | |
212 | 215 |
tcg_gen_andi_tl(cpu_PR[r], tn, 3); |
213 | 216 |
else { |
214 | 217 |
if (r == PR_PID) |
215 |
tcg_gen_helper_0_1(helper_tlb_flush_pid, tn);
|
|
218 |
gen_helper_tlb_flush_pid(tn);
|
|
216 | 219 |
if (dc->tb_flags & S_FLAG && r == PR_SPC) |
217 |
tcg_gen_helper_0_1(helper_spc_write, tn);
|
|
220 |
gen_helper_spc_write(tn);
|
|
218 | 221 |
else if (r == PR_CCS) |
219 | 222 |
dc->cpustate_changed = 1; |
220 | 223 |
tcg_gen_mov_tl(cpu_PR[r], tn); |
... | ... | |
223 | 226 |
|
224 | 227 |
static inline void t_gen_raise_exception(uint32_t index) |
225 | 228 |
{ |
226 |
tcg_gen_helper_0_1(helper_raise_exception, tcg_const_tl(index)); |
|
229 |
TCGv_i32 tmp = tcg_const_i32(index); |
|
230 |
gen_helper_raise_exception(tmp); |
|
231 |
tcg_temp_free_i32(tmp); |
|
227 | 232 |
} |
228 | 233 |
|
229 | 234 |
static void t_gen_lsl(TCGv d, TCGv a, TCGv b) |
230 | 235 |
{ |
231 | 236 |
TCGv t0, t_31; |
232 | 237 |
|
233 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
238 |
t0 = tcg_temp_new(); |
|
234 | 239 |
t_31 = tcg_const_tl(31); |
235 | 240 |
tcg_gen_shl_tl(d, a, b); |
236 | 241 |
|
... | ... | |
246 | 251 |
{ |
247 | 252 |
TCGv t0, t_31; |
248 | 253 |
|
249 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
250 |
t_31 = tcg_temp_new(TCG_TYPE_TL);
|
|
254 |
t0 = tcg_temp_new(); |
|
255 |
t_31 = tcg_temp_new(); |
|
251 | 256 |
tcg_gen_shr_tl(d, a, b); |
252 | 257 |
|
253 | 258 |
tcg_gen_movi_tl(t_31, 31); |
... | ... | |
263 | 268 |
{ |
264 | 269 |
TCGv t0, t_31; |
265 | 270 |
|
266 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
267 |
t_31 = tcg_temp_new(TCG_TYPE_TL);
|
|
271 |
t0 = tcg_temp_new(); |
|
272 |
t_31 = tcg_temp_new(); |
|
268 | 273 |
tcg_gen_sar_tl(d, a, b); |
269 | 274 |
|
270 | 275 |
tcg_gen_movi_tl(t_31, 31); |
... | ... | |
278 | 283 |
/* 64-bit signed mul, lower result in d and upper in d2. */ |
279 | 284 |
static void t_gen_muls(TCGv d, TCGv d2, TCGv a, TCGv b) |
280 | 285 |
{ |
281 |
TCGv t0, t1; |
|
286 |
TCGv_i64 t0, t1;
|
|
282 | 287 |
|
283 |
t0 = tcg_temp_new(TCG_TYPE_I64);
|
|
284 |
t1 = tcg_temp_new(TCG_TYPE_I64);
|
|
288 |
t0 = tcg_temp_new_i64();
|
|
289 |
t1 = tcg_temp_new_i64();
|
|
285 | 290 |
|
286 |
tcg_gen_ext32s_i64(t0, a);
|
|
287 |
tcg_gen_ext32s_i64(t1, b);
|
|
291 |
tcg_gen_ext_i32_i64(t0, a);
|
|
292 |
tcg_gen_ext_i32_i64(t1, b);
|
|
288 | 293 |
tcg_gen_mul_i64(t0, t0, t1); |
289 | 294 |
|
290 | 295 |
tcg_gen_trunc_i64_i32(d, t0); |
291 | 296 |
tcg_gen_shri_i64(t0, t0, 32); |
292 | 297 |
tcg_gen_trunc_i64_i32(d2, t0); |
293 | 298 |
|
294 |
tcg_temp_free(t0); |
|
295 |
tcg_temp_free(t1); |
|
299 |
tcg_temp_free_i64(t0);
|
|
300 |
tcg_temp_free_i64(t1);
|
|
296 | 301 |
} |
297 | 302 |
|
298 | 303 |
/* 64-bit unsigned muls, lower result in d and upper in d2. */ |
299 | 304 |
static void t_gen_mulu(TCGv d, TCGv d2, TCGv a, TCGv b) |
300 | 305 |
{ |
301 |
TCGv t0, t1; |
|
306 |
TCGv_i64 t0, t1;
|
|
302 | 307 |
|
303 |
t0 = tcg_temp_new(TCG_TYPE_I64);
|
|
304 |
t1 = tcg_temp_new(TCG_TYPE_I64);
|
|
308 |
t0 = tcg_temp_new_i64();
|
|
309 |
t1 = tcg_temp_new_i64();
|
|
305 | 310 |
|
306 | 311 |
tcg_gen_extu_i32_i64(t0, a); |
307 | 312 |
tcg_gen_extu_i32_i64(t1, b); |
... | ... | |
311 | 316 |
tcg_gen_shri_i64(t0, t0, 32); |
312 | 317 |
tcg_gen_trunc_i64_i32(d2, t0); |
313 | 318 |
|
314 |
tcg_temp_free(t0); |
|
315 |
tcg_temp_free(t1); |
|
319 |
tcg_temp_free_i64(t0);
|
|
320 |
tcg_temp_free_i64(t1);
|
|
316 | 321 |
} |
317 | 322 |
|
318 | 323 |
/* 32bit branch-free binary search for counting leading zeros. */ |
319 | 324 |
static void t_gen_lz_i32(TCGv d, TCGv x) |
320 | 325 |
{ |
321 |
TCGv y, m, n; |
|
326 |
TCGv_i32 y, m, n;
|
|
322 | 327 |
|
323 |
y = tcg_temp_new(TCG_TYPE_I32);
|
|
324 |
m = tcg_temp_new(TCG_TYPE_I32);
|
|
325 |
n = tcg_temp_new(TCG_TYPE_I32);
|
|
328 |
y = tcg_temp_new_i32();
|
|
329 |
m = tcg_temp_new_i32();
|
|
330 |
n = tcg_temp_new_i32();
|
|
326 | 331 |
|
327 | 332 |
/* y = -(x >> 16) */ |
328 | 333 |
tcg_gen_shri_i32(y, x, 16); |
... | ... | |
413 | 418 |
*/ |
414 | 419 |
|
415 | 420 |
l1 = gen_new_label(); |
416 |
sbit = tcg_temp_new(TCG_TYPE_TL);
|
|
417 |
bset = tcg_temp_new(TCG_TYPE_TL);
|
|
418 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
421 |
sbit = tcg_temp_new(); |
|
422 |
bset = tcg_temp_new(); |
|
423 |
t0 = tcg_temp_new(); |
|
419 | 424 |
|
420 | 425 |
/* Compute bset and sbit. */ |
421 | 426 |
tcg_gen_andi_tl(sbit, b, 31); |
... | ... | |
463 | 468 |
{ |
464 | 469 |
TCGv c; |
465 | 470 |
|
466 |
c = tcg_temp_new(TCG_TYPE_TL);
|
|
471 |
c = tcg_temp_new(); |
|
467 | 472 |
t_gen_mov_TN_preg(c, PR_CCS); |
468 | 473 |
/* Propagate carry into d. */ |
469 | 474 |
tcg_gen_andi_tl(c, c, 1 << flag); |
... | ... | |
479 | 484 |
if (dc->flags_x) { |
480 | 485 |
TCGv c; |
481 | 486 |
|
482 |
c = tcg_temp_new(TCG_TYPE_TL);
|
|
487 |
c = tcg_temp_new(); |
|
483 | 488 |
t_gen_mov_TN_preg(c, PR_CCS); |
484 | 489 |
/* C flag is already at bit 0. */ |
485 | 490 |
tcg_gen_andi_tl(c, c, C_FLAG); |
... | ... | |
489 | 494 |
} else { |
490 | 495 |
TCGv x, c; |
491 | 496 |
|
492 |
x = tcg_temp_new(TCG_TYPE_TL);
|
|
493 |
c = tcg_temp_new(TCG_TYPE_TL);
|
|
497 |
x = tcg_temp_new(); |
|
498 |
c = tcg_temp_new(); |
|
494 | 499 |
t_gen_mov_TN_preg(x, PR_CCS); |
495 | 500 |
tcg_gen_mov_tl(c, x); |
496 | 501 |
|
... | ... | |
512 | 517 |
if (dc->flags_x) { |
513 | 518 |
TCGv c; |
514 | 519 |
|
515 |
c = tcg_temp_new(TCG_TYPE_TL);
|
|
520 |
c = tcg_temp_new(); |
|
516 | 521 |
t_gen_mov_TN_preg(c, PR_CCS); |
517 | 522 |
/* C flag is already at bit 0. */ |
518 | 523 |
tcg_gen_andi_tl(c, c, C_FLAG); |
... | ... | |
522 | 527 |
} else { |
523 | 528 |
TCGv x, c; |
524 | 529 |
|
525 |
x = tcg_temp_new(TCG_TYPE_TL);
|
|
526 |
c = tcg_temp_new(TCG_TYPE_TL);
|
|
530 |
x = tcg_temp_new(); |
|
531 |
c = tcg_temp_new(); |
|
527 | 532 |
t_gen_mov_TN_preg(x, PR_CCS); |
528 | 533 |
tcg_gen_mov_tl(c, x); |
529 | 534 |
|
... | ... | |
545 | 550 |
{ |
546 | 551 |
TCGv t, org_s; |
547 | 552 |
|
548 |
t = tcg_temp_new(TCG_TYPE_TL);
|
|
549 |
org_s = tcg_temp_new(TCG_TYPE_TL);
|
|
553 |
t = tcg_temp_new(); |
|
554 |
org_s = tcg_temp_new(); |
|
550 | 555 |
|
551 | 556 |
/* d and s may refer to the same object. */ |
552 | 557 |
tcg_gen_mov_tl(org_s, s); |
... | ... | |
564 | 569 |
{ |
565 | 570 |
TCGv t; |
566 | 571 |
/* d and s refer the same object. */ |
567 |
t = tcg_temp_new(TCG_TYPE_TL);
|
|
572 |
t = tcg_temp_new(); |
|
568 | 573 |
tcg_gen_mov_tl(t, s); |
569 | 574 |
tcg_gen_shli_tl(d, t, 16); |
570 | 575 |
tcg_gen_shri_tl(t, t, 16); |
... | ... | |
601 | 606 |
TCGv t, org_s; |
602 | 607 |
|
603 | 608 |
/* d and s refer the same object. */ |
604 |
t = tcg_temp_new(TCG_TYPE_TL);
|
|
605 |
org_s = tcg_temp_new(TCG_TYPE_TL);
|
|
609 |
t = tcg_temp_new(); |
|
610 |
org_s = tcg_temp_new(); |
|
606 | 611 |
tcg_gen_mov_tl(org_s, s); |
607 | 612 |
|
608 | 613 |
tcg_gen_shli_tl(t, org_s, bitrev[0].shift); |
... | ... | |
626 | 631 |
int l1; |
627 | 632 |
|
628 | 633 |
l1 = gen_new_label(); |
629 |
btaken = tcg_temp_new(TCG_TYPE_TL);
|
|
634 |
btaken = tcg_temp_new(); |
|
630 | 635 |
|
631 | 636 |
/* Conditional jmp. */ |
632 | 637 |
tcg_gen_mov_tl(btaken, env_btaken); |
... | ... | |
692 | 697 |
switch (dc->cc_op) |
693 | 698 |
{ |
694 | 699 |
case CC_OP_MCP: |
695 |
tcg_gen_helper_0_0(helper_evaluate_flags_mcp);
|
|
700 |
gen_helper_evaluate_flags_mcp();
|
|
696 | 701 |
break; |
697 | 702 |
case CC_OP_MULS: |
698 |
tcg_gen_helper_0_0(helper_evaluate_flags_muls);
|
|
703 |
gen_helper_evaluate_flags_muls();
|
|
699 | 704 |
break; |
700 | 705 |
case CC_OP_MULU: |
701 |
tcg_gen_helper_0_0(helper_evaluate_flags_mulu);
|
|
706 |
gen_helper_evaluate_flags_mulu();
|
|
702 | 707 |
break; |
703 | 708 |
case CC_OP_MOVE: |
704 | 709 |
case CC_OP_AND: |
... | ... | |
710 | 715 |
switch (dc->cc_size) |
711 | 716 |
{ |
712 | 717 |
case 4: |
713 |
tcg_gen_helper_0_0(helper_evaluate_flags_move_4);
|
|
718 |
gen_helper_evaluate_flags_move_4();
|
|
714 | 719 |
break; |
715 | 720 |
case 2: |
716 |
tcg_gen_helper_0_0(helper_evaluate_flags_move_2);
|
|
721 |
gen_helper_evaluate_flags_move_2();
|
|
717 | 722 |
break; |
718 | 723 |
default: |
719 |
tcg_gen_helper_0_0(helper_evaluate_flags);
|
|
724 |
gen_helper_evaluate_flags();
|
|
720 | 725 |
break; |
721 | 726 |
} |
722 | 727 |
break; |
... | ... | |
728 | 733 |
switch (dc->cc_size) |
729 | 734 |
{ |
730 | 735 |
case 4: |
731 |
tcg_gen_helper_0_0(helper_evaluate_flags_alu_4);
|
|
736 |
gen_helper_evaluate_flags_alu_4();
|
|
732 | 737 |
break; |
733 | 738 |
default: |
734 |
tcg_gen_helper_0_0(helper_evaluate_flags);
|
|
739 |
gen_helper_evaluate_flags();
|
|
735 | 740 |
break; |
736 | 741 |
} |
737 | 742 |
} |
... | ... | |
927 | 932 |
writeback = 1; |
928 | 933 |
|
929 | 934 |
if (op == CC_OP_BOUND || op == CC_OP_BTST) |
930 |
tmp = tcg_temp_local_new(TCG_TYPE_TL);
|
|
935 |
tmp = tcg_temp_local_new(); |
|
931 | 936 |
|
932 | 937 |
if (op == CC_OP_CMP) { |
933 |
tmp = tcg_temp_new(TCG_TYPE_TL);
|
|
938 |
tmp = tcg_temp_new(); |
|
934 | 939 |
writeback = 0; |
935 | 940 |
} else if (size == 4) { |
936 | 941 |
tmp = d; |
937 | 942 |
writeback = 0; |
938 | 943 |
} else |
939 |
tmp = tcg_temp_new(TCG_TYPE_TL);
|
|
944 |
tmp = tcg_temp_new(); |
|
940 | 945 |
|
941 | 946 |
|
942 | 947 |
cris_pre_alu_update_cc(dc, op, op_a, op_b, size); |
... | ... | |
951 | 956 |
tcg_gen_andi_tl(d, d, ~0xffff); |
952 | 957 |
tcg_gen_or_tl(d, d, tmp); |
953 | 958 |
} |
954 |
if (GET_TCGV(tmp) != GET_TCGV(d))
|
|
959 |
if (!TCGV_EQUAL(tmp, d))
|
|
955 | 960 |
tcg_temp_free(tmp); |
956 | 961 |
} |
957 | 962 |
|
... | ... | |
1088 | 1093 |
{ |
1089 | 1094 |
TCGv tmp; |
1090 | 1095 |
|
1091 |
tmp = tcg_temp_new(TCG_TYPE_TL);
|
|
1096 |
tmp = tcg_temp_new(); |
|
1092 | 1097 |
tcg_gen_xori_tl(tmp, cpu_PR[PR_CCS], |
1093 | 1098 |
C_FLAG | Z_FLAG); |
1094 | 1099 |
/* Overlay the C flag on top of the Z. */ |
... | ... | |
1121 | 1126 |
{ |
1122 | 1127 |
TCGv n, z; |
1123 | 1128 |
|
1124 |
n = tcg_temp_new(TCG_TYPE_TL);
|
|
1125 |
z = tcg_temp_new(TCG_TYPE_TL);
|
|
1129 |
n = tcg_temp_new(); |
|
1130 |
z = tcg_temp_new(); |
|
1126 | 1131 |
|
1127 | 1132 |
/* To avoid a shift we overlay everything on |
1128 | 1133 |
the V flag. */ |
... | ... | |
1145 | 1150 |
{ |
1146 | 1151 |
TCGv n, z; |
1147 | 1152 |
|
1148 |
n = tcg_temp_new(TCG_TYPE_TL);
|
|
1149 |
z = tcg_temp_new(TCG_TYPE_TL);
|
|
1153 |
n = tcg_temp_new(); |
|
1154 |
z = tcg_temp_new(); |
|
1150 | 1155 |
|
1151 | 1156 |
/* To avoid a shift we overlay everything on |
1152 | 1157 |
the V flag. */ |
... | ... | |
1215 | 1220 |
tcg_gen_movi_tl(env_btaken, 1); |
1216 | 1221 |
} |
1217 | 1222 |
|
1223 |
static void gen_load64(DisasContext *dc, TCGv_i64 dst, TCGv addr) |
|
1224 |
{ |
|
1225 |
int mem_index = cpu_mmu_index(dc->env); |
|
1226 |
|
|
1227 |
/* If we get a fault on a delayslot we must keep the jmp state in |
|
1228 |
the cpu-state to be able to re-execute the jmp. */ |
|
1229 |
if (dc->delayed_branch == 1) |
|
1230 |
cris_store_direct_jmp(dc); |
|
1231 |
|
|
1232 |
tcg_gen_qemu_ld64(dst, addr, mem_index); |
|
1233 |
} |
|
1234 |
|
|
1218 | 1235 |
static void gen_load(DisasContext *dc, TCGv dst, TCGv addr, |
1219 | 1236 |
unsigned int size, int sign) |
1220 | 1237 |
{ |
... | ... | |
1240 | 1257 |
else if (size == 4) { |
1241 | 1258 |
tcg_gen_qemu_ld32u(dst, addr, mem_index); |
1242 | 1259 |
} |
1243 |
else if (size == 8) {
|
|
1244 |
tcg_gen_qemu_ld64(dst, addr, mem_index);
|
|
1260 |
else { |
|
1261 |
abort();
|
|
1245 | 1262 |
} |
1246 | 1263 |
} |
1247 | 1264 |
|
... | ... | |
1284 | 1301 |
tcg_gen_ext8s_i32(d, s); |
1285 | 1302 |
else if (size == 2) |
1286 | 1303 |
tcg_gen_ext16s_i32(d, s); |
1287 |
else if(GET_TCGV(d) != GET_TCGV(s))
|
|
1304 |
else if(!TCGV_EQUAL(d, s))
|
|
1288 | 1305 |
tcg_gen_mov_tl(d, s); |
1289 | 1306 |
} |
1290 | 1307 |
|
... | ... | |
1294 | 1311 |
tcg_gen_ext8u_i32(d, s); |
1295 | 1312 |
else if (size == 2) |
1296 | 1313 |
tcg_gen_ext16u_i32(d, s); |
1297 |
else if (GET_TCGV(d) != GET_TCGV(s))
|
|
1314 |
else if (!TCGV_EQUAL(d, s))
|
|
1298 | 1315 |
tcg_gen_mov_tl(d, s); |
1299 | 1316 |
} |
1300 | 1317 |
|
... | ... | |
1546 | 1563 |
DIS(fprintf (logfile, "btstq %u, $r%d\n", dc->op1, dc->op2)); |
1547 | 1564 |
|
1548 | 1565 |
cris_cc_mask(dc, CC_MASK_NZ); |
1549 |
l0 = tcg_temp_local_new(TCG_TYPE_TL);
|
|
1566 |
l0 = tcg_temp_local_new(); |
|
1550 | 1567 |
cris_alu(dc, CC_OP_BTST, |
1551 | 1568 |
l0, cpu_R[dc->op2], tcg_const_tl(dc->op1), 4); |
1552 | 1569 |
cris_update_cc_op(dc, CC_OP_FLAGS, 4); |
... | ... | |
1613 | 1630 |
else { |
1614 | 1631 |
TCGv t0; |
1615 | 1632 |
|
1616 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
1633 |
t0 = tcg_temp_new(); |
|
1617 | 1634 |
dec_prep_move_r(dc, dc->op1, dc->op2, size, 0, t0); |
1618 | 1635 |
cris_alu(dc, CC_OP_MOVE, |
1619 | 1636 |
cpu_R[dc->op2], |
... | ... | |
1653 | 1670 |
t[0] = cpu_R[dc->op2]; |
1654 | 1671 |
t[1] = cpu_R[dc->op1]; |
1655 | 1672 |
} else { |
1656 |
t[0] = tcg_temp_new(TCG_TYPE_TL);
|
|
1657 |
t[1] = tcg_temp_new(TCG_TYPE_TL);
|
|
1673 |
t[0] = tcg_temp_new(); |
|
1674 |
t[1] = tcg_temp_new(); |
|
1658 | 1675 |
} |
1659 | 1676 |
} |
1660 | 1677 |
|
... | ... | |
1689 | 1706 |
DIS(fprintf (logfile, "lz $r%u, $r%u\n", |
1690 | 1707 |
dc->op1, dc->op2)); |
1691 | 1708 |
cris_cc_mask(dc, CC_MASK_NZ); |
1692 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
1709 |
t0 = tcg_temp_new(); |
|
1693 | 1710 |
dec_prep_alu_r(dc, dc->op1, dc->op2, 4, 0, cpu_R[dc->op2], t0); |
1694 | 1711 |
cris_alu(dc, CC_OP_LZ, cpu_R[dc->op2], cpu_R[dc->op2], t0, 4); |
1695 | 1712 |
tcg_temp_free(t0); |
... | ... | |
1812 | 1829 |
DIS(fprintf (logfile, "bound.%c $r%u, $r%u\n", |
1813 | 1830 |
memsize_char(size), dc->op1, dc->op2)); |
1814 | 1831 |
cris_cc_mask(dc, CC_MASK_NZ); |
1815 |
l0 = tcg_temp_local_new(TCG_TYPE_TL);
|
|
1832 |
l0 = tcg_temp_local_new(); |
|
1816 | 1833 |
dec_prep_move_r(dc, dc->op1, dc->op2, size, 0, l0); |
1817 | 1834 |
cris_alu(dc, CC_OP_BOUND, cpu_R[dc->op2], cpu_R[dc->op2], l0, 4); |
1818 | 1835 |
tcg_temp_free(l0); |
... | ... | |
1842 | 1859 |
dc->op1, dc->op2)); |
1843 | 1860 |
cris_cc_mask(dc, CC_MASK_NZ); |
1844 | 1861 |
|
1845 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
1862 |
t0 = tcg_temp_new(); |
|
1846 | 1863 |
tcg_gen_sari_tl(t0, cpu_R[dc->op1], 31); |
1847 | 1864 |
tcg_gen_xor_tl(cpu_R[dc->op2], cpu_R[dc->op1], t0); |
1848 | 1865 |
tcg_gen_sub_tl(cpu_R[dc->op2], cpu_R[dc->op2], t0); |
... | ... | |
1916 | 1933 |
swapmode_name(dc->op2, modename), dc->op1)); |
1917 | 1934 |
|
1918 | 1935 |
cris_cc_mask(dc, CC_MASK_NZ); |
1919 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
1936 |
t0 = tcg_temp_new(); |
|
1920 | 1937 |
t_gen_mov_TN_reg(t0, dc->op1); |
1921 | 1938 |
if (dc->op2 & 8) |
1922 | 1939 |
tcg_gen_not_tl(t0, t0); |
... | ... | |
1952 | 1969 |
DIS(fprintf (logfile, "addi.%c $r%u, $r%u\n", |
1953 | 1970 |
memsize_char(memsize_zz(dc)), dc->op2, dc->op1)); |
1954 | 1971 |
cris_cc_mask(dc, 0); |
1955 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
1972 |
t0 = tcg_temp_new(); |
|
1956 | 1973 |
tcg_gen_shl_tl(t0, cpu_R[dc->op2], tcg_const_tl(dc->zzsize)); |
1957 | 1974 |
tcg_gen_add_tl(cpu_R[dc->op1], cpu_R[dc->op1], t0); |
1958 | 1975 |
tcg_temp_free(t0); |
... | ... | |
1965 | 1982 |
DIS(fprintf (logfile, "addi.%c $r%u, $r%u, $acr\n", |
1966 | 1983 |
memsize_char(memsize_zz(dc)), dc->op2, dc->op1)); |
1967 | 1984 |
cris_cc_mask(dc, 0); |
1968 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
1985 |
t0 = tcg_temp_new(); |
|
1969 | 1986 |
tcg_gen_shl_tl(t0, cpu_R[dc->op2], tcg_const_tl(dc->zzsize)); |
1970 | 1987 |
tcg_gen_add_tl(cpu_R[R_ACR], cpu_R[dc->op1], t0); |
1971 | 1988 |
tcg_temp_free(t0); |
... | ... | |
1994 | 2011 |
dc->op1, dc->op2)); |
1995 | 2012 |
cris_cc_mask(dc, CC_MASK_NZ); |
1996 | 2013 |
|
1997 |
l0 = tcg_temp_local_new(TCG_TYPE_TL);
|
|
2014 |
l0 = tcg_temp_local_new(); |
|
1998 | 2015 |
cris_alu(dc, CC_OP_BTST, l0, cpu_R[dc->op2], cpu_R[dc->op1], 4); |
1999 | 2016 |
cris_update_cc_op(dc, CC_OP_FLAGS, 4); |
2000 | 2017 |
t_gen_mov_preg_TN(dc, PR_CCS, l0); |
... | ... | |
2027 | 2044 |
dc->op1, dc->op2)); |
2028 | 2045 |
|
2029 | 2046 |
cris_cc_mask(dc, CC_MASK_NZ); |
2030 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
2047 |
t0 = tcg_temp_new(); |
|
2031 | 2048 |
dec_prep_move_r(dc, dc->op1, dc->op2, size, 0, t0); |
2032 | 2049 |
cris_alu(dc, CC_OP_MOVE, cpu_R[dc->op2], cpu_R[dc->op2], t0, 4); |
2033 | 2050 |
tcg_temp_free(t0); |
... | ... | |
2044 | 2061 |
dc->op1, dc->op2)); |
2045 | 2062 |
|
2046 | 2063 |
cris_cc_mask(dc, CC_MASK_NZ); |
2047 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
2064 |
t0 = tcg_temp_new(); |
|
2048 | 2065 |
/* Size can only be qi or hi. */ |
2049 | 2066 |
t_gen_sext(t0, cpu_R[dc->op1], size); |
2050 | 2067 |
cris_alu(dc, CC_OP_MOVE, |
... | ... | |
2063 | 2080 |
dc->op1, dc->op2)); |
2064 | 2081 |
|
2065 | 2082 |
cris_cc_mask(dc, CC_MASK_NZVC); |
2066 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
2083 |
t0 = tcg_temp_new(); |
|
2067 | 2084 |
/* Size can only be qi or hi. */ |
2068 | 2085 |
t_gen_zext(t0, cpu_R[dc->op1], size); |
2069 | 2086 |
cris_alu(dc, CC_OP_ADD, |
... | ... | |
2082 | 2099 |
dc->op1, dc->op2)); |
2083 | 2100 |
|
2084 | 2101 |
cris_cc_mask(dc, CC_MASK_NZVC); |
2085 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
2102 |
t0 = tcg_temp_new(); |
|
2086 | 2103 |
/* Size can only be qi or hi. */ |
2087 | 2104 |
t_gen_sext(t0, cpu_R[dc->op1], size); |
2088 | 2105 |
cris_alu(dc, CC_OP_ADD, |
... | ... | |
2101 | 2118 |
dc->op1, dc->op2)); |
2102 | 2119 |
|
2103 | 2120 |
cris_cc_mask(dc, CC_MASK_NZVC); |
2104 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
2121 |
t0 = tcg_temp_new(); |
|
2105 | 2122 |
/* Size can only be qi or hi. */ |
2106 | 2123 |
t_gen_zext(t0, cpu_R[dc->op1], size); |
2107 | 2124 |
cris_alu(dc, CC_OP_SUB, |
... | ... | |
2120 | 2137 |
dc->op1, dc->op2)); |
2121 | 2138 |
|
2122 | 2139 |
cris_cc_mask(dc, CC_MASK_NZVC); |
2123 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
2140 |
t0 = tcg_temp_new(); |
|
2124 | 2141 |
/* Size can only be qi or hi. */ |
2125 | 2142 |
t_gen_sext(t0, cpu_R[dc->op1], size); |
2126 | 2143 |
cris_alu(dc, CC_OP_SUB, |
... | ... | |
2203 | 2220 |
{ |
2204 | 2221 |
DIS(fprintf (logfile, "move $r%u, $s%u\n", dc->op1, dc->op2)); |
2205 | 2222 |
cris_cc_mask(dc, 0); |
2206 |
tcg_gen_helper_0_2(helper_movl_sreg_reg, |
|
2207 |
tcg_const_tl(dc->op2), tcg_const_tl(dc->op1)); |
|
2223 |
gen_helper_movl_sreg_reg(tcg_const_tl(dc->op2), tcg_const_tl(dc->op1)); |
|
2208 | 2224 |
return 2; |
2209 | 2225 |
} |
2210 | 2226 |
static unsigned int dec_move_sr(DisasContext *dc) |
2211 | 2227 |
{ |
2212 | 2228 |
DIS(fprintf (logfile, "move $s%u, $r%u\n", dc->op2, dc->op1)); |
2213 | 2229 |
cris_cc_mask(dc, 0); |
2214 |
tcg_gen_helper_0_2(helper_movl_reg_sreg, |
|
2215 |
tcg_const_tl(dc->op1), tcg_const_tl(dc->op2)); |
|
2230 |
gen_helper_movl_reg_sreg(tcg_const_tl(dc->op1), tcg_const_tl(dc->op2)); |
|
2216 | 2231 |
return 2; |
2217 | 2232 |
} |
2218 | 2233 |
|
... | ... | |
2222 | 2237 |
DIS(fprintf (logfile, "move $r%u, $p%u\n", dc->op1, dc->op2)); |
2223 | 2238 |
cris_cc_mask(dc, 0); |
2224 | 2239 |
|
2225 |
t[0] = tcg_temp_new(TCG_TYPE_TL);
|
|
2240 |
t[0] = tcg_temp_new(); |
|
2226 | 2241 |
if (dc->op2 == PR_CCS) { |
2227 | 2242 |
cris_evaluate_flags(dc); |
2228 | 2243 |
t_gen_mov_TN_reg(t[0], dc->op1); |
2229 | 2244 |
if (dc->tb_flags & U_FLAG) { |
2230 |
t[1] = tcg_temp_new(TCG_TYPE_TL);
|
|
2245 |
t[1] = tcg_temp_new(); |
|
2231 | 2246 |
/* User space is not allowed to touch all flags. */ |
2232 | 2247 |
tcg_gen_andi_tl(t[0], t[0], 0x39f); |
2233 | 2248 |
tcg_gen_andi_tl(t[1], cpu_PR[PR_CCS], ~0x39f); |
... | ... | |
2255 | 2270 |
if (dc->op2 == PR_CCS) |
2256 | 2271 |
cris_evaluate_flags(dc); |
2257 | 2272 |
|
2258 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
2273 |
t0 = tcg_temp_new(); |
|
2259 | 2274 |
t_gen_mov_TN_preg(t0, dc->op2); |
2260 | 2275 |
cris_alu(dc, CC_OP_MOVE, |
2261 | 2276 |
cpu_R[dc->op1], cpu_R[dc->op1], t0, preg_sizes[dc->op2]); |
... | ... | |
2282 | 2297 |
else { |
2283 | 2298 |
TCGv t0; |
2284 | 2299 |
|
2285 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
2300 |
t0 = tcg_temp_new(); |
|
2286 | 2301 |
insn_len = dec_prep_move_m(dc, 0, memsize, t0); |
2287 | 2302 |
cris_cc_mask(dc, CC_MASK_NZ); |
2288 | 2303 |
cris_alu(dc, CC_OP_MOVE, |
... | ... | |
2295 | 2310 |
|
2296 | 2311 |
static inline void cris_alu_m_alloc_temps(TCGv *t) |
2297 | 2312 |
{ |
2298 |
t[0] = tcg_temp_new(TCG_TYPE_TL);
|
|
2299 |
t[1] = tcg_temp_new(TCG_TYPE_TL);
|
|
2313 |
t[0] = tcg_temp_new(); |
|
2314 |
t[1] = tcg_temp_new(); |
|
2300 | 2315 |
} |
2301 | 2316 |
|
2302 | 2317 |
static inline void cris_alu_m_free_temps(TCGv *t) |
... | ... | |
2580 | 2595 |
dc->op1, dc->postinc ? "+]" : "]", |
2581 | 2596 |
dc->op2)); |
2582 | 2597 |
|
2583 |
l[0] = tcg_temp_local_new(TCG_TYPE_TL);
|
|
2584 |
l[1] = tcg_temp_local_new(TCG_TYPE_TL);
|
|
2598 |
l[0] = tcg_temp_local_new(); |
|
2599 |
l[1] = tcg_temp_local_new(); |
|
2585 | 2600 |
insn_len = dec_prep_alu_m(dc, 0, memsize, l[0], l[1]); |
2586 | 2601 |
cris_cc_mask(dc, CC_MASK_NZ); |
2587 | 2602 |
cris_alu(dc, CC_OP_BOUND, cpu_R[dc->op2], l[0], l[1], 4); |
... | ... | |
2694 | 2709 |
/* prepare store. Address in T0, value in T1. */ |
2695 | 2710 |
if (dc->op2 == PR_CCS) |
2696 | 2711 |
cris_evaluate_flags(dc); |
2697 |
t0 = tcg_temp_new(TCG_TYPE_TL);
|
|
2712 |
t0 = tcg_temp_new(); |
|
2698 | 2713 |
t_gen_mov_TN_preg(t0, dc->op2); |
2699 | 2714 |
cris_flush_cc_state(dc); |
2700 | 2715 |
gen_store(dc, cpu_R[dc->op1], t0, memsize); |
... | ... | |
2708 | 2723 |
|
2709 | 2724 |
static unsigned int dec_movem_mr(DisasContext *dc) |
2710 | 2725 |
{ |
2711 |
TCGv tmp[16]; |
|
2726 |
TCGv_i64 tmp[16]; |
|
2727 |
TCGv tmp32; |
|
2712 | 2728 |
TCGv addr; |
2713 | 2729 |
int i; |
2714 | 2730 |
int nr = dc->op2 + 1; |
... | ... | |
2716 | 2732 |
DIS(fprintf (logfile, "movem [$r%u%s, $r%u\n", dc->op1, |
2717 | 2733 |
dc->postinc ? "+]" : "]", dc->op2)); |
2718 | 2734 |
|
2719 |
addr = tcg_temp_new(TCG_TYPE_TL);
|
|
2735 |
addr = tcg_temp_new(); |
|
2720 | 2736 |
/* There are probably better ways of doing this. */ |
2721 | 2737 |
cris_flush_cc_state(dc); |
2722 | 2738 |
for (i = 0; i < (nr >> 1); i++) { |
2723 |
tmp[i] = tcg_temp_new(TCG_TYPE_I64);
|
|
2739 |
tmp[i] = tcg_temp_new_i64();
|
|
2724 | 2740 |
tcg_gen_addi_tl(addr, cpu_R[dc->op1], i * 8); |
2725 |
gen_load(dc, tmp[i], addr, 8, 0);
|
|
2741 |
gen_load64(dc, tmp[i], addr);
|
|
2726 | 2742 |
} |
2727 | 2743 |
if (nr & 1) { |
2728 |
tmp[i] = tcg_temp_new(TCG_TYPE_I32);
|
|
2744 |
tmp32 = tcg_temp_new_i32();
|
|
2729 | 2745 |
tcg_gen_addi_tl(addr, cpu_R[dc->op1], i * 8); |
2730 |
gen_load(dc, tmp[i], addr, 4, 0);
|
|
2746 |
gen_load(dc, tmp32, addr, 4, 0);
|
|
2731 | 2747 |
} |
2732 | 2748 |
tcg_temp_free(addr); |
2733 | 2749 |
|
... | ... | |
2735 | 2751 |
tcg_gen_trunc_i64_i32(cpu_R[i * 2], tmp[i]); |
2736 | 2752 |
tcg_gen_shri_i64(tmp[i], tmp[i], 32); |
2737 | 2753 |
tcg_gen_trunc_i64_i32(cpu_R[i * 2 + 1], tmp[i]); |
2738 |
tcg_temp_free(tmp[i]); |
|
2754 |
tcg_temp_free_i64(tmp[i]);
|
|
2739 | 2755 |
} |
2740 | 2756 |
if (nr & 1) { |
2741 |
tcg_gen_mov_tl(cpu_R[dc->op2], tmp[i]);
|
|
2742 |
tcg_temp_free(tmp[i]);
|
|
2757 |
tcg_gen_mov_tl(cpu_R[dc->op2], tmp32);
|
|
2758 |
tcg_temp_free(tmp32);
|
|
2743 | 2759 |
} |
2744 | 2760 |
|
2745 | 2761 |
/* writeback the updated pointer value. */ |
... | ... | |
2762 | 2778 |
|
2763 | 2779 |
cris_flush_cc_state(dc); |
2764 | 2780 |
|
2765 |
tmp = tcg_temp_new(TCG_TYPE_TL);
|
|
2766 |
addr = tcg_temp_new(TCG_TYPE_TL);
|
|
2781 |
tmp = tcg_temp_new(); |
|
2782 |
addr = tcg_temp_new(); |
|
2767 | 2783 |
tcg_gen_movi_tl(tmp, 4); |
2768 | 2784 |
tcg_gen_mov_tl(addr, cpu_R[dc->op1]); |
2769 | 2785 |
for (i = 0; i <= dc->op2; i++) { |
... | ... | |
2960 | 2976 |
/* rfe. */ |
2961 | 2977 |
DIS(fprintf(logfile, "rfe\n")); |
2962 | 2978 |
cris_evaluate_flags(dc); |
2963 |
tcg_gen_helper_0_0(helper_rfe);
|
|
2979 |
gen_helper_rfe();
|
|
2964 | 2980 |
dc->is_jmp = DISAS_UPDATE; |
2965 | 2981 |
break; |
2966 | 2982 |
case 5: |
2967 | 2983 |
/* rfn. */ |
2968 | 2984 |
DIS(fprintf(logfile, "rfn\n")); |
2969 | 2985 |
cris_evaluate_flags(dc); |
2970 |
tcg_gen_helper_0_0(helper_rfn);
|
|
2986 |
gen_helper_rfn();
|
|
2971 | 2987 |
dc->is_jmp = DISAS_UPDATE; |
2972 | 2988 |
break; |
2973 | 2989 |
case 6: |
... | ... | |
3502 | 3518 |
|
3503 | 3519 |
tcg_initialized = 1; |
3504 | 3520 |
|
3505 |
cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
|
|
3506 |
cc_x = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3521 |
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
|
|
3522 |
cc_x = tcg_global_mem_new(TCG_AREG0, |
|
3507 | 3523 |
offsetof(CPUState, cc_x), "cc_x"); |
3508 |
cc_src = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3524 |
cc_src = tcg_global_mem_new(TCG_AREG0, |
|
3509 | 3525 |
offsetof(CPUState, cc_src), "cc_src"); |
3510 |
cc_dest = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3526 |
cc_dest = tcg_global_mem_new(TCG_AREG0, |
|
3511 | 3527 |
offsetof(CPUState, cc_dest), |
3512 | 3528 |
"cc_dest"); |
3513 |
cc_result = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3529 |
cc_result = tcg_global_mem_new(TCG_AREG0, |
|
3514 | 3530 |
offsetof(CPUState, cc_result), |
3515 | 3531 |
"cc_result"); |
3516 |
cc_op = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3532 |
cc_op = tcg_global_mem_new(TCG_AREG0, |
|
3517 | 3533 |
offsetof(CPUState, cc_op), "cc_op"); |
3518 |
cc_size = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3534 |
cc_size = tcg_global_mem_new(TCG_AREG0, |
|
3519 | 3535 |
offsetof(CPUState, cc_size), |
3520 | 3536 |
"cc_size"); |
3521 |
cc_mask = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3537 |
cc_mask = tcg_global_mem_new(TCG_AREG0, |
|
3522 | 3538 |
offsetof(CPUState, cc_mask), |
3523 | 3539 |
"cc_mask"); |
3524 | 3540 |
|
3525 |
env_pc = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3541 |
env_pc = tcg_global_mem_new(TCG_AREG0, |
|
3526 | 3542 |
offsetof(CPUState, pc), |
3527 | 3543 |
"pc"); |
3528 |
env_btarget = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3544 |
env_btarget = tcg_global_mem_new(TCG_AREG0, |
|
3529 | 3545 |
offsetof(CPUState, btarget), |
3530 | 3546 |
"btarget"); |
3531 |
env_btaken = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3547 |
env_btaken = tcg_global_mem_new(TCG_AREG0, |
|
3532 | 3548 |
offsetof(CPUState, btaken), |
3533 | 3549 |
"btaken"); |
3534 | 3550 |
for (i = 0; i < 16; i++) { |
3535 |
cpu_R[i] = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3551 |
cpu_R[i] = tcg_global_mem_new(TCG_AREG0, |
|
3536 | 3552 |
offsetof(CPUState, regs[i]), |
3537 | 3553 |
regnames[i]); |
3538 | 3554 |
} |
3539 | 3555 |
for (i = 0; i < 16; i++) { |
3540 |
cpu_PR[i] = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
|
|
3556 |
cpu_PR[i] = tcg_global_mem_new(TCG_AREG0, |
|
3541 | 3557 |
offsetof(CPUState, pregs[i]), |
3542 | 3558 |
pregnames[i]); |
3543 | 3559 |
} |
3544 | 3560 |
|
3545 |
TCG_HELPER(helper_raise_exception); |
|
3546 |
TCG_HELPER(helper_dump); |
|
3547 |
|
|
3548 |
TCG_HELPER(helper_tlb_flush_pid); |
|
3549 |
TCG_HELPER(helper_movl_sreg_reg); |
|
3550 |
TCG_HELPER(helper_movl_reg_sreg); |
|
3551 |
TCG_HELPER(helper_rfe); |
|
3552 |
TCG_HELPER(helper_rfn); |
|
3561 |
#define GEN_HELPER 2 |
|
3562 |
#include "helper.h" |
|
3553 | 3563 |
|
3554 |
TCG_HELPER(helper_evaluate_flags_muls); |
|
3555 |
TCG_HELPER(helper_evaluate_flags_mulu); |
|
3556 |
TCG_HELPER(helper_evaluate_flags_mcp); |
|
3557 |
TCG_HELPER(helper_evaluate_flags_alu_4); |
|
3558 |
TCG_HELPER(helper_evaluate_flags_move_4); |
|
3559 |
TCG_HELPER(helper_evaluate_flags_move_2); |
|
3560 |
TCG_HELPER(helper_evaluate_flags); |
|
3561 |
TCG_HELPER(helper_top_evaluate_flags); |
|
3562 | 3564 |
return env; |
3563 | 3565 |
} |
3564 | 3566 |
|
Also available in: Unified diff