1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (c) 2021 Loongson Technology Corporation Limited
6 static void maybe_nanbox_load(TCGv freg, MemOp mop)
8 if ((mop & MO_SIZE) == MO_32) {
9 gen_nanbox_s(freg, freg);
13 static bool gen_fload_i(DisasContext *ctx, arg_fr_i *a, MemOp mop)
15 TCGv addr = gpr_src(ctx, a->rj, EXT_NONE);
19 temp = tcg_temp_new();
20 tcg_gen_addi_tl(temp, addr, a->imm);
24 tcg_gen_qemu_ld_tl(cpu_fpr[a->fd], addr, ctx->mem_idx, mop);
25 maybe_nanbox_load(cpu_fpr[a->fd], mop);
34 static bool gen_fstore_i(DisasContext *ctx, arg_fr_i *a, MemOp mop)
36 TCGv addr = gpr_src(ctx, a->rj, EXT_NONE);
40 temp = tcg_temp_new();
41 tcg_gen_addi_tl(temp, addr, a->imm);
45 tcg_gen_qemu_st_tl(cpu_fpr[a->fd], addr, ctx->mem_idx, mop);
53 static bool gen_floadx(DisasContext *ctx, arg_frr *a, MemOp mop)
55 TCGv src1 = gpr_src(ctx, a->rj, EXT_NONE);
56 TCGv src2 = gpr_src(ctx, a->rk, EXT_NONE);
57 TCGv addr = tcg_temp_new();
59 tcg_gen_add_tl(addr, src1, src2);
60 tcg_gen_qemu_ld_tl(cpu_fpr[a->fd], addr, ctx->mem_idx, mop);
61 maybe_nanbox_load(cpu_fpr[a->fd], mop);
67 static bool gen_fstorex(DisasContext *ctx, arg_frr *a, MemOp mop)
69 TCGv src1 = gpr_src(ctx, a->rj, EXT_NONE);
70 TCGv src2 = gpr_src(ctx, a->rk, EXT_NONE);
71 TCGv addr = tcg_temp_new();
73 tcg_gen_add_tl(addr, src1, src2);
74 tcg_gen_qemu_st_tl(cpu_fpr[a->fd], addr, ctx->mem_idx, mop);
80 static bool gen_fload_gt(DisasContext *ctx, arg_frr *a, MemOp mop)
82 TCGv src1 = gpr_src(ctx, a->rj, EXT_NONE);
83 TCGv src2 = gpr_src(ctx, a->rk, EXT_NONE);
84 TCGv addr = tcg_temp_new();
86 gen_helper_asrtgt_d(cpu_env, src1, src2);
87 tcg_gen_add_tl(addr, src1, src2);
88 tcg_gen_qemu_ld_tl(cpu_fpr[a->fd], addr, ctx->mem_idx, mop);
89 maybe_nanbox_load(cpu_fpr[a->fd], mop);
95 static bool gen_fstore_gt(DisasContext *ctx, arg_frr *a, MemOp mop)
97 TCGv src1 = gpr_src(ctx, a->rj, EXT_NONE);
98 TCGv src2 = gpr_src(ctx, a->rk, EXT_NONE);
99 TCGv addr = tcg_temp_new();
101 gen_helper_asrtgt_d(cpu_env, src1, src2);
102 tcg_gen_add_tl(addr, src1, src2);
103 tcg_gen_qemu_st_tl(cpu_fpr[a->fd], addr, ctx->mem_idx, mop);
109 static bool gen_fload_le(DisasContext *ctx, arg_frr *a, MemOp mop)
111 TCGv src1 = gpr_src(ctx, a->rj, EXT_NONE);
112 TCGv src2 = gpr_src(ctx, a->rk, EXT_NONE);
113 TCGv addr = tcg_temp_new();
115 gen_helper_asrtle_d(cpu_env, src1, src2);
116 tcg_gen_add_tl(addr, src1, src2);
117 tcg_gen_qemu_ld_tl(cpu_fpr[a->fd], addr, ctx->mem_idx, mop);
118 maybe_nanbox_load(cpu_fpr[a->fd], mop);
124 static bool gen_fstore_le(DisasContext *ctx, arg_frr *a, MemOp mop)
126 TCGv src1 = gpr_src(ctx, a->rj, EXT_NONE);
127 TCGv src2 = gpr_src(ctx, a->rk, EXT_NONE);
128 TCGv addr = tcg_temp_new();
130 gen_helper_asrtle_d(cpu_env, src1, src2);
131 tcg_gen_add_tl(addr, src1, src2);
132 tcg_gen_qemu_st_tl(cpu_fpr[a->fd], addr, ctx->mem_idx, mop);
138 TRANS(fld_s, gen_fload_i, MO_TEUL)
139 TRANS(fst_s, gen_fstore_i, MO_TEUL)
140 TRANS(fld_d, gen_fload_i, MO_TEUQ)
141 TRANS(fst_d, gen_fstore_i, MO_TEUQ)
142 TRANS(fldx_s, gen_floadx, MO_TEUL)
143 TRANS(fldx_d, gen_floadx, MO_TEUQ)
144 TRANS(fstx_s, gen_fstorex, MO_TEUL)
145 TRANS(fstx_d, gen_fstorex, MO_TEUQ)
146 TRANS(fldgt_s, gen_fload_gt, MO_TEUL)
147 TRANS(fldgt_d, gen_fload_gt, MO_TEUQ)
148 TRANS(fldle_s, gen_fload_le, MO_TEUL)
149 TRANS(fldle_d, gen_fload_le, MO_TEUQ)
150 TRANS(fstgt_s, gen_fstore_gt, MO_TEUL)
151 TRANS(fstgt_d, gen_fstore_gt, MO_TEUQ)
152 TRANS(fstle_s, gen_fstore_le, MO_TEUL)
153 TRANS(fstle_d, gen_fstore_le, MO_TEUQ)