]> Git Repo - qemu.git/blob - target/loongarch/insn_trans/trans_farith.c.inc
target/loongarch: Add floating point arithmetic instruction translation
[qemu.git] / target / loongarch / insn_trans / trans_farith.c.inc
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (c) 2021 Loongson Technology Corporation Limited
4  */
5
6 static bool gen_fff(DisasContext *ctx, arg_fff *a,
7                     void (*func)(TCGv, TCGv_env, TCGv, TCGv))
8 {
9     func(cpu_fpr[a->fd], cpu_env, cpu_fpr[a->fj], cpu_fpr[a->fk]);
10     return true;
11 }
12
13 static bool gen_ff(DisasContext *ctx, arg_ff *a,
14                    void (*func)(TCGv, TCGv_env, TCGv))
15 {
16     func(cpu_fpr[a->fd], cpu_env, cpu_fpr[a->fj]);
17     return true;
18 }
19
20 static bool gen_muladd(DisasContext *ctx, arg_ffff *a,
21                        void (*func)(TCGv, TCGv_env, TCGv, TCGv, TCGv, TCGv_i32),
22                        int flag)
23 {
24     TCGv_i32 tflag = tcg_constant_i32(flag);
25     func(cpu_fpr[a->fd], cpu_env, cpu_fpr[a->fj],
26          cpu_fpr[a->fk], cpu_fpr[a->fa], tflag);
27     return true;
28 }
29
30 static bool trans_fcopysign_s(DisasContext *ctx, arg_fcopysign_s *a)
31 {
32     tcg_gen_deposit_i64(cpu_fpr[a->fd], cpu_fpr[a->fk], cpu_fpr[a->fj], 0, 31);
33     return true;
34 }
35
36 static bool trans_fcopysign_d(DisasContext *ctx, arg_fcopysign_d *a)
37 {
38     tcg_gen_deposit_i64(cpu_fpr[a->fd], cpu_fpr[a->fk], cpu_fpr[a->fj], 0, 63);
39     return true;
40 }
41
42 static bool trans_fabs_s(DisasContext *ctx, arg_fabs_s *a)
43 {
44     tcg_gen_andi_i64(cpu_fpr[a->fd], cpu_fpr[a->fj], MAKE_64BIT_MASK(0, 31));
45     gen_nanbox_s(cpu_fpr[a->fd], cpu_fpr[a->fd]);
46     return true;
47 }
48
49 static bool trans_fabs_d(DisasContext *ctx, arg_fabs_d *a)
50 {
51     tcg_gen_andi_i64(cpu_fpr[a->fd], cpu_fpr[a->fj], MAKE_64BIT_MASK(0, 63));
52     return true;
53 }
54
55 static bool trans_fneg_s(DisasContext *ctx, arg_fneg_s *a)
56 {
57     tcg_gen_xori_i64(cpu_fpr[a->fd], cpu_fpr[a->fj], 0x80000000);
58     gen_nanbox_s(cpu_fpr[a->fd], cpu_fpr[a->fd]);
59     return true;
60 }
61
62 static bool trans_fneg_d(DisasContext *ctx, arg_fneg_d *a)
63 {
64     tcg_gen_xori_i64(cpu_fpr[a->fd], cpu_fpr[a->fj], 0x8000000000000000LL);
65     return true;
66 }
67
68 TRANS(fadd_s, gen_fff, gen_helper_fadd_s)
69 TRANS(fadd_d, gen_fff, gen_helper_fadd_d)
70 TRANS(fsub_s, gen_fff, gen_helper_fsub_s)
71 TRANS(fsub_d, gen_fff, gen_helper_fsub_d)
72 TRANS(fmul_s, gen_fff, gen_helper_fmul_s)
73 TRANS(fmul_d, gen_fff, gen_helper_fmul_d)
74 TRANS(fdiv_s, gen_fff, gen_helper_fdiv_s)
75 TRANS(fdiv_d, gen_fff, gen_helper_fdiv_d)
76 TRANS(fmax_s, gen_fff, gen_helper_fmax_s)
77 TRANS(fmax_d, gen_fff, gen_helper_fmax_d)
78 TRANS(fmin_s, gen_fff, gen_helper_fmin_s)
79 TRANS(fmin_d, gen_fff, gen_helper_fmin_d)
80 TRANS(fmaxa_s, gen_fff, gen_helper_fmaxa_s)
81 TRANS(fmaxa_d, gen_fff, gen_helper_fmaxa_d)
82 TRANS(fmina_s, gen_fff, gen_helper_fmina_s)
83 TRANS(fmina_d, gen_fff, gen_helper_fmina_d)
84 TRANS(fscaleb_s, gen_fff, gen_helper_fscaleb_s)
85 TRANS(fscaleb_d, gen_fff, gen_helper_fscaleb_d)
86 TRANS(fsqrt_s, gen_ff, gen_helper_fsqrt_s)
87 TRANS(fsqrt_d, gen_ff, gen_helper_fsqrt_d)
88 TRANS(frecip_s, gen_ff, gen_helper_frecip_s)
89 TRANS(frecip_d, gen_ff, gen_helper_frecip_d)
90 TRANS(frsqrt_s, gen_ff, gen_helper_frsqrt_s)
91 TRANS(frsqrt_d, gen_ff, gen_helper_frsqrt_d)
92 TRANS(flogb_s, gen_ff, gen_helper_flogb_s)
93 TRANS(flogb_d, gen_ff, gen_helper_flogb_d)
94 TRANS(fclass_s, gen_ff, gen_helper_fclass_s)
95 TRANS(fclass_d, gen_ff, gen_helper_fclass_d)
96 TRANS(fmadd_s, gen_muladd, gen_helper_fmuladd_s, 0)
97 TRANS(fmadd_d, gen_muladd, gen_helper_fmuladd_d, 0)
98 TRANS(fmsub_s, gen_muladd, gen_helper_fmuladd_s, float_muladd_negate_c)
99 TRANS(fmsub_d, gen_muladd, gen_helper_fmuladd_d, float_muladd_negate_c)
100 TRANS(fnmadd_s, gen_muladd, gen_helper_fmuladd_s,
101       float_muladd_negate_product | float_muladd_negate_c)
102 TRANS(fnmadd_d, gen_muladd, gen_helper_fmuladd_d,
103       float_muladd_negate_product | float_muladd_negate_c)
104 TRANS(fnmsub_s, gen_muladd, gen_helper_fmuladd_s, float_muladd_negate_product)
105 TRANS(fnmsub_d, gen_muladd, gen_helper_fmuladd_d, float_muladd_negate_product)
This page took 0.027853 seconds and 4 git commands to generate.