2 * Octeon-specific instructions translation routines
4 * Copyright (c) 2022 Pavel Dovgalyuk
6 * SPDX-License-Identifier: GPL-2.0-or-later
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
)
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
);
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
);
35 tcg_gen_and_tl(bcond
, p
, t0
);
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
;
46 static bool trans_BADDU(DisasContext
*ctx
, arg_BADDU
*a
)
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);
65 static bool trans_DMUL(DisasContext
*ctx
, arg_DMUL
*a
)
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
);
83 static bool trans_EXTS(DisasContext
*ctx
, arg_EXTS
*a
)
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
);
99 static bool trans_CINS(DisasContext
*ctx
, arg_CINS
*a
)
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
);
115 static bool trans_POP(DisasContext
*ctx
, arg_POP
*a
)
125 gen_load_gpr(t0
, a
->rs
);
127 tcg_gen_andi_i64(t0
, t0
, 0xffffffff);
129 tcg_gen_ctpop_tl(t0
, t0
);
130 gen_store_gpr(t0
, a
->rd
);
134 static bool trans_SEQNE(DisasContext
*ctx
, arg_SEQNE
*a
)
146 gen_load_gpr(t0
, a
->rs
);
147 gen_load_gpr(t1
, a
->rt
);
150 tcg_gen_setcond_tl(TCG_COND_NE
, cpu_gpr
[a
->rd
], t1
, t0
);
152 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_gpr
[a
->rd
], t1
, t0
);
157 static bool trans_SEQNEI(DisasContext
*ctx
, arg_SEQNEI
*a
)
168 gen_load_gpr(t0
, a
->rs
);
170 /* Sign-extend to 64 bit value */
171 target_ulong imm
= a
->imm
;
173 tcg_gen_setcondi_tl(TCG_COND_NE
, cpu_gpr
[a
->rt
], t0
, imm
);
175 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_gpr
[a
->rt
], t0
, imm
);