Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
frts.c
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2.1 of the GNU Lesser General Public License 
00007   as published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU Lesser General Public 
00021   License along with this program; if not, write the Free Software 
00022   Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 
00023   USA.
00024 
00025   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00026   Mountain View, CA 94043, or:
00027 
00028   http://www.sgi.com
00029 
00030   For further information regarding this notice, see:
00031 
00032   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00033 
00034 */
00035 
00036 
00037 #include <stdarg.h>
00038 #include <cmplrs/host.h>
00039 
00040 #ifdef MFEF77_C
00041         /* include these only if support for mfef77 ftn->c is needed */
00042 #include <libftn.h>
00043 
00044 int _con1 = 1;
00045 int _con2 = 2;
00046 int _con3 = 3;
00047 int _con4 = 4;
00048 int _con5 = 5;
00049 int _con6 = 6;
00050 int _con7 = 7;
00051 int _con8 = 8;
00052 int _con9 = 9;
00053 int _con10 = 10;
00054 int _con11 = 11;
00055 int _con12 = 12;
00056 int _con13 = 13;
00057 int _con14 = 14;
00058 int _con18 = 18;
00059 int _con19 = 19;
00060 
00061 long _lcon1 = 1;
00062 
00063 int __jmax(int argcnt, ...)
00064 {
00065   int arg, maxarg;
00066   va_list ap;
00067 
00068   va_start(ap, argcnt);
00069   maxarg = va_arg(ap, int);
00070   while (--argcnt > 0) {
00071     arg = va_arg(ap, int);
00072     if (arg > maxarg) maxarg = arg;
00073   }  /* while */
00074   va_end(ap);
00075   return maxarg;
00076 }  /* __jmax */
00077 
00078 long long __kmax(int argcnt, ...)
00079 {
00080   long long arg, maxarg;
00081   va_list ap;
00082 
00083   va_start(ap, argcnt);
00084   maxarg = va_arg(ap, long long);
00085   while (--argcnt > 0) {
00086     arg = va_arg(ap, long long);
00087     if (arg > maxarg) maxarg = arg;
00088   }  /* while */
00089   va_end(ap);
00090   return maxarg;
00091 }  /* __kmax */
00092 
00093 float __rmax(int argcnt, ...)
00094 {
00095   float  arg, maxarg;
00096   va_list ap;
00097 
00098   va_start(ap, argcnt);
00099   maxarg = va_arg(ap, double);
00100   while (--argcnt > 0) {
00101     arg = va_arg(ap, double);
00102     if (arg > maxarg) maxarg = arg;
00103   }  /* while */
00104   va_end(ap);
00105   return maxarg;
00106 }  /* __rmax */
00107 
00108 double __dmax(int argcnt, ...)
00109 {
00110   double  arg, maxarg;
00111   va_list ap;
00112 
00113   va_start(ap, argcnt);
00114   maxarg = va_arg(ap, double);
00115   while (--argcnt > 0) {
00116     arg = va_arg(ap, double);
00117     if (arg > maxarg) maxarg = arg;
00118   }  /* while */
00119   va_end(ap);
00120   return maxarg;
00121 }  /* __dmax */
00122 
00123 float __ajmax0(int argcnt, ...)
00124 {
00125   int arg, maxarg;
00126   va_list ap;
00127 
00128   va_start(ap, argcnt);
00129   maxarg = va_arg(ap, int);
00130   while (--argcnt > 0) {
00131     arg = va_arg(ap, int);
00132     if (arg > maxarg) maxarg = arg;
00133   }  /* while */
00134   va_end(ap);
00135   return (float)maxarg;
00136 }  /* __ajmax0 */
00137 
00138 float __akmax0(int argcnt, ...)
00139 {
00140   long long arg, maxarg;
00141   va_list ap;
00142 
00143   va_start(ap, argcnt);
00144   maxarg = va_arg(ap, long long);
00145   while (--argcnt > 0) {
00146     arg = va_arg(ap, long long);
00147     if (arg > maxarg) maxarg = arg;
00148   }  /* while */
00149   va_end(ap);
00150   return (float)maxarg;
00151 }  /* __akmax0 */
00152 
00153 int __jmax1(int argcnt, ...)
00154 {
00155   float  arg, maxarg;
00156   va_list ap;
00157 
00158   va_start(ap, argcnt);
00159   maxarg = va_arg(ap, double);
00160   while (--argcnt > 0) {
00161     arg = va_arg(ap, double);
00162     if (arg > maxarg) maxarg = arg;
00163   }  /* while */
00164   va_end(ap);
00165   return (int)maxarg;
00166 }  /* __jmax1 */
00167 
00168 long long __kmax1(int argcnt, ...)
00169 {
00170   float  arg, maxarg;
00171   va_list ap;
00172 
00173   va_start(ap, argcnt);
00174   maxarg = va_arg(ap, double);
00175   while (--argcnt > 0) {
00176     arg = va_arg(ap, double);
00177     if (arg > maxarg) maxarg = arg;
00178   }  /* while */
00179   va_end(ap);
00180   return (long long)maxarg;
00181 }  /* __kmax1 */
00182 
00183 int __jmin(int argcnt, ...)
00184 {
00185   int arg, minarg;
00186   va_list ap;
00187 
00188   va_start(ap, argcnt);
00189   minarg = va_arg(ap, int);
00190   while (--argcnt > 0) {
00191     arg = va_arg(ap, int);
00192     if (arg < minarg) minarg = arg;
00193   }  /* while */
00194   va_end(ap);
00195   return minarg;
00196 }  /* __jmin */
00197 
00198 long long __kmin(int argcnt, ...)
00199 {
00200   long long arg, minarg;
00201   va_list ap;
00202 
00203   va_start(ap, argcnt);
00204   minarg = va_arg(ap, long long);
00205   while (--argcnt > 0) {
00206     arg = va_arg(ap, long long);
00207     if (arg < minarg) minarg = arg;
00208   }  /* while */
00209   va_end(ap);
00210   return minarg;
00211 }  /* __kmin */
00212 
00213 float __rmin(int argcnt, ...)
00214 {
00215   float  arg, minarg;
00216   va_list ap;
00217 
00218   va_start(ap, argcnt);
00219   minarg = va_arg(ap, double);
00220   while (--argcnt > 0) {
00221     arg = va_arg(ap, double);
00222     if (arg < minarg) minarg = arg;
00223   }  /* while */
00224   va_end(ap);
00225   return minarg;
00226 }  /* __rmin */
00227 
00228 double __dmin(int argcnt, ...)
00229 {
00230   double  arg, minarg;
00231   va_list ap;
00232 
00233   va_start(ap, argcnt);
00234   minarg = va_arg(ap, double);
00235   while (--argcnt > 0) {
00236     arg = va_arg(ap, double);
00237     if (arg < minarg) minarg = arg;
00238   }  /* while */
00239   va_end(ap);
00240   return minarg;
00241 }  /* __dmin */
00242 
00243 float __ajmin0(int argcnt, ...)
00244 {
00245   int arg, minarg;
00246   va_list ap;
00247 
00248   va_start(ap, argcnt);
00249   minarg = va_arg(ap, int);
00250   while (--argcnt > 0) {
00251     arg = va_arg(ap, int);
00252     if (arg < minarg) minarg = arg;
00253   }  /* while */
00254   va_end(ap);
00255   return (float)minarg;
00256 }  /* __ajmin0 */
00257 
00258 float __akmin0(int argcnt, ...)
00259 {
00260   long long arg, minarg;
00261   va_list ap;
00262 
00263   va_start(ap, argcnt);
00264   minarg = va_arg(ap, long long);
00265   while (--argcnt > 0) {
00266     arg = va_arg(ap, long long);
00267     if (arg < minarg) minarg = arg;
00268   }  /* while */
00269   va_end(ap);
00270   return (float)minarg;
00271 }  /* __akmin0 */
00272 
00273 int __jmin1(int argcnt, ...)
00274 {
00275   float  arg, minarg;
00276   va_list ap;
00277 
00278   va_start(ap, argcnt);
00279   minarg = va_arg(ap, double);
00280   while (--argcnt > 0) {
00281     arg = va_arg(ap, double);
00282     if (arg < minarg) minarg = arg;
00283   }  /* while */
00284   va_end(ap);
00285   return (int)minarg;
00286 }  /* __jmin1 */
00287 
00288 long long __kmin1(int argcnt, ...)
00289 {
00290   float  arg, minarg;
00291   va_list ap;
00292 
00293   va_start(ap, argcnt);
00294   minarg = va_arg(ap, double);
00295   while (--argcnt > 0) {
00296     arg = va_arg(ap, double);
00297     if (arg < minarg) minarg = arg;
00298   }  /* while */
00299   va_end(ap);
00300   return (long long)minarg;
00301 }  /* __kmin1 */
00302 
00303 /* Character concatenation. */
00304 char *_concat(char *dp, int dl, int *dlp, char *ap, int al, char *bp, int bl)
00305 /* (dp, dl) = (ap, al) // (dp, bl).  Length stored in *dlp. */
00306 {
00307   char *p = dp;
00308   *dlp = al + bl;
00309   if (*dlp > dl) {
00310     fprintf(stderr, "Overflow in _concat.\n");
00311     exit(1);
00312   }  /* if */
00313   while (al-- > 0) *p++ = *ap++;
00314   while (bl-- > 0) *p++ = *bp++;
00315   return dp;
00316 }  /* _concat */
00317 
00318 /* Complex number constructors: */
00319 struct _cpx_float _cpx_float(float r, float i)
00320 {
00321   struct _cpx_float t;
00322   t.r = r;
00323   t.i = i;
00324   return t;
00325 }  /* _cpx_float */
00326 
00327 struct _cpx_float _cpx_make_float_from_double(struct _cpx_double d)
00328 {
00329   struct _cpx_float t;
00330   t.r = d.r;
00331   t.i = d.i;
00332   return t;
00333 }  /* _cpx_make_float_from_double */
00334 
00335 struct _cpx_double _cpx_double(double r, double i)
00336 {
00337   struct _cpx_double t;
00338   t.r = r;
00339   t.i = i;
00340   return t;
00341 }  /* _cpx_double */
00342 
00343 struct _cpx_double _cpx_make_double_from_float(struct _cpx_float f)
00344 {
00345   struct _cpx_double t;
00346   t.r = f.r;
00347   t.i = f.i;
00348   return t;
00349 }  /* _cpx_make_double_from_float */
00350 
00351 struct _cpx_float _xnegate_float(struct _cpx_float a)
00352 {
00353   struct _cpx_float t;
00354   t.r = -a.r;
00355   t.i = -a.i;
00356   return t;
00357 }  /* _xnegate_float */
00358 
00359 struct _cpx_double _xnegate_double(struct _cpx_double a)
00360 {
00361   struct _cpx_double t;
00362   t.r = -a.r;
00363   t.i = -a.i;
00364   return t;
00365 }  /* _xnegate_double */
00366 
00367 struct _cpx_float _xadd_float(struct _cpx_float a, struct _cpx_float b)
00368 {
00369   struct _cpx_float t;
00370   t.r = a.r + b.r;
00371   t.i = a.i + b.i;
00372   return t;
00373 }  /* _xadd_float */
00374 
00375 struct _cpx_double _xadd_double(struct _cpx_double a, struct _cpx_double b)
00376 {
00377   struct _cpx_double t;
00378   t.r = a.r + b.r;
00379   t.i = a.i + b.i;
00380   return t;
00381 }  /* _xadd_double */
00382 
00383 struct _cpx_float _xsubtract_float(struct _cpx_float a, struct _cpx_float b)
00384 {
00385   struct _cpx_float t;
00386   t.r = a.r - b.r;
00387   t.i = a.i - b.i;
00388   return t;
00389 }  /* _xsubtract_float */
00390 
00391 struct _cpx_double _xsubtract_double(struct _cpx_double a, struct _cpx_double b)
00392 {
00393   struct _cpx_double t;
00394   t.r = a.r - b.r;
00395   t.i = a.i - b.i;
00396   return t;
00397 }  /* _xsubtract_double */
00398 
00399 struct _cpx_float _xmultiply_float(struct _cpx_float a, struct _cpx_float b)
00400 {
00401   struct _cpx_float t;
00402   t.r = a.r*b.r - a.i*b.i;
00403   t.i = a.i*b.r + a.r*b.i;
00404   return t;
00405 }  /* _xmultiply_float */
00406 
00407 struct _cpx_double _xmultiply_double(struct _cpx_double a, struct _cpx_double b)
00408 {
00409   struct _cpx_double t;
00410   t.r = a.r*b.r - a.i*b.i;
00411   t.i = a.i*b.r + a.r*b.i;
00412   return t;
00413 }  /* _xmultiply_double */
00414 
00415 struct _cpx_float _xdivide_float(struct _cpx_float a, struct _cpx_float b)
00416 {
00417   struct _cpx_float t;
00418   float d = b.r*b.r+b.i*b.i;
00419   t.r = (a.r*b.r+a.i*b.i)/d;
00420   t.i = (a.i*b.r-a.r*b.i)/d;
00421   return t;
00422 }  /* _xdivide_float */
00423 
00424 struct _cpx_double _xdivide_double(struct _cpx_double a, struct _cpx_double b)
00425 {
00426   struct _cpx_double t;
00427   double d = b.r*b.r+b.i*b.i;
00428   t.r = (a.r*b.r+a.i*b.i)/d;
00429   t.i = (a.i*b.r-a.r*b.i)/d;
00430   return t;
00431 }  /* _xdivide_double */
00432 
00433 int _xeq_float(struct _cpx_float a, struct _cpx_float b)
00434 {
00435   return a.r == b.r && a.i == b.i;
00436 }  /* _xeq_float */
00437 
00438 int _xeq_double(struct _cpx_double a, struct _cpx_double b)
00439 {
00440   return a.r == b.r && a.i == b.i;
00441 }  /* _xeq_double */
00442 
00443 int _xne_float(struct _cpx_float a, struct _cpx_float b)
00444 {
00445   return a.r != b.r || a.i != b.i;
00446 }  /* _xne_float */
00447 
00448 int _xne_double(struct _cpx_double a, struct _cpx_double b)
00449 {
00450   return a.r != b.r || a.i != b.i;
00451 }  /* _xne_double */
00452 
00453 /* Hack alert:  The complex exponentation functions take a pointer to the
00454    result as the first parameter.  Since c_gen_be.c doesn't realize it's
00455    a complex exponentiation until it's already put out the left hand side
00456    of the assignment statement, it was easiest to just code these stub
00457    routines to call the real functions. */
00458 
00459 struct _cpx_float pow_ci_stub(struct _cpx_float *a, int *b)
00460 {
00461 struct _cpx_float temp;
00462 pow_ci(&temp,a,b);
00463 return temp;
00464 }
00465 
00466 struct _cpx_float pow_cl_stub(struct _cpx_float *a, long long *b)
00467 {
00468 struct _cpx_float temp;
00469 pow_cl(&temp,a,b);
00470 return temp;
00471 }
00472 
00473 struct _cpx_float pow_cc_stub(struct _cpx_float *a, struct _cpx_float *b)
00474 {
00475 struct _cpx_float temp1;
00476 complex temp2;
00477 temp2 = __powcc(a->r, a->i, b->r, b->i);
00478 temp1.r = temp2.real;
00479 temp1.i = temp2.imag;
00480 return temp1;
00481 }
00482 
00483 struct _cpx_double pow_zi_stub(struct _cpx_double *a, int *b)
00484 {
00485 struct _cpx_double temp;
00486 pow_zi_(&temp,a,b);
00487 return temp;
00488 }
00489 
00490 struct _cpx_double pow_zl_stub(struct _cpx_double *a, long long *b)
00491 {
00492 struct _cpx_double temp;
00493 pow_zl_(&temp,a,b);
00494 return temp;
00495 }
00496 
00497 struct _cpx_double pow_zz_stub(struct _cpx_double *a, struct _cpx_double *b)
00498 {
00499 struct _cpx_double temp;
00500 pow_zz(&temp,a,b);
00501 return temp;
00502 }
00503 
00504 #endif /* MFEF77_C */
00505 
00506 /* Routines for RSHIFT.  No error checking is done. */
00507 
00508 int8 rshft_b(int8 *m, int8 *k)
00509 {
00510   int8 l;
00511   l = -*k;
00512   return(shft_b(m, &l));
00513 }
00514 
00515 int16 rshft_h(int16 *m, int16 *k)
00516 {
00517   int16 l;
00518   l = -*k;
00519   return(shft_h(m, &l));
00520 }
00521 
00522 int32 rshft_l(int32 *m, int32 *k)
00523 {
00524   int32 l;
00525   l = -*k;
00526   return(shft_l(m, &l));
00527 }
00528 
00529 int64 rshft_ll(int64 *m, int64 *k)
00530 {
00531   int64 l;
00532   l = -*k;
00533   return(shft_ll(m, &l));
00534 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines