fpu_arith.c 2.97 KB
Newer Older
1
// SPDX-License-Identifier: GPL-2.0
Linus Torvalds's avatar
Linus Torvalds committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*---------------------------------------------------------------------------+
 |  fpu_arith.c                                                              |
 |                                                                           |
 | Code to implement the FPU register/register arithmetic instructions       |
 |                                                                           |
 | Copyright (C) 1992,1993,1997                                              |
 |                  W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
 |                  E-mail   billm@suburbia.net                              |
 |                                                                           |
 |                                                                           |
 +---------------------------------------------------------------------------*/

#include "fpu_system.h"
#include "fpu_emu.h"
#include "control_w.h"
#include "status_w.h"

void fadd__(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
21 22 23 24
	/* fadd st,st(i) */
	int i = FPU_rm;
	clear_C1();
	FPU_add(&st(i), FPU_gettagi(i), 0, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
25 26 27 28
}

void fmul__(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
29 30 31 32
	/* fmul st,st(i) */
	int i = FPU_rm;
	clear_C1();
	FPU_mul(&st(i), FPU_gettagi(i), 0, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
33 34 35 36
}

void fsub__(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
37 38 39
	/* fsub st,st(i) */
	clear_C1();
	FPU_sub(0, FPU_rm, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
40 41 42 43
}

void fsubr_(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
44 45 46
	/* fsubr st,st(i) */
	clear_C1();
	FPU_sub(REV, FPU_rm, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
47 48 49 50
}

void fdiv__(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
51 52 53
	/* fdiv st,st(i) */
	clear_C1();
	FPU_div(0, FPU_rm, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
54 55 56 57
}

void fdivr_(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
58 59 60
	/* fdivr st,st(i) */
	clear_C1();
	FPU_div(REV, FPU_rm, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
61 62 63 64
}

void fadd_i(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
65 66 67 68
	/* fadd st(i),st */
	int i = FPU_rm;
	clear_C1();
	FPU_add(&st(i), FPU_gettagi(i), i, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
69 70 71 72
}

void fmul_i(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
73 74 75
	/* fmul st(i),st */
	clear_C1();
	FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
76 77 78 79
}

void fsubri(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
80 81 82
	/* fsubr st(i),st */
	clear_C1();
	FPU_sub(DEST_RM, FPU_rm, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
83 84 85 86
}

void fsub_i(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
87 88 89
	/* fsub st(i),st */
	clear_C1();
	FPU_sub(REV | DEST_RM, FPU_rm, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
90 91 92 93
}

void fdivri(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
94 95 96
	/* fdivr st(i),st */
	clear_C1();
	FPU_div(DEST_RM, FPU_rm, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
97 98 99 100
}

void fdiv_i(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
101 102 103
	/* fdiv st(i),st */
	clear_C1();
	FPU_div(REV | DEST_RM, FPU_rm, control_word);
Linus Torvalds's avatar
Linus Torvalds committed
104 105 106 107
}

void faddp_(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
108 109 110 111 112
	/* faddp st(i),st */
	int i = FPU_rm;
	clear_C1();
	if (FPU_add(&st(i), FPU_gettagi(i), i, control_word) >= 0)
		FPU_pop();
Linus Torvalds's avatar
Linus Torvalds committed
113 114 115 116
}

void fmulp_(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
117 118 119 120
	/* fmulp st(i),st */
	clear_C1();
	if (FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0)
		FPU_pop();
Linus Torvalds's avatar
Linus Torvalds committed
121 122 123 124
}

void fsubrp(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
125 126 127 128
	/* fsubrp st(i),st */
	clear_C1();
	if (FPU_sub(DEST_RM, FPU_rm, control_word) >= 0)
		FPU_pop();
Linus Torvalds's avatar
Linus Torvalds committed
129 130 131 132
}

void fsubp_(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
133 134 135 136
	/* fsubp st(i),st */
	clear_C1();
	if (FPU_sub(REV | DEST_RM, FPU_rm, control_word) >= 0)
		FPU_pop();
Linus Torvalds's avatar
Linus Torvalds committed
137 138 139 140
}

void fdivrp(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
141 142 143 144
	/* fdivrp st(i),st */
	clear_C1();
	if (FPU_div(DEST_RM, FPU_rm, control_word) >= 0)
		FPU_pop();
Linus Torvalds's avatar
Linus Torvalds committed
145 146 147 148
}

void fdivp_(void)
{
Ingo Molnar's avatar
Ingo Molnar committed
149 150 151 152
	/* fdivp st(i),st */
	clear_C1();
	if (FPU_div(REV | DEST_RM, FPU_rm, control_word) >= 0)
		FPU_pop();
Linus Torvalds's avatar
Linus Torvalds committed
153
}