xref: /qemu/target/ppc/translate/dfp-impl.c.inc (revision ad75a51e)
1139c1837SPaolo Bonzini/*** Decimal Floating Point ***/
2139c1837SPaolo Bonzini
3139c1837SPaolo Bonzinistatic inline TCGv_ptr gen_fprp_ptr(int reg)
4139c1837SPaolo Bonzini{
5139c1837SPaolo Bonzini    TCGv_ptr r = tcg_temp_new_ptr();
6ad75a51eSRichard Henderson    tcg_gen_addi_ptr(r, tcg_env, offsetof(CPUPPCState, vsr[reg].u64[0]));
7139c1837SPaolo Bonzini    return r;
8139c1837SPaolo Bonzini}
9139c1837SPaolo Bonzini
10afdc9310SLuis Pires#define TRANS_DFP_T_A_B_Rc(NAME)                             \
11afdc9310SLuis Piresstatic bool trans_##NAME(DisasContext *ctx, arg_##NAME *a)   \
12139c1837SPaolo Bonzini{                                                            \
13afdc9310SLuis Pires    TCGv_ptr rt, ra, rb;                                     \
14afdc9310SLuis Pires    REQUIRE_INSNS_FLAGS2(ctx, DFP);                          \
15afdc9310SLuis Pires    REQUIRE_FPU(ctx);                                        \
16afdc9310SLuis Pires    rt = gen_fprp_ptr(a->rt);                                \
17afdc9310SLuis Pires    ra = gen_fprp_ptr(a->ra);                                \
18afdc9310SLuis Pires    rb = gen_fprp_ptr(a->rb);                                \
19ad75a51eSRichard Henderson    gen_helper_##NAME(tcg_env, rt, ra, rb);                  \
20afdc9310SLuis Pires    if (unlikely(a->rc)) {                                   \
21139c1837SPaolo Bonzini        gen_set_cr1_from_fpscr(ctx);                         \
22139c1837SPaolo Bonzini    }                                                        \
23afdc9310SLuis Pires    return true;                                             \
24139c1837SPaolo Bonzini}
25139c1837SPaolo Bonzini
2685c38a46SLuis Pires#define TRANS_DFP_BF_A_B(NAME)                               \
2785c38a46SLuis Piresstatic bool trans_##NAME(DisasContext *ctx, arg_##NAME *a)   \
28139c1837SPaolo Bonzini{                                                            \
29139c1837SPaolo Bonzini    TCGv_ptr ra, rb;                                         \
3085c38a46SLuis Pires    REQUIRE_INSNS_FLAGS2(ctx, DFP);                          \
3185c38a46SLuis Pires    REQUIRE_FPU(ctx);                                        \
3285c38a46SLuis Pires    ra = gen_fprp_ptr(a->ra);                                \
3385c38a46SLuis Pires    rb = gen_fprp_ptr(a->rb);                                \
3485c38a46SLuis Pires    gen_helper_##NAME(cpu_crf[a->bf],                        \
35ad75a51eSRichard Henderson                      tcg_env, ra, rb);                      \
3685c38a46SLuis Pires    return true;                                             \
37139c1837SPaolo Bonzini}
38139c1837SPaolo Bonzini
3985c38a46SLuis Pires#define TRANS_DFP_BF_I_B(NAME)                               \
4085c38a46SLuis Piresstatic bool trans_##NAME(DisasContext *ctx, arg_##NAME *a)   \
41139c1837SPaolo Bonzini{                                                            \
42139c1837SPaolo Bonzini    TCGv_ptr rb;                                             \
4385c38a46SLuis Pires    REQUIRE_INSNS_FLAGS2(ctx, DFP);                          \
4485c38a46SLuis Pires    REQUIRE_FPU(ctx);                                        \
4585c38a46SLuis Pires    rb = gen_fprp_ptr(a->rb);                                \
4685c38a46SLuis Pires    gen_helper_##NAME(cpu_crf[a->bf],                        \
47ad75a51eSRichard Henderson                      tcg_env, tcg_constant_i32(a->uim), rb);\
4885c38a46SLuis Pires    return true;                                             \
49139c1837SPaolo Bonzini}
50139c1837SPaolo Bonzini
5187bc8e52SLuis Pires#define TRANS_DFP_BF_A_DCM(NAME)                             \
5287bc8e52SLuis Piresstatic bool trans_##NAME(DisasContext *ctx, arg_##NAME *a)   \
53139c1837SPaolo Bonzini{                                                            \
54139c1837SPaolo Bonzini    TCGv_ptr ra;                                             \
5587bc8e52SLuis Pires    REQUIRE_INSNS_FLAGS2(ctx, DFP);                          \
5687bc8e52SLuis Pires    REQUIRE_FPU(ctx);                                        \
5787bc8e52SLuis Pires    ra = gen_fprp_ptr(a->fra);                               \
5887bc8e52SLuis Pires    gen_helper_##NAME(cpu_crf[a->bf],                        \
59ad75a51eSRichard Henderson                      tcg_env, ra, tcg_constant_i32(a->dm)); \
6087bc8e52SLuis Pires    return true;                                             \
61139c1837SPaolo Bonzini}
62139c1837SPaolo Bonzini
6378464edbSLuis Pires#define TRANS_DFP_T_B_U32_U32_Rc(NAME, U32F1, U32F2)         \
6478464edbSLuis Piresstatic bool trans_##NAME(DisasContext *ctx, arg_##NAME *a)   \
65139c1837SPaolo Bonzini{                                                            \
66139c1837SPaolo Bonzini    TCGv_ptr rt, rb;                                         \
6778464edbSLuis Pires    REQUIRE_INSNS_FLAGS2(ctx, DFP);                          \
6878464edbSLuis Pires    REQUIRE_FPU(ctx);                                        \
6978464edbSLuis Pires    rt = gen_fprp_ptr(a->frt);                               \
7078464edbSLuis Pires    rb = gen_fprp_ptr(a->frb);                               \
71ad75a51eSRichard Henderson    gen_helper_##NAME(tcg_env, rt, rb,                       \
7278464edbSLuis Pires                      tcg_constant_i32(a->U32F1),            \
7378464edbSLuis Pires                      tcg_constant_i32(a->U32F2));           \
7478464edbSLuis Pires    if (unlikely(a->rc)) {                                   \
75139c1837SPaolo Bonzini        gen_set_cr1_from_fpscr(ctx);                         \
76139c1837SPaolo Bonzini    }                                                        \
7778464edbSLuis Pires    return true;                                             \
78139c1837SPaolo Bonzini}
79139c1837SPaolo Bonzini
80a8f4bce6SLuis Pires#define TRANS_DFP_T_A_B_I32_Rc(NAME, I32FLD)                 \
81a8f4bce6SLuis Piresstatic bool trans_##NAME(DisasContext *ctx, arg_##NAME *a)   \
82139c1837SPaolo Bonzini{                                                            \
83139c1837SPaolo Bonzini    TCGv_ptr rt, ra, rb;                                     \
84a8f4bce6SLuis Pires    REQUIRE_INSNS_FLAGS2(ctx, DFP);                          \
85a8f4bce6SLuis Pires    REQUIRE_FPU(ctx);                                        \
86a8f4bce6SLuis Pires    rt = gen_fprp_ptr(a->frt);                               \
87a8f4bce6SLuis Pires    ra = gen_fprp_ptr(a->fra);                               \
88a8f4bce6SLuis Pires    rb = gen_fprp_ptr(a->frb);                               \
89ad75a51eSRichard Henderson    gen_helper_##NAME(tcg_env, rt, ra, rb,                   \
90a8f4bce6SLuis Pires                      tcg_constant_i32(a->I32FLD));          \
91a8f4bce6SLuis Pires    if (unlikely(a->rc)) {                                   \
92139c1837SPaolo Bonzini        gen_set_cr1_from_fpscr(ctx);                         \
93139c1837SPaolo Bonzini    }                                                        \
94a8f4bce6SLuis Pires    return true;                                             \
95139c1837SPaolo Bonzini}
96139c1837SPaolo Bonzini
97c8ef4d1eSLuis Pires#define TRANS_DFP_T_B_Rc(NAME)                               \
98c8ef4d1eSLuis Piresstatic bool trans_##NAME(DisasContext *ctx, arg_##NAME *a)   \
99139c1837SPaolo Bonzini{                                                            \
100139c1837SPaolo Bonzini    TCGv_ptr rt, rb;                                         \
101c8ef4d1eSLuis Pires    REQUIRE_INSNS_FLAGS2(ctx, DFP);                          \
102c8ef4d1eSLuis Pires    REQUIRE_FPU(ctx);                                        \
103c8ef4d1eSLuis Pires    rt = gen_fprp_ptr(a->rt);                                \
104c8ef4d1eSLuis Pires    rb = gen_fprp_ptr(a->rb);                                \
105ad75a51eSRichard Henderson    gen_helper_##NAME(tcg_env, rt, rb);                      \
106c8ef4d1eSLuis Pires    if (unlikely(a->rc)) {                                   \
107139c1837SPaolo Bonzini        gen_set_cr1_from_fpscr(ctx);                         \
108139c1837SPaolo Bonzini    }                                                        \
109c8ef4d1eSLuis Pires    return true;                                             \
110139c1837SPaolo Bonzini}
111139c1837SPaolo Bonzini
112a2329747SLuis Pires#define TRANS_DFP_T_FPR_I32_Rc(NAME, FPRFLD, I32FLD)         \
113a2329747SLuis Piresstatic bool trans_##NAME(DisasContext *ctx, arg_##NAME *a)   \
114139c1837SPaolo Bonzini{                                                            \
115a2329747SLuis Pires    TCGv_ptr rt, rx;                                         \
116a2329747SLuis Pires    REQUIRE_INSNS_FLAGS2(ctx, DFP);                          \
117a2329747SLuis Pires    REQUIRE_FPU(ctx);                                        \
118a2329747SLuis Pires    rt = gen_fprp_ptr(a->rt);                                \
119a2329747SLuis Pires    rx = gen_fprp_ptr(a->FPRFLD);                            \
120ad75a51eSRichard Henderson    gen_helper_##NAME(tcg_env, rt, rx,                       \
121a2329747SLuis Pires                      tcg_constant_i32(a->I32FLD));          \
122a2329747SLuis Pires    if (unlikely(a->rc)) {                                   \
123139c1837SPaolo Bonzini        gen_set_cr1_from_fpscr(ctx);                         \
124139c1837SPaolo Bonzini    }                                                        \
125a2329747SLuis Pires    return true;                                             \
126139c1837SPaolo Bonzini}
127139c1837SPaolo Bonzini
128afdc9310SLuis PiresTRANS_DFP_T_A_B_Rc(DADD)
129afdc9310SLuis PiresTRANS_DFP_T_A_B_Rc(DADDQ)
130afdc9310SLuis PiresTRANS_DFP_T_A_B_Rc(DSUB)
131afdc9310SLuis PiresTRANS_DFP_T_A_B_Rc(DSUBQ)
132afdc9310SLuis PiresTRANS_DFP_T_A_B_Rc(DMUL)
133afdc9310SLuis PiresTRANS_DFP_T_A_B_Rc(DMULQ)
134afdc9310SLuis PiresTRANS_DFP_T_A_B_Rc(DDIV)
135afdc9310SLuis PiresTRANS_DFP_T_A_B_Rc(DDIVQ)
13685c38a46SLuis PiresTRANS_DFP_BF_A_B(DCMPU)
13785c38a46SLuis PiresTRANS_DFP_BF_A_B(DCMPUQ)
13885c38a46SLuis PiresTRANS_DFP_BF_A_B(DCMPO)
13985c38a46SLuis PiresTRANS_DFP_BF_A_B(DCMPOQ)
14087bc8e52SLuis PiresTRANS_DFP_BF_A_DCM(DTSTDC)
14187bc8e52SLuis PiresTRANS_DFP_BF_A_DCM(DTSTDCQ)
14287bc8e52SLuis PiresTRANS_DFP_BF_A_DCM(DTSTDG)
14387bc8e52SLuis PiresTRANS_DFP_BF_A_DCM(DTSTDGQ)
14485c38a46SLuis PiresTRANS_DFP_BF_A_B(DTSTEX)
14585c38a46SLuis PiresTRANS_DFP_BF_A_B(DTSTEXQ)
14685c38a46SLuis PiresTRANS_DFP_BF_A_B(DTSTSF)
14785c38a46SLuis PiresTRANS_DFP_BF_A_B(DTSTSFQ)
14885c38a46SLuis PiresTRANS_DFP_BF_I_B(DTSTSFI)
14985c38a46SLuis PiresTRANS_DFP_BF_I_B(DTSTSFIQ)
15078464edbSLuis PiresTRANS_DFP_T_B_U32_U32_Rc(DQUAI, te, rmc)
15178464edbSLuis PiresTRANS_DFP_T_B_U32_U32_Rc(DQUAIQ, te, rmc)
152a8f4bce6SLuis PiresTRANS_DFP_T_A_B_I32_Rc(DQUA, rmc)
153a8f4bce6SLuis PiresTRANS_DFP_T_A_B_I32_Rc(DQUAQ, rmc)
154a8f4bce6SLuis PiresTRANS_DFP_T_A_B_I32_Rc(DRRND, rmc)
155a8f4bce6SLuis PiresTRANS_DFP_T_A_B_I32_Rc(DRRNDQ, rmc)
15678464edbSLuis PiresTRANS_DFP_T_B_U32_U32_Rc(DRINTX, r, rmc)
15778464edbSLuis PiresTRANS_DFP_T_B_U32_U32_Rc(DRINTXQ, r, rmc)
15878464edbSLuis PiresTRANS_DFP_T_B_U32_U32_Rc(DRINTN, r, rmc)
15978464edbSLuis PiresTRANS_DFP_T_B_U32_U32_Rc(DRINTNQ, r, rmc)
160c8ef4d1eSLuis PiresTRANS_DFP_T_B_Rc(DCTDP)
161c8ef4d1eSLuis PiresTRANS_DFP_T_B_Rc(DCTQPQ)
162c8ef4d1eSLuis PiresTRANS_DFP_T_B_Rc(DRSP)
163c8ef4d1eSLuis PiresTRANS_DFP_T_B_Rc(DRDPQ)
164c8ef4d1eSLuis PiresTRANS_DFP_T_B_Rc(DCFFIX)
165c8ef4d1eSLuis PiresTRANS_DFP_T_B_Rc(DCFFIXQ)
166c8ef4d1eSLuis PiresTRANS_DFP_T_B_Rc(DCTFIX)
167c8ef4d1eSLuis PiresTRANS_DFP_T_B_Rc(DCTFIXQ)
168a2329747SLuis PiresTRANS_DFP_T_FPR_I32_Rc(DDEDPD, rb, sp)
169a2329747SLuis PiresTRANS_DFP_T_FPR_I32_Rc(DDEDPDQ, rb, sp)
170a2329747SLuis PiresTRANS_DFP_T_FPR_I32_Rc(DENBCD, rb, s)
171a2329747SLuis PiresTRANS_DFP_T_FPR_I32_Rc(DENBCDQ, rb, s)
172c8ef4d1eSLuis PiresTRANS_DFP_T_B_Rc(DXEX)
173c8ef4d1eSLuis PiresTRANS_DFP_T_B_Rc(DXEXQ)
174afdc9310SLuis PiresTRANS_DFP_T_A_B_Rc(DIEX)
175afdc9310SLuis PiresTRANS_DFP_T_A_B_Rc(DIEXQ)
176a2329747SLuis PiresTRANS_DFP_T_FPR_I32_Rc(DSCLI, ra, sh)
177a2329747SLuis PiresTRANS_DFP_T_FPR_I32_Rc(DSCLIQ, ra, sh)
178a2329747SLuis PiresTRANS_DFP_T_FPR_I32_Rc(DSCRI, ra, sh)
179a2329747SLuis PiresTRANS_DFP_T_FPR_I32_Rc(DSCRIQ, ra, sh)
180d39b2cc7SLuis Pires
181d39b2cc7SLuis Piresstatic bool trans_DCFFIXQQ(DisasContext *ctx, arg_DCFFIXQQ *a)
182d39b2cc7SLuis Pires{
183d39b2cc7SLuis Pires    TCGv_ptr rt, rb;
184d39b2cc7SLuis Pires
185d39b2cc7SLuis Pires    REQUIRE_INSNS_FLAGS2(ctx, DFP);
186d39b2cc7SLuis Pires    REQUIRE_FPU(ctx);
187d39b2cc7SLuis Pires    REQUIRE_VECTOR(ctx);
188d39b2cc7SLuis Pires
189d39b2cc7SLuis Pires    rt = gen_fprp_ptr(a->frtp);
190d39b2cc7SLuis Pires    rb = gen_avr_ptr(a->vrb);
191ad75a51eSRichard Henderson    gen_helper_DCFFIXQQ(tcg_env, rt, rb);
192d39b2cc7SLuis Pires
193d39b2cc7SLuis Pires    return true;
194d39b2cc7SLuis Pires}
195328747f3SLuis Pires
196328747f3SLuis Piresstatic bool trans_DCTFIXQQ(DisasContext *ctx, arg_DCTFIXQQ *a)
197328747f3SLuis Pires{
198328747f3SLuis Pires    TCGv_ptr rt, rb;
199328747f3SLuis Pires
200328747f3SLuis Pires    REQUIRE_INSNS_FLAGS2(ctx, DFP);
201328747f3SLuis Pires    REQUIRE_FPU(ctx);
202328747f3SLuis Pires    REQUIRE_VECTOR(ctx);
203328747f3SLuis Pires
204328747f3SLuis Pires    rt = gen_avr_ptr(a->vrt);
205328747f3SLuis Pires    rb = gen_fprp_ptr(a->frbp);
206ad75a51eSRichard Henderson    gen_helper_DCTFIXQQ(tcg_env, rt, rb);
207328747f3SLuis Pires
208328747f3SLuis Pires    return true;
209328747f3SLuis Pires}
210