1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2da957e11SThomas Gleixner /*---------------------------------------------------------------------------+
3da957e11SThomas Gleixner | fpu_arith.c |
4da957e11SThomas Gleixner | |
5da957e11SThomas Gleixner | Code to implement the FPU register/register arithmetic instructions |
6da957e11SThomas Gleixner | |
7da957e11SThomas Gleixner | Copyright (C) 1992,1993,1997 |
8da957e11SThomas Gleixner | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
9da957e11SThomas Gleixner | E-mail billm@suburbia.net |
10da957e11SThomas Gleixner | |
11da957e11SThomas Gleixner | |
12da957e11SThomas Gleixner +---------------------------------------------------------------------------*/
13da957e11SThomas Gleixner
14da957e11SThomas Gleixner #include "fpu_system.h"
15da957e11SThomas Gleixner #include "fpu_emu.h"
16da957e11SThomas Gleixner #include "control_w.h"
17da957e11SThomas Gleixner #include "status_w.h"
18da957e11SThomas Gleixner
fadd__(void)19da957e11SThomas Gleixner void fadd__(void)
20da957e11SThomas Gleixner {
21da957e11SThomas Gleixner /* fadd st,st(i) */
22da957e11SThomas Gleixner int i = FPU_rm;
23da957e11SThomas Gleixner clear_C1();
24da957e11SThomas Gleixner FPU_add(&st(i), FPU_gettagi(i), 0, control_word);
25da957e11SThomas Gleixner }
26da957e11SThomas Gleixner
fmul__(void)27da957e11SThomas Gleixner void fmul__(void)
28da957e11SThomas Gleixner {
29da957e11SThomas Gleixner /* fmul st,st(i) */
30da957e11SThomas Gleixner int i = FPU_rm;
31da957e11SThomas Gleixner clear_C1();
32da957e11SThomas Gleixner FPU_mul(&st(i), FPU_gettagi(i), 0, control_word);
33da957e11SThomas Gleixner }
34da957e11SThomas Gleixner
fsub__(void)35da957e11SThomas Gleixner void fsub__(void)
36da957e11SThomas Gleixner {
37da957e11SThomas Gleixner /* fsub st,st(i) */
38da957e11SThomas Gleixner clear_C1();
39da957e11SThomas Gleixner FPU_sub(0, FPU_rm, control_word);
40da957e11SThomas Gleixner }
41da957e11SThomas Gleixner
fsubr_(void)42da957e11SThomas Gleixner void fsubr_(void)
43da957e11SThomas Gleixner {
44da957e11SThomas Gleixner /* fsubr st,st(i) */
45da957e11SThomas Gleixner clear_C1();
46da957e11SThomas Gleixner FPU_sub(REV, FPU_rm, control_word);
47da957e11SThomas Gleixner }
48da957e11SThomas Gleixner
fdiv__(void)49da957e11SThomas Gleixner void fdiv__(void)
50da957e11SThomas Gleixner {
51da957e11SThomas Gleixner /* fdiv st,st(i) */
52da957e11SThomas Gleixner clear_C1();
53da957e11SThomas Gleixner FPU_div(0, FPU_rm, control_word);
54da957e11SThomas Gleixner }
55da957e11SThomas Gleixner
fdivr_(void)56da957e11SThomas Gleixner void fdivr_(void)
57da957e11SThomas Gleixner {
58da957e11SThomas Gleixner /* fdivr st,st(i) */
59da957e11SThomas Gleixner clear_C1();
60da957e11SThomas Gleixner FPU_div(REV, FPU_rm, control_word);
61da957e11SThomas Gleixner }
62da957e11SThomas Gleixner
fadd_i(void)63da957e11SThomas Gleixner void fadd_i(void)
64da957e11SThomas Gleixner {
65da957e11SThomas Gleixner /* fadd st(i),st */
66da957e11SThomas Gleixner int i = FPU_rm;
67da957e11SThomas Gleixner clear_C1();
68da957e11SThomas Gleixner FPU_add(&st(i), FPU_gettagi(i), i, control_word);
69da957e11SThomas Gleixner }
70da957e11SThomas Gleixner
fmul_i(void)71da957e11SThomas Gleixner void fmul_i(void)
72da957e11SThomas Gleixner {
73da957e11SThomas Gleixner /* fmul st(i),st */
74da957e11SThomas Gleixner clear_C1();
75da957e11SThomas Gleixner FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word);
76da957e11SThomas Gleixner }
77da957e11SThomas Gleixner
fsubri(void)78da957e11SThomas Gleixner void fsubri(void)
79da957e11SThomas Gleixner {
80da957e11SThomas Gleixner /* fsubr st(i),st */
81da957e11SThomas Gleixner clear_C1();
82da957e11SThomas Gleixner FPU_sub(DEST_RM, FPU_rm, control_word);
83da957e11SThomas Gleixner }
84da957e11SThomas Gleixner
fsub_i(void)85da957e11SThomas Gleixner void fsub_i(void)
86da957e11SThomas Gleixner {
87da957e11SThomas Gleixner /* fsub st(i),st */
88da957e11SThomas Gleixner clear_C1();
89da957e11SThomas Gleixner FPU_sub(REV | DEST_RM, FPU_rm, control_word);
90da957e11SThomas Gleixner }
91da957e11SThomas Gleixner
fdivri(void)92da957e11SThomas Gleixner void fdivri(void)
93da957e11SThomas Gleixner {
94da957e11SThomas Gleixner /* fdivr st(i),st */
95da957e11SThomas Gleixner clear_C1();
96da957e11SThomas Gleixner FPU_div(DEST_RM, FPU_rm, control_word);
97da957e11SThomas Gleixner }
98da957e11SThomas Gleixner
fdiv_i(void)99da957e11SThomas Gleixner void fdiv_i(void)
100da957e11SThomas Gleixner {
101da957e11SThomas Gleixner /* fdiv st(i),st */
102da957e11SThomas Gleixner clear_C1();
103da957e11SThomas Gleixner FPU_div(REV | DEST_RM, FPU_rm, control_word);
104da957e11SThomas Gleixner }
105da957e11SThomas Gleixner
faddp_(void)106da957e11SThomas Gleixner void faddp_(void)
107da957e11SThomas Gleixner {
108da957e11SThomas Gleixner /* faddp st(i),st */
109da957e11SThomas Gleixner int i = FPU_rm;
110da957e11SThomas Gleixner clear_C1();
111da957e11SThomas Gleixner if (FPU_add(&st(i), FPU_gettagi(i), i, control_word) >= 0)
112da957e11SThomas Gleixner FPU_pop();
113da957e11SThomas Gleixner }
114da957e11SThomas Gleixner
fmulp_(void)115da957e11SThomas Gleixner void fmulp_(void)
116da957e11SThomas Gleixner {
117da957e11SThomas Gleixner /* fmulp st(i),st */
118da957e11SThomas Gleixner clear_C1();
119da957e11SThomas Gleixner if (FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0)
120da957e11SThomas Gleixner FPU_pop();
121da957e11SThomas Gleixner }
122da957e11SThomas Gleixner
fsubrp(void)123da957e11SThomas Gleixner void fsubrp(void)
124da957e11SThomas Gleixner {
125da957e11SThomas Gleixner /* fsubrp st(i),st */
126da957e11SThomas Gleixner clear_C1();
127da957e11SThomas Gleixner if (FPU_sub(DEST_RM, FPU_rm, control_word) >= 0)
128da957e11SThomas Gleixner FPU_pop();
129da957e11SThomas Gleixner }
130da957e11SThomas Gleixner
fsubp_(void)131da957e11SThomas Gleixner void fsubp_(void)
132da957e11SThomas Gleixner {
133da957e11SThomas Gleixner /* fsubp st(i),st */
134da957e11SThomas Gleixner clear_C1();
135da957e11SThomas Gleixner if (FPU_sub(REV | DEST_RM, FPU_rm, control_word) >= 0)
136da957e11SThomas Gleixner FPU_pop();
137da957e11SThomas Gleixner }
138da957e11SThomas Gleixner
fdivrp(void)139da957e11SThomas Gleixner void fdivrp(void)
140da957e11SThomas Gleixner {
141da957e11SThomas Gleixner /* fdivrp st(i),st */
142da957e11SThomas Gleixner clear_C1();
143da957e11SThomas Gleixner if (FPU_div(DEST_RM, FPU_rm, control_word) >= 0)
144da957e11SThomas Gleixner FPU_pop();
145da957e11SThomas Gleixner }
146da957e11SThomas Gleixner
fdivp_(void)147da957e11SThomas Gleixner void fdivp_(void)
148da957e11SThomas Gleixner {
149da957e11SThomas Gleixner /* fdivp st(i),st */
150da957e11SThomas Gleixner clear_C1();
151da957e11SThomas Gleixner if (FPU_div(REV | DEST_RM, FPU_rm, control_word) >= 0)
152da957e11SThomas Gleixner FPU_pop();
153da957e11SThomas Gleixner }
154