1 // SPDX-License-Identifier: GPL-2.0
2 /*---------------------------------------------------------------------------+
5 | Set FPU register tags. |
8 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
9 | E-mail billm@jacobi.maths.monash.edu.au |
12 +---------------------------------------------------------------------------*/
15 #include "fpu_system.h"
16 #include "exception.h"
20 fpu_tag_word |= 3 << ((top & 7) * 2);
26 return (fpu_tag_word >> ((top & 7) * 2)) & 3;
29 int FPU_gettagi(int stnr)
31 return (fpu_tag_word >> (((top + stnr) & 7) * 2)) & 3;
34 int FPU_gettag(int regnr)
36 return (fpu_tag_word >> ((regnr & 7) * 2)) & 3;
39 void FPU_settag0(int tag)
43 fpu_tag_word &= ~(3 << (regnr * 2));
44 fpu_tag_word |= (tag & 3) << (regnr * 2);
47 void FPU_settagi(int stnr, int tag)
49 int regnr = stnr + top;
51 fpu_tag_word &= ~(3 << (regnr * 2));
52 fpu_tag_word |= (tag & 3) << (regnr * 2);
55 void FPU_settag(int regnr, int tag)
58 fpu_tag_word &= ~(3 << (regnr * 2));
59 fpu_tag_word |= (tag & 3) << (regnr * 2);
62 int FPU_Special(FPU_REG const *ptr)
64 int exp = exponent(ptr);
66 if (exp == EXP_BIAS + EXP_UNDER)
68 else if (exp != EXP_BIAS + EXP_OVER)
70 else if ((ptr->sigh == 0x80000000) && (ptr->sigl == 0))
75 int isNaN(FPU_REG const *ptr)
77 return ((exponent(ptr) == EXP_BIAS + EXP_OVER)
78 && !((ptr->sigh == 0x80000000) && (ptr->sigl == 0)));
81 int FPU_empty_i(int stnr)
83 int regnr = (top + stnr) & 7;
85 return ((fpu_tag_word >> (regnr * 2)) & 3) == TAG_Empty;
88 int FPU_stackoverflow(FPU_REG ** st_new_ptr)
90 *st_new_ptr = &st(-1);
92 return ((fpu_tag_word >> (((top - 1) & 7) * 2)) & 3) != TAG_Empty;
95 void FPU_copy_to_regi(FPU_REG const *r, u_char tag, int stnr)
97 reg_copy(r, &st(stnr));
98 FPU_settagi(stnr, tag);
101 void FPU_copy_to_reg1(FPU_REG const *r, u_char tag)
107 void FPU_copy_to_reg0(FPU_REG const *r, u_char tag)
114 fpu_tag_word &= ~(3 << (regnr * 2));
115 fpu_tag_word |= (tag & 3) << (regnr * 2);