qapi: Improve specificity of type/member descriptions
[qemu/armbru.git] / target / mips / tcg / octeon_translate.c
blob103c304d104dbe4df168eba4ee3e09dfa3c8304e
1 /*
2 * Octeon-specific instructions translation routines
4 * Copyright (c) 2022 Pavel Dovgalyuk
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
9 #include "qemu/osdep.h"
10 #include "tcg/tcg-op.h"
11 #include "tcg/tcg-op-gvec.h"
12 #include "exec/helper-gen.h"
13 #include "translate.h"
15 /* Include the auto-generated decoder. */
16 #include "decode-octeon.c.inc"
18 static bool trans_BBIT(DisasContext *ctx, arg_BBIT *a)
20 TCGv p;
22 if (ctx->hflags & MIPS_HFLAG_BMASK) {
23 LOG_DISAS("Branch in delay / forbidden slot at PC 0x"
24 TARGET_FMT_lx "\n", ctx->base.pc_next);
25 generate_exception_end(ctx, EXCP_RI);
26 return true;
29 /* Load needed operands */
30 TCGv t0 = tcg_temp_new();
31 gen_load_gpr(t0, a->rs);
33 p = tcg_constant_tl(1ULL << a->p);
34 if (a->set) {
35 tcg_gen_and_tl(bcond, p, t0);
36 } else {
37 tcg_gen_andc_tl(bcond, p, t0);
40 ctx->hflags |= MIPS_HFLAG_BC;
41 ctx->btarget = ctx->base.pc_next + 4 + a->offset * 4;
42 ctx->hflags |= MIPS_HFLAG_BDS32;
43 return true;
46 static bool trans_BADDU(DisasContext *ctx, arg_BADDU *a)
48 TCGv t0, t1;
50 if (a->rt == 0) {
51 /* nop */
52 return true;
55 t0 = tcg_temp_new();
56 t1 = tcg_temp_new();
57 gen_load_gpr(t0, a->rs);
58 gen_load_gpr(t1, a->rt);
60 tcg_gen_add_tl(t0, t0, t1);
61 tcg_gen_andi_i64(cpu_gpr[a->rd], t0, 0xff);
62 return true;
65 static bool trans_DMUL(DisasContext *ctx, arg_DMUL *a)
67 TCGv t0, t1;
69 if (a->rt == 0) {
70 /* nop */
71 return true;
74 t0 = tcg_temp_new();
75 t1 = tcg_temp_new();
76 gen_load_gpr(t0, a->rs);
77 gen_load_gpr(t1, a->rt);
79 tcg_gen_mul_i64(cpu_gpr[a->rd], t0, t1);
80 return true;
83 static bool trans_EXTS(DisasContext *ctx, arg_EXTS *a)
85 TCGv t0;
87 if (a->rt == 0) {
88 /* nop */
89 return true;
92 t0 = tcg_temp_new();
93 gen_load_gpr(t0, a->rs);
94 tcg_gen_sextract_tl(t0, t0, a->p, a->lenm1 + 1);
95 gen_store_gpr(t0, a->rt);
96 return true;
99 static bool trans_CINS(DisasContext *ctx, arg_CINS *a)
101 TCGv t0;
103 if (a->rt == 0) {
104 /* nop */
105 return true;
108 t0 = tcg_temp_new();
109 gen_load_gpr(t0, a->rs);
110 tcg_gen_deposit_z_tl(t0, t0, a->p, a->lenm1 + 1);
111 gen_store_gpr(t0, a->rt);
112 return true;
115 static bool trans_POP(DisasContext *ctx, arg_POP *a)
117 TCGv t0;
119 if (a->rd == 0) {
120 /* nop */
121 return true;
124 t0 = tcg_temp_new();
125 gen_load_gpr(t0, a->rs);
126 if (!a->dw) {
127 tcg_gen_andi_i64(t0, t0, 0xffffffff);
129 tcg_gen_ctpop_tl(t0, t0);
130 gen_store_gpr(t0, a->rd);
131 return true;
134 static bool trans_SEQNE(DisasContext *ctx, arg_SEQNE *a)
136 TCGv t0, t1;
138 if (a->rd == 0) {
139 /* nop */
140 return true;
143 t0 = tcg_temp_new();
144 t1 = tcg_temp_new();
146 gen_load_gpr(t0, a->rs);
147 gen_load_gpr(t1, a->rt);
149 if (a->ne) {
150 tcg_gen_setcond_tl(TCG_COND_NE, cpu_gpr[a->rd], t1, t0);
151 } else {
152 tcg_gen_setcond_tl(TCG_COND_EQ, cpu_gpr[a->rd], t1, t0);
154 return true;
157 static bool trans_SEQNEI(DisasContext *ctx, arg_SEQNEI *a)
159 TCGv t0;
161 if (a->rt == 0) {
162 /* nop */
163 return true;
166 t0 = tcg_temp_new();
168 gen_load_gpr(t0, a->rs);
170 /* Sign-extend to 64 bit value */
171 target_ulong imm = a->imm;
172 if (a->ne) {
173 tcg_gen_setcondi_tl(TCG_COND_NE, cpu_gpr[a->rt], t0, imm);
174 } else {
175 tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_gpr[a->rt], t0, imm);
177 return true;