blob: 09006dc474a0aff09dc87ef55bcd87657c20aa5d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*---------------------------------------------------------------------------+
3 | fpu_arith.c |
4 | |
5 | Code to implement the FPU register/register arithmetic instructions |
6 | |
7 | Copyright (C) 1992,1993,1997 |
8 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
9 | E-mail billm@suburbia.net |
10 | |
11 | |
12 +---------------------------------------------------------------------------*/
13
14#include "fpu_system.h"
15#include "fpu_emu.h"
16#include "control_w.h"
17#include "status_w.h"
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019void fadd__(void)
20{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010021 /* fadd st,st(i) */
22 int i = FPU_rm;
23 clear_C1();
24 FPU_add(&st(i), FPU_gettagi(i), 0, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025}
26
Linus Torvalds1da177e2005-04-16 15:20:36 -070027void fmul__(void)
28{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010029 /* fmul st,st(i) */
30 int i = FPU_rm;
31 clear_C1();
32 FPU_mul(&st(i), FPU_gettagi(i), 0, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070033}
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035void fsub__(void)
36{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010037 /* fsub st,st(i) */
38 clear_C1();
39 FPU_sub(0, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040}
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042void fsubr_(void)
43{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010044 /* fsubr st,st(i) */
45 clear_C1();
46 FPU_sub(REV, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047}
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049void fdiv__(void)
50{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010051 /* fdiv st,st(i) */
52 clear_C1();
53 FPU_div(0, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054}
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056void fdivr_(void)
57{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010058 /* fdivr st,st(i) */
59 clear_C1();
60 FPU_div(REV, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070061}
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063void fadd_i(void)
64{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010065 /* fadd st(i),st */
66 int i = FPU_rm;
67 clear_C1();
68 FPU_add(&st(i), FPU_gettagi(i), i, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069}
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071void fmul_i(void)
72{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010073 /* fmul st(i),st */
74 clear_C1();
75 FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076}
77
Linus Torvalds1da177e2005-04-16 15:20:36 -070078void fsubri(void)
79{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010080 /* fsubr st(i),st */
81 clear_C1();
82 FPU_sub(DEST_RM, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083}
84
Linus Torvalds1da177e2005-04-16 15:20:36 -070085void fsub_i(void)
86{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010087 /* fsub st(i),st */
88 clear_C1();
89 FPU_sub(REV | DEST_RM, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090}
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092void fdivri(void)
93{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010094 /* fdivr st(i),st */
95 clear_C1();
96 FPU_div(DEST_RM, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070097}
98
Linus Torvalds1da177e2005-04-16 15:20:36 -070099void fdiv_i(void)
100{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100101 /* fdiv st(i),st */
102 clear_C1();
103 FPU_div(REV | DEST_RM, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104}
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106void faddp_(void)
107{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100108 /* faddp st(i),st */
109 int i = FPU_rm;
110 clear_C1();
111 if (FPU_add(&st(i), FPU_gettagi(i), i, control_word) >= 0)
112 FPU_pop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113}
114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115void fmulp_(void)
116{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100117 /* fmulp st(i),st */
118 clear_C1();
119 if (FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0)
120 FPU_pop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121}
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123void fsubrp(void)
124{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100125 /* fsubrp st(i),st */
126 clear_C1();
127 if (FPU_sub(DEST_RM, FPU_rm, control_word) >= 0)
128 FPU_pop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129}
130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131void fsubp_(void)
132{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100133 /* fsubp st(i),st */
134 clear_C1();
135 if (FPU_sub(REV | DEST_RM, FPU_rm, control_word) >= 0)
136 FPU_pop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137}
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139void fdivrp(void)
140{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100141 /* fdivrp st(i),st */
142 clear_C1();
143 if (FPU_div(DEST_RM, FPU_rm, control_word) >= 0)
144 FPU_pop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145}
146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147void fdivp_(void)
148{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100149 /* fdivp st(i),st */
150 clear_C1();
151 if (FPU_div(REV | DEST_RM, FPU_rm, control_word) >= 0)
152 FPU_pop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153}