Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* ieee754 floating point arithmetic |
| 2 | * single and double precision |
| 3 | * |
| 4 | * BUGS |
| 5 | * not much dp done |
| 6 | * doesn't generate IEEE754_INEXACT |
| 7 | * |
| 8 | */ |
| 9 | /* |
| 10 | * MIPS floating point support |
| 11 | * Copyright (C) 1994-2000 Algorithmics Ltd. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * |
| 13 | * ######################################################################## |
| 14 | * |
| 15 | * This program is free software; you can distribute it and/or modify it |
| 16 | * under the terms of the GNU General Public License (Version 2) as |
| 17 | * published by the Free Software Foundation. |
| 18 | * |
| 19 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 22 | * for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License along |
| 25 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 26 | * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. |
| 27 | * |
| 28 | * ######################################################################## |
| 29 | */ |
| 30 | |
Ralf Baechle | cae5506 | 2014-04-16 00:47:59 +0200 | [diff] [blame] | 31 | #include <linux/compiler.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | #include "ieee754int.h" |
Ralf Baechle | efec3c4 | 2005-10-23 13:46:25 +0100 | [diff] [blame] | 34 | #include "ieee754sp.h" |
| 35 | #include "ieee754dp.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | /* special constants |
| 38 | */ |
| 39 | |
Ralf Baechle | 90efba3 | 2014-04-25 03:19:57 +0200 | [diff] [blame^] | 40 | #define DPSTR(s, b, mh, ml) \ |
| 41 | { \ |
| 42 | .sign = (s), \ |
| 43 | .bexp = (b), \ |
| 44 | .manthi = (mh), \ |
| 45 | .mantlo = (ml) \ |
| 46 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Ralf Baechle | 2370881 | 2014-04-16 01:16:02 +0200 | [diff] [blame] | 48 | const struct ieee754dp_const __ieee754dp_spcvals[] = { |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 49 | DPSTR(0, DP_EMIN - 1 + DP_EBIAS, 0, 0), /* + zero */ |
| 50 | DPSTR(1, DP_EMIN - 1 + DP_EBIAS, 0, 0), /* - zero */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | DPSTR(0, DP_EBIAS, 0, 0), /* + 1.0 */ |
| 52 | DPSTR(1, DP_EBIAS, 0, 0), /* - 1.0 */ |
| 53 | DPSTR(0, 3 + DP_EBIAS, 0x40000, 0), /* + 10.0 */ |
| 54 | DPSTR(1, 3 + DP_EBIAS, 0x40000, 0), /* - 10.0 */ |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 55 | DPSTR(0, DP_EMAX + 1 + DP_EBIAS, 0, 0), /* + infinity */ |
| 56 | DPSTR(1, DP_EMAX + 1 + DP_EBIAS, 0, 0), /* - infinity */ |
Ralf Baechle | 21a151d | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 57 | DPSTR(0, DP_EMAX+1+DP_EBIAS, 0x7FFFF, 0xFFFFFFFF), /* + indef quiet Nan */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | DPSTR(0, DP_EMAX + DP_EBIAS, 0xFFFFF, 0xFFFFFFFF), /* + max */ |
| 59 | DPSTR(1, DP_EMAX + DP_EBIAS, 0xFFFFF, 0xFFFFFFFF), /* - max */ |
| 60 | DPSTR(0, DP_EMIN + DP_EBIAS, 0, 0), /* + min normal */ |
| 61 | DPSTR(1, DP_EMIN + DP_EBIAS, 0, 0), /* - min normal */ |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 62 | DPSTR(0, DP_EMIN - 1 + DP_EBIAS, 0, 1), /* + min denormal */ |
| 63 | DPSTR(1, DP_EMIN - 1 + DP_EBIAS, 0, 1), /* - min denormal */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | DPSTR(0, 31 + DP_EBIAS, 0, 0), /* + 1.0e31 */ |
| 65 | DPSTR(0, 63 + DP_EBIAS, 0, 0), /* + 1.0e63 */ |
| 66 | }; |
| 67 | |
Ralf Baechle | 90efba3 | 2014-04-25 03:19:57 +0200 | [diff] [blame^] | 68 | #define SPSTR(s, b, m) \ |
| 69 | { \ |
| 70 | .sign = (s), \ |
| 71 | .bexp = (b), \ |
| 72 | .mant = (m) \ |
| 73 | } |
| 74 | |
Ralf Baechle | 2370881 | 2014-04-16 01:16:02 +0200 | [diff] [blame] | 75 | const struct ieee754sp_const __ieee754sp_spcvals[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | SPSTR(0, SP_EMIN - 1 + SP_EBIAS, 0), /* + zero */ |
| 77 | SPSTR(1, SP_EMIN - 1 + SP_EBIAS, 0), /* - zero */ |
| 78 | SPSTR(0, SP_EBIAS, 0), /* + 1.0 */ |
| 79 | SPSTR(1, SP_EBIAS, 0), /* - 1.0 */ |
| 80 | SPSTR(0, 3 + SP_EBIAS, 0x200000), /* + 10.0 */ |
| 81 | SPSTR(1, 3 + SP_EBIAS, 0x200000), /* - 10.0 */ |
| 82 | SPSTR(0, SP_EMAX + 1 + SP_EBIAS, 0), /* + infinity */ |
| 83 | SPSTR(1, SP_EMAX + 1 + SP_EBIAS, 0), /* - infinity */ |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 84 | SPSTR(0, SP_EMAX+1+SP_EBIAS, 0x3FFFFF), /* + indef quiet Nan */ |
| 85 | SPSTR(0, SP_EMAX + SP_EBIAS, 0x7FFFFF), /* + max normal */ |
| 86 | SPSTR(1, SP_EMAX + SP_EBIAS, 0x7FFFFF), /* - max normal */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | SPSTR(0, SP_EMIN + SP_EBIAS, 0), /* + min normal */ |
| 88 | SPSTR(1, SP_EMIN + SP_EBIAS, 0), /* - min normal */ |
| 89 | SPSTR(0, SP_EMIN - 1 + SP_EBIAS, 1), /* + min denormal */ |
| 90 | SPSTR(1, SP_EMIN - 1 + SP_EBIAS, 1), /* - min denormal */ |
| 91 | SPSTR(0, 31 + SP_EBIAS, 0), /* + 1.0e31 */ |
| 92 | SPSTR(0, 63 + SP_EBIAS, 0), /* + 1.0e63 */ |
| 93 | }; |