~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/math-emu/sp_mul.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/mips/math-emu/sp_mul.c (Architecture sparc64) and /arch/alpha/math-emu/sp_mul.c (Architecture alpha)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /* IEEE754 floating point arithmetic              
  3  * single precision                               
  4  */                                               
  5 /*                                                
  6  * MIPS floating point support                    
  7  * Copyright (C) 1994-2000 Algorithmics Ltd.      
  8  */                                               
  9                                                   
 10 #include "ieee754sp.h"                            
 11                                                   
 12 union ieee754sp ieee754sp_mul(union ieee754sp     
 13 {                                                 
 14         int re;                                   
 15         int rs;                                   
 16         unsigned int rm;                          
 17         unsigned short lxm;                       
 18         unsigned short hxm;                       
 19         unsigned short lym;                       
 20         unsigned short hym;                       
 21         unsigned int lrm;                         
 22         unsigned int hrm;                         
 23         unsigned int t;                           
 24         unsigned int at;                          
 25                                                   
 26         COMPXSP;                                  
 27         COMPYSP;                                  
 28                                                   
 29         EXPLODEXSP;                               
 30         EXPLODEYSP;                               
 31                                                   
 32         ieee754_clearcx();                        
 33                                                   
 34         FLUSHXSP;                                 
 35         FLUSHYSP;                                 
 36                                                   
 37         switch (CLPAIR(xc, yc)) {                 
 38         case CLPAIR(IEEE754_CLASS_QNAN, IEEE75    
 39         case CLPAIR(IEEE754_CLASS_ZERO, IEEE75    
 40         case CLPAIR(IEEE754_CLASS_NORM, IEEE75    
 41         case CLPAIR(IEEE754_CLASS_DNORM, IEEE7    
 42         case CLPAIR(IEEE754_CLASS_INF, IEEE754    
 43                 return ieee754sp_nanxcpt(y);      
 44                                                   
 45         case CLPAIR(IEEE754_CLASS_SNAN, IEEE75    
 46         case CLPAIR(IEEE754_CLASS_SNAN, IEEE75    
 47         case CLPAIR(IEEE754_CLASS_SNAN, IEEE75    
 48         case CLPAIR(IEEE754_CLASS_SNAN, IEEE75    
 49         case CLPAIR(IEEE754_CLASS_SNAN, IEEE75    
 50         case CLPAIR(IEEE754_CLASS_SNAN, IEEE75    
 51                 return ieee754sp_nanxcpt(x);      
 52                                                   
 53         case CLPAIR(IEEE754_CLASS_ZERO, IEEE75    
 54         case CLPAIR(IEEE754_CLASS_NORM, IEEE75    
 55         case CLPAIR(IEEE754_CLASS_DNORM, IEEE7    
 56         case CLPAIR(IEEE754_CLASS_INF, IEEE754    
 57                 return y;                         
 58                                                   
 59         case CLPAIR(IEEE754_CLASS_QNAN, IEEE75    
 60         case CLPAIR(IEEE754_CLASS_QNAN, IEEE75    
 61         case CLPAIR(IEEE754_CLASS_QNAN, IEEE75    
 62         case CLPAIR(IEEE754_CLASS_QNAN, IEEE75    
 63         case CLPAIR(IEEE754_CLASS_QNAN, IEEE75    
 64                 return x;                         
 65                                                   
 66                                                   
 67         /*                                        
 68          * Infinity handling                      
 69          */                                       
 70         case CLPAIR(IEEE754_CLASS_INF, IEEE754    
 71         case CLPAIR(IEEE754_CLASS_ZERO, IEEE75    
 72                 ieee754_setcx(IEEE754_INVALID_    
 73                 return ieee754sp_indef();         
 74                                                   
 75         case CLPAIR(IEEE754_CLASS_NORM, IEEE75    
 76         case CLPAIR(IEEE754_CLASS_DNORM, IEEE7    
 77         case CLPAIR(IEEE754_CLASS_INF, IEEE754    
 78         case CLPAIR(IEEE754_CLASS_INF, IEEE754    
 79         case CLPAIR(IEEE754_CLASS_INF, IEEE754    
 80                 return ieee754sp_inf(xs ^ ys);    
 81                                                   
 82         case CLPAIR(IEEE754_CLASS_ZERO, IEEE75    
 83         case CLPAIR(IEEE754_CLASS_ZERO, IEEE75    
 84         case CLPAIR(IEEE754_CLASS_ZERO, IEEE75    
 85         case CLPAIR(IEEE754_CLASS_NORM, IEEE75    
 86         case CLPAIR(IEEE754_CLASS_DNORM, IEEE7    
 87                 return ieee754sp_zero(xs ^ ys)    
 88                                                   
 89                                                   
 90         case CLPAIR(IEEE754_CLASS_DNORM, IEEE7    
 91                 SPDNORMX;                         
 92                 fallthrough;                      
 93         case CLPAIR(IEEE754_CLASS_NORM, IEEE75    
 94                 SPDNORMY;                         
 95                 break;                            
 96                                                   
 97         case CLPAIR(IEEE754_CLASS_DNORM, IEEE7    
 98                 SPDNORMX;                         
 99                 break;                            
100                                                   
101         case CLPAIR(IEEE754_CLASS_NORM, IEEE75    
102                 break;                            
103         }                                         
104         /* rm = xm * ym, re = xe+ye basically     
105         assert(xm & SP_HIDDEN_BIT);               
106         assert(ym & SP_HIDDEN_BIT);               
107                                                   
108         re = xe + ye;                             
109         rs = xs ^ ys;                             
110                                                   
111         /* shunt to top of word */                
112         xm <<= 32 - (SP_FBITS + 1);               
113         ym <<= 32 - (SP_FBITS + 1);               
114                                                   
115         /*                                        
116          * Multiply 32 bits xm, ym to give hig    
117          */                                       
118         lxm = xm & 0xffff;                        
119         hxm = xm >> 16;                           
120         lym = ym & 0xffff;                        
121         hym = ym >> 16;                           
122                                                   
123         lrm = lxm * lym;        /* 16 * 16 =>     
124         hrm = hxm * hym;        /* 16 * 16 =>     
125                                                   
126         t = lxm * hym; /* 16 * 16 => 32 */        
127         at = lrm + (t << 16);                     
128         hrm += at < lrm;                          
129         lrm = at;                                 
130         hrm = hrm + (t >> 16);                    
131                                                   
132         t = hxm * lym; /* 16 * 16 => 32 */        
133         at = lrm + (t << 16);                     
134         hrm += at < lrm;                          
135         lrm = at;                                 
136         hrm = hrm + (t >> 16);                    
137                                                   
138         rm = hrm | (lrm != 0);                    
139                                                   
140         /*                                        
141          * Sticky shift down to normal roundin    
142          */                                       
143         if ((int) rm < 0) {                       
144                 rm = (rm >> (32 - (SP_FBITS +     
145                     ((rm << (SP_FBITS + 1 + 3)    
146                 re++;                             
147         } else {                                  
148                 rm = (rm >> (32 - (SP_FBITS +     
149                      ((rm << (SP_FBITS + 1 + 3    
150         }                                         
151         assert(rm & (SP_HIDDEN_BIT << 3));        
152                                                   
153         return ieee754sp_format(rs, re, rm);      
154 }                                                 
155                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php