Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /*---------------------------------------------------------------------------+ |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | void fadd__(void) |
| 20 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 21 | /* fadd st,st(i) */ |
| 22 | int i = FPU_rm; |
| 23 | clear_C1(); |
| 24 | FPU_add(&st(i), FPU_gettagi(i), 0, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | } |
| 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | void fmul__(void) |
| 28 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 29 | /* fmul st,st(i) */ |
| 30 | int i = FPU_rm; |
| 31 | clear_C1(); |
| 32 | FPU_mul(&st(i), FPU_gettagi(i), 0, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | void fsub__(void) |
| 36 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 37 | /* fsub st,st(i) */ |
| 38 | clear_C1(); |
| 39 | FPU_sub(0, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | void fsubr_(void) |
| 43 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 44 | /* fsubr st,st(i) */ |
| 45 | clear_C1(); |
| 46 | FPU_sub(REV, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | void fdiv__(void) |
| 50 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 51 | /* fdiv st,st(i) */ |
| 52 | clear_C1(); |
| 53 | FPU_div(0, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | void fdivr_(void) |
| 57 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 58 | /* fdivr st,st(i) */ |
| 59 | clear_C1(); |
| 60 | FPU_div(REV, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | void fadd_i(void) |
| 64 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 65 | /* fadd st(i),st */ |
| 66 | int i = FPU_rm; |
| 67 | clear_C1(); |
| 68 | FPU_add(&st(i), FPU_gettagi(i), i, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | void fmul_i(void) |
| 72 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 73 | /* fmul st(i),st */ |
| 74 | clear_C1(); |
| 75 | FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | void fsubri(void) |
| 79 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 80 | /* fsubr st(i),st */ |
| 81 | clear_C1(); |
| 82 | FPU_sub(DEST_RM, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | void fsub_i(void) |
| 86 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 87 | /* fsub st(i),st */ |
| 88 | clear_C1(); |
| 89 | FPU_sub(REV | DEST_RM, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | void fdivri(void) |
| 93 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 94 | /* fdivr st(i),st */ |
| 95 | clear_C1(); |
| 96 | FPU_div(DEST_RM, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | void fdiv_i(void) |
| 100 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 101 | /* fdiv st(i),st */ |
| 102 | clear_C1(); |
| 103 | FPU_div(REV | DEST_RM, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | void faddp_(void) |
| 107 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 108 | /* 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | void fmulp_(void) |
| 116 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 117 | /* fmulp st(i),st */ |
| 118 | clear_C1(); |
| 119 | if (FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0) |
| 120 | FPU_pop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | } |
| 122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | void fsubrp(void) |
| 124 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 125 | /* fsubrp st(i),st */ |
| 126 | clear_C1(); |
| 127 | if (FPU_sub(DEST_RM, FPU_rm, control_word) >= 0) |
| 128 | FPU_pop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | void fsubp_(void) |
| 132 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 133 | /* fsubp st(i),st */ |
| 134 | clear_C1(); |
| 135 | if (FPU_sub(REV | DEST_RM, FPU_rm, control_word) >= 0) |
| 136 | FPU_pop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | void fdivrp(void) |
| 140 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 141 | /* fdivrp st(i),st */ |
| 142 | clear_C1(); |
| 143 | if (FPU_div(DEST_RM, FPU_rm, control_word) >= 0) |
| 144 | FPU_pop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | void fdivp_(void) |
| 148 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 149 | /* fdivp st(i),st */ |
| 150 | clear_C1(); |
| 151 | if (FPU_div(REV | DEST_RM, FPU_rm, control_word) >= 0) |
| 152 | FPU_pop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | } |