11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * IEEE754 floating point 31da177e4SLinus Torvalds * double precision internal header file 41da177e4SLinus Torvalds */ 51da177e4SLinus Torvalds /* 61da177e4SLinus Torvalds * MIPS floating point support 71da177e4SLinus Torvalds * Copyright (C) 1994-2000 Algorithmics Ltd. 81da177e4SLinus Torvalds * 91da177e4SLinus Torvalds * ######################################################################## 101da177e4SLinus Torvalds * 111da177e4SLinus Torvalds * This program is free software; you can distribute it and/or modify it 121da177e4SLinus Torvalds * under the terms of the GNU General Public License (Version 2) as 131da177e4SLinus Torvalds * published by the Free Software Foundation. 141da177e4SLinus Torvalds * 151da177e4SLinus Torvalds * This program is distributed in the hope it will be useful, but WITHOUT 161da177e4SLinus Torvalds * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 171da177e4SLinus Torvalds * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 181da177e4SLinus Torvalds * for more details. 191da177e4SLinus Torvalds * 201da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License along 211da177e4SLinus Torvalds * with this program; if not, write to the Free Software Foundation, Inc., 221da177e4SLinus Torvalds * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 231da177e4SLinus Torvalds * 241da177e4SLinus Torvalds * ######################################################################## 251da177e4SLinus Torvalds */ 261da177e4SLinus Torvalds 27cae55066SRalf Baechle #include <linux/compiler.h> 281da177e4SLinus Torvalds 291da177e4SLinus Torvalds #include "ieee754int.h" 301da177e4SLinus Torvalds 311da177e4SLinus Torvalds #define assert(expr) ((void)0) 321da177e4SLinus Torvalds 331da177e4SLinus Torvalds /* 3bit extended single precision sticky right shift */ 341da177e4SLinus Torvalds #define SPXSRSXn(rs) \ 351da177e4SLinus Torvalds (xe += rs, \ 36*ad8fb553SRalf Baechle xm = (rs > (SP_FBITS+3))?1:((xm) >> (rs)) | ((xm) << (32-(rs)) != 0)) 371da177e4SLinus Torvalds 381da177e4SLinus Torvalds #define SPXSRSX1() \ 391da177e4SLinus Torvalds (xe++, (xm = (xm >> 1) | (xm & 1))) 401da177e4SLinus Torvalds 411da177e4SLinus Torvalds #define SPXSRSYn(rs) \ 421da177e4SLinus Torvalds (ye+=rs, \ 43*ad8fb553SRalf Baechle ym = (rs > (SP_FBITS+3))?1:((ym) >> (rs)) | ((ym) << (32-(rs)) != 0)) 441da177e4SLinus Torvalds 451da177e4SLinus Torvalds #define SPXSRSY1() \ 461da177e4SLinus Torvalds (ye++, (ym = (ym >> 1) | (ym & 1))) 471da177e4SLinus Torvalds 481da177e4SLinus Torvalds /* convert denormal to normalized with extended exponent */ 491da177e4SLinus Torvalds #define SPDNORMx(m,e) \ 50*ad8fb553SRalf Baechle while ((m >> SP_FBITS) == 0) { m <<= 1; e--; } 511da177e4SLinus Torvalds #define SPDNORMX SPDNORMx(xm, xe) 521da177e4SLinus Torvalds #define SPDNORMY SPDNORMx(ym, ye) 531da177e4SLinus Torvalds 542209bcb1SRalf Baechle static inline union ieee754sp buildsp(int s, int bx, unsigned m) 551da177e4SLinus Torvalds { 562209bcb1SRalf Baechle union ieee754sp r; 571da177e4SLinus Torvalds 581da177e4SLinus Torvalds assert((s) == 0 || (s) == 1); 591da177e4SLinus Torvalds assert((bx) >= SP_EMIN - 1 + SP_EBIAS 601da177e4SLinus Torvalds && (bx) <= SP_EMAX + 1 + SP_EBIAS); 61*ad8fb553SRalf Baechle assert(((m) >> SP_FBITS) == 0); 621da177e4SLinus Torvalds 631da177e4SLinus Torvalds r.parts.sign = s; 641da177e4SLinus Torvalds r.parts.bexp = bx; 651da177e4SLinus Torvalds r.parts.mant = m; 661da177e4SLinus Torvalds 671da177e4SLinus Torvalds return r; 681da177e4SLinus Torvalds } 691da177e4SLinus Torvalds 702209bcb1SRalf Baechle extern int ieee754sp_isnan(union ieee754sp); 712209bcb1SRalf Baechle extern int ieee754sp_issnan(union ieee754sp); 72cae55066SRalf Baechle extern int __cold ieee754si_xcpt(int, const char *, ...); 73cae55066SRalf Baechle extern s64 __cold ieee754di_xcpt(s64, const char *, ...); 742209bcb1SRalf Baechle extern union ieee754sp __cold ieee754sp_xcpt(union ieee754sp, const char *, ...); 752209bcb1SRalf Baechle extern union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp, const char *, ...); 762209bcb1SRalf Baechle extern union ieee754sp ieee754sp_bestnan(union ieee754sp, union ieee754sp); 772209bcb1SRalf Baechle extern union ieee754sp ieee754sp_format(int, int, unsigned); 781da177e4SLinus Torvalds 791da177e4SLinus Torvalds 801da177e4SLinus Torvalds #define SPNORMRET2(s, e, m, name, a0, a1) \ 811da177e4SLinus Torvalds { \ 822209bcb1SRalf Baechle union ieee754sp V = ieee754sp_format(s, e, m); \ 8347fa0c02SRalf Baechle \ 849e8bad1fSRalf Baechle if (ieee754_tstx()) \ 851da177e4SLinus Torvalds return ieee754sp_xcpt(V, name, a0, a1); \ 861da177e4SLinus Torvalds else \ 871da177e4SLinus Torvalds return V; \ 881da177e4SLinus Torvalds } 891da177e4SLinus Torvalds 901da177e4SLinus Torvalds #define SPNORMRET1(s, e, m, name, a0) SPNORMRET2(s, e, m, name, a0, a0) 91