4 * Copyright (c) 2005-2009 Stuart Brady <stuart.brady@gmail.com>
5 * Copyright (c) 2007 Randolph Chung <tausq@debian.org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library 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 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
31 #include "qemu-common.h"
37 typedef void (cond_helper
)(void);
38 typedef void (load_helper
)(void);
39 typedef void (store_helper
)(void);
41 #define DYNGEN_OP(op) static inline op;
44 #define DYNGEN_OP(op) static inline op {}
50 #define DYNAMIC_PC 1 /* dynamic PC value */
51 #define JUMP_PC 2 /* dynamic PC value which takes only two values
52 according to jump_pc[T2] */
54 /* global register indexes */
55 static TCGv_ptr cpu_env
;
56 static char cpu_reg_names
[
59 static TCGv cpu_gr
[32];
60 static TCGv cpu_sr
[8];
61 static TCGv cpu_cr
[32];
64 #include "gen-icount.h"
66 void hppa_translate_init(void)
71 cpu_env
= tcg_global_reg_new_ptr(TCG_AREG0
, "env");
75 for (i
= 0; i
< 32; i
++) {
77 cpu_gr
[i
] = tcg_global_mem_new(TCG_AREG0
,
78 offsetof(CPUState
, gr
[i
]), p
);
79 p
+= (i
< 10) ? 3 : 4;
83 typedef struct DisasContext
{
87 struct TranslationBlock
*tb
;
91 static void disas_hppa_insn(DisasContext
* dc
);
93 static uint32_t field(uint32_t val
, int start
, int length
)
96 val
&= ~(~0 << length
);
100 static int32_t field_signext(uint32_t val
, int start
, int length
)
103 if (val
& (1 << (length
- 1)))
106 val
&= ~(~0 << length
);
110 static int32_t field_lowsignext(uint32_t val
, int start
, int length
)
112 if (val
& (1 << start
)) {
114 val
|= ~0 << (length
- 1);
117 val
&= ~(~0 << (length
- 1));
122 static int32_t signext(uint32_t val
, int length
)
124 if (val
& (1 << (length
- 1)))
129 static uint32_t assemble_12(uint32_t x
, uint32_t y
)
131 return (y
<< 11) | ((x
& 1) << 10) | ((x
>> 1) & ~(~0 << 10));
134 static uint32_t assemble_17(uint32_t x
, uint32_t y
, uint32_t z
)
136 return (z
<< 16) | (x
<< 11) | ((y
& 1) << 10) | ((y
>> 1) & ~(~0 << 10));
139 static uint32_t assemble_21(uint32_t x
)
141 return ((x
& 1) << 20) |
142 (((x
>> 1) & ~(~0 << 11)) << 9) |
143 (((x
>> 14) & ~(~0 << 2)) << 7) |
144 (((x
>> 16) & ~(~0 << 5)) << 2) |
145 ((x
>> 12) & ~(~0 << 2));
148 /* General registers */
149 static inline void gen_movl_reg_TN(int reg
, TCGv tn
)
152 tcg_gen_movi_tl(tn
, 0);
154 tcg_gen_mov_tl(tn
, cpu_gr
[reg
]);
157 static inline void gen_movl_TN_reg(int reg
, TCGv tn
)
162 tcg_gen_mov_tl(cpu_gr
[reg
], tn
);
165 /* Control registers */
166 static inline void gen_movl_cr_TN(int cr
, TCGv tn
)
168 tcg_gen_mov_tl(tn
, cpu_cr
[cr
]);
171 static inline void gen_movl_TN_cr(int cr
, TCGv tn
)
173 tcg_gen_mov_tl(cpu_cr
[cr
], tn
);
176 /* Space registers */
177 static inline void gen_movl_sr_TN(int sr
, TCGv tn
)
179 tcg_gen_mov_tl(tn
, cpu_sr
[sr
]);
182 static inline void gen_movl_TN_sr(int sr
, TCGv tn
)
184 tcg_gen_mov_tl(cpu_sr
[sr
], tn
);
187 static void gen_goto_tb(DisasContext
*dc
, int tb_num
,
188 target_ulong pc
, target_ulong npc
)
190 TranslationBlock
*tb
;
192 if ((tb
->pc
& TARGET_PAGE_MASK
) == (pc
& TARGET_PAGE_MASK
)) {
193 tcg_gen_goto_tb(tb_num
);
194 gen_op_save_pc(pc
, npc
);
195 tcg_gen_exit_tb((long)tb
+ tb_num
);
197 gen_op_save_pc(pc
, npc
);
202 static void gen_branch(DisasContext
*dc
, long tb
,
203 target_ulong pc
, target_ulong npc
)
205 gen_goto_tb(dc
, tb
, pc
, npc
);
208 /* T0 == opd1, T1 == opd2 */
209 static cond_helper
* const gen_cond_add
[8] = {
213 gen_op_eval_add_slteq
,
220 /* T0 == opd1, T1 == opd2 */
221 static cond_helper
* const gen_cond_sub
[8] = {
225 gen_op_eval_sub_slteq
,
227 gen_op_eval_sub_ulteq
,
232 /* T0 == opd1, T1 == opd2 */
233 static cond_helper
* const gen_cond_addc
[8] = {
236 gen_op_eval_addc_slt
,
237 gen_op_eval_addc_slteq
,
238 gen_op_eval_addc_nuv
,
239 gen_op_eval_addc_znv
,
244 /* T0 == opd1, T1 == opd2 */
245 static cond_helper
* const gen_cond_subb
[8] = {
248 gen_op_eval_subb_slt
,
249 gen_op_eval_subb_slteq
,
250 gen_op_eval_subb_ult
,
251 gen_op_eval_subb_ulteq
,
257 static cond_helper
* const gen_cond_log
[8] = {
261 gen_op_eval_log_slteq
,
262 gen_op_eval_never
, /* undefined */
263 gen_op_eval_never
, /* undefined */
264 gen_op_eval_never
, /* undefined */
269 static cond_helper
* const gen_cond_unit
[8] = {
271 gen_op_eval_never
, /* undefined */
272 gen_op_eval_unit_sbz
,
273 gen_op_eval_unit_shz
,
274 gen_op_eval_unit_sdc
,
275 gen_op_eval_never
, /* undefined */
276 gen_op_eval_unit_sbc
,
277 gen_op_eval_unit_shc
,
280 /* T0 == res, T2 == carry */
281 static cond_helper
* const gen_cond_sed
[8] = {
288 gen_op_eval_log_sgteq
,
292 static void gen_branch_cond(DisasContext
*dc
, long tb
, target_ulong disp
,
297 target
= dc
->iaoq
[0] + disp
+ 8;
299 l1
= gen_new_label();
302 gen_op_jnz_T2_label(l1
);
304 gen_op_jz_T2_label(l1
);
307 if (n
&& ((int32_t)disp
>= 0))
308 gen_goto_tb(dc
, 0, target
, target
+ 4);
310 gen_goto_tb(dc
, 0, dc
->iaoq
[1], target
);
315 if (n
&& ((int32_t)disp
< 0))
316 gen_goto_tb(dc
, 1, dc
->iaoq
[1] + 4, dc
->iaoq
[1] + 8);
318 gen_goto_tb(dc
, 1, dc
->iaoq
[1], dc
->iaoq
[1] + 4);
321 static void gen_nullify_cond(DisasContext
*dc
, long tb
, int f
)
325 l1
= gen_new_label();
328 gen_op_jnz_T2_label(l1
);
330 gen_op_jz_T2_label(l1
);
333 gen_goto_tb(dc
, 0, dc
->iaoq
[1] + 4, dc
->iaoq
[1] + 8);
338 gen_goto_tb(dc
, 1, dc
->iaoq
[1], dc
->iaoq
[1] + 4);
344 static void save_state(DisasContext
*dc
)
350 gen_intermediate_code_internal(CPUState
*env
, TranslationBlock
*tb
,
353 target_ulong pc_start
, last_pc
;
354 uint16_t *gen_opc_end
;
356 DisasContext dc1
, *dc
= &dc1
;
361 memset(dc
, 0, sizeof(DisasContext
));
364 dc
->iaoq
[0] = pc_start
;
365 dc
->iaoq
[1] = (target_ulong
) tb
->cs_base
;
366 last_pc
= dc
->iaoq
[0];
367 dc
->iasq
[0] = dc
->iasq
[1] = 0; /* FIXME */
368 gen_opc_end
= gen_opc_buf
+ OPC_MAX_SIZE
;
370 max_insns
= tb
->cflags
& CF_COUNT_MASK
;
372 max_insns
= CF_COUNT_MASK
;
375 while (!dc
->is_br
&& gen_opc_ptr
< gen_opc_end
) {
376 if (unlikely(!TAILQ_EMPTY(&env
->breakpoints
))) {
377 TAILQ_FOREACH(bp
, &env
->breakpoints
, entry
) {
378 if (bp
->pc
== dc
->iaoq
[0]) {
379 gen_op_save_pc(dc
->iaoq
[0], dc
->iaoq
[1]);
389 fprintf(logfile
, "Search PC...\n");
390 j
= gen_opc_ptr
- gen_opc_buf
;
394 gen_opc_instr_start
[lj
++] = 0;
395 gen_opc_pc
[lj
] = dc
->iaoq
[0];
396 gen_opc_instr_start
[lj
] = 1;
397 gen_opc_icount
[lj
] = num_insns
;
400 if (num_insns
+ 1 == max_insns
&& (tb
->cflags
& CF_LAST_IO
))
402 last_pc
= dc
->iaoq
[0];
408 /* if we reach a page boundary, we stop generation so that the
409 PC of a TT_TFAULT exception is always in the right page */
410 if ((dc
->iaoq
[0] & (TARGET_PAGE_SIZE
- 1)) == 0)
412 /* if single step mode, we generate only one instruction and
413 generate an exception */
414 if (env
->singlestep_enabled
|| singlestep
)
416 if (num_insns
>= max_insns
)
419 if (tb
->cflags
& CF_LAST_IO
)
421 if (env
->singlestep_enabled
|| singlestep
) {
422 gen_op_save_pc(dc
->iaoq
[0], dc
->iaoq
[1]);
425 } else if (!dc
->is_br
) {
426 gen_op_save_pc(dc
->iaoq
[0], dc
->iaoq
[1]);
431 gen_icount_end(tb
, num_insns
);
432 *gen_opc_ptr
= INDEX_op_end
;
434 j
= gen_opc_ptr
- gen_opc_buf
;
437 gen_opc_instr_start
[lj
++] = 0;
445 gen_opc_jump_pc[0] = dc->jump_pc[0];
446 gen_opc_jump_pc[1] = dc->jump_pc[1];
449 tb
->size
= last_pc
+ 4 - pc_start
;
450 tb
->icount
= num_insns
;
453 if (loglevel
& CPU_LOG_TB_IN_ASM
) {
454 fprintf(logfile
, "--------------\n");
455 fprintf(logfile
, "IN: %s\n", lookup_symbol(pc_start
));
456 target_disas(logfile
, pc_start
, last_pc
+ 4 - pc_start
, 0);
457 fprintf(logfile
, "\n");
462 void gen_intermediate_code(CPUState
*env
, TranslationBlock
*tb
)
464 gen_intermediate_code_internal(env
, tb
, 0);
467 void gen_intermediate_code_pc(CPUState
*env
, TranslationBlock
*tb
)
469 gen_intermediate_code_internal(env
, tb
, 1);
472 #define LDST_CMPLT_NONE 0
473 #define LDST_CMPLT_S 1
474 #define LDST_CMPLT_SM 2
475 #define LDST_CMPLT_M 3
476 #define LDST_CMPLT_MA 4
477 #define LDST_CMPLT_MB 5
479 static int get_ldst_cmplt(uint32_t insn
)
481 int indexed_load
= (field(insn
, 12, 1) == 0);
483 int u
= field(insn
, 13, 1);
484 int m
= field(insn
, 5, 1);
486 if (u
== 0 && m
== 0)
487 return LDST_CMPLT_NONE
;
488 else if (u
== 0 && m
== 1)
490 else if (u
== 1 && m
== 0)
492 else if (u
== 1 && m
== 1)
493 return LDST_CMPLT_SM
;
495 int a
= field(insn
, 13, 1);
496 int m
= field(insn
, 5, 1);
497 uint32_t ext4
= field(insn
, 6, 4);
499 if (ext4
<= 7) /* load */
500 im5
= field_signext(insn
, 16, 5);
502 im5
= field_signext(insn
, 0, 5);
505 return LDST_CMPLT_NONE
;
506 else if (a
== 0 && m
== 1 && im5
!= 0)
507 return LDST_CMPLT_MA
;
508 else if (a
== 1 && m
== 1)
509 return LDST_CMPLT_MB
;
511 return LDST_CMPLT_NONE
;
514 static void gen_load(uint32_t insn
, int shift
, load_helper
*op
)
516 int indexed_load
= (field(insn
, 12, 1) == 0);
517 int cmplt
= get_ldst_cmplt(insn
);
518 int b
= field(insn
, 21, 5);
519 int t
= field(insn
, 0, 5);
521 /* load value at address T0 to T1 */
524 int x
= field(insn
, 16, 5);
528 gen_movl_reg_TN(x
, cpu_T
[0]);
529 tcg_gen_shli_tl(cpu_T
[0], cpu_T
[0], shift
);
533 gen_movl_reg_TN(x
, cpu_T
[0]);
537 target_long im5
= field_lowsignext(insn
, 16, 5);
538 tcg_gen_movi_tl(cpu_T
[0], im5
);
544 gen_movl_reg_TN(b
, cpu_T
[1]);
545 tcg_gen_mov_tl(cpu_T
[2], cpu_T
[0]); /* copy dx to T2 */
546 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]); /* T0 = GR[b] + dx */
547 tcg_gen_add_tl(cpu_T
[1], cpu_T
[2], cpu_T
[1]); /* GR[b] += dx */
548 gen_movl_TN_reg(b
, cpu_T
[1]);
554 gen_movl_reg_TN(b
, cpu_T
[1]);
555 tcg_gen_mov_tl(cpu_T
[2], cpu_T
[1]);
556 tcg_gen_add_tl(cpu_T
[1], cpu_T
[0], cpu_T
[1]); /* GR[b] += dx */
557 gen_movl_TN_reg(b
, cpu_T
[1]);
558 tcg_gen_mov_tl(cpu_T
[0], cpu_T
[2]); /* T0 = GR[b] */
562 gen_movl_reg_TN(b
, cpu_T
[1]);
563 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]); /* T0 = GR[b] + dx */
568 gen_movl_TN_reg(t
, cpu_T
[1]);
571 static void gen_store(uint32_t insn
, store_helper
*op
)
573 target_long im5
= field_lowsignext(insn
, 0, 5);
574 int r
= field(insn
, 16, 5);
575 int b
= field(insn
, 21, 5);
576 int cmplt
= get_ldst_cmplt(insn
);
578 /* store T1 at address T0 */
580 tcg_gen_movi_tl(cpu_T
[0], im5
);
583 gen_movl_reg_TN(b
, cpu_T
[1]);
584 tcg_gen_mov_tl(cpu_T
[2], cpu_T
[0]); /* T2 = dx */
585 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]); /* offset = GR[b] + dx */
586 tcg_gen_add_tl(cpu_T
[1], cpu_T
[2], cpu_T
[1]); /* GR[b] += dx */
587 gen_movl_TN_reg(b
, cpu_T
[1]);
590 gen_movl_reg_TN(b
, cpu_T
[1]);
591 tcg_gen_mov_tl(cpu_T
[2], cpu_T
[1]); /* T2 = GR[b] */
592 tcg_gen_add_tl(cpu_T
[1], cpu_T
[0], cpu_T
[1]); /* GR[b] += dx */
593 gen_movl_TN_reg(b
, cpu_T
[1]);
594 tcg_gen_mov_tl(cpu_T
[0], cpu_T
[2]); /* offset = GR[b] */
597 gen_movl_reg_TN(b
, cpu_T
[1]);
598 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]); /* offset = GR[b] + dx */
601 gen_movl_reg_TN(r
, cpu_T
[1]);
606 static void gen_shrpw(uint32_t insn
)
608 int r1
= field(insn
, 16, 5);
609 int r2
= field(insn
, 21, 5);
610 int t
= field(insn
, 0, 5);
612 gen_movl_reg_TN(r1
, cpu_T
[1]);
613 gen_movl_reg_TN(r2
, cpu_T
[2]);
615 gen_movl_TN_reg(t
, cpu_T
[0]);
618 static void gen_extrw(uint32_t insn
)
620 int r
= field(insn
, 21, 5);
621 int t
= field(insn
, 16, 5);
622 int clen
= 32 - field(insn
, 0, 5);
623 int se
= field(insn
, 10, 1);
625 tcg_gen_movi_tl(cpu_T
[1], clen
);
626 gen_movl_reg_TN(r
, cpu_T
[2]);
628 gen_movl_TN_reg(t
, cpu_T
[0]);
631 static void gen_depw(uint32_t insn
)
633 int t
= field(insn
, 21, 5);
634 int r
= field(insn
, 16, 5);
635 int clen
= 32 - field(insn
, 0, 5);
636 int nz
= field(insn
, 10, 1);
638 tcg_gen_movi_tl(cpu_T
[1], clen
);
639 gen_movl_reg_TN(r
, cpu_T
[2]);
641 gen_movl_TN_reg(t
, cpu_T
[0]);
644 static void gen_depwi(uint32_t insn
)
646 int t
= field(insn
, 21, 5);
647 target_long im5
= field_signext(insn
, 16, 5);
648 int clen
= 32 - field(insn
, 0, 5);
649 int nz
= field(insn
, 10, 1);
651 tcg_gen_movi_tl(cpu_T
[1], clen
);
652 tcg_gen_movi_tl(cpu_T
[2], im5
);
654 gen_movl_TN_reg(t
, cpu_T
[0]);
657 static void disas_hppa_insn(DisasContext
* dc
)
663 insn
= ldl_code(dc
->iaoq
[0]);
664 op
= field(insn
, 26, 6);
683 case 0x00: /* System_op */
686 ext8
= field(insn
, 5, 8);
688 case 0x00: /* BREAK */
692 case 0x20: /* SYNC/SYNCDMA */
693 if (field(insn
, 20, 1))
704 case 0x65: /* RFI,R (RFIR) */
706 gen_op_restore_shadow();
711 gen_op_check_priv0();
712 gen_op_ssm(field(insn
, 16, 7));
713 gen_movl_TN_reg(field(insn
, 0, 5), cpu_T
[0]);
717 gen_op_check_priv0();
718 gen_op_rsm(field(insn
, 16, 7));
719 gen_movl_TN_reg(field(insn
, 0, 5), cpu_T
[0]);
722 case 0xc3: /* MTSM */
723 gen_op_check_priv0();
724 gen_movl_reg_TN(field(insn
, 16, 5), cpu_T
[0]);
728 case 0x85: /* LDSID */
731 s
= field(insn
, 14, 2);
732 b
= field(insn
, 21, 5);
733 t
= field(insn
, 0, 5);
737 case 0xc1: /* MTSP */
739 int sr
= field(insn
, 13, 3);
740 int r
= field(insn
, 16, 5);
741 gen_movl_reg_TN(r
, cpu_T
[0]);
742 gen_movl_TN_sr(sr
, cpu_T
[0]);
746 case 0x25: /* MFSP */
748 int sr
= field(insn
, 13, 3);
749 int t
= field(insn
, 0, 5);
751 gen_op_check_priv0();
752 gen_movl_sr_TN(sr
, cpu_T
[0]);
753 gen_movl_TN_reg(t
, cpu_T
[0]);
758 case 0xa5: /* MFIA */
762 case 0xc2: /* MTCTL */
765 t
= field(insn
, 21, 5);
766 r
= field(insn
, 16, 5);
770 gen_op_check_priv0();
772 case 0: /* recovery counter */
773 /* TODO: mask 32-bits for 64-bit op */
789 /* Undefined in PSW[Q] set */
795 gen_movl_reg_TN(r
, cpu_T
[0]);
796 gen_movl_TN_cr(0, cpu_T
[0]);
800 gen_movl_cr_TN(23, cpu_T
[0]);
801 gen_movl_reg_TN(r
, cpu_T
[1]);
802 tcg_gen_andc_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
803 gen_movl_TN_cr(23, cpu_T
[0]);
806 case 10: /* CCR/SCR */
807 case 11: /* SAR - handled differently on 64-bit */
808 gen_movl_reg_TN(r
, cpu_T
[0]);
809 tcg_gen_ext8u_tl(cpu_T
[0], cpu_T
[0]);
810 gen_movl_TN_cr(10, cpu_T
[0]);
817 case 0xc6: /* MTSARCM */
821 case 0x45: /* MFCTL/MFCTL,W */
824 r
= field(insn
, 21, 5);
825 t
= field(insn
, 0, 5);
828 if (r
!= 11 && r
!= 26 && r
!= 27)
829 gen_op_check_priv0();
830 if (r
== 16) /* interval timer */
831 gen_op_check_int_timer_priv();
833 if ((r
>= 17 && r
<= 22) || (r
== 0)) {
834 gen_movl_cr_TN(r
, cpu_T
[0]);
835 gen_movl_TN_reg(t
, cpu_T
[0]);
836 } else if (r
== 11) { /* SAR */
837 /* Check - may need to mask and shift */
838 gen_movl_cr_TN(r
, cpu_T
[0]);
839 gen_movl_TN_reg(t
, cpu_T
[0]);
841 gen_movl_cr_TN(r
, cpu_T
[0]);
842 gen_movl_TN_reg(t
, cpu_T
[0]);
854 case 0x01: /* Mem_Mgmt */
857 ext5
= field(insn
, 0, 5);
858 if (!field(insn
, 12, 1)) {
860 ext7
= field(insn
, 6, 7);
862 case 0x08: /* PITLB */
863 case 0x09: /* PITLBE */
864 case 0x0a: /* FIC,0A (FIC) */
865 case 0x0b: /* FICE */
867 case 0x20: /* IITLBT */
868 case 0x18: /* PITLB,L */
870 case 0x01: /* IITLBA */
871 case 0x00: /* IITLBP */
881 ext8
= field(insn
, 6, 8);
884 case 0x48: /* PDTLB */
885 case 0x49: /* PDTLBE */
886 case 0x4a: /* FDC (index) */
887 case 0x4b: /* FDCE */
889 case 0x46: /* PROBE,R (PROBER) */
890 case 0xc6: /* PROBEI,R (PROBERI) */
891 case 0x47: /* PROBE,W (PROBEW) */
892 case 0xc7: /* PROBEI,W (PROBEWI) */
896 case 0x60: /* IDTLBT */
897 case 0x58: /* PDTLB,L */
898 case 0xca: /* FDC (imm) */
900 case 0x41: /* IDTLBA */
901 case 0x40: /* IDTLBP */
913 case 0x02: /* Arith/Log */
916 r2
= field(insn
, 21, 5);
917 r1
= field(insn
, 16, 5);
918 c
= field(insn
, 13, 3);
919 f
= field(insn
, 12, 1);
920 ext6
= field(insn
, 6, 6);
921 t
= field(insn
, 0, 5);
922 gen_movl_reg_TN(r1
, cpu_T
[0]);
923 gen_movl_reg_TN(r2
, cpu_T
[1]);
925 /* Opcode Extensions */
930 gen_helper_add_cc(cpu_T
[0], cpu_T
[0], cpu_T
[1]);
932 case 0x28: /* ADD,L (ADDL) */
935 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
937 case 0x38: /* ADD,TSV (ADDO) */
938 gen_op_eval_add_sv();
939 /* gen_op_overflow_trap(); */
942 gen_helper_add_cc(cpu_T
[0], cpu_T
[0], cpu_T
[1]);
944 case 0x1c: /* ADD,C (ADDC) */
947 gen_helper_addc_cc(cpu_T
[0], cpu_T
[0], cpu_T
[1]);
949 case 0x3c: /* ADD,C,TSV (ADDCO) */
950 gen_op_eval_addc_sv();
951 /* gen_op_overflow_trap(); */
954 gen_helper_addc_cc(cpu_T
[0], cpu_T
[0], cpu_T
[1]);
956 case 0x19: /* SHLADD (1) (SH1ADD) */
957 tcg_gen_shli_tl(cpu_T
[0], cpu_T
[0], 1);
959 gen_cond_add
[c
](); /* FIXME */
960 gen_helper_add_cc(cpu_T
[0], cpu_T
[0], cpu_T
[1]);
962 case 0x29: /* SHLADD,L (1) (SH1ADDL) */
963 tcg_gen_shli_tl(cpu_T
[0], cpu_T
[0], 1);
966 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
968 case 0x39: /* SHLADD,TSV (1) (SH1ADDO) */
969 gen_op_eval_add_sv(); /* FIXME */
970 /* gen_op_overflow_trap(); */
971 tcg_gen_shli_tl(cpu_T
[0], cpu_T
[0], 1);
973 gen_cond_add
[c
](); /* FIXME */
974 gen_helper_add_cc(cpu_T
[0], cpu_T
[0], cpu_T
[1]);
976 case 0x1a: /* SHLADD (2) (SH2ADD) */
977 tcg_gen_shli_tl(cpu_T
[0], cpu_T
[0], 2);
979 gen_cond_add
[c
](); /* FIXME */
980 gen_helper_add_cc(cpu_T
[0], cpu_T
[0], cpu_T
[1]);
982 case 0x2a: /* SHLADD,L (2) (SH2ADDL) */
983 tcg_gen_shli_tl(cpu_T
[0], cpu_T
[0], 2);
986 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
988 case 0x3a: /* SHLADD,TSV (2) (SH2ADDO) */
989 gen_op_eval_add_sv(); /* FIXME */
990 /* gen_op_overflow_trap(); */
991 tcg_gen_shli_tl(cpu_T
[0], cpu_T
[0], 2);
993 gen_cond_add
[c
](); /* FIXME */
994 gen_helper_add_cc(cpu_T
[0], cpu_T
[0], cpu_T
[1]);
996 case 0x1b: /* SHLADD (3) (SH3ADD) */
997 tcg_gen_shli_tl(cpu_T
[0], cpu_T
[0], 3);
999 gen_cond_add
[c
](); /* FIXME */
1000 gen_helper_add_cc(cpu_T
[0], cpu_T
[0], cpu_T
[1]);
1002 case 0x2b: /* SHLADD,L (3) (SH3ADDL) */
1003 tcg_gen_shli_tl(cpu_T
[0], cpu_T
[0], 3);
1006 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1008 case 0x3b: /* SHLADD,TSV (3) (SH3ADDO) */
1009 gen_op_eval_add_sv(); /* FIXME */
1010 /* gen_op_overflow_trap(); */
1011 tcg_gen_shli_tl(cpu_T
[0], cpu_T
[0], 3);
1013 gen_cond_add
[c
](); /* FIXME */
1014 gen_helper_add_cc(cpu_T
[0], cpu_T
[0], cpu_T
[1]);
1016 case 0x10: /* SUB */
1019 gen_op_sub_T1_T0_cc();
1021 case 0x30: /* SUB,TSV (SUBO) */
1022 gen_op_eval_sub_sv();
1023 /* gen_op_overflow_trap(); */
1026 gen_op_sub_T1_T0_cc();
1028 case 0x13: /* SUB,TC (SUBT) */
1031 /* gen_cond_trap(); */
1032 gen_op_sub_T1_T0_cc();
1034 case 0x33: /* SUB,TSV,TC (SUBTO) */
1035 gen_op_eval_sub_sv();
1036 /* gen_op_overflow_trap(); */
1039 /* gen_cond_trap(); */
1040 gen_op_sub_T1_T0_cc();
1042 case 0x14: /* SUB,B (SUBB) */
1045 gen_op_subb_T1_T0_cc();
1047 case 0x34: /* SUB,B,TSV (SUBBO) */
1048 gen_op_eval_subb_sv();
1049 /* gen_op_overflow_trap(); */
1052 gen_op_subb_T1_T0_cc();
1056 gen_cond_ds[c](); */
1059 case 0x00: /* ANDCM */
1060 tcg_gen_andc_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1064 case 0x08: /* AND */
1065 tcg_gen_and_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1070 tcg_gen_or_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1074 case 0x0a: /* XOR */
1075 tcg_gen_xor_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1079 case 0x0e: /* UXOR */
1080 gen_op_uxor_T1_T0();
1084 case 0x22: /* CMPCLR (COMCLR) */
1087 tcg_gen_movi_tl(cpu_T
[0], 0);
1089 case 0x26: /* UADDCM */
1090 /* FIXME: 'c' specifies unit size */
1091 gen_op_uaddcm_T1_T0();
1095 case 0x27: /* UADDCM,TC (UADDCMT) */
1096 /* FIXME: 'c' specifies unit size */
1097 gen_op_uaddcm_T1_T0();
1100 /* gen_cond_trap(); */
1103 case 0x2e: /* DCOR */
1105 gen_op_undef_insn();
1107 tcg_gen_mov_tl(cpu_T
[0], cpu_T
[1]);
1111 case 0x2f: /* DCOR,I (IDCOR) */
1113 gen_op_undef_insn();
1115 tcg_gen_mov_tl(cpu_T
[0], cpu_T
[1]);
1119 #ifdef TARGET_HPPA64
1120 /* Also included in MAX-1 (PA-7100LC and PA-7300LC) */
1121 case 0x0f: /* HADD */
1122 case 0x0d: /* HADD,SS */
1123 case 0x0c: /* HADD,US */
1124 case 0x07: /* HSUB */
1125 case 0x05: /* HSUB,SS */
1126 case 0x04: /* HSUB,US */
1127 case 0x0b: /* HAVG (HAVE) */
1128 case 0x1d: /* HSHLADD (1) (HSL1ADD) */
1129 case 0x1e: /* HSHLADD (2) (HSL2ADD) */
1130 case 0x1f: /* HSHLADD (3) (HSL3ADD) */
1131 case 0x15: /* HSHRADD (1) (HSR1ADD) */
1132 case 0x16: /* HSHRADD (2) (HSR2ADD) */
1133 case 0x17: /* HSHRADD (3) (HSR3ADD) */
1136 default: /* Undefined Instruction */
1137 gen_op_undef_insn();
1140 gen_movl_TN_reg(t
, cpu_T
[0]);
1142 gen_nullify_cond(dc
, (long)dc
->tb
, f
);
1146 case 0x03: /* Index_Mem */
1148 int ext4
= field(insn
, 6, 4);
1150 /* XXX: gen_op_*_raw only works for user-mode emulation
1151 * we really need gen_load and gen_store to be macros
1152 * to allow _phys and _virtual to be used
1154 case 0x00: /* LDB (index/short) (LDBX/LDBS) */
1155 gen_load(insn
, 0, gen_op_ldb_raw
);
1157 case 0x01: /* LDH (index/short) (LDHX/LDHS) */
1158 gen_load(insn
, 1, gen_op_ldh_raw
);
1160 case 0x02: /* LDW (index/short) (LDWX/LDWS) */
1161 gen_load(insn
, 2, gen_op_ldw_raw
);
1163 case 0x06: /* LDWA (index/short) (LDWAX/LDWAS) */
1164 gen_op_check_priv0();
1165 gen_load(insn
, 2, gen_op_ldw_phys
);
1167 case 0x07: /* LDCW (index/short) (LDCWX/LDCWS) */
1168 gen_load(insn
, 2, gen_op_ldcw_raw
);
1170 case 0x08: /* STB (short) (STBS) */
1171 gen_store(insn
, gen_op_stb_raw
);
1173 case 0x09: /* STH (short) (STHS) */
1174 gen_store(insn
, gen_op_sth_raw
);
1176 case 0x0a: /* STW (short) (STWS) */
1177 gen_store(insn
, gen_op_stw_raw
);
1179 case 0x0c: /* STBY (short) (STBYS) */
1182 case 0x0e: /* STWA (short) (STWAS) */
1183 gen_store(insn
, gen_op_stw_phys
);
1186 #ifdef TARGET_HPPA64
1187 case 0x03: /* LDD (index/short) */
1188 case 0x04: /* LDDA (index/short) */
1189 case 0x05: /* LDCD (index/short) */
1190 case 0x0b: /* STD (short) */
1191 case 0x0d: /* STDBY (short) */
1192 case 0x0f: /* STDA (short) */
1200 case 0x04: /* SPOPn */
1207 case 0x05: /* DIAG */
1208 case 0x06: /* FMPYADD */
1211 case 0x08: /* LDIL */
1215 t
= field(insn
, 21, 5);
1217 im21
= assemble_21(field(insn
, 0, 21)) << (32 - 21);
1218 tcg_gen_movi_tl(cpu_T
[0], im21
);
1219 gen_movl_TN_reg(t
, cpu_T
[0]);
1224 case 0x09: /* Copr_w */
1225 if (!field(insn
, 12, 1))
1226 if (!field(insn
, 9, 1))
1227 /* CLDW (index) (CLDWX) */ {}
1229 /* CSTW (index) (CSTWX) */ {}
1231 if (!field(insn
, 9, 1))
1232 /* CLDW (short) (CLDWS) */ {}
1234 /* CSTW (short) (CSTWS) */ {}
1237 case 0x0a: /* ADDIL */
1241 r
= field(insn
, 21, 5);
1242 im21
= assemble_21(field(insn
, 0, 21)) << (32 - 21);
1243 gen_movl_reg_TN(r
, cpu_T
[1]);
1244 tcg_gen_movi_tl(cpu_T
[0], im21
);
1245 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1246 gen_movl_TN_reg(1, cpu_T
[0]);
1250 case 0x0b: /* Copr_dw */
1251 if (!field(insn
, 12, 1))
1252 if (!field(insn
, 9, 1))
1253 /* CLDD (index) (CLDDX) */ {}
1255 /* CSTD (index) (CLTDX) */ {}
1257 if (!field(insn
, 9, 1))
1258 /* CLDD (short) (CLDDS) */ {}
1260 /* CSTD (short) (CSTDS) */ {}
1263 case 0x0c: /* COPR */
1266 case 0x0d: /* LDO - Load Offset */
1270 b
= field(insn
, 21, 5);
1271 t
= field(insn
, 16, 5);
1272 im14
= field_lowsignext(insn
, 0, 14);
1273 gen_movl_reg_TN(b
, cpu_T
[0]);
1274 tcg_gen_movi_tl(cpu_T
[1], im14
);
1275 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1276 gen_movl_TN_reg(t
, cpu_T
[0]);
1280 case 0x0e: /* Float */
1281 case 0x0f: /* Product Specific */
1284 case 0x10: /* LDB */
1285 case 0x11: /* LDH */
1286 case 0x12: /* LDW */
1290 b
= field(insn
, 21, 5);
1291 t
= field(insn
, 16, 5);
1292 s
= field(insn
, 14, 2);
1293 im14
= field_lowsignext(insn
, 0, 14);
1294 gen_movl_reg_TN(b
, cpu_T
[0]);
1295 tcg_gen_movi_tl(cpu_T
[1], s
);
1296 /* gen_op_space_sel_T0_T1(); */
1297 tcg_gen_movi_tl(cpu_T
[1], im14
);
1298 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1300 case 0x10: /* LDB */
1301 tcg_gen_qemu_ld8u(cpu_T
[1], cpu_T
[0], dc
->mem_idx
);
1303 case 0x11: /* LDH */
1304 tcg_gen_qemu_ld16u(cpu_T
[1], cpu_T
[0], dc
->mem_idx
);
1306 case 0x12: /* LDW */
1307 tcg_gen_qemu_ld32u(cpu_T
[1], cpu_T
[0], dc
->mem_idx
);
1310 gen_movl_TN_reg(t
, cpu_T
[1]);
1314 case 0x13: /* LDW,M (LDWM) post-incr/pre-decr */
1318 b
= field(insn
, 21, 5);
1319 t
= field(insn
, 16, 5);
1320 s
= field(insn
, 14, 2);
1321 im14
= field_lowsignext(insn
, 0, 14);
1322 gen_movl_reg_TN(b
, cpu_T
[0]);
1323 /* tcg_gen_movi_tl(cpu_T[1], s); */
1324 /* gen_op_space_sel_T0_T1(); */
1325 /* XXX: check this */
1326 if (im14
& (1 << 31)) {
1327 tcg_gen_movi_tl(cpu_T
[1], im14
);
1328 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1330 tcg_gen_qemu_ld32u(cpu_T
[1], cpu_T
[0], dc
->mem_idx
);
1331 gen_movl_TN_reg(t
, cpu_T
[1]);
1332 if (!(im14
& (1 << 31))) {
1333 tcg_gen_movi_tl(cpu_T
[1], im14
);
1334 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1336 gen_movl_TN_reg(b
, cpu_T
[0]);
1340 #ifdef TARGET_HPPA64
1341 case 0x14: /* Load_dw */
1342 /* LDD/FLDD (long) */
1345 case 0x16: /* FLDW,M */
1346 case 0x17: /* LDW,M pre-incr/post-decr */
1350 case 0x18: /* STB */
1351 case 0x19: /* STH */
1352 case 0x1a: /* STW */
1356 b
= field(insn
, 21, 5);
1357 r
= field(insn
, 16, 5);
1358 s
= field(insn
, 14, 2);
1359 im14
= field_lowsignext(insn
, 0, 14);
1360 gen_movl_reg_TN(b
, cpu_T
[0]);
1361 /* tcg_gen_movi_tl(cpu_T[1], s); */
1362 /* gen_op_space_sel_T0_T1(); */
1363 tcg_gen_movi_tl(cpu_T
[1], im14
);
1364 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1365 gen_movl_reg_TN(r
, cpu_T
[1]);
1367 case 0x18: /* STB */
1368 tcg_gen_qemu_st8(cpu_T
[1], cpu_T
[0], dc
->mem_idx
);
1370 case 0x19: /* STH */
1371 tcg_gen_qemu_st16(cpu_T
[1], cpu_T
[0], dc
->mem_idx
);
1373 case 0x1a: /* STW */
1374 tcg_gen_qemu_st32(cpu_T
[1], cpu_T
[0], dc
->mem_idx
);
1380 case 0x1b: /* STW,M (STWM) post-incr/pre-decr */
1384 b
= field(insn
, 21, 5);
1385 r
= field(insn
, 16, 5);
1386 s
= field(insn
, 14, 2);
1387 im14
= field_lowsignext(insn
, 0, 14);
1388 gen_movl_reg_TN(b
, cpu_T
[0]);
1389 /* tcg_gen_movi_tl(cpu_T[1], s); */
1390 /* gen_op_space_sel_T0_T1(); */
1391 /* XXX: check this */
1392 if (im14
& (1 << 31)) {
1393 tcg_gen_movi_tl(cpu_T
[1], im14
);
1394 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1396 gen_movl_reg_TN(r
, cpu_T
[1]);
1397 tcg_gen_qemu_st32(cpu_T
[1], cpu_T
[0], dc
->mem_idx
);
1398 if (!(im14
& (1 << 31))) {
1399 tcg_gen_movi_tl(cpu_T
[1], im14
);
1400 tcg_gen_add_tl(cpu_T
[0], cpu_T
[1], cpu_T
[0]);
1402 gen_movl_TN_reg(b
, cpu_T
[0]);
1406 #ifdef TARGET_HPPA64
1407 case 0x1c: /* Store_dw */
1408 /* STD/FSTD (long) */
1411 case 0x1e: /* FSTW,M */
1412 case 0x1f: /* STW,M pre-incr/post-decr */
1416 case 0x20: /* CMPB (true) (COMBT) */
1417 case 0x21: /* CMPIB (true) (COMIBT) */
1418 case 0x22: /* CMPB (false) (COMBF) */
1419 case 0x23: /* CMPIB (false) (COMIBF) */
1424 case 0x20: /* CMPB (true) (COMBT) */
1425 case 0x22: /* CMPB (false) (COMBF) */
1428 r2
= field(insn
, 21, 5);
1429 r1
= field(insn
, 16, 5);
1430 gen_movl_reg_TN(r1
, cpu_T
[0]);
1431 gen_movl_reg_TN(r2
, cpu_T
[1]);
1434 case 0x21: /* CMPIB (true) (COMIBT) */
1435 case 0x23: /* CMPIB (false) (COMIBF) */
1439 r
= field(insn
, 21, 5);
1440 im5
= field_lowsignext(insn
, 16, 5);
1441 tcg_gen_movi_tl(cpu_T
[0], im5
);
1442 gen_movl_reg_TN(r
, cpu_T
[1]);
1446 f
= field(insn
, 27, 1);
1447 c
= field(insn
, 13, 3);
1448 w1
= field(insn
, 2, 11);
1449 n
= field(insn
, 1, 1);
1450 w
= field(insn
, 0, 1);
1451 disp
= signext(assemble_12(w1
, w
), 12) << 2;
1454 gen_branch_cond(dc
, (long)dc
->tb
, disp
, n
, f
);
1461 case 0x24: /* CMPICLR (COMICLR) */
1465 if (field(insn
, 11, 1))
1466 gen_op_undef_insn();
1468 r
= field(insn
, 21, 5);
1469 t
= field(insn
, 16, 5);
1470 c
= field(insn
, 13, 3);
1471 f
= field(insn
, 12, 1);
1472 im11
= field_lowsignext(insn
, 0, 11);
1473 gen_movl_reg_TN(r
, cpu_T
[0]);
1474 tcg_gen_movi_tl(cpu_T
[1], im11
);
1477 tcg_gen_movi_tl(cpu_T
[0], 0);
1478 gen_movl_TN_reg(t
, cpu_T
[0]);
1480 gen_nullify_cond(dc
, (long)dc
->tb
, f
);
1485 case 0x25: /* SUBI / SUBI,TSV (SUBIO) */
1489 r
= field(insn
, 21, 5);
1490 t
= field(insn
, 16, 5);
1491 c
= field(insn
, 13, 3);
1492 f
= field(insn
, 12, 1);
1493 o
= field(insn
, 11, 1);
1494 im11
= field_lowsignext(insn
, 0, 11);
1495 gen_movl_reg_TN(r
, cpu_T
[0]);
1497 gen_op_eval_sub_sv();
1498 /* gen_op_overflow_trap(); */
1502 gen_op_sub_T1_T0_cc();
1504 gen_nullify_cond(dc
, (long)dc
->tb
, f
);
1508 case 0x26: /* FMPYSUB */
1512 #ifdef TARGET_HPPA64
1513 case 0x27: /* CMPB (dw true) */
1517 case 0x28: /* ADDB (true) (ADDBT) */
1518 case 0x29: /* ADDIB (true) (ADDIBT) */
1519 case 0x2a: /* ADDB (false) (ADDBF) */
1520 case 0x2b: /* ADDIB (false) (ADDIBF) */
1525 case 0x28: /* ADDB (true) (ADDBT) */
1526 case 0x2a: /* ADDB (false) (ADDBF) */
1529 r2
= field(insn
, 21, 5);
1530 r1
= field(insn
, 16, 5);
1531 gen_movl_reg_TN(r1
, cpu_T
[0]);
1532 gen_movl_reg_TN(r2
, cpu_T
[1]);
1535 case 0x29: /* ADDIB (true) (ADDIBT) */
1536 case 0x2b: /* ADDIB (false) (ADDIBF) */
1540 r
= field(insn
, 21, 5);
1541 im5
= field_lowsignext(insn
, 16, 5);
1542 tcg_gen_movi_tl(cpu_T
[0], im5
);
1543 gen_movl_reg_TN(r
, cpu_T
[1]);
1547 f
= field(insn
, 27, 1);
1548 c
= field(insn
, 13, 3);
1549 w1
= field(insn
, 2, 11);
1550 n
= field(insn
, 1, 1);
1551 w
= field(insn
, 0, 1);
1552 disp
= signext(assemble_12(w1
, w
), 12) << 2;
1555 gen_branch_cond(dc
, (long)dc
->tb
, disp
, n
, f
);
1562 case 0x2c: /* ADDI,TC (ADDIT) / ADDI,TSV,TC (ADDITO) */
1563 case 0x2d: /* ADDI / ADDI,TSV (ADDIO) */
1567 r
= field(insn
, 21, 5);
1568 t
= field(insn
, 16, 5);
1569 c
= field(insn
, 13, 3);
1570 f
= field(insn
, 12, 1);
1571 o
= field(insn
, 11, 1);
1572 im11
= field_lowsignext(insn
, 0, 11);
1573 gen_movl_reg_TN(r
, cpu_T
[0]);
1574 tcg_gen_movi_tl(cpu_T
[1], im11
);
1576 gen_op_eval_add_sv();
1577 /* gen_op_overflow_trap(); */
1581 if (op
== 0x2c) /* ADDI,TC (ADDIT) / ADDI,TSV,TC (ADDITO) */
1582 ; /* gen_cond_trap(); */
1584 gen_helper_add_cc(cpu_T
[0], cpu_T
[0], cpu_T
[1]);
1585 if ((c
|| f
) && (op
== 0x2d)) /* ADDI / ADDI,TSV (ADDIO) */
1586 gen_nullify_cond(dc
, (long)dc
->tb
, f
);
1587 gen_movl_TN_reg(t
, cpu_T
[0]);
1591 #ifdef TARGET_HPPA64
1592 case 0x2e: /* Fp_fused */
1593 case 0x2f: /* CMPB (dw false) */
1597 case 0x30: /* BB (sar) (BVB) */
1599 case 0x32: /* MOVB */
1600 case 0x33: /* MOVIB */
1601 /* disp = signext(assemble_12(w1, w), 12) << 2; */
1606 case 0x34: /* Shift/Extract */
1609 ext3
= field(insn
, 10, 3);
1611 case 0: /* VSHD = SHRPW with SAR */
1612 gen_movl_cr_TN(11, cpu_T
[0]);
1615 case 2: /* SHD = SHRPW */
1617 int sa
= 31 - field(insn
, 5, 5);
1618 tcg_gen_movi_tl(cpu_T
[0], sa
);
1622 case 4: /* VEXTRU = EXTRW,U with SAR */
1623 case 5: /* VEXTRS = EXTRW,S with SAR */
1624 gen_movl_cr_TN(11, cpu_T
[0]);
1627 case 6: /* EXTRU = EXTRW,U */
1628 case 7: /* EXTRS = EXTRW,S */
1630 int pos
= field(insn
, 5, 5);
1631 tcg_gen_movi_tl(cpu_T
[0], pos
);
1639 case 0x35: /* Deposit */
1642 ext3
= field(insn
, 10, 3);
1644 case 0: /* VZDEP = DEPW,Z with SAR */
1645 case 1: /* VDEP = DEPW with SAR */
1646 gen_movl_cr_TN(11, cpu_T
[0]);
1649 case 2: /* ZDEP = DEPW,Z */
1650 case 3: /* DEP = DEPW */
1652 int cpos
= field(insn
, 5, 5);
1653 tcg_gen_movi_tl(cpu_T
[0], cpos
);
1657 case 4: /* VZDEPI = DEPW,Z */
1658 case 5: /* VDEPI = DEPW,Z */
1659 gen_movl_cr_TN(11, cpu_T
[0]);
1662 case 6: /* ZDEPI = DEPWI,Z */
1663 case 7: /* DEPI = DEPWI */
1665 int cpos
= field(insn
, 5, 5);
1666 tcg_gen_movi_tl(cpu_T
[0], cpos
);
1674 #ifdef TARGET_HPPA64
1675 case 0x36: /* EXTRD */
1680 case 0x39: /* BE,L (BLE) */
1682 int b
, w1
, s
, w2
, n
, w
;
1684 b
= field(insn
, 21, 5);
1685 w1
= field(insn
, 16, 5);
1686 s
= field(insn
, 13, 3);
1687 w2
= field(insn
, 2, 11);
1688 n
= field(insn
, 1, 1);
1689 w
= field(insn
, 0, 1);
1690 disp
= signext(assemble_17(w1
,w2
,w
),17) << 2;
1698 case 0x3a: /* Branch */
1700 int t
, w
, w1
, ext3
, w2
, n
;
1702 ext3
= field(insn
, 13, 3);
1703 t
= field(insn
, 21, 5);
1704 w1
= field(insn
, 16, 5);
1705 w2
= field(insn
, 2, 11);
1706 n
= field(insn
, 1, 1);
1707 w
= field(insn
, 0, 1);
1708 disp
= signext(assemble_17(w1
,w2
,w
),17) << 2;
1710 case 0: /* B,L (BL) */
1711 /* TODO: dc->iaoq[1] + 4 into t */
1713 gen_branch(dc
, 0, dc
->iaoq
[0] + disp
+ 8, dc
->iaoq
[0] + disp
+ 12);
1715 gen_branch(dc
, 0, dc
->iaoq
[1], dc
->iaoq
[0] + disp
+ 8);
1719 /* if w == 0 ( ill_insn ) */
1721 case 1: /* B,GATE (GATE) */
1730 #ifdef TARGET_HPPA64
1731 case 0x3b: /* CMPIB (dw) */
1734 case 0x3c: /* DEPD */
1735 case 0x3d: /* DEPI */
1738 case 0x3e: /* Multimedia (MAX-2) */
1750 default: /* Illegal Instruction */
1755 dc
->iaoq
[0] = dc
->iaoq
[1];
1756 dc
->iaoq
[1] = dc
->iaoq
[1] + 4;
1759 CPUHPPAState
*cpu_hppa_init(const char *cpu_model
)
1763 env
= qemu_mallocz(sizeof(CPUHPPAState
));
1765 hppa_translate_init();
1767 qemu_init_vcpu(env
);
1771 void cpu_dump_state(CPUState
*env
, FILE *f
,
1772 int (*cpu_fprintf
)(FILE *f
, const char *fmt
, ...),
1777 cpu_fprintf(f
, "PSW = %08X\n", env
->psw
);
1778 for (i
=0; i
<31; i
++) {
1779 cpu_fprintf(f
, "R%02d=%08x", i
, env
->gr
[i
]);
1781 cpu_fprintf(f
, "\n");
1783 cpu_fprintf(f
, " ");
1786 for (i
=0; i
<31; i
++) {
1787 cpu_fprintf(f
, "CR%02d=%08x", i
, env
->cr
[i
]);
1789 cpu_fprintf(f
, "\n");
1791 cpu_fprintf(f
, " ");
1794 cpu_fprintf(f
, "IAOQ = %08X %08X\tIASQ = %08X %08X\n",
1795 env
->iaoq
[0], env
->iaoq
[1], env
->iasq
[0], env
->iasq
[1]);
1798 void gen_pc_load(CPUState
*env
, TranslationBlock
*tb
,
1799 unsigned long searched_pc
, int pc_pos
, void *puc
)
1801 env
->iaoq
[0] = gen_opc_pc
[pc_pos
];
1802 env
->iaoq
[1] = gen_opc_npc
[pc_pos
];