1*a685f7d0SPhilippe Mathieu-Daudé /*
2*a685f7d0SPhilippe Mathieu-Daudé * Address Computation and Large Constant Instructions
3*a685f7d0SPhilippe Mathieu-Daudé *
4*a685f7d0SPhilippe Mathieu-Daudé * Copyright (c) 2004-2005 Jocelyn Mayer
5*a685f7d0SPhilippe Mathieu-Daudé * Copyright (c) 2006 Marius Groeger (FPU operations)
6*a685f7d0SPhilippe Mathieu-Daudé * Copyright (c) 2006 Thiemo Seufer (MIPS32R2 support)
7*a685f7d0SPhilippe Mathieu-Daudé * Copyright (c) 2009 CodeSourcery (MIPS16 and microMIPS support)
8*a685f7d0SPhilippe Mathieu-Daudé * Copyright (c) 2012 Jia Liu & Dongxue Zhang (MIPS ASE DSP support)
9*a685f7d0SPhilippe Mathieu-Daudé * Copyright (c) 2020 Philippe Mathieu-Daudé
10*a685f7d0SPhilippe Mathieu-Daudé *
11*a685f7d0SPhilippe Mathieu-Daudé * SPDX-License-Identifier: LGPL-2.1-or-later
12*a685f7d0SPhilippe Mathieu-Daudé */
13*a685f7d0SPhilippe Mathieu-Daudé #include "qemu/osdep.h"
14*a685f7d0SPhilippe Mathieu-Daudé #include "translate.h"
15*a685f7d0SPhilippe Mathieu-Daudé
gen_lsa(DisasContext * ctx,int rd,int rt,int rs,int sa)16*a685f7d0SPhilippe Mathieu-Daudé bool gen_lsa(DisasContext *ctx, int rd, int rt, int rs, int sa)
17*a685f7d0SPhilippe Mathieu-Daudé {
18*a685f7d0SPhilippe Mathieu-Daudé TCGv t0;
19*a685f7d0SPhilippe Mathieu-Daudé TCGv t1;
20*a685f7d0SPhilippe Mathieu-Daudé
21*a685f7d0SPhilippe Mathieu-Daudé if (rd == 0) {
22*a685f7d0SPhilippe Mathieu-Daudé /* Treat as NOP. */
23*a685f7d0SPhilippe Mathieu-Daudé return true;
24*a685f7d0SPhilippe Mathieu-Daudé }
25*a685f7d0SPhilippe Mathieu-Daudé t0 = tcg_temp_new();
26*a685f7d0SPhilippe Mathieu-Daudé t1 = tcg_temp_new();
27*a685f7d0SPhilippe Mathieu-Daudé gen_load_gpr(t0, rs);
28*a685f7d0SPhilippe Mathieu-Daudé gen_load_gpr(t1, rt);
29*a685f7d0SPhilippe Mathieu-Daudé tcg_gen_shli_tl(t0, t0, sa + 1);
30*a685f7d0SPhilippe Mathieu-Daudé tcg_gen_add_tl(cpu_gpr[rd], t0, t1);
31*a685f7d0SPhilippe Mathieu-Daudé tcg_gen_ext32s_tl(cpu_gpr[rd], cpu_gpr[rd]);
32*a685f7d0SPhilippe Mathieu-Daudé return true;
33*a685f7d0SPhilippe Mathieu-Daudé }
34*a685f7d0SPhilippe Mathieu-Daudé
gen_dlsa(DisasContext * ctx,int rd,int rt,int rs,int sa)35*a685f7d0SPhilippe Mathieu-Daudé bool gen_dlsa(DisasContext *ctx, int rd, int rt, int rs, int sa)
36*a685f7d0SPhilippe Mathieu-Daudé {
37*a685f7d0SPhilippe Mathieu-Daudé TCGv t0;
38*a685f7d0SPhilippe Mathieu-Daudé TCGv t1;
39*a685f7d0SPhilippe Mathieu-Daudé
40*a685f7d0SPhilippe Mathieu-Daudé check_mips_64(ctx);
41*a685f7d0SPhilippe Mathieu-Daudé
42*a685f7d0SPhilippe Mathieu-Daudé if (rd == 0) {
43*a685f7d0SPhilippe Mathieu-Daudé /* Treat as NOP. */
44*a685f7d0SPhilippe Mathieu-Daudé return true;
45*a685f7d0SPhilippe Mathieu-Daudé }
46*a685f7d0SPhilippe Mathieu-Daudé t0 = tcg_temp_new();
47*a685f7d0SPhilippe Mathieu-Daudé t1 = tcg_temp_new();
48*a685f7d0SPhilippe Mathieu-Daudé gen_load_gpr(t0, rs);
49*a685f7d0SPhilippe Mathieu-Daudé gen_load_gpr(t1, rt);
50*a685f7d0SPhilippe Mathieu-Daudé tcg_gen_shli_tl(t0, t0, sa + 1);
51*a685f7d0SPhilippe Mathieu-Daudé tcg_gen_add_tl(cpu_gpr[rd], t0, t1);
52*a685f7d0SPhilippe Mathieu-Daudé return true;
53*a685f7d0SPhilippe Mathieu-Daudé }
54