target/mips/tx79: Move PCPYLD / PCPYUD opcodes to decodetree
[qemu/kevin.git] / target / mips / tx79_translate.c
blob6e90eb64608b467adadc20780f4a0c564f77b3ad
1 /*
2 * Toshiba TX79-specific instructions translation routines
4 * Copyright (c) 2018 Fredrik Noring
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
9 #include "qemu/osdep.h"
10 #include "tcg/tcg-op.h"
11 #include "exec/helper-gen.h"
12 #include "translate.h"
14 /* Include the auto-generated decoder. */
15 #include "decode-tx79.c.inc"
17 bool decode_ext_tx79(DisasContext *ctx, uint32_t insn)
19 if (TARGET_LONG_BITS == 64 && decode_tx79(ctx, insn)) {
20 return true;
22 return false;
25 static bool trans_MFHI1(DisasContext *ctx, arg_rtype *a)
27 gen_store_gpr(cpu_HI[1], a->rd);
29 return true;
32 static bool trans_MFLO1(DisasContext *ctx, arg_rtype *a)
34 gen_store_gpr(cpu_LO[1], a->rd);
36 return true;
39 static bool trans_MTHI1(DisasContext *ctx, arg_rtype *a)
41 gen_load_gpr(cpu_HI[1], a->rs);
43 return true;
46 static bool trans_MTLO1(DisasContext *ctx, arg_rtype *a)
48 gen_load_gpr(cpu_LO[1], a->rs);
50 return true;
53 /* Parallel Copy Halfword */
54 static bool trans_PCPYH(DisasContext *s, arg_rtype *a)
56 if (a->rd == 0) {
57 /* nop */
58 return true;
61 if (a->rt == 0) {
62 tcg_gen_movi_i64(cpu_gpr[a->rd], 0);
63 tcg_gen_movi_i64(cpu_gpr_hi[a->rd], 0);
64 return true;
67 tcg_gen_deposit_i64(cpu_gpr[a->rd], cpu_gpr[a->rt], cpu_gpr[a->rt], 16, 16);
68 tcg_gen_deposit_i64(cpu_gpr[a->rd], cpu_gpr[a->rd], cpu_gpr[a->rd], 32, 32);
69 tcg_gen_deposit_i64(cpu_gpr_hi[a->rd], cpu_gpr_hi[a->rt], cpu_gpr_hi[a->rt], 16, 16);
70 tcg_gen_deposit_i64(cpu_gpr_hi[a->rd], cpu_gpr_hi[a->rd], cpu_gpr_hi[a->rd], 32, 32);
72 return true;
75 /* Parallel Copy Lower Doubleword */
76 static bool trans_PCPYLD(DisasContext *s, arg_rtype *a)
78 if (a->rd == 0) {
79 /* nop */
80 return true;
83 if (a->rs == 0) {
84 tcg_gen_movi_i64(cpu_gpr_hi[a->rd], 0);
85 } else {
86 tcg_gen_mov_i64(cpu_gpr_hi[a->rd], cpu_gpr[a->rs]);
89 if (a->rt == 0) {
90 tcg_gen_movi_i64(cpu_gpr[a->rd], 0);
91 } else if (a->rd != a->rt) {
92 tcg_gen_mov_i64(cpu_gpr[a->rd], cpu_gpr[a->rt]);
95 return true;
98 /* Parallel Copy Upper Doubleword */
99 static bool trans_PCPYUD(DisasContext *s, arg_rtype *a)
101 if (a->rd == 0) {
102 /* nop */
103 return true;
106 gen_load_gpr_hi(cpu_gpr[a->rd], a->rs);
108 if (a->rt == 0) {
109 tcg_gen_movi_i64(cpu_gpr_hi[a->rd], 0);
110 } else if (a->rd != a->rt) {
111 tcg_gen_mov_i64(cpu_gpr_hi[a->rd], cpu_gpr_hi[a->rt]);
114 return true;