2 * CRIS emulation for qemu: main translation routines.
4 * Copyright (c) 2008 AXIS Communications AB
5 * Written by Edgar E. Iglesias.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
23 * The condition code translation is in need of attention.
31 #include "crisv32-decode.h"
38 # define LOG_DIS(...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)
40 # define LOG_DIS(...) do { } while (0)
44 #define BUG() (gen_BUG(dc, __FILE__, __LINE__))
45 #define BUG_ON(x) ({if (x) BUG();})
49 /* Used by the decoder. */
50 #define EXTRACT_FIELD(src, start, end) \
51 (((src) >> start) & ((1 << (end - start + 1)) - 1))
53 #define CC_MASK_NZ 0xc
54 #define CC_MASK_NZV 0xe
55 #define CC_MASK_NZVC 0xf
56 #define CC_MASK_RNZV 0x10e
58 static TCGv_ptr cpu_env
;
59 static TCGv cpu_R
[16];
60 static TCGv cpu_PR
[16];
64 static TCGv cc_result
;
69 static TCGv env_btaken
;
70 static TCGv env_btarget
;
73 #include "gen-icount.h"
75 /* This is the state at translation time. */
76 typedef struct DisasContext
{
81 unsigned int (*decoder
)(CPUCRISState
*env
, struct DisasContext
*dc
);
86 unsigned int zsize
, zzsize
;
100 int cc_size_uptodate
; /* -1 invalid or last written value. */
102 int cc_x_uptodate
; /* 1 - ccs, 2 - known | X_FLAG. 0 not uptodate. */
103 int flags_uptodate
; /* Wether or not $ccs is uptodate. */
104 int flagx_known
; /* Wether or not flags_x has the x flag known at
108 int clear_x
; /* Clear x after this insn? */
109 int clear_prefix
; /* Clear prefix after this insn? */
110 int clear_locked_irq
; /* Clear the irq lockout. */
111 int cpustate_changed
;
112 unsigned int tb_flags
; /* tb dependent flags. */
117 #define JMP_DIRECT_CC 2
118 #define JMP_INDIRECT 3
119 int jmp
; /* 0=nojmp, 1=direct, 2=indirect. */
124 struct TranslationBlock
*tb
;
125 int singlestep_enabled
;
128 static void gen_BUG(DisasContext
*dc
, const char *file
, int line
)
130 printf ("BUG: pc=%x %s %d\n", dc
->pc
, file
, line
);
131 qemu_log("BUG: pc=%x %s %d\n", dc
->pc
, file
, line
);
132 cpu_abort(dc
->env
, "%s:%d\n", file
, line
);
135 static const char *regnames
[] =
137 "$r0", "$r1", "$r2", "$r3",
138 "$r4", "$r5", "$r6", "$r7",
139 "$r8", "$r9", "$r10", "$r11",
140 "$r12", "$r13", "$sp", "$acr",
142 static const char *pregnames
[] =
144 "$bz", "$vr", "$pid", "$srs",
145 "$wz", "$exs", "$eda", "$mof",
146 "$dz", "$ebp", "$erp", "$srp",
147 "$nrp", "$ccs", "$usp", "$spc",
150 /* We need this table to handle preg-moves with implicit width. */
151 static int preg_sizes
[] = {
162 #define t_gen_mov_TN_env(tn, member) \
163 _t_gen_mov_TN_env((tn), offsetof(CPUCRISState, member))
164 #define t_gen_mov_env_TN(member, tn) \
165 _t_gen_mov_env_TN(offsetof(CPUCRISState, member), (tn))
167 static inline void t_gen_mov_TN_reg(TCGv tn
, int r
)
170 fprintf(stderr
, "wrong register read $r%d\n", r
);
171 tcg_gen_mov_tl(tn
, cpu_R
[r
]);
173 static inline void t_gen_mov_reg_TN(int r
, TCGv tn
)
176 fprintf(stderr
, "wrong register write $r%d\n", r
);
177 tcg_gen_mov_tl(cpu_R
[r
], tn
);
180 static inline void _t_gen_mov_TN_env(TCGv tn
, int offset
)
182 if (offset
> sizeof (CPUCRISState
))
183 fprintf(stderr
, "wrong load from env from off=%d\n", offset
);
184 tcg_gen_ld_tl(tn
, cpu_env
, offset
);
186 static inline void _t_gen_mov_env_TN(int offset
, TCGv tn
)
188 if (offset
> sizeof (CPUCRISState
))
189 fprintf(stderr
, "wrong store to env at off=%d\n", offset
);
190 tcg_gen_st_tl(tn
, cpu_env
, offset
);
193 static inline void t_gen_mov_TN_preg(TCGv tn
, int r
)
196 fprintf(stderr
, "wrong register read $p%d\n", r
);
197 if (r
== PR_BZ
|| r
== PR_WZ
|| r
== PR_DZ
)
198 tcg_gen_mov_tl(tn
, tcg_const_tl(0));
200 tcg_gen_mov_tl(tn
, tcg_const_tl(32));
202 tcg_gen_mov_tl(tn
, cpu_PR
[r
]);
204 static inline void t_gen_mov_preg_TN(DisasContext
*dc
, int r
, TCGv tn
)
207 fprintf(stderr
, "wrong register write $p%d\n", r
);
208 if (r
== PR_BZ
|| r
== PR_WZ
|| r
== PR_DZ
)
210 else if (r
== PR_SRS
)
211 tcg_gen_andi_tl(cpu_PR
[r
], tn
, 3);
214 gen_helper_tlb_flush_pid(cpu_env
, tn
);
215 if (dc
->tb_flags
& S_FLAG
&& r
== PR_SPC
)
216 gen_helper_spc_write(cpu_env
, tn
);
217 else if (r
== PR_CCS
)
218 dc
->cpustate_changed
= 1;
219 tcg_gen_mov_tl(cpu_PR
[r
], tn
);
223 /* Sign extend at translation time. */
224 static int sign_extend(unsigned int val
, unsigned int width
)
236 static int cris_fetch(CPUCRISState
*env
, DisasContext
*dc
, uint32_t addr
,
237 unsigned int size
, unsigned int sign
)
244 r
= cpu_ldl_code(env
, addr
);
250 r
= cpu_ldsw_code(env
, addr
);
252 r
= cpu_lduw_code(env
, addr
);
259 r
= cpu_ldsb_code(env
, addr
);
261 r
= cpu_ldub_code(env
, addr
);
266 cpu_abort(dc
->env
, "Invalid fetch size %d\n", size
);
272 static void cris_lock_irq(DisasContext
*dc
)
274 dc
->clear_locked_irq
= 0;
275 t_gen_mov_env_TN(locked_irq
, tcg_const_tl(1));
278 static inline void t_gen_raise_exception(uint32_t index
)
280 TCGv_i32 tmp
= tcg_const_i32(index
);
281 gen_helper_raise_exception(cpu_env
, tmp
);
282 tcg_temp_free_i32(tmp
);
285 static void t_gen_lsl(TCGv d
, TCGv a
, TCGv b
)
290 t_31
= tcg_const_tl(31);
291 tcg_gen_shl_tl(d
, a
, b
);
293 tcg_gen_sub_tl(t0
, t_31
, b
);
294 tcg_gen_sar_tl(t0
, t0
, t_31
);
295 tcg_gen_and_tl(t0
, t0
, d
);
296 tcg_gen_xor_tl(d
, d
, t0
);
301 static void t_gen_lsr(TCGv d
, TCGv a
, TCGv b
)
306 t_31
= tcg_temp_new();
307 tcg_gen_shr_tl(d
, a
, b
);
309 tcg_gen_movi_tl(t_31
, 31);
310 tcg_gen_sub_tl(t0
, t_31
, b
);
311 tcg_gen_sar_tl(t0
, t0
, t_31
);
312 tcg_gen_and_tl(t0
, t0
, d
);
313 tcg_gen_xor_tl(d
, d
, t0
);
318 static void t_gen_asr(TCGv d
, TCGv a
, TCGv b
)
323 t_31
= tcg_temp_new();
324 tcg_gen_sar_tl(d
, a
, b
);
326 tcg_gen_movi_tl(t_31
, 31);
327 tcg_gen_sub_tl(t0
, t_31
, b
);
328 tcg_gen_sar_tl(t0
, t0
, t_31
);
329 tcg_gen_or_tl(d
, d
, t0
);
334 /* 64-bit signed mul, lower result in d and upper in d2. */
335 static void t_gen_muls(TCGv d
, TCGv d2
, TCGv a
, TCGv b
)
339 t0
= tcg_temp_new_i64();
340 t1
= tcg_temp_new_i64();
342 tcg_gen_ext_i32_i64(t0
, a
);
343 tcg_gen_ext_i32_i64(t1
, b
);
344 tcg_gen_mul_i64(t0
, t0
, t1
);
346 tcg_gen_trunc_i64_i32(d
, t0
);
347 tcg_gen_shri_i64(t0
, t0
, 32);
348 tcg_gen_trunc_i64_i32(d2
, t0
);
350 tcg_temp_free_i64(t0
);
351 tcg_temp_free_i64(t1
);
354 /* 64-bit unsigned muls, lower result in d and upper in d2. */
355 static void t_gen_mulu(TCGv d
, TCGv d2
, TCGv a
, TCGv b
)
359 t0
= tcg_temp_new_i64();
360 t1
= tcg_temp_new_i64();
362 tcg_gen_extu_i32_i64(t0
, a
);
363 tcg_gen_extu_i32_i64(t1
, b
);
364 tcg_gen_mul_i64(t0
, t0
, t1
);
366 tcg_gen_trunc_i64_i32(d
, t0
);
367 tcg_gen_shri_i64(t0
, t0
, 32);
368 tcg_gen_trunc_i64_i32(d2
, t0
);
370 tcg_temp_free_i64(t0
);
371 tcg_temp_free_i64(t1
);
374 static void t_gen_cris_dstep(TCGv d
, TCGv a
, TCGv b
)
378 l1
= gen_new_label();
385 tcg_gen_shli_tl(d
, a
, 1);
386 tcg_gen_brcond_tl(TCG_COND_LTU
, d
, b
, l1
);
387 tcg_gen_sub_tl(d
, d
, b
);
391 static void t_gen_cris_mstep(TCGv d
, TCGv a
, TCGv b
, TCGv ccs
)
401 tcg_gen_shli_tl(d
, a
, 1);
402 tcg_gen_shli_tl(t
, ccs
, 31 - 3);
403 tcg_gen_sari_tl(t
, t
, 31);
404 tcg_gen_and_tl(t
, t
, b
);
405 tcg_gen_add_tl(d
, d
, t
);
409 /* Extended arithmetics on CRIS. */
410 static inline void t_gen_add_flag(TCGv d
, int flag
)
415 t_gen_mov_TN_preg(c
, PR_CCS
);
416 /* Propagate carry into d. */
417 tcg_gen_andi_tl(c
, c
, 1 << flag
);
419 tcg_gen_shri_tl(c
, c
, flag
);
420 tcg_gen_add_tl(d
, d
, c
);
424 static inline void t_gen_addx_carry(DisasContext
*dc
, TCGv d
)
426 if (dc
->flagx_known
) {
431 t_gen_mov_TN_preg(c
, PR_CCS
);
432 /* C flag is already at bit 0. */
433 tcg_gen_andi_tl(c
, c
, C_FLAG
);
434 tcg_gen_add_tl(d
, d
, c
);
442 t_gen_mov_TN_preg(x
, PR_CCS
);
443 tcg_gen_mov_tl(c
, x
);
445 /* Propagate carry into d if X is set. Branch free. */
446 tcg_gen_andi_tl(c
, c
, C_FLAG
);
447 tcg_gen_andi_tl(x
, x
, X_FLAG
);
448 tcg_gen_shri_tl(x
, x
, 4);
450 tcg_gen_and_tl(x
, x
, c
);
451 tcg_gen_add_tl(d
, d
, x
);
457 static inline void t_gen_subx_carry(DisasContext
*dc
, TCGv d
)
459 if (dc
->flagx_known
) {
464 t_gen_mov_TN_preg(c
, PR_CCS
);
465 /* C flag is already at bit 0. */
466 tcg_gen_andi_tl(c
, c
, C_FLAG
);
467 tcg_gen_sub_tl(d
, d
, c
);
475 t_gen_mov_TN_preg(x
, PR_CCS
);
476 tcg_gen_mov_tl(c
, x
);
478 /* Propagate carry into d if X is set. Branch free. */
479 tcg_gen_andi_tl(c
, c
, C_FLAG
);
480 tcg_gen_andi_tl(x
, x
, X_FLAG
);
481 tcg_gen_shri_tl(x
, x
, 4);
483 tcg_gen_and_tl(x
, x
, c
);
484 tcg_gen_sub_tl(d
, d
, x
);
490 /* Swap the two bytes within each half word of the s operand.
491 T0 = ((T0 << 8) & 0xff00ff00) | ((T0 >> 8) & 0x00ff00ff) */
492 static inline void t_gen_swapb(TCGv d
, TCGv s
)
497 org_s
= tcg_temp_new();
499 /* d and s may refer to the same object. */
500 tcg_gen_mov_tl(org_s
, s
);
501 tcg_gen_shli_tl(t
, org_s
, 8);
502 tcg_gen_andi_tl(d
, t
, 0xff00ff00);
503 tcg_gen_shri_tl(t
, org_s
, 8);
504 tcg_gen_andi_tl(t
, t
, 0x00ff00ff);
505 tcg_gen_or_tl(d
, d
, t
);
507 tcg_temp_free(org_s
);
510 /* Swap the halfwords of the s operand. */
511 static inline void t_gen_swapw(TCGv d
, TCGv s
)
514 /* d and s refer the same object. */
516 tcg_gen_mov_tl(t
, s
);
517 tcg_gen_shli_tl(d
, t
, 16);
518 tcg_gen_shri_tl(t
, t
, 16);
519 tcg_gen_or_tl(d
, d
, t
);
523 /* Reverse the within each byte.
524 T0 = (((T0 << 7) & 0x80808080) |
525 ((T0 << 5) & 0x40404040) |
526 ((T0 << 3) & 0x20202020) |
527 ((T0 << 1) & 0x10101010) |
528 ((T0 >> 1) & 0x08080808) |
529 ((T0 >> 3) & 0x04040404) |
530 ((T0 >> 5) & 0x02020202) |
531 ((T0 >> 7) & 0x01010101));
533 static inline void t_gen_swapr(TCGv d
, TCGv s
)
536 int shift
; /* LSL when positive, LSR when negative. */
551 /* d and s refer the same object. */
553 org_s
= tcg_temp_new();
554 tcg_gen_mov_tl(org_s
, s
);
556 tcg_gen_shli_tl(t
, org_s
, bitrev
[0].shift
);
557 tcg_gen_andi_tl(d
, t
, bitrev
[0].mask
);
558 for (i
= 1; i
< ARRAY_SIZE(bitrev
); i
++) {
559 if (bitrev
[i
].shift
>= 0) {
560 tcg_gen_shli_tl(t
, org_s
, bitrev
[i
].shift
);
562 tcg_gen_shri_tl(t
, org_s
, -bitrev
[i
].shift
);
564 tcg_gen_andi_tl(t
, t
, bitrev
[i
].mask
);
565 tcg_gen_or_tl(d
, d
, t
);
568 tcg_temp_free(org_s
);
571 static void t_gen_cc_jmp(TCGv pc_true
, TCGv pc_false
)
575 l1
= gen_new_label();
577 /* Conditional jmp. */
578 tcg_gen_mov_tl(env_pc
, pc_false
);
579 tcg_gen_brcondi_tl(TCG_COND_EQ
, env_btaken
, 0, l1
);
580 tcg_gen_mov_tl(env_pc
, pc_true
);
584 static void gen_goto_tb(DisasContext
*dc
, int n
, target_ulong dest
)
586 TranslationBlock
*tb
;
588 if ((tb
->pc
& TARGET_PAGE_MASK
) == (dest
& TARGET_PAGE_MASK
)) {
590 tcg_gen_movi_tl(env_pc
, dest
);
591 tcg_gen_exit_tb((tcg_target_long
)tb
+ n
);
593 tcg_gen_movi_tl(env_pc
, dest
);
598 static inline void cris_clear_x_flag(DisasContext
*dc
)
600 if (dc
->flagx_known
&& dc
->flags_x
)
601 dc
->flags_uptodate
= 0;
607 static void cris_flush_cc_state(DisasContext
*dc
)
609 if (dc
->cc_size_uptodate
!= dc
->cc_size
) {
610 tcg_gen_movi_tl(cc_size
, dc
->cc_size
);
611 dc
->cc_size_uptodate
= dc
->cc_size
;
613 tcg_gen_movi_tl(cc_op
, dc
->cc_op
);
614 tcg_gen_movi_tl(cc_mask
, dc
->cc_mask
);
617 static void cris_evaluate_flags(DisasContext
*dc
)
619 if (dc
->flags_uptodate
)
622 cris_flush_cc_state(dc
);
627 gen_helper_evaluate_flags_mcp(cpu_PR
[PR_CCS
], cpu_env
,
628 cpu_PR
[PR_CCS
], cc_src
,
632 gen_helper_evaluate_flags_muls(cpu_PR
[PR_CCS
], cpu_env
,
633 cpu_PR
[PR_CCS
], cc_result
,
637 gen_helper_evaluate_flags_mulu(cpu_PR
[PR_CCS
], cpu_env
,
638 cpu_PR
[PR_CCS
], cc_result
,
651 gen_helper_evaluate_flags_move_4(cpu_PR
[PR_CCS
],
652 cpu_env
, cpu_PR
[PR_CCS
], cc_result
);
655 gen_helper_evaluate_flags_move_2(cpu_PR
[PR_CCS
],
656 cpu_env
, cpu_PR
[PR_CCS
], cc_result
);
659 gen_helper_evaluate_flags(cpu_env
);
668 if (dc
->cc_size
== 4)
669 gen_helper_evaluate_flags_sub_4(cpu_PR
[PR_CCS
], cpu_env
,
670 cpu_PR
[PR_CCS
], cc_src
, cc_dest
, cc_result
);
672 gen_helper_evaluate_flags(cpu_env
);
679 gen_helper_evaluate_flags_alu_4(cpu_PR
[PR_CCS
], cpu_env
,
680 cpu_PR
[PR_CCS
], cc_src
, cc_dest
, cc_result
);
683 gen_helper_evaluate_flags(cpu_env
);
689 if (dc
->flagx_known
) {
691 tcg_gen_ori_tl(cpu_PR
[PR_CCS
],
692 cpu_PR
[PR_CCS
], X_FLAG
);
693 else if (dc
->cc_op
== CC_OP_FLAGS
)
694 tcg_gen_andi_tl(cpu_PR
[PR_CCS
],
695 cpu_PR
[PR_CCS
], ~X_FLAG
);
697 dc
->flags_uptodate
= 1;
700 static void cris_cc_mask(DisasContext
*dc
, unsigned int mask
)
709 /* Check if we need to evaluate the condition codes due to
711 ovl
= (dc
->cc_mask
^ mask
) & ~mask
;
713 /* TODO: optimize this case. It trigs all the time. */
714 cris_evaluate_flags (dc
);
720 static void cris_update_cc_op(DisasContext
*dc
, int op
, int size
)
724 dc
->flags_uptodate
= 0;
727 static inline void cris_update_cc_x(DisasContext
*dc
)
729 /* Save the x flag state at the time of the cc snapshot. */
730 if (dc
->flagx_known
) {
731 if (dc
->cc_x_uptodate
== (2 | dc
->flags_x
))
733 tcg_gen_movi_tl(cc_x
, dc
->flags_x
);
734 dc
->cc_x_uptodate
= 2 | dc
->flags_x
;
737 tcg_gen_andi_tl(cc_x
, cpu_PR
[PR_CCS
], X_FLAG
);
738 dc
->cc_x_uptodate
= 1;
742 /* Update cc prior to executing ALU op. Needs source operands untouched. */
743 static void cris_pre_alu_update_cc(DisasContext
*dc
, int op
,
744 TCGv dst
, TCGv src
, int size
)
747 cris_update_cc_op(dc
, op
, size
);
748 tcg_gen_mov_tl(cc_src
, src
);
757 tcg_gen_mov_tl(cc_dest
, dst
);
759 cris_update_cc_x(dc
);
763 /* Update cc after executing ALU op. needs the result. */
764 static inline void cris_update_result(DisasContext
*dc
, TCGv res
)
767 tcg_gen_mov_tl(cc_result
, res
);
770 /* Returns one if the write back stage should execute. */
771 static void cris_alu_op_exec(DisasContext
*dc
, int op
,
772 TCGv dst
, TCGv a
, TCGv b
, int size
)
774 /* Emit the ALU insns. */
778 tcg_gen_add_tl(dst
, a
, b
);
779 /* Extended arithmetics. */
780 t_gen_addx_carry(dc
, dst
);
783 tcg_gen_add_tl(dst
, a
, b
);
784 t_gen_add_flag(dst
, 0); /* C_FLAG. */
787 tcg_gen_add_tl(dst
, a
, b
);
788 t_gen_add_flag(dst
, 8); /* R_FLAG. */
791 tcg_gen_sub_tl(dst
, a
, b
);
792 /* Extended arithmetics. */
793 t_gen_subx_carry(dc
, dst
);
796 tcg_gen_mov_tl(dst
, b
);
799 tcg_gen_or_tl(dst
, a
, b
);
802 tcg_gen_and_tl(dst
, a
, b
);
805 tcg_gen_xor_tl(dst
, a
, b
);
808 t_gen_lsl(dst
, a
, b
);
811 t_gen_lsr(dst
, a
, b
);
814 t_gen_asr(dst
, a
, b
);
817 tcg_gen_neg_tl(dst
, b
);
818 /* Extended arithmetics. */
819 t_gen_subx_carry(dc
, dst
);
822 gen_helper_lz(dst
, b
);
825 t_gen_muls(dst
, cpu_PR
[PR_MOF
], a
, b
);
828 t_gen_mulu(dst
, cpu_PR
[PR_MOF
], a
, b
);
831 t_gen_cris_dstep(dst
, a
, b
);
834 t_gen_cris_mstep(dst
, a
, b
, cpu_PR
[PR_CCS
]);
839 l1
= gen_new_label();
840 tcg_gen_mov_tl(dst
, a
);
841 tcg_gen_brcond_tl(TCG_COND_LEU
, a
, b
, l1
);
842 tcg_gen_mov_tl(dst
, b
);
847 tcg_gen_sub_tl(dst
, a
, b
);
848 /* Extended arithmetics. */
849 t_gen_subx_carry(dc
, dst
);
852 qemu_log("illegal ALU op.\n");
858 tcg_gen_andi_tl(dst
, dst
, 0xff);
860 tcg_gen_andi_tl(dst
, dst
, 0xffff);
863 static void cris_alu(DisasContext
*dc
, int op
,
864 TCGv d
, TCGv op_a
, TCGv op_b
, int size
)
871 if (op
== CC_OP_CMP
) {
872 tmp
= tcg_temp_new();
874 } else if (size
== 4) {
878 tmp
= tcg_temp_new();
881 cris_pre_alu_update_cc(dc
, op
, op_a
, op_b
, size
);
882 cris_alu_op_exec(dc
, op
, tmp
, op_a
, op_b
, size
);
883 cris_update_result(dc
, tmp
);
888 tcg_gen_andi_tl(d
, d
, ~0xff);
890 tcg_gen_andi_tl(d
, d
, ~0xffff);
891 tcg_gen_or_tl(d
, d
, tmp
);
893 if (!TCGV_EQUAL(tmp
, d
))
897 static int arith_cc(DisasContext
*dc
)
901 case CC_OP_ADDC
: return 1;
902 case CC_OP_ADD
: return 1;
903 case CC_OP_SUB
: return 1;
904 case CC_OP_DSTEP
: return 1;
905 case CC_OP_LSL
: return 1;
906 case CC_OP_LSR
: return 1;
907 case CC_OP_ASR
: return 1;
908 case CC_OP_CMP
: return 1;
909 case CC_OP_NEG
: return 1;
910 case CC_OP_OR
: return 1;
911 case CC_OP_AND
: return 1;
912 case CC_OP_XOR
: return 1;
913 case CC_OP_MULU
: return 1;
914 case CC_OP_MULS
: return 1;
922 static void gen_tst_cc (DisasContext
*dc
, TCGv cc
, int cond
)
924 int arith_opt
, move_opt
;
926 /* TODO: optimize more condition codes. */
929 * If the flags are live, we've gotta look into the bits of CCS.
930 * Otherwise, if we just did an arithmetic operation we try to
931 * evaluate the condition code faster.
933 * When this function is done, T0 should be non-zero if the condition
936 arith_opt
= arith_cc(dc
) && !dc
->flags_uptodate
;
937 move_opt
= (dc
->cc_op
== CC_OP_MOVE
);
940 if ((arith_opt
|| move_opt
)
941 && dc
->cc_x_uptodate
!= (2 | X_FLAG
)) {
942 tcg_gen_setcond_tl(TCG_COND_EQ
, cc
,
943 cc_result
, tcg_const_tl(0));
946 cris_evaluate_flags(dc
);
948 cpu_PR
[PR_CCS
], Z_FLAG
);
952 if ((arith_opt
|| move_opt
)
953 && dc
->cc_x_uptodate
!= (2 | X_FLAG
)) {
954 tcg_gen_mov_tl(cc
, cc_result
);
956 cris_evaluate_flags(dc
);
957 tcg_gen_xori_tl(cc
, cpu_PR
[PR_CCS
],
959 tcg_gen_andi_tl(cc
, cc
, Z_FLAG
);
963 cris_evaluate_flags(dc
);
964 tcg_gen_andi_tl(cc
, cpu_PR
[PR_CCS
], C_FLAG
);
967 cris_evaluate_flags(dc
);
968 tcg_gen_xori_tl(cc
, cpu_PR
[PR_CCS
], C_FLAG
);
969 tcg_gen_andi_tl(cc
, cc
, C_FLAG
);
972 cris_evaluate_flags(dc
);
973 tcg_gen_andi_tl(cc
, cpu_PR
[PR_CCS
], V_FLAG
);
976 cris_evaluate_flags(dc
);
977 tcg_gen_xori_tl(cc
, cpu_PR
[PR_CCS
],
979 tcg_gen_andi_tl(cc
, cc
, V_FLAG
);
982 if (arith_opt
|| move_opt
) {
985 if (dc
->cc_size
== 1)
987 else if (dc
->cc_size
== 2)
990 tcg_gen_shri_tl(cc
, cc_result
, bits
);
991 tcg_gen_xori_tl(cc
, cc
, 1);
993 cris_evaluate_flags(dc
);
994 tcg_gen_xori_tl(cc
, cpu_PR
[PR_CCS
],
996 tcg_gen_andi_tl(cc
, cc
, N_FLAG
);
1000 if (arith_opt
|| move_opt
) {
1003 if (dc
->cc_size
== 1)
1005 else if (dc
->cc_size
== 2)
1008 tcg_gen_shri_tl(cc
, cc_result
, bits
);
1009 tcg_gen_andi_tl(cc
, cc
, 1);
1012 cris_evaluate_flags(dc
);
1013 tcg_gen_andi_tl(cc
, cpu_PR
[PR_CCS
],
1018 cris_evaluate_flags(dc
);
1019 tcg_gen_andi_tl(cc
, cpu_PR
[PR_CCS
],
1023 cris_evaluate_flags(dc
);
1027 tmp
= tcg_temp_new();
1028 tcg_gen_xori_tl(tmp
, cpu_PR
[PR_CCS
],
1030 /* Overlay the C flag on top of the Z. */
1031 tcg_gen_shli_tl(cc
, tmp
, 2);
1032 tcg_gen_and_tl(cc
, tmp
, cc
);
1033 tcg_gen_andi_tl(cc
, cc
, Z_FLAG
);
1039 cris_evaluate_flags(dc
);
1040 /* Overlay the V flag on top of the N. */
1041 tcg_gen_shli_tl(cc
, cpu_PR
[PR_CCS
], 2);
1043 cpu_PR
[PR_CCS
], cc
);
1044 tcg_gen_andi_tl(cc
, cc
, N_FLAG
);
1045 tcg_gen_xori_tl(cc
, cc
, N_FLAG
);
1048 cris_evaluate_flags(dc
);
1049 /* Overlay the V flag on top of the N. */
1050 tcg_gen_shli_tl(cc
, cpu_PR
[PR_CCS
], 2);
1052 cpu_PR
[PR_CCS
], cc
);
1053 tcg_gen_andi_tl(cc
, cc
, N_FLAG
);
1056 cris_evaluate_flags(dc
);
1063 /* To avoid a shift we overlay everything on
1065 tcg_gen_shri_tl(n
, cpu_PR
[PR_CCS
], 2);
1066 tcg_gen_shri_tl(z
, cpu_PR
[PR_CCS
], 1);
1068 tcg_gen_xori_tl(z
, z
, 2);
1070 tcg_gen_xor_tl(n
, n
, cpu_PR
[PR_CCS
]);
1071 tcg_gen_xori_tl(n
, n
, 2);
1072 tcg_gen_and_tl(cc
, z
, n
);
1073 tcg_gen_andi_tl(cc
, cc
, 2);
1080 cris_evaluate_flags(dc
);
1087 /* To avoid a shift we overlay everything on
1089 tcg_gen_shri_tl(n
, cpu_PR
[PR_CCS
], 2);
1090 tcg_gen_shri_tl(z
, cpu_PR
[PR_CCS
], 1);
1092 tcg_gen_xor_tl(n
, n
, cpu_PR
[PR_CCS
]);
1093 tcg_gen_or_tl(cc
, z
, n
);
1094 tcg_gen_andi_tl(cc
, cc
, 2);
1101 cris_evaluate_flags(dc
);
1102 tcg_gen_andi_tl(cc
, cpu_PR
[PR_CCS
], P_FLAG
);
1105 tcg_gen_movi_tl(cc
, 1);
1113 static void cris_store_direct_jmp(DisasContext
*dc
)
1115 /* Store the direct jmp state into the cpu-state. */
1116 if (dc
->jmp
== JMP_DIRECT
|| dc
->jmp
== JMP_DIRECT_CC
) {
1117 if (dc
->jmp
== JMP_DIRECT
) {
1118 tcg_gen_movi_tl(env_btaken
, 1);
1120 tcg_gen_movi_tl(env_btarget
, dc
->jmp_pc
);
1121 dc
->jmp
= JMP_INDIRECT
;
1125 static void cris_prepare_cc_branch (DisasContext
*dc
,
1126 int offset
, int cond
)
1128 /* This helps us re-schedule the micro-code to insns in delay-slots
1129 before the actual jump. */
1130 dc
->delayed_branch
= 2;
1131 dc
->jmp
= JMP_DIRECT_CC
;
1132 dc
->jmp_pc
= dc
->pc
+ offset
;
1134 gen_tst_cc (dc
, env_btaken
, cond
);
1135 tcg_gen_movi_tl(env_btarget
, dc
->jmp_pc
);
1139 /* jumps, when the dest is in a live reg for example. Direct should be set
1140 when the dest addr is constant to allow tb chaining. */
1141 static inline void cris_prepare_jmp (DisasContext
*dc
, unsigned int type
)
1143 /* This helps us re-schedule the micro-code to insns in delay-slots
1144 before the actual jump. */
1145 dc
->delayed_branch
= 2;
1147 if (type
== JMP_INDIRECT
) {
1148 tcg_gen_movi_tl(env_btaken
, 1);
1152 static void gen_load64(DisasContext
*dc
, TCGv_i64 dst
, TCGv addr
)
1154 int mem_index
= cpu_mmu_index(dc
->env
);
1156 /* If we get a fault on a delayslot we must keep the jmp state in
1157 the cpu-state to be able to re-execute the jmp. */
1158 if (dc
->delayed_branch
== 1)
1159 cris_store_direct_jmp(dc
);
1161 tcg_gen_qemu_ld64(dst
, addr
, mem_index
);
1164 static void gen_load(DisasContext
*dc
, TCGv dst
, TCGv addr
,
1165 unsigned int size
, int sign
)
1167 int mem_index
= cpu_mmu_index(dc
->env
);
1169 /* If we get a fault on a delayslot we must keep the jmp state in
1170 the cpu-state to be able to re-execute the jmp. */
1171 if (dc
->delayed_branch
== 1)
1172 cris_store_direct_jmp(dc
);
1176 tcg_gen_qemu_ld8s(dst
, addr
, mem_index
);
1178 tcg_gen_qemu_ld8u(dst
, addr
, mem_index
);
1180 else if (size
== 2) {
1182 tcg_gen_qemu_ld16s(dst
, addr
, mem_index
);
1184 tcg_gen_qemu_ld16u(dst
, addr
, mem_index
);
1186 else if (size
== 4) {
1187 tcg_gen_qemu_ld32u(dst
, addr
, mem_index
);
1194 static void gen_store (DisasContext
*dc
, TCGv addr
, TCGv val
,
1197 int mem_index
= cpu_mmu_index(dc
->env
);
1199 /* If we get a fault on a delayslot we must keep the jmp state in
1200 the cpu-state to be able to re-execute the jmp. */
1201 if (dc
->delayed_branch
== 1)
1202 cris_store_direct_jmp(dc
);
1205 /* Conditional writes. We only support the kind were X and P are known
1206 at translation time. */
1207 if (dc
->flagx_known
&& dc
->flags_x
&& (dc
->tb_flags
& P_FLAG
)) {
1209 cris_evaluate_flags(dc
);
1210 tcg_gen_ori_tl(cpu_PR
[PR_CCS
], cpu_PR
[PR_CCS
], C_FLAG
);
1215 tcg_gen_qemu_st8(val
, addr
, mem_index
);
1217 tcg_gen_qemu_st16(val
, addr
, mem_index
);
1219 tcg_gen_qemu_st32(val
, addr
, mem_index
);
1221 if (dc
->flagx_known
&& dc
->flags_x
) {
1222 cris_evaluate_flags(dc
);
1223 tcg_gen_andi_tl(cpu_PR
[PR_CCS
], cpu_PR
[PR_CCS
], ~C_FLAG
);
1227 static inline void t_gen_sext(TCGv d
, TCGv s
, int size
)
1230 tcg_gen_ext8s_i32(d
, s
);
1232 tcg_gen_ext16s_i32(d
, s
);
1233 else if(!TCGV_EQUAL(d
, s
))
1234 tcg_gen_mov_tl(d
, s
);
1237 static inline void t_gen_zext(TCGv d
, TCGv s
, int size
)
1240 tcg_gen_ext8u_i32(d
, s
);
1242 tcg_gen_ext16u_i32(d
, s
);
1243 else if (!TCGV_EQUAL(d
, s
))
1244 tcg_gen_mov_tl(d
, s
);
1248 static char memsize_char(int size
)
1252 case 1: return 'b'; break;
1253 case 2: return 'w'; break;
1254 case 4: return 'd'; break;
1262 static inline unsigned int memsize_z(DisasContext
*dc
)
1264 return dc
->zsize
+ 1;
1267 static inline unsigned int memsize_zz(DisasContext
*dc
)
1278 static inline void do_postinc (DisasContext
*dc
, int size
)
1281 tcg_gen_addi_tl(cpu_R
[dc
->op1
], cpu_R
[dc
->op1
], size
);
1284 static inline void dec_prep_move_r(DisasContext
*dc
, int rs
, int rd
,
1285 int size
, int s_ext
, TCGv dst
)
1288 t_gen_sext(dst
, cpu_R
[rs
], size
);
1290 t_gen_zext(dst
, cpu_R
[rs
], size
);
1293 /* Prepare T0 and T1 for a register alu operation.
1294 s_ext decides if the operand1 should be sign-extended or zero-extended when
1296 static void dec_prep_alu_r(DisasContext
*dc
, int rs
, int rd
,
1297 int size
, int s_ext
, TCGv dst
, TCGv src
)
1299 dec_prep_move_r(dc
, rs
, rd
, size
, s_ext
, src
);
1302 t_gen_sext(dst
, cpu_R
[rd
], size
);
1304 t_gen_zext(dst
, cpu_R
[rd
], size
);
1307 static int dec_prep_move_m(CPUCRISState
*env
, DisasContext
*dc
,
1308 int s_ext
, int memsize
, TCGv dst
)
1316 is_imm
= rs
== 15 && dc
->postinc
;
1318 /* Load [$rs] onto T1. */
1320 insn_len
= 2 + memsize
;
1324 imm
= cris_fetch(env
, dc
, dc
->pc
+ 2, memsize
, s_ext
);
1325 tcg_gen_movi_tl(dst
, imm
);
1328 cris_flush_cc_state(dc
);
1329 gen_load(dc
, dst
, cpu_R
[rs
], memsize
, 0);
1331 t_gen_sext(dst
, dst
, memsize
);
1333 t_gen_zext(dst
, dst
, memsize
);
1338 /* Prepare T0 and T1 for a memory + alu operation.
1339 s_ext decides if the operand1 should be sign-extended or zero-extended when
1341 static int dec_prep_alu_m(CPUCRISState
*env
, DisasContext
*dc
,
1342 int s_ext
, int memsize
, TCGv dst
, TCGv src
)
1346 insn_len
= dec_prep_move_m(env
, dc
, s_ext
, memsize
, src
);
1347 tcg_gen_mov_tl(dst
, cpu_R
[dc
->op2
]);
1352 static const char *cc_name(int cc
)
1354 static const char *cc_names
[16] = {
1355 "cc", "cs", "ne", "eq", "vc", "vs", "pl", "mi",
1356 "ls", "hi", "ge", "lt", "gt", "le", "a", "p"
1359 return cc_names
[cc
];
1363 /* Start of insn decoders. */
1365 static int dec_bccq(CPUCRISState
*env
, DisasContext
*dc
)
1369 uint32_t cond
= dc
->op2
;
1371 offset
= EXTRACT_FIELD (dc
->ir
, 1, 7);
1372 sign
= EXTRACT_FIELD(dc
->ir
, 0, 0);
1375 offset
|= sign
<< 8;
1376 offset
= sign_extend(offset
, 8);
1378 LOG_DIS("b%s %x\n", cc_name(cond
), dc
->pc
+ offset
);
1380 /* op2 holds the condition-code. */
1381 cris_cc_mask(dc
, 0);
1382 cris_prepare_cc_branch (dc
, offset
, cond
);
1385 static int dec_addoq(CPUCRISState
*env
, DisasContext
*dc
)
1389 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 7);
1390 imm
= sign_extend(dc
->op1
, 7);
1392 LOG_DIS("addoq %d, $r%u\n", imm
, dc
->op2
);
1393 cris_cc_mask(dc
, 0);
1394 /* Fetch register operand, */
1395 tcg_gen_addi_tl(cpu_R
[R_ACR
], cpu_R
[dc
->op2
], imm
);
1399 static int dec_addq(CPUCRISState
*env
, DisasContext
*dc
)
1401 LOG_DIS("addq %u, $r%u\n", dc
->op1
, dc
->op2
);
1403 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 5);
1405 cris_cc_mask(dc
, CC_MASK_NZVC
);
1407 cris_alu(dc
, CC_OP_ADD
,
1408 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], tcg_const_tl(dc
->op1
), 4);
1411 static int dec_moveq(CPUCRISState
*env
, DisasContext
*dc
)
1415 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 5);
1416 imm
= sign_extend(dc
->op1
, 5);
1417 LOG_DIS("moveq %d, $r%u\n", imm
, dc
->op2
);
1419 tcg_gen_movi_tl(cpu_R
[dc
->op2
], imm
);
1422 static int dec_subq(CPUCRISState
*env
, DisasContext
*dc
)
1424 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 5);
1426 LOG_DIS("subq %u, $r%u\n", dc
->op1
, dc
->op2
);
1428 cris_cc_mask(dc
, CC_MASK_NZVC
);
1429 cris_alu(dc
, CC_OP_SUB
,
1430 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], tcg_const_tl(dc
->op1
), 4);
1433 static int dec_cmpq(CPUCRISState
*env
, DisasContext
*dc
)
1436 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 5);
1437 imm
= sign_extend(dc
->op1
, 5);
1439 LOG_DIS("cmpq %d, $r%d\n", imm
, dc
->op2
);
1440 cris_cc_mask(dc
, CC_MASK_NZVC
);
1442 cris_alu(dc
, CC_OP_CMP
,
1443 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], tcg_const_tl(imm
), 4);
1446 static int dec_andq(CPUCRISState
*env
, DisasContext
*dc
)
1449 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 5);
1450 imm
= sign_extend(dc
->op1
, 5);
1452 LOG_DIS("andq %d, $r%d\n", imm
, dc
->op2
);
1453 cris_cc_mask(dc
, CC_MASK_NZ
);
1455 cris_alu(dc
, CC_OP_AND
,
1456 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], tcg_const_tl(imm
), 4);
1459 static int dec_orq(CPUCRISState
*env
, DisasContext
*dc
)
1462 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 5);
1463 imm
= sign_extend(dc
->op1
, 5);
1464 LOG_DIS("orq %d, $r%d\n", imm
, dc
->op2
);
1465 cris_cc_mask(dc
, CC_MASK_NZ
);
1467 cris_alu(dc
, CC_OP_OR
,
1468 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], tcg_const_tl(imm
), 4);
1471 static int dec_btstq(CPUCRISState
*env
, DisasContext
*dc
)
1473 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 4);
1474 LOG_DIS("btstq %u, $r%d\n", dc
->op1
, dc
->op2
);
1476 cris_cc_mask(dc
, CC_MASK_NZ
);
1477 cris_evaluate_flags(dc
);
1478 gen_helper_btst(cpu_PR
[PR_CCS
], cpu_env
, cpu_R
[dc
->op2
],
1479 tcg_const_tl(dc
->op1
), cpu_PR
[PR_CCS
]);
1480 cris_alu(dc
, CC_OP_MOVE
,
1481 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], 4);
1482 cris_update_cc_op(dc
, CC_OP_FLAGS
, 4);
1483 dc
->flags_uptodate
= 1;
1486 static int dec_asrq(CPUCRISState
*env
, DisasContext
*dc
)
1488 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 4);
1489 LOG_DIS("asrq %u, $r%d\n", dc
->op1
, dc
->op2
);
1490 cris_cc_mask(dc
, CC_MASK_NZ
);
1492 tcg_gen_sari_tl(cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], dc
->op1
);
1493 cris_alu(dc
, CC_OP_MOVE
,
1495 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], 4);
1498 static int dec_lslq(CPUCRISState
*env
, DisasContext
*dc
)
1500 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 4);
1501 LOG_DIS("lslq %u, $r%d\n", dc
->op1
, dc
->op2
);
1503 cris_cc_mask(dc
, CC_MASK_NZ
);
1505 tcg_gen_shli_tl(cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], dc
->op1
);
1507 cris_alu(dc
, CC_OP_MOVE
,
1509 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], 4);
1512 static int dec_lsrq(CPUCRISState
*env
, DisasContext
*dc
)
1514 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 4);
1515 LOG_DIS("lsrq %u, $r%d\n", dc
->op1
, dc
->op2
);
1517 cris_cc_mask(dc
, CC_MASK_NZ
);
1519 tcg_gen_shri_tl(cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], dc
->op1
);
1520 cris_alu(dc
, CC_OP_MOVE
,
1522 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], 4);
1526 static int dec_move_r(CPUCRISState
*env
, DisasContext
*dc
)
1528 int size
= memsize_zz(dc
);
1530 LOG_DIS("move.%c $r%u, $r%u\n",
1531 memsize_char(size
), dc
->op1
, dc
->op2
);
1533 cris_cc_mask(dc
, CC_MASK_NZ
);
1535 dec_prep_move_r(dc
, dc
->op1
, dc
->op2
, size
, 0, cpu_R
[dc
->op2
]);
1536 cris_cc_mask(dc
, CC_MASK_NZ
);
1537 cris_update_cc_op(dc
, CC_OP_MOVE
, 4);
1538 cris_update_cc_x(dc
);
1539 cris_update_result(dc
, cpu_R
[dc
->op2
]);
1544 t0
= tcg_temp_new();
1545 dec_prep_move_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t0
);
1546 cris_alu(dc
, CC_OP_MOVE
,
1548 cpu_R
[dc
->op2
], t0
, size
);
1554 static int dec_scc_r(CPUCRISState
*env
, DisasContext
*dc
)
1558 LOG_DIS("s%s $r%u\n",
1559 cc_name(cond
), dc
->op1
);
1565 gen_tst_cc (dc
, cpu_R
[dc
->op1
], cond
);
1566 l1
= gen_new_label();
1567 tcg_gen_brcondi_tl(TCG_COND_EQ
, cpu_R
[dc
->op1
], 0, l1
);
1568 tcg_gen_movi_tl(cpu_R
[dc
->op1
], 1);
1572 tcg_gen_movi_tl(cpu_R
[dc
->op1
], 1);
1574 cris_cc_mask(dc
, 0);
1578 static inline void cris_alu_alloc_temps(DisasContext
*dc
, int size
, TCGv
*t
)
1581 t
[0] = cpu_R
[dc
->op2
];
1582 t
[1] = cpu_R
[dc
->op1
];
1584 t
[0] = tcg_temp_new();
1585 t
[1] = tcg_temp_new();
1589 static inline void cris_alu_free_temps(DisasContext
*dc
, int size
, TCGv
*t
)
1592 tcg_temp_free(t
[0]);
1593 tcg_temp_free(t
[1]);
1597 static int dec_and_r(CPUCRISState
*env
, DisasContext
*dc
)
1600 int size
= memsize_zz(dc
);
1602 LOG_DIS("and.%c $r%u, $r%u\n",
1603 memsize_char(size
), dc
->op1
, dc
->op2
);
1605 cris_cc_mask(dc
, CC_MASK_NZ
);
1607 cris_alu_alloc_temps(dc
, size
, t
);
1608 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t
[0], t
[1]);
1609 cris_alu(dc
, CC_OP_AND
, cpu_R
[dc
->op2
], t
[0], t
[1], size
);
1610 cris_alu_free_temps(dc
, size
, t
);
1614 static int dec_lz_r(CPUCRISState
*env
, DisasContext
*dc
)
1617 LOG_DIS("lz $r%u, $r%u\n",
1619 cris_cc_mask(dc
, CC_MASK_NZ
);
1620 t0
= tcg_temp_new();
1621 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, 4, 0, cpu_R
[dc
->op2
], t0
);
1622 cris_alu(dc
, CC_OP_LZ
, cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t0
, 4);
1627 static int dec_lsl_r(CPUCRISState
*env
, DisasContext
*dc
)
1630 int size
= memsize_zz(dc
);
1632 LOG_DIS("lsl.%c $r%u, $r%u\n",
1633 memsize_char(size
), dc
->op1
, dc
->op2
);
1635 cris_cc_mask(dc
, CC_MASK_NZ
);
1636 cris_alu_alloc_temps(dc
, size
, t
);
1637 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t
[0], t
[1]);
1638 tcg_gen_andi_tl(t
[1], t
[1], 63);
1639 cris_alu(dc
, CC_OP_LSL
, cpu_R
[dc
->op2
], t
[0], t
[1], size
);
1640 cris_alu_alloc_temps(dc
, size
, t
);
1644 static int dec_lsr_r(CPUCRISState
*env
, DisasContext
*dc
)
1647 int size
= memsize_zz(dc
);
1649 LOG_DIS("lsr.%c $r%u, $r%u\n",
1650 memsize_char(size
), dc
->op1
, dc
->op2
);
1652 cris_cc_mask(dc
, CC_MASK_NZ
);
1653 cris_alu_alloc_temps(dc
, size
, t
);
1654 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t
[0], t
[1]);
1655 tcg_gen_andi_tl(t
[1], t
[1], 63);
1656 cris_alu(dc
, CC_OP_LSR
, cpu_R
[dc
->op2
], t
[0], t
[1], size
);
1657 cris_alu_free_temps(dc
, size
, t
);
1661 static int dec_asr_r(CPUCRISState
*env
, DisasContext
*dc
)
1664 int size
= memsize_zz(dc
);
1666 LOG_DIS("asr.%c $r%u, $r%u\n",
1667 memsize_char(size
), dc
->op1
, dc
->op2
);
1669 cris_cc_mask(dc
, CC_MASK_NZ
);
1670 cris_alu_alloc_temps(dc
, size
, t
);
1671 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 1, t
[0], t
[1]);
1672 tcg_gen_andi_tl(t
[1], t
[1], 63);
1673 cris_alu(dc
, CC_OP_ASR
, cpu_R
[dc
->op2
], t
[0], t
[1], size
);
1674 cris_alu_free_temps(dc
, size
, t
);
1678 static int dec_muls_r(CPUCRISState
*env
, DisasContext
*dc
)
1681 int size
= memsize_zz(dc
);
1683 LOG_DIS("muls.%c $r%u, $r%u\n",
1684 memsize_char(size
), dc
->op1
, dc
->op2
);
1685 cris_cc_mask(dc
, CC_MASK_NZV
);
1686 cris_alu_alloc_temps(dc
, size
, t
);
1687 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 1, t
[0], t
[1]);
1689 cris_alu(dc
, CC_OP_MULS
, cpu_R
[dc
->op2
], t
[0], t
[1], 4);
1690 cris_alu_free_temps(dc
, size
, t
);
1694 static int dec_mulu_r(CPUCRISState
*env
, DisasContext
*dc
)
1697 int size
= memsize_zz(dc
);
1699 LOG_DIS("mulu.%c $r%u, $r%u\n",
1700 memsize_char(size
), dc
->op1
, dc
->op2
);
1701 cris_cc_mask(dc
, CC_MASK_NZV
);
1702 cris_alu_alloc_temps(dc
, size
, t
);
1703 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t
[0], t
[1]);
1705 cris_alu(dc
, CC_OP_MULU
, cpu_R
[dc
->op2
], t
[0], t
[1], 4);
1706 cris_alu_alloc_temps(dc
, size
, t
);
1711 static int dec_dstep_r(CPUCRISState
*env
, DisasContext
*dc
)
1713 LOG_DIS("dstep $r%u, $r%u\n", dc
->op1
, dc
->op2
);
1714 cris_cc_mask(dc
, CC_MASK_NZ
);
1715 cris_alu(dc
, CC_OP_DSTEP
,
1716 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], cpu_R
[dc
->op1
], 4);
1720 static int dec_xor_r(CPUCRISState
*env
, DisasContext
*dc
)
1723 int size
= memsize_zz(dc
);
1724 LOG_DIS("xor.%c $r%u, $r%u\n",
1725 memsize_char(size
), dc
->op1
, dc
->op2
);
1726 BUG_ON(size
!= 4); /* xor is dword. */
1727 cris_cc_mask(dc
, CC_MASK_NZ
);
1728 cris_alu_alloc_temps(dc
, size
, t
);
1729 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t
[0], t
[1]);
1731 cris_alu(dc
, CC_OP_XOR
, cpu_R
[dc
->op2
], t
[0], t
[1], 4);
1732 cris_alu_free_temps(dc
, size
, t
);
1736 static int dec_bound_r(CPUCRISState
*env
, DisasContext
*dc
)
1739 int size
= memsize_zz(dc
);
1740 LOG_DIS("bound.%c $r%u, $r%u\n",
1741 memsize_char(size
), dc
->op1
, dc
->op2
);
1742 cris_cc_mask(dc
, CC_MASK_NZ
);
1743 l0
= tcg_temp_local_new();
1744 dec_prep_move_r(dc
, dc
->op1
, dc
->op2
, size
, 0, l0
);
1745 cris_alu(dc
, CC_OP_BOUND
, cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], l0
, 4);
1750 static int dec_cmp_r(CPUCRISState
*env
, DisasContext
*dc
)
1753 int size
= memsize_zz(dc
);
1754 LOG_DIS("cmp.%c $r%u, $r%u\n",
1755 memsize_char(size
), dc
->op1
, dc
->op2
);
1756 cris_cc_mask(dc
, CC_MASK_NZVC
);
1757 cris_alu_alloc_temps(dc
, size
, t
);
1758 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t
[0], t
[1]);
1760 cris_alu(dc
, CC_OP_CMP
, cpu_R
[dc
->op2
], t
[0], t
[1], size
);
1761 cris_alu_free_temps(dc
, size
, t
);
1765 static int dec_abs_r(CPUCRISState
*env
, DisasContext
*dc
)
1769 LOG_DIS("abs $r%u, $r%u\n",
1771 cris_cc_mask(dc
, CC_MASK_NZ
);
1773 t0
= tcg_temp_new();
1774 tcg_gen_sari_tl(t0
, cpu_R
[dc
->op1
], 31);
1775 tcg_gen_xor_tl(cpu_R
[dc
->op2
], cpu_R
[dc
->op1
], t0
);
1776 tcg_gen_sub_tl(cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t0
);
1779 cris_alu(dc
, CC_OP_MOVE
,
1780 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], 4);
1784 static int dec_add_r(CPUCRISState
*env
, DisasContext
*dc
)
1787 int size
= memsize_zz(dc
);
1788 LOG_DIS("add.%c $r%u, $r%u\n",
1789 memsize_char(size
), dc
->op1
, dc
->op2
);
1790 cris_cc_mask(dc
, CC_MASK_NZVC
);
1791 cris_alu_alloc_temps(dc
, size
, t
);
1792 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t
[0], t
[1]);
1794 cris_alu(dc
, CC_OP_ADD
, cpu_R
[dc
->op2
], t
[0], t
[1], size
);
1795 cris_alu_free_temps(dc
, size
, t
);
1799 static int dec_addc_r(CPUCRISState
*env
, DisasContext
*dc
)
1801 LOG_DIS("addc $r%u, $r%u\n",
1803 cris_evaluate_flags(dc
);
1804 /* Set for this insn. */
1805 dc
->flagx_known
= 1;
1806 dc
->flags_x
= X_FLAG
;
1808 cris_cc_mask(dc
, CC_MASK_NZVC
);
1809 cris_alu(dc
, CC_OP_ADDC
,
1810 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], cpu_R
[dc
->op1
], 4);
1814 static int dec_mcp_r(CPUCRISState
*env
, DisasContext
*dc
)
1816 LOG_DIS("mcp $p%u, $r%u\n",
1818 cris_evaluate_flags(dc
);
1819 cris_cc_mask(dc
, CC_MASK_RNZV
);
1820 cris_alu(dc
, CC_OP_MCP
,
1821 cpu_R
[dc
->op1
], cpu_R
[dc
->op1
], cpu_PR
[dc
->op2
], 4);
1826 static char * swapmode_name(int mode
, char *modename
) {
1829 modename
[i
++] = 'n';
1831 modename
[i
++] = 'w';
1833 modename
[i
++] = 'b';
1835 modename
[i
++] = 'r';
1841 static int dec_swap_r(CPUCRISState
*env
, DisasContext
*dc
)
1847 LOG_DIS("swap%s $r%u\n",
1848 swapmode_name(dc
->op2
, modename
), dc
->op1
);
1850 cris_cc_mask(dc
, CC_MASK_NZ
);
1851 t0
= tcg_temp_new();
1852 t_gen_mov_TN_reg(t0
, dc
->op1
);
1854 tcg_gen_not_tl(t0
, t0
);
1856 t_gen_swapw(t0
, t0
);
1858 t_gen_swapb(t0
, t0
);
1860 t_gen_swapr(t0
, t0
);
1861 cris_alu(dc
, CC_OP_MOVE
,
1862 cpu_R
[dc
->op1
], cpu_R
[dc
->op1
], t0
, 4);
1867 static int dec_or_r(CPUCRISState
*env
, DisasContext
*dc
)
1870 int size
= memsize_zz(dc
);
1871 LOG_DIS("or.%c $r%u, $r%u\n",
1872 memsize_char(size
), dc
->op1
, dc
->op2
);
1873 cris_cc_mask(dc
, CC_MASK_NZ
);
1874 cris_alu_alloc_temps(dc
, size
, t
);
1875 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t
[0], t
[1]);
1876 cris_alu(dc
, CC_OP_OR
, cpu_R
[dc
->op2
], t
[0], t
[1], size
);
1877 cris_alu_free_temps(dc
, size
, t
);
1881 static int dec_addi_r(CPUCRISState
*env
, DisasContext
*dc
)
1884 LOG_DIS("addi.%c $r%u, $r%u\n",
1885 memsize_char(memsize_zz(dc
)), dc
->op2
, dc
->op1
);
1886 cris_cc_mask(dc
, 0);
1887 t0
= tcg_temp_new();
1888 tcg_gen_shl_tl(t0
, cpu_R
[dc
->op2
], tcg_const_tl(dc
->zzsize
));
1889 tcg_gen_add_tl(cpu_R
[dc
->op1
], cpu_R
[dc
->op1
], t0
);
1894 static int dec_addi_acr(CPUCRISState
*env
, DisasContext
*dc
)
1897 LOG_DIS("addi.%c $r%u, $r%u, $acr\n",
1898 memsize_char(memsize_zz(dc
)), dc
->op2
, dc
->op1
);
1899 cris_cc_mask(dc
, 0);
1900 t0
= tcg_temp_new();
1901 tcg_gen_shl_tl(t0
, cpu_R
[dc
->op2
], tcg_const_tl(dc
->zzsize
));
1902 tcg_gen_add_tl(cpu_R
[R_ACR
], cpu_R
[dc
->op1
], t0
);
1907 static int dec_neg_r(CPUCRISState
*env
, DisasContext
*dc
)
1910 int size
= memsize_zz(dc
);
1911 LOG_DIS("neg.%c $r%u, $r%u\n",
1912 memsize_char(size
), dc
->op1
, dc
->op2
);
1913 cris_cc_mask(dc
, CC_MASK_NZVC
);
1914 cris_alu_alloc_temps(dc
, size
, t
);
1915 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t
[0], t
[1]);
1917 cris_alu(dc
, CC_OP_NEG
, cpu_R
[dc
->op2
], t
[0], t
[1], size
);
1918 cris_alu_free_temps(dc
, size
, t
);
1922 static int dec_btst_r(CPUCRISState
*env
, DisasContext
*dc
)
1924 LOG_DIS("btst $r%u, $r%u\n",
1926 cris_cc_mask(dc
, CC_MASK_NZ
);
1927 cris_evaluate_flags(dc
);
1928 gen_helper_btst(cpu_PR
[PR_CCS
], cpu_env
, cpu_R
[dc
->op2
],
1929 cpu_R
[dc
->op1
], cpu_PR
[PR_CCS
]);
1930 cris_alu(dc
, CC_OP_MOVE
, cpu_R
[dc
->op2
],
1931 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], 4);
1932 cris_update_cc_op(dc
, CC_OP_FLAGS
, 4);
1933 dc
->flags_uptodate
= 1;
1937 static int dec_sub_r(CPUCRISState
*env
, DisasContext
*dc
)
1940 int size
= memsize_zz(dc
);
1941 LOG_DIS("sub.%c $r%u, $r%u\n",
1942 memsize_char(size
), dc
->op1
, dc
->op2
);
1943 cris_cc_mask(dc
, CC_MASK_NZVC
);
1944 cris_alu_alloc_temps(dc
, size
, t
);
1945 dec_prep_alu_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t
[0], t
[1]);
1946 cris_alu(dc
, CC_OP_SUB
, cpu_R
[dc
->op2
], t
[0], t
[1], size
);
1947 cris_alu_free_temps(dc
, size
, t
);
1951 /* Zero extension. From size to dword. */
1952 static int dec_movu_r(CPUCRISState
*env
, DisasContext
*dc
)
1955 int size
= memsize_z(dc
);
1956 LOG_DIS("movu.%c $r%u, $r%u\n",
1960 cris_cc_mask(dc
, CC_MASK_NZ
);
1961 t0
= tcg_temp_new();
1962 dec_prep_move_r(dc
, dc
->op1
, dc
->op2
, size
, 0, t0
);
1963 cris_alu(dc
, CC_OP_MOVE
, cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t0
, 4);
1968 /* Sign extension. From size to dword. */
1969 static int dec_movs_r(CPUCRISState
*env
, DisasContext
*dc
)
1972 int size
= memsize_z(dc
);
1973 LOG_DIS("movs.%c $r%u, $r%u\n",
1977 cris_cc_mask(dc
, CC_MASK_NZ
);
1978 t0
= tcg_temp_new();
1979 /* Size can only be qi or hi. */
1980 t_gen_sext(t0
, cpu_R
[dc
->op1
], size
);
1981 cris_alu(dc
, CC_OP_MOVE
,
1982 cpu_R
[dc
->op2
], cpu_R
[dc
->op1
], t0
, 4);
1987 /* zero extension. From size to dword. */
1988 static int dec_addu_r(CPUCRISState
*env
, DisasContext
*dc
)
1991 int size
= memsize_z(dc
);
1992 LOG_DIS("addu.%c $r%u, $r%u\n",
1996 cris_cc_mask(dc
, CC_MASK_NZVC
);
1997 t0
= tcg_temp_new();
1998 /* Size can only be qi or hi. */
1999 t_gen_zext(t0
, cpu_R
[dc
->op1
], size
);
2000 cris_alu(dc
, CC_OP_ADD
,
2001 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t0
, 4);
2006 /* Sign extension. From size to dword. */
2007 static int dec_adds_r(CPUCRISState
*env
, DisasContext
*dc
)
2010 int size
= memsize_z(dc
);
2011 LOG_DIS("adds.%c $r%u, $r%u\n",
2015 cris_cc_mask(dc
, CC_MASK_NZVC
);
2016 t0
= tcg_temp_new();
2017 /* Size can only be qi or hi. */
2018 t_gen_sext(t0
, cpu_R
[dc
->op1
], size
);
2019 cris_alu(dc
, CC_OP_ADD
,
2020 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t0
, 4);
2025 /* Zero extension. From size to dword. */
2026 static int dec_subu_r(CPUCRISState
*env
, DisasContext
*dc
)
2029 int size
= memsize_z(dc
);
2030 LOG_DIS("subu.%c $r%u, $r%u\n",
2034 cris_cc_mask(dc
, CC_MASK_NZVC
);
2035 t0
= tcg_temp_new();
2036 /* Size can only be qi or hi. */
2037 t_gen_zext(t0
, cpu_R
[dc
->op1
], size
);
2038 cris_alu(dc
, CC_OP_SUB
,
2039 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t0
, 4);
2044 /* Sign extension. From size to dword. */
2045 static int dec_subs_r(CPUCRISState
*env
, DisasContext
*dc
)
2048 int size
= memsize_z(dc
);
2049 LOG_DIS("subs.%c $r%u, $r%u\n",
2053 cris_cc_mask(dc
, CC_MASK_NZVC
);
2054 t0
= tcg_temp_new();
2055 /* Size can only be qi or hi. */
2056 t_gen_sext(t0
, cpu_R
[dc
->op1
], size
);
2057 cris_alu(dc
, CC_OP_SUB
,
2058 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t0
, 4);
2063 static int dec_setclrf(CPUCRISState
*env
, DisasContext
*dc
)
2066 int set
= (~dc
->opcode
>> 2) & 1;
2069 flags
= (EXTRACT_FIELD(dc
->ir
, 12, 15) << 4)
2070 | EXTRACT_FIELD(dc
->ir
, 0, 3);
2071 if (set
&& flags
== 0) {
2074 } else if (!set
&& (flags
& 0x20)) {
2079 set
? "set" : "clr",
2083 /* User space is not allowed to touch these. Silently ignore. */
2084 if (dc
->tb_flags
& U_FLAG
) {
2085 flags
&= ~(S_FLAG
| I_FLAG
| U_FLAG
);
2088 if (flags
& X_FLAG
) {
2089 dc
->flagx_known
= 1;
2091 dc
->flags_x
= X_FLAG
;
2096 /* Break the TB if any of the SPI flag changes. */
2097 if (flags
& (P_FLAG
| S_FLAG
)) {
2098 tcg_gen_movi_tl(env_pc
, dc
->pc
+ 2);
2099 dc
->is_jmp
= DISAS_UPDATE
;
2100 dc
->cpustate_changed
= 1;
2103 /* For the I flag, only act on posedge. */
2104 if ((flags
& I_FLAG
)) {
2105 tcg_gen_movi_tl(env_pc
, dc
->pc
+ 2);
2106 dc
->is_jmp
= DISAS_UPDATE
;
2107 dc
->cpustate_changed
= 1;
2111 /* Simply decode the flags. */
2112 cris_evaluate_flags (dc
);
2113 cris_update_cc_op(dc
, CC_OP_FLAGS
, 4);
2114 cris_update_cc_x(dc
);
2115 tcg_gen_movi_tl(cc_op
, dc
->cc_op
);
2118 if (!(dc
->tb_flags
& U_FLAG
) && (flags
& U_FLAG
)) {
2119 /* Enter user mode. */
2120 t_gen_mov_env_TN(ksp
, cpu_R
[R_SP
]);
2121 tcg_gen_mov_tl(cpu_R
[R_SP
], cpu_PR
[PR_USP
]);
2122 dc
->cpustate_changed
= 1;
2124 tcg_gen_ori_tl(cpu_PR
[PR_CCS
], cpu_PR
[PR_CCS
], flags
);
2127 tcg_gen_andi_tl(cpu_PR
[PR_CCS
], cpu_PR
[PR_CCS
], ~flags
);
2129 dc
->flags_uptodate
= 1;
2134 static int dec_move_rs(CPUCRISState
*env
, DisasContext
*dc
)
2136 LOG_DIS("move $r%u, $s%u\n", dc
->op1
, dc
->op2
);
2137 cris_cc_mask(dc
, 0);
2138 gen_helper_movl_sreg_reg(cpu_env
, tcg_const_tl(dc
->op2
),
2139 tcg_const_tl(dc
->op1
));
2142 static int dec_move_sr(CPUCRISState
*env
, DisasContext
*dc
)
2144 LOG_DIS("move $s%u, $r%u\n", dc
->op2
, dc
->op1
);
2145 cris_cc_mask(dc
, 0);
2146 gen_helper_movl_reg_sreg(cpu_env
, tcg_const_tl(dc
->op1
),
2147 tcg_const_tl(dc
->op2
));
2151 static int dec_move_rp(CPUCRISState
*env
, DisasContext
*dc
)
2154 LOG_DIS("move $r%u, $p%u\n", dc
->op1
, dc
->op2
);
2155 cris_cc_mask(dc
, 0);
2157 t
[0] = tcg_temp_new();
2158 if (dc
->op2
== PR_CCS
) {
2159 cris_evaluate_flags(dc
);
2160 t_gen_mov_TN_reg(t
[0], dc
->op1
);
2161 if (dc
->tb_flags
& U_FLAG
) {
2162 t
[1] = tcg_temp_new();
2163 /* User space is not allowed to touch all flags. */
2164 tcg_gen_andi_tl(t
[0], t
[0], 0x39f);
2165 tcg_gen_andi_tl(t
[1], cpu_PR
[PR_CCS
], ~0x39f);
2166 tcg_gen_or_tl(t
[0], t
[1], t
[0]);
2167 tcg_temp_free(t
[1]);
2171 t_gen_mov_TN_reg(t
[0], dc
->op1
);
2173 t_gen_mov_preg_TN(dc
, dc
->op2
, t
[0]);
2174 if (dc
->op2
== PR_CCS
) {
2175 cris_update_cc_op(dc
, CC_OP_FLAGS
, 4);
2176 dc
->flags_uptodate
= 1;
2178 tcg_temp_free(t
[0]);
2181 static int dec_move_pr(CPUCRISState
*env
, DisasContext
*dc
)
2184 LOG_DIS("move $p%u, $r%u\n", dc
->op2
, dc
->op1
);
2185 cris_cc_mask(dc
, 0);
2187 if (dc
->op2
== PR_CCS
)
2188 cris_evaluate_flags(dc
);
2190 if (dc
->op2
== PR_DZ
) {
2191 tcg_gen_movi_tl(cpu_R
[dc
->op1
], 0);
2193 t0
= tcg_temp_new();
2194 t_gen_mov_TN_preg(t0
, dc
->op2
);
2195 cris_alu(dc
, CC_OP_MOVE
,
2196 cpu_R
[dc
->op1
], cpu_R
[dc
->op1
], t0
,
2197 preg_sizes
[dc
->op2
]);
2203 static int dec_move_mr(CPUCRISState
*env
, DisasContext
*dc
)
2205 int memsize
= memsize_zz(dc
);
2207 LOG_DIS("move.%c [$r%u%s, $r%u\n",
2208 memsize_char(memsize
),
2209 dc
->op1
, dc
->postinc
? "+]" : "]",
2213 insn_len
= dec_prep_move_m(env
, dc
, 0, 4, cpu_R
[dc
->op2
]);
2214 cris_cc_mask(dc
, CC_MASK_NZ
);
2215 cris_update_cc_op(dc
, CC_OP_MOVE
, 4);
2216 cris_update_cc_x(dc
);
2217 cris_update_result(dc
, cpu_R
[dc
->op2
]);
2222 t0
= tcg_temp_new();
2223 insn_len
= dec_prep_move_m(env
, dc
, 0, memsize
, t0
);
2224 cris_cc_mask(dc
, CC_MASK_NZ
);
2225 cris_alu(dc
, CC_OP_MOVE
,
2226 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t0
, memsize
);
2229 do_postinc(dc
, memsize
);
2233 static inline void cris_alu_m_alloc_temps(TCGv
*t
)
2235 t
[0] = tcg_temp_new();
2236 t
[1] = tcg_temp_new();
2239 static inline void cris_alu_m_free_temps(TCGv
*t
)
2241 tcg_temp_free(t
[0]);
2242 tcg_temp_free(t
[1]);
2245 static int dec_movs_m(CPUCRISState
*env
, DisasContext
*dc
)
2248 int memsize
= memsize_z(dc
);
2250 LOG_DIS("movs.%c [$r%u%s, $r%u\n",
2251 memsize_char(memsize
),
2252 dc
->op1
, dc
->postinc
? "+]" : "]",
2255 cris_alu_m_alloc_temps(t
);
2257 insn_len
= dec_prep_alu_m(env
, dc
, 1, memsize
, t
[0], t
[1]);
2258 cris_cc_mask(dc
, CC_MASK_NZ
);
2259 cris_alu(dc
, CC_OP_MOVE
,
2260 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t
[1], 4);
2261 do_postinc(dc
, memsize
);
2262 cris_alu_m_free_temps(t
);
2266 static int dec_addu_m(CPUCRISState
*env
, DisasContext
*dc
)
2269 int memsize
= memsize_z(dc
);
2271 LOG_DIS("addu.%c [$r%u%s, $r%u\n",
2272 memsize_char(memsize
),
2273 dc
->op1
, dc
->postinc
? "+]" : "]",
2276 cris_alu_m_alloc_temps(t
);
2278 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, t
[0], t
[1]);
2279 cris_cc_mask(dc
, CC_MASK_NZVC
);
2280 cris_alu(dc
, CC_OP_ADD
,
2281 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t
[1], 4);
2282 do_postinc(dc
, memsize
);
2283 cris_alu_m_free_temps(t
);
2287 static int dec_adds_m(CPUCRISState
*env
, DisasContext
*dc
)
2290 int memsize
= memsize_z(dc
);
2292 LOG_DIS("adds.%c [$r%u%s, $r%u\n",
2293 memsize_char(memsize
),
2294 dc
->op1
, dc
->postinc
? "+]" : "]",
2297 cris_alu_m_alloc_temps(t
);
2299 insn_len
= dec_prep_alu_m(env
, dc
, 1, memsize
, t
[0], t
[1]);
2300 cris_cc_mask(dc
, CC_MASK_NZVC
);
2301 cris_alu(dc
, CC_OP_ADD
, cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t
[1], 4);
2302 do_postinc(dc
, memsize
);
2303 cris_alu_m_free_temps(t
);
2307 static int dec_subu_m(CPUCRISState
*env
, DisasContext
*dc
)
2310 int memsize
= memsize_z(dc
);
2312 LOG_DIS("subu.%c [$r%u%s, $r%u\n",
2313 memsize_char(memsize
),
2314 dc
->op1
, dc
->postinc
? "+]" : "]",
2317 cris_alu_m_alloc_temps(t
);
2319 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, t
[0], t
[1]);
2320 cris_cc_mask(dc
, CC_MASK_NZVC
);
2321 cris_alu(dc
, CC_OP_SUB
, cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t
[1], 4);
2322 do_postinc(dc
, memsize
);
2323 cris_alu_m_free_temps(t
);
2327 static int dec_subs_m(CPUCRISState
*env
, DisasContext
*dc
)
2330 int memsize
= memsize_z(dc
);
2332 LOG_DIS("subs.%c [$r%u%s, $r%u\n",
2333 memsize_char(memsize
),
2334 dc
->op1
, dc
->postinc
? "+]" : "]",
2337 cris_alu_m_alloc_temps(t
);
2339 insn_len
= dec_prep_alu_m(env
, dc
, 1, memsize
, t
[0], t
[1]);
2340 cris_cc_mask(dc
, CC_MASK_NZVC
);
2341 cris_alu(dc
, CC_OP_SUB
, cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t
[1], 4);
2342 do_postinc(dc
, memsize
);
2343 cris_alu_m_free_temps(t
);
2347 static int dec_movu_m(CPUCRISState
*env
, DisasContext
*dc
)
2350 int memsize
= memsize_z(dc
);
2353 LOG_DIS("movu.%c [$r%u%s, $r%u\n",
2354 memsize_char(memsize
),
2355 dc
->op1
, dc
->postinc
? "+]" : "]",
2358 cris_alu_m_alloc_temps(t
);
2359 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, t
[0], t
[1]);
2360 cris_cc_mask(dc
, CC_MASK_NZ
);
2361 cris_alu(dc
, CC_OP_MOVE
, cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t
[1], 4);
2362 do_postinc(dc
, memsize
);
2363 cris_alu_m_free_temps(t
);
2367 static int dec_cmpu_m(CPUCRISState
*env
, DisasContext
*dc
)
2370 int memsize
= memsize_z(dc
);
2372 LOG_DIS("cmpu.%c [$r%u%s, $r%u\n",
2373 memsize_char(memsize
),
2374 dc
->op1
, dc
->postinc
? "+]" : "]",
2377 cris_alu_m_alloc_temps(t
);
2378 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, t
[0], t
[1]);
2379 cris_cc_mask(dc
, CC_MASK_NZVC
);
2380 cris_alu(dc
, CC_OP_CMP
, cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t
[1], 4);
2381 do_postinc(dc
, memsize
);
2382 cris_alu_m_free_temps(t
);
2386 static int dec_cmps_m(CPUCRISState
*env
, DisasContext
*dc
)
2389 int memsize
= memsize_z(dc
);
2391 LOG_DIS("cmps.%c [$r%u%s, $r%u\n",
2392 memsize_char(memsize
),
2393 dc
->op1
, dc
->postinc
? "+]" : "]",
2396 cris_alu_m_alloc_temps(t
);
2397 insn_len
= dec_prep_alu_m(env
, dc
, 1, memsize
, t
[0], t
[1]);
2398 cris_cc_mask(dc
, CC_MASK_NZVC
);
2399 cris_alu(dc
, CC_OP_CMP
,
2400 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t
[1],
2402 do_postinc(dc
, memsize
);
2403 cris_alu_m_free_temps(t
);
2407 static int dec_cmp_m(CPUCRISState
*env
, DisasContext
*dc
)
2410 int memsize
= memsize_zz(dc
);
2412 LOG_DIS("cmp.%c [$r%u%s, $r%u\n",
2413 memsize_char(memsize
),
2414 dc
->op1
, dc
->postinc
? "+]" : "]",
2417 cris_alu_m_alloc_temps(t
);
2418 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, t
[0], t
[1]);
2419 cris_cc_mask(dc
, CC_MASK_NZVC
);
2420 cris_alu(dc
, CC_OP_CMP
,
2421 cpu_R
[dc
->op2
], cpu_R
[dc
->op2
], t
[1],
2423 do_postinc(dc
, memsize
);
2424 cris_alu_m_free_temps(t
);
2428 static int dec_test_m(CPUCRISState
*env
, DisasContext
*dc
)
2431 int memsize
= memsize_zz(dc
);
2433 LOG_DIS("test.%c [$r%u%s] op2=%x\n",
2434 memsize_char(memsize
),
2435 dc
->op1
, dc
->postinc
? "+]" : "]",
2438 cris_evaluate_flags(dc
);
2440 cris_alu_m_alloc_temps(t
);
2441 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, t
[0], t
[1]);
2442 cris_cc_mask(dc
, CC_MASK_NZ
);
2443 tcg_gen_andi_tl(cpu_PR
[PR_CCS
], cpu_PR
[PR_CCS
], ~3);
2445 cris_alu(dc
, CC_OP_CMP
,
2446 cpu_R
[dc
->op2
], t
[1], tcg_const_tl(0), memsize_zz(dc
));
2447 do_postinc(dc
, memsize
);
2448 cris_alu_m_free_temps(t
);
2452 static int dec_and_m(CPUCRISState
*env
, DisasContext
*dc
)
2455 int memsize
= memsize_zz(dc
);
2457 LOG_DIS("and.%c [$r%u%s, $r%u\n",
2458 memsize_char(memsize
),
2459 dc
->op1
, dc
->postinc
? "+]" : "]",
2462 cris_alu_m_alloc_temps(t
);
2463 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, t
[0], t
[1]);
2464 cris_cc_mask(dc
, CC_MASK_NZ
);
2465 cris_alu(dc
, CC_OP_AND
, cpu_R
[dc
->op2
], t
[0], t
[1], memsize_zz(dc
));
2466 do_postinc(dc
, memsize
);
2467 cris_alu_m_free_temps(t
);
2471 static int dec_add_m(CPUCRISState
*env
, DisasContext
*dc
)
2474 int memsize
= memsize_zz(dc
);
2476 LOG_DIS("add.%c [$r%u%s, $r%u\n",
2477 memsize_char(memsize
),
2478 dc
->op1
, dc
->postinc
? "+]" : "]",
2481 cris_alu_m_alloc_temps(t
);
2482 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, t
[0], t
[1]);
2483 cris_cc_mask(dc
, CC_MASK_NZVC
);
2484 cris_alu(dc
, CC_OP_ADD
,
2485 cpu_R
[dc
->op2
], t
[0], t
[1], memsize_zz(dc
));
2486 do_postinc(dc
, memsize
);
2487 cris_alu_m_free_temps(t
);
2491 static int dec_addo_m(CPUCRISState
*env
, DisasContext
*dc
)
2494 int memsize
= memsize_zz(dc
);
2496 LOG_DIS("add.%c [$r%u%s, $r%u\n",
2497 memsize_char(memsize
),
2498 dc
->op1
, dc
->postinc
? "+]" : "]",
2501 cris_alu_m_alloc_temps(t
);
2502 insn_len
= dec_prep_alu_m(env
, dc
, 1, memsize
, t
[0], t
[1]);
2503 cris_cc_mask(dc
, 0);
2504 cris_alu(dc
, CC_OP_ADD
, cpu_R
[R_ACR
], t
[0], t
[1], 4);
2505 do_postinc(dc
, memsize
);
2506 cris_alu_m_free_temps(t
);
2510 static int dec_bound_m(CPUCRISState
*env
, DisasContext
*dc
)
2513 int memsize
= memsize_zz(dc
);
2515 LOG_DIS("bound.%c [$r%u%s, $r%u\n",
2516 memsize_char(memsize
),
2517 dc
->op1
, dc
->postinc
? "+]" : "]",
2520 l
[0] = tcg_temp_local_new();
2521 l
[1] = tcg_temp_local_new();
2522 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, l
[0], l
[1]);
2523 cris_cc_mask(dc
, CC_MASK_NZ
);
2524 cris_alu(dc
, CC_OP_BOUND
, cpu_R
[dc
->op2
], l
[0], l
[1], 4);
2525 do_postinc(dc
, memsize
);
2526 tcg_temp_free(l
[0]);
2527 tcg_temp_free(l
[1]);
2531 static int dec_addc_mr(CPUCRISState
*env
, DisasContext
*dc
)
2535 LOG_DIS("addc [$r%u%s, $r%u\n",
2536 dc
->op1
, dc
->postinc
? "+]" : "]",
2539 cris_evaluate_flags(dc
);
2541 /* Set for this insn. */
2542 dc
->flagx_known
= 1;
2543 dc
->flags_x
= X_FLAG
;
2545 cris_alu_m_alloc_temps(t
);
2546 insn_len
= dec_prep_alu_m(env
, dc
, 0, 4, t
[0], t
[1]);
2547 cris_cc_mask(dc
, CC_MASK_NZVC
);
2548 cris_alu(dc
, CC_OP_ADDC
, cpu_R
[dc
->op2
], t
[0], t
[1], 4);
2550 cris_alu_m_free_temps(t
);
2554 static int dec_sub_m(CPUCRISState
*env
, DisasContext
*dc
)
2557 int memsize
= memsize_zz(dc
);
2559 LOG_DIS("sub.%c [$r%u%s, $r%u ir=%x zz=%x\n",
2560 memsize_char(memsize
),
2561 dc
->op1
, dc
->postinc
? "+]" : "]",
2562 dc
->op2
, dc
->ir
, dc
->zzsize
);
2564 cris_alu_m_alloc_temps(t
);
2565 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, t
[0], t
[1]);
2566 cris_cc_mask(dc
, CC_MASK_NZVC
);
2567 cris_alu(dc
, CC_OP_SUB
, cpu_R
[dc
->op2
], t
[0], t
[1], memsize
);
2568 do_postinc(dc
, memsize
);
2569 cris_alu_m_free_temps(t
);
2573 static int dec_or_m(CPUCRISState
*env
, DisasContext
*dc
)
2576 int memsize
= memsize_zz(dc
);
2578 LOG_DIS("or.%c [$r%u%s, $r%u pc=%x\n",
2579 memsize_char(memsize
),
2580 dc
->op1
, dc
->postinc
? "+]" : "]",
2583 cris_alu_m_alloc_temps(t
);
2584 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, t
[0], t
[1]);
2585 cris_cc_mask(dc
, CC_MASK_NZ
);
2586 cris_alu(dc
, CC_OP_OR
,
2587 cpu_R
[dc
->op2
], t
[0], t
[1], memsize_zz(dc
));
2588 do_postinc(dc
, memsize
);
2589 cris_alu_m_free_temps(t
);
2593 static int dec_move_mp(CPUCRISState
*env
, DisasContext
*dc
)
2596 int memsize
= memsize_zz(dc
);
2599 LOG_DIS("move.%c [$r%u%s, $p%u\n",
2600 memsize_char(memsize
),
2602 dc
->postinc
? "+]" : "]",
2605 cris_alu_m_alloc_temps(t
);
2606 insn_len
= dec_prep_alu_m(env
, dc
, 0, memsize
, t
[0], t
[1]);
2607 cris_cc_mask(dc
, 0);
2608 if (dc
->op2
== PR_CCS
) {
2609 cris_evaluate_flags(dc
);
2610 if (dc
->tb_flags
& U_FLAG
) {
2611 /* User space is not allowed to touch all flags. */
2612 tcg_gen_andi_tl(t
[1], t
[1], 0x39f);
2613 tcg_gen_andi_tl(t
[0], cpu_PR
[PR_CCS
], ~0x39f);
2614 tcg_gen_or_tl(t
[1], t
[0], t
[1]);
2618 t_gen_mov_preg_TN(dc
, dc
->op2
, t
[1]);
2620 do_postinc(dc
, memsize
);
2621 cris_alu_m_free_temps(t
);
2625 static int dec_move_pm(CPUCRISState
*env
, DisasContext
*dc
)
2630 memsize
= preg_sizes
[dc
->op2
];
2632 LOG_DIS("move.%c $p%u, [$r%u%s\n",
2633 memsize_char(memsize
),
2634 dc
->op2
, dc
->op1
, dc
->postinc
? "+]" : "]");
2636 /* prepare store. Address in T0, value in T1. */
2637 if (dc
->op2
== PR_CCS
)
2638 cris_evaluate_flags(dc
);
2639 t0
= tcg_temp_new();
2640 t_gen_mov_TN_preg(t0
, dc
->op2
);
2641 cris_flush_cc_state(dc
);
2642 gen_store(dc
, cpu_R
[dc
->op1
], t0
, memsize
);
2645 cris_cc_mask(dc
, 0);
2647 tcg_gen_addi_tl(cpu_R
[dc
->op1
], cpu_R
[dc
->op1
], memsize
);
2651 static int dec_movem_mr(CPUCRISState
*env
, DisasContext
*dc
)
2657 int nr
= dc
->op2
+ 1;
2659 LOG_DIS("movem [$r%u%s, $r%u\n", dc
->op1
,
2660 dc
->postinc
? "+]" : "]", dc
->op2
);
2662 addr
= tcg_temp_new();
2663 /* There are probably better ways of doing this. */
2664 cris_flush_cc_state(dc
);
2665 for (i
= 0; i
< (nr
>> 1); i
++) {
2666 tmp
[i
] = tcg_temp_new_i64();
2667 tcg_gen_addi_tl(addr
, cpu_R
[dc
->op1
], i
* 8);
2668 gen_load64(dc
, tmp
[i
], addr
);
2671 tmp32
= tcg_temp_new_i32();
2672 tcg_gen_addi_tl(addr
, cpu_R
[dc
->op1
], i
* 8);
2673 gen_load(dc
, tmp32
, addr
, 4, 0);
2676 tcg_temp_free(addr
);
2678 for (i
= 0; i
< (nr
>> 1); i
++) {
2679 tcg_gen_trunc_i64_i32(cpu_R
[i
* 2], tmp
[i
]);
2680 tcg_gen_shri_i64(tmp
[i
], tmp
[i
], 32);
2681 tcg_gen_trunc_i64_i32(cpu_R
[i
* 2 + 1], tmp
[i
]);
2682 tcg_temp_free_i64(tmp
[i
]);
2685 tcg_gen_mov_tl(cpu_R
[dc
->op2
], tmp32
);
2686 tcg_temp_free(tmp32
);
2689 /* writeback the updated pointer value. */
2691 tcg_gen_addi_tl(cpu_R
[dc
->op1
], cpu_R
[dc
->op1
], nr
* 4);
2693 /* gen_load might want to evaluate the previous insns flags. */
2694 cris_cc_mask(dc
, 0);
2698 static int dec_movem_rm(CPUCRISState
*env
, DisasContext
*dc
)
2704 LOG_DIS("movem $r%u, [$r%u%s\n", dc
->op2
, dc
->op1
,
2705 dc
->postinc
? "+]" : "]");
2707 cris_flush_cc_state(dc
);
2709 tmp
= tcg_temp_new();
2710 addr
= tcg_temp_new();
2711 tcg_gen_movi_tl(tmp
, 4);
2712 tcg_gen_mov_tl(addr
, cpu_R
[dc
->op1
]);
2713 for (i
= 0; i
<= dc
->op2
; i
++) {
2714 /* Displace addr. */
2715 /* Perform the store. */
2716 gen_store(dc
, addr
, cpu_R
[i
], 4);
2717 tcg_gen_add_tl(addr
, addr
, tmp
);
2720 tcg_gen_mov_tl(cpu_R
[dc
->op1
], addr
);
2721 cris_cc_mask(dc
, 0);
2723 tcg_temp_free(addr
);
2727 static int dec_move_rm(CPUCRISState
*env
, DisasContext
*dc
)
2731 memsize
= memsize_zz(dc
);
2733 LOG_DIS("move.%c $r%u, [$r%u]\n",
2734 memsize_char(memsize
), dc
->op2
, dc
->op1
);
2736 /* prepare store. */
2737 cris_flush_cc_state(dc
);
2738 gen_store(dc
, cpu_R
[dc
->op1
], cpu_R
[dc
->op2
], memsize
);
2741 tcg_gen_addi_tl(cpu_R
[dc
->op1
], cpu_R
[dc
->op1
], memsize
);
2742 cris_cc_mask(dc
, 0);
2746 static int dec_lapcq(CPUCRISState
*env
, DisasContext
*dc
)
2748 LOG_DIS("lapcq %x, $r%u\n",
2749 dc
->pc
+ dc
->op1
*2, dc
->op2
);
2750 cris_cc_mask(dc
, 0);
2751 tcg_gen_movi_tl(cpu_R
[dc
->op2
], dc
->pc
+ dc
->op1
* 2);
2755 static int dec_lapc_im(CPUCRISState
*env
, DisasContext
*dc
)
2763 cris_cc_mask(dc
, 0);
2764 imm
= cris_fetch(env
, dc
, dc
->pc
+ 2, 4, 0);
2765 LOG_DIS("lapc 0x%x, $r%u\n", imm
+ dc
->pc
, dc
->op2
);
2769 tcg_gen_movi_tl(cpu_R
[rd
], pc
);
2773 /* Jump to special reg. */
2774 static int dec_jump_p(CPUCRISState
*env
, DisasContext
*dc
)
2776 LOG_DIS("jump $p%u\n", dc
->op2
);
2778 if (dc
->op2
== PR_CCS
)
2779 cris_evaluate_flags(dc
);
2780 t_gen_mov_TN_preg(env_btarget
, dc
->op2
);
2781 /* rete will often have low bit set to indicate delayslot. */
2782 tcg_gen_andi_tl(env_btarget
, env_btarget
, ~1);
2783 cris_cc_mask(dc
, 0);
2784 cris_prepare_jmp(dc
, JMP_INDIRECT
);
2788 /* Jump and save. */
2789 static int dec_jas_r(CPUCRISState
*env
, DisasContext
*dc
)
2791 LOG_DIS("jas $r%u, $p%u\n", dc
->op1
, dc
->op2
);
2792 cris_cc_mask(dc
, 0);
2793 /* Store the return address in Pd. */
2794 tcg_gen_mov_tl(env_btarget
, cpu_R
[dc
->op1
]);
2797 t_gen_mov_preg_TN(dc
, dc
->op2
, tcg_const_tl(dc
->pc
+ 4));
2799 cris_prepare_jmp(dc
, JMP_INDIRECT
);
2803 static int dec_jas_im(CPUCRISState
*env
, DisasContext
*dc
)
2807 imm
= cris_fetch(env
, dc
, dc
->pc
+ 2, 4, 0);
2809 LOG_DIS("jas 0x%x\n", imm
);
2810 cris_cc_mask(dc
, 0);
2811 /* Store the return address in Pd. */
2812 t_gen_mov_preg_TN(dc
, dc
->op2
, tcg_const_tl(dc
->pc
+ 8));
2815 cris_prepare_jmp(dc
, JMP_DIRECT
);
2819 static int dec_jasc_im(CPUCRISState
*env
, DisasContext
*dc
)
2823 imm
= cris_fetch(env
, dc
, dc
->pc
+ 2, 4, 0);
2825 LOG_DIS("jasc 0x%x\n", imm
);
2826 cris_cc_mask(dc
, 0);
2827 /* Store the return address in Pd. */
2828 t_gen_mov_preg_TN(dc
, dc
->op2
, tcg_const_tl(dc
->pc
+ 8 + 4));
2831 cris_prepare_jmp(dc
, JMP_DIRECT
);
2835 static int dec_jasc_r(CPUCRISState
*env
, DisasContext
*dc
)
2837 LOG_DIS("jasc_r $r%u, $p%u\n", dc
->op1
, dc
->op2
);
2838 cris_cc_mask(dc
, 0);
2839 /* Store the return address in Pd. */
2840 tcg_gen_mov_tl(env_btarget
, cpu_R
[dc
->op1
]);
2841 t_gen_mov_preg_TN(dc
, dc
->op2
, tcg_const_tl(dc
->pc
+ 4 + 4));
2842 cris_prepare_jmp(dc
, JMP_INDIRECT
);
2846 static int dec_bcc_im(CPUCRISState
*env
, DisasContext
*dc
)
2849 uint32_t cond
= dc
->op2
;
2851 offset
= cris_fetch(env
, dc
, dc
->pc
+ 2, 2, 1);
2853 LOG_DIS("b%s %d pc=%x dst=%x\n",
2854 cc_name(cond
), offset
,
2855 dc
->pc
, dc
->pc
+ offset
);
2857 cris_cc_mask(dc
, 0);
2858 /* op2 holds the condition-code. */
2859 cris_prepare_cc_branch (dc
, offset
, cond
);
2863 static int dec_bas_im(CPUCRISState
*env
, DisasContext
*dc
)
2868 simm
= cris_fetch(env
, dc
, dc
->pc
+ 2, 4, 0);
2870 LOG_DIS("bas 0x%x, $p%u\n", dc
->pc
+ simm
, dc
->op2
);
2871 cris_cc_mask(dc
, 0);
2872 /* Store the return address in Pd. */
2873 t_gen_mov_preg_TN(dc
, dc
->op2
, tcg_const_tl(dc
->pc
+ 8));
2875 dc
->jmp_pc
= dc
->pc
+ simm
;
2876 cris_prepare_jmp(dc
, JMP_DIRECT
);
2880 static int dec_basc_im(CPUCRISState
*env
, DisasContext
*dc
)
2883 simm
= cris_fetch(env
, dc
, dc
->pc
+ 2, 4, 0);
2885 LOG_DIS("basc 0x%x, $p%u\n", dc
->pc
+ simm
, dc
->op2
);
2886 cris_cc_mask(dc
, 0);
2887 /* Store the return address in Pd. */
2888 t_gen_mov_preg_TN(dc
, dc
->op2
, tcg_const_tl(dc
->pc
+ 12));
2890 dc
->jmp_pc
= dc
->pc
+ simm
;
2891 cris_prepare_jmp(dc
, JMP_DIRECT
);
2895 static int dec_rfe_etc(CPUCRISState
*env
, DisasContext
*dc
)
2897 cris_cc_mask(dc
, 0);
2899 if (dc
->op2
== 15) {
2900 t_gen_mov_env_TN(halted
, tcg_const_tl(1));
2901 tcg_gen_movi_tl(env_pc
, dc
->pc
+ 2);
2902 t_gen_raise_exception(EXCP_HLT
);
2906 switch (dc
->op2
& 7) {
2910 cris_evaluate_flags(dc
);
2911 gen_helper_rfe(cpu_env
);
2912 dc
->is_jmp
= DISAS_UPDATE
;
2917 cris_evaluate_flags(dc
);
2918 gen_helper_rfn(cpu_env
);
2919 dc
->is_jmp
= DISAS_UPDATE
;
2922 LOG_DIS("break %d\n", dc
->op1
);
2923 cris_evaluate_flags (dc
);
2925 tcg_gen_movi_tl(env_pc
, dc
->pc
+ 2);
2927 /* Breaks start at 16 in the exception vector. */
2928 t_gen_mov_env_TN(trap_vector
,
2929 tcg_const_tl(dc
->op1
+ 16));
2930 t_gen_raise_exception(EXCP_BREAK
);
2931 dc
->is_jmp
= DISAS_UPDATE
;
2934 printf ("op2=%x\n", dc
->op2
);
2942 static int dec_ftag_fidx_d_m(CPUCRISState
*env
, DisasContext
*dc
)
2947 static int dec_ftag_fidx_i_m(CPUCRISState
*env
, DisasContext
*dc
)
2952 static int dec_null(CPUCRISState
*env
, DisasContext
*dc
)
2954 printf ("unknown insn pc=%x opc=%x op1=%x op2=%x\n",
2955 dc
->pc
, dc
->opcode
, dc
->op1
, dc
->op2
);
2961 static struct decoder_info
{
2966 int (*dec
)(CPUCRISState
*env
, DisasContext
*dc
);
2968 /* Order matters here. */
2969 {DEC_MOVEQ
, dec_moveq
},
2970 {DEC_BTSTQ
, dec_btstq
},
2971 {DEC_CMPQ
, dec_cmpq
},
2972 {DEC_ADDOQ
, dec_addoq
},
2973 {DEC_ADDQ
, dec_addq
},
2974 {DEC_SUBQ
, dec_subq
},
2975 {DEC_ANDQ
, dec_andq
},
2977 {DEC_ASRQ
, dec_asrq
},
2978 {DEC_LSLQ
, dec_lslq
},
2979 {DEC_LSRQ
, dec_lsrq
},
2980 {DEC_BCCQ
, dec_bccq
},
2982 {DEC_BCC_IM
, dec_bcc_im
},
2983 {DEC_JAS_IM
, dec_jas_im
},
2984 {DEC_JAS_R
, dec_jas_r
},
2985 {DEC_JASC_IM
, dec_jasc_im
},
2986 {DEC_JASC_R
, dec_jasc_r
},
2987 {DEC_BAS_IM
, dec_bas_im
},
2988 {DEC_BASC_IM
, dec_basc_im
},
2989 {DEC_JUMP_P
, dec_jump_p
},
2990 {DEC_LAPC_IM
, dec_lapc_im
},
2991 {DEC_LAPCQ
, dec_lapcq
},
2993 {DEC_RFE_ETC
, dec_rfe_etc
},
2994 {DEC_ADDC_MR
, dec_addc_mr
},
2996 {DEC_MOVE_MP
, dec_move_mp
},
2997 {DEC_MOVE_PM
, dec_move_pm
},
2998 {DEC_MOVEM_MR
, dec_movem_mr
},
2999 {DEC_MOVEM_RM
, dec_movem_rm
},
3000 {DEC_MOVE_PR
, dec_move_pr
},
3001 {DEC_SCC_R
, dec_scc_r
},
3002 {DEC_SETF
, dec_setclrf
},
3003 {DEC_CLEARF
, dec_setclrf
},
3005 {DEC_MOVE_SR
, dec_move_sr
},
3006 {DEC_MOVE_RP
, dec_move_rp
},
3007 {DEC_SWAP_R
, dec_swap_r
},
3008 {DEC_ABS_R
, dec_abs_r
},
3009 {DEC_LZ_R
, dec_lz_r
},
3010 {DEC_MOVE_RS
, dec_move_rs
},
3011 {DEC_BTST_R
, dec_btst_r
},
3012 {DEC_ADDC_R
, dec_addc_r
},
3014 {DEC_DSTEP_R
, dec_dstep_r
},
3015 {DEC_XOR_R
, dec_xor_r
},
3016 {DEC_MCP_R
, dec_mcp_r
},
3017 {DEC_CMP_R
, dec_cmp_r
},
3019 {DEC_ADDI_R
, dec_addi_r
},
3020 {DEC_ADDI_ACR
, dec_addi_acr
},
3022 {DEC_ADD_R
, dec_add_r
},
3023 {DEC_SUB_R
, dec_sub_r
},
3025 {DEC_ADDU_R
, dec_addu_r
},
3026 {DEC_ADDS_R
, dec_adds_r
},
3027 {DEC_SUBU_R
, dec_subu_r
},
3028 {DEC_SUBS_R
, dec_subs_r
},
3029 {DEC_LSL_R
, dec_lsl_r
},
3031 {DEC_AND_R
, dec_and_r
},
3032 {DEC_OR_R
, dec_or_r
},
3033 {DEC_BOUND_R
, dec_bound_r
},
3034 {DEC_ASR_R
, dec_asr_r
},
3035 {DEC_LSR_R
, dec_lsr_r
},
3037 {DEC_MOVU_R
, dec_movu_r
},
3038 {DEC_MOVS_R
, dec_movs_r
},
3039 {DEC_NEG_R
, dec_neg_r
},
3040 {DEC_MOVE_R
, dec_move_r
},
3042 {DEC_FTAG_FIDX_I_M
, dec_ftag_fidx_i_m
},
3043 {DEC_FTAG_FIDX_D_M
, dec_ftag_fidx_d_m
},
3045 {DEC_MULS_R
, dec_muls_r
},
3046 {DEC_MULU_R
, dec_mulu_r
},
3048 {DEC_ADDU_M
, dec_addu_m
},
3049 {DEC_ADDS_M
, dec_adds_m
},
3050 {DEC_SUBU_M
, dec_subu_m
},
3051 {DEC_SUBS_M
, dec_subs_m
},
3053 {DEC_CMPU_M
, dec_cmpu_m
},
3054 {DEC_CMPS_M
, dec_cmps_m
},
3055 {DEC_MOVU_M
, dec_movu_m
},
3056 {DEC_MOVS_M
, dec_movs_m
},
3058 {DEC_CMP_M
, dec_cmp_m
},
3059 {DEC_ADDO_M
, dec_addo_m
},
3060 {DEC_BOUND_M
, dec_bound_m
},
3061 {DEC_ADD_M
, dec_add_m
},
3062 {DEC_SUB_M
, dec_sub_m
},
3063 {DEC_AND_M
, dec_and_m
},
3064 {DEC_OR_M
, dec_or_m
},
3065 {DEC_MOVE_RM
, dec_move_rm
},
3066 {DEC_TEST_M
, dec_test_m
},
3067 {DEC_MOVE_MR
, dec_move_mr
},
3072 static unsigned int crisv32_decoder(CPUCRISState
*env
, DisasContext
*dc
)
3077 if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP
| CPU_LOG_TB_OP_OPT
))) {
3078 tcg_gen_debug_insn_start(dc
->pc
);
3081 /* Load a halfword onto the instruction register. */
3082 dc
->ir
= cris_fetch(env
, dc
, dc
->pc
, 2, 0);
3084 /* Now decode it. */
3085 dc
->opcode
= EXTRACT_FIELD(dc
->ir
, 4, 11);
3086 dc
->op1
= EXTRACT_FIELD(dc
->ir
, 0, 3);
3087 dc
->op2
= EXTRACT_FIELD(dc
->ir
, 12, 15);
3088 dc
->zsize
= EXTRACT_FIELD(dc
->ir
, 4, 4);
3089 dc
->zzsize
= EXTRACT_FIELD(dc
->ir
, 4, 5);
3090 dc
->postinc
= EXTRACT_FIELD(dc
->ir
, 10, 10);
3092 /* Large switch for all insns. */
3093 for (i
= 0; i
< ARRAY_SIZE(decinfo
); i
++) {
3094 if ((dc
->opcode
& decinfo
[i
].mask
) == decinfo
[i
].bits
)
3096 insn_len
= decinfo
[i
].dec(env
, dc
);
3101 #if !defined(CONFIG_USER_ONLY)
3102 /* Single-stepping ? */
3103 if (dc
->tb_flags
& S_FLAG
) {
3106 l1
= gen_new_label();
3107 tcg_gen_brcondi_tl(TCG_COND_NE
, cpu_PR
[PR_SPC
], dc
->pc
, l1
);
3108 /* We treat SPC as a break with an odd trap vector. */
3109 cris_evaluate_flags (dc
);
3110 t_gen_mov_env_TN(trap_vector
, tcg_const_tl(3));
3111 tcg_gen_movi_tl(env_pc
, dc
->pc
+ insn_len
);
3112 tcg_gen_movi_tl(cpu_PR
[PR_SPC
], dc
->pc
+ insn_len
);
3113 t_gen_raise_exception(EXCP_BREAK
);
3120 static void check_breakpoint(CPUCRISState
*env
, DisasContext
*dc
)
3124 if (unlikely(!QTAILQ_EMPTY(&env
->breakpoints
))) {
3125 QTAILQ_FOREACH(bp
, &env
->breakpoints
, entry
) {
3126 if (bp
->pc
== dc
->pc
) {
3127 cris_evaluate_flags (dc
);
3128 tcg_gen_movi_tl(env_pc
, dc
->pc
);
3129 t_gen_raise_exception(EXCP_DEBUG
);
3130 dc
->is_jmp
= DISAS_UPDATE
;
3136 #include "translate_v10.c"
3139 * Delay slots on QEMU/CRIS.
3141 * If an exception hits on a delayslot, the core will let ERP (the Exception
3142 * Return Pointer) point to the branch (the previous) insn and set the lsb to
3143 * to give SW a hint that the exception actually hit on the dslot.
3145 * CRIS expects all PC addresses to be 16-bit aligned. The lsb is ignored by
3146 * the core and any jmp to an odd addresses will mask off that lsb. It is
3147 * simply there to let sw know there was an exception on a dslot.
3149 * When the software returns from an exception, the branch will re-execute.
3150 * On QEMU care needs to be taken when a branch+delayslot sequence is broken
3151 * and the branch and delayslot dont share pages.
3153 * The TB contaning the branch insn will set up env->btarget and evaluate
3154 * env->btaken. When the translation loop exits we will note that the branch
3155 * sequence is broken and let env->dslot be the size of the branch insn (those
3158 * The TB contaning the delayslot will have the PC of its real insn (i.e no lsb
3159 * set). It will also expect to have env->dslot setup with the size of the
3160 * delay slot so that env->pc - env->dslot point to the branch insn. This TB
3161 * will execute the dslot and take the branch, either to btarget or just one
3164 * When exceptions occur, we check for env->dslot in do_interrupt to detect
3165 * broken branch sequences and setup $erp accordingly (i.e let it point to the
3166 * branch and set lsb). Then env->dslot gets cleared so that the exception
3167 * handler can enter. When returning from exceptions (jump $erp) the lsb gets
3168 * masked off and we will reexecute the branch insn.
3172 /* generate intermediate code for basic block 'tb'. */
3174 gen_intermediate_code_internal(CPUCRISState
*env
, TranslationBlock
*tb
,
3177 uint16_t *gen_opc_end
;
3179 unsigned int insn_len
;
3181 struct DisasContext ctx
;
3182 struct DisasContext
*dc
= &ctx
;
3183 uint32_t next_page_start
;
3188 qemu_log_try_set_file(stderr
);
3190 if (env
->pregs
[PR_VR
] == 32) {
3191 dc
->decoder
= crisv32_decoder
;
3192 dc
->clear_locked_irq
= 0;
3194 dc
->decoder
= crisv10_decoder
;
3195 dc
->clear_locked_irq
= 1;
3198 /* Odd PC indicates that branch is rexecuting due to exception in the
3199 * delayslot, like in real hw.
3201 pc_start
= tb
->pc
& ~1;
3205 gen_opc_end
= gen_opc_buf
+ OPC_MAX_SIZE
;
3207 dc
->is_jmp
= DISAS_NEXT
;
3210 dc
->singlestep_enabled
= env
->singlestep_enabled
;
3211 dc
->flags_uptodate
= 1;
3212 dc
->flagx_known
= 1;
3213 dc
->flags_x
= tb
->flags
& X_FLAG
;
3214 dc
->cc_x_uptodate
= 0;
3217 dc
->clear_prefix
= 0;
3219 cris_update_cc_op(dc
, CC_OP_FLAGS
, 4);
3220 dc
->cc_size_uptodate
= -1;
3222 /* Decode TB flags. */
3223 dc
->tb_flags
= tb
->flags
& (S_FLAG
| P_FLAG
| U_FLAG \
3224 | X_FLAG
| PFIX_FLAG
);
3225 dc
->delayed_branch
= !!(tb
->flags
& 7);
3226 if (dc
->delayed_branch
)
3227 dc
->jmp
= JMP_INDIRECT
;
3229 dc
->jmp
= JMP_NOJMP
;
3231 dc
->cpustate_changed
= 0;
3233 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM
)) {
3235 "srch=%d pc=%x %x flg=%" PRIx64
" bt=%x ds=%u ccs=%x\n"
3241 search_pc
, dc
->pc
, dc
->ppc
,
3242 (uint64_t)tb
->flags
,
3243 env
->btarget
, (unsigned)tb
->flags
& 7,
3245 env
->pregs
[PR_PID
], env
->pregs
[PR_USP
],
3246 env
->regs
[0], env
->regs
[1], env
->regs
[2], env
->regs
[3],
3247 env
->regs
[4], env
->regs
[5], env
->regs
[6], env
->regs
[7],
3248 env
->regs
[8], env
->regs
[9],
3249 env
->regs
[10], env
->regs
[11],
3250 env
->regs
[12], env
->regs
[13],
3251 env
->regs
[14], env
->regs
[15]);
3252 qemu_log("--------------\n");
3253 qemu_log("IN: %s\n", lookup_symbol(pc_start
));
3256 next_page_start
= (pc_start
& TARGET_PAGE_MASK
) + TARGET_PAGE_SIZE
;
3259 max_insns
= tb
->cflags
& CF_COUNT_MASK
;
3261 max_insns
= CF_COUNT_MASK
;
3266 check_breakpoint(env
, dc
);
3269 j
= gen_opc_ptr
- gen_opc_buf
;
3273 gen_opc_instr_start
[lj
++] = 0;
3275 if (dc
->delayed_branch
== 1)
3276 gen_opc_pc
[lj
] = dc
->ppc
| 1;
3278 gen_opc_pc
[lj
] = dc
->pc
;
3279 gen_opc_instr_start
[lj
] = 1;
3280 gen_opc_icount
[lj
] = num_insns
;
3284 LOG_DIS("%8.8x:\t", dc
->pc
);
3286 if (num_insns
+ 1 == max_insns
&& (tb
->cflags
& CF_LAST_IO
))
3290 insn_len
= dc
->decoder(env
, dc
);
3294 cris_clear_x_flag(dc
);
3297 /* Check for delayed branches here. If we do it before
3298 actually generating any host code, the simulator will just
3299 loop doing nothing for on this program location. */
3300 if (dc
->delayed_branch
) {
3301 dc
->delayed_branch
--;
3302 if (dc
->delayed_branch
== 0)
3305 t_gen_mov_env_TN(dslot
,
3307 if (dc
->cpustate_changed
|| !dc
->flagx_known
3308 || (dc
->flags_x
!= (tb
->flags
& X_FLAG
))) {
3309 cris_store_direct_jmp(dc
);
3312 if (dc
->clear_locked_irq
) {
3313 dc
->clear_locked_irq
= 0;
3314 t_gen_mov_env_TN(locked_irq
,
3318 if (dc
->jmp
== JMP_DIRECT_CC
) {
3321 l1
= gen_new_label();
3322 cris_evaluate_flags(dc
);
3324 /* Conditional jmp. */
3325 tcg_gen_brcondi_tl(TCG_COND_EQ
,
3327 gen_goto_tb(dc
, 1, dc
->jmp_pc
);
3329 gen_goto_tb(dc
, 0, dc
->pc
);
3330 dc
->is_jmp
= DISAS_TB_JUMP
;
3331 dc
->jmp
= JMP_NOJMP
;
3332 } else if (dc
->jmp
== JMP_DIRECT
) {
3333 cris_evaluate_flags(dc
);
3334 gen_goto_tb(dc
, 0, dc
->jmp_pc
);
3335 dc
->is_jmp
= DISAS_TB_JUMP
;
3336 dc
->jmp
= JMP_NOJMP
;
3338 t_gen_cc_jmp(env_btarget
,
3339 tcg_const_tl(dc
->pc
));
3340 dc
->is_jmp
= DISAS_JUMP
;
3346 /* If we are rexecuting a branch due to exceptions on
3347 delay slots dont break. */
3348 if (!(tb
->pc
& 1) && env
->singlestep_enabled
)
3350 } while (!dc
->is_jmp
&& !dc
->cpustate_changed
3351 && gen_opc_ptr
< gen_opc_end
3353 && (dc
->pc
< next_page_start
)
3354 && num_insns
< max_insns
);
3356 if (dc
->clear_locked_irq
)
3357 t_gen_mov_env_TN(locked_irq
, tcg_const_tl(0));
3361 if (tb
->cflags
& CF_LAST_IO
)
3363 /* Force an update if the per-tb cpu state has changed. */
3364 if (dc
->is_jmp
== DISAS_NEXT
3365 && (dc
->cpustate_changed
|| !dc
->flagx_known
3366 || (dc
->flags_x
!= (tb
->flags
& X_FLAG
)))) {
3367 dc
->is_jmp
= DISAS_UPDATE
;
3368 tcg_gen_movi_tl(env_pc
, npc
);
3370 /* Broken branch+delayslot sequence. */
3371 if (dc
->delayed_branch
== 1) {
3372 /* Set env->dslot to the size of the branch insn. */
3373 t_gen_mov_env_TN(dslot
, tcg_const_tl(dc
->pc
- dc
->ppc
));
3374 cris_store_direct_jmp(dc
);
3377 cris_evaluate_flags (dc
);
3379 if (unlikely(env
->singlestep_enabled
)) {
3380 if (dc
->is_jmp
== DISAS_NEXT
)
3381 tcg_gen_movi_tl(env_pc
, npc
);
3382 t_gen_raise_exception(EXCP_DEBUG
);
3384 switch(dc
->is_jmp
) {
3386 gen_goto_tb(dc
, 1, npc
);
3391 /* indicate that the hash table must be used
3392 to find the next TB */
3397 /* nothing more to generate */
3401 gen_icount_end(tb
, num_insns
);
3402 *gen_opc_ptr
= INDEX_op_end
;
3404 j
= gen_opc_ptr
- gen_opc_buf
;
3407 gen_opc_instr_start
[lj
++] = 0;
3409 tb
->size
= dc
->pc
- pc_start
;
3410 tb
->icount
= num_insns
;
3415 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM
)) {
3416 log_target_disas(pc_start
, dc
->pc
- pc_start
,
3417 dc
->env
->pregs
[PR_VR
]);
3418 qemu_log("\nisize=%d osize=%td\n",
3419 dc
->pc
- pc_start
, gen_opc_ptr
- gen_opc_buf
);
3425 void gen_intermediate_code (CPUCRISState
*env
, struct TranslationBlock
*tb
)
3427 gen_intermediate_code_internal(env
, tb
, 0);
3430 void gen_intermediate_code_pc (CPUCRISState
*env
, struct TranslationBlock
*tb
)
3432 gen_intermediate_code_internal(env
, tb
, 1);
3435 void cpu_dump_state (CPUCRISState
*env
, FILE *f
, fprintf_function cpu_fprintf
,
3444 cpu_fprintf(f
, "PC=%x CCS=%x btaken=%d btarget=%x\n"
3445 "cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\n",
3446 env
->pc
, env
->pregs
[PR_CCS
], env
->btaken
, env
->btarget
,
3448 env
->cc_src
, env
->cc_dest
, env
->cc_result
, env
->cc_mask
);
3451 for (i
= 0; i
< 16; i
++) {
3452 cpu_fprintf(f
, "%s=%8.8x ",regnames
[i
], env
->regs
[i
]);
3453 if ((i
+ 1) % 4 == 0)
3454 cpu_fprintf(f
, "\n");
3456 cpu_fprintf(f
, "\nspecial regs:\n");
3457 for (i
= 0; i
< 16; i
++) {
3458 cpu_fprintf(f
, "%s=%8.8x ", pregnames
[i
], env
->pregs
[i
]);
3459 if ((i
+ 1) % 4 == 0)
3460 cpu_fprintf(f
, "\n");
3462 srs
= env
->pregs
[PR_SRS
];
3463 cpu_fprintf(f
, "\nsupport function regs bank %x:\n", srs
);
3464 if (srs
< ARRAY_SIZE(env
->sregs
)) {
3465 for (i
= 0; i
< 16; i
++) {
3466 cpu_fprintf(f
, "s%2.2d=%8.8x ",
3467 i
, env
->sregs
[srs
][i
]);
3468 if ((i
+ 1) % 4 == 0)
3469 cpu_fprintf(f
, "\n");
3472 cpu_fprintf(f
, "\n\n");
3488 void cris_cpu_list(FILE *f
, fprintf_function cpu_fprintf
)
3492 (*cpu_fprintf
)(f
, "Available CPUs:\n");
3493 for (i
= 0; i
< ARRAY_SIZE(cris_cores
); i
++) {
3494 (*cpu_fprintf
)(f
, " %s\n", cris_cores
[i
].name
);
3498 static uint32_t vr_by_name(const char *name
)
3501 for (i
= 0; i
< ARRAY_SIZE(cris_cores
); i
++) {
3502 if (strcmp(name
, cris_cores
[i
].name
) == 0) {
3503 return cris_cores
[i
].vr
;
3509 CRISCPU
*cpu_cris_init(const char *cpu_model
)
3513 static int tcg_initialized
= 0;
3516 cpu
= CRIS_CPU(object_new(TYPE_CRIS_CPU
));
3519 env
->pregs
[PR_VR
] = vr_by_name(cpu_model
);
3521 cpu_reset(CPU(cpu
));
3522 qemu_init_vcpu(env
);
3524 if (tcg_initialized
) {
3528 tcg_initialized
= 1;
3530 #define GEN_HELPER 2
3533 if (env
->pregs
[PR_VR
] < 32) {
3534 cpu_crisv10_init(env
);
3539 cpu_env
= tcg_global_reg_new_ptr(TCG_AREG0
, "env");
3540 cc_x
= tcg_global_mem_new(TCG_AREG0
,
3541 offsetof(CPUCRISState
, cc_x
), "cc_x");
3542 cc_src
= tcg_global_mem_new(TCG_AREG0
,
3543 offsetof(CPUCRISState
, cc_src
), "cc_src");
3544 cc_dest
= tcg_global_mem_new(TCG_AREG0
,
3545 offsetof(CPUCRISState
, cc_dest
),
3547 cc_result
= tcg_global_mem_new(TCG_AREG0
,
3548 offsetof(CPUCRISState
, cc_result
),
3550 cc_op
= tcg_global_mem_new(TCG_AREG0
,
3551 offsetof(CPUCRISState
, cc_op
), "cc_op");
3552 cc_size
= tcg_global_mem_new(TCG_AREG0
,
3553 offsetof(CPUCRISState
, cc_size
),
3555 cc_mask
= tcg_global_mem_new(TCG_AREG0
,
3556 offsetof(CPUCRISState
, cc_mask
),
3559 env_pc
= tcg_global_mem_new(TCG_AREG0
,
3560 offsetof(CPUCRISState
, pc
),
3562 env_btarget
= tcg_global_mem_new(TCG_AREG0
,
3563 offsetof(CPUCRISState
, btarget
),
3565 env_btaken
= tcg_global_mem_new(TCG_AREG0
,
3566 offsetof(CPUCRISState
, btaken
),
3568 for (i
= 0; i
< 16; i
++) {
3569 cpu_R
[i
] = tcg_global_mem_new(TCG_AREG0
,
3570 offsetof(CPUCRISState
, regs
[i
]),
3573 for (i
= 0; i
< 16; i
++) {
3574 cpu_PR
[i
] = tcg_global_mem_new(TCG_AREG0
,
3575 offsetof(CPUCRISState
, pregs
[i
]),
3582 void restore_state_to_opc(CPUCRISState
*env
, TranslationBlock
*tb
, int pc_pos
)
3584 env
->pc
= gen_opc_pc
[pc_pos
];