Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
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 of the GNU General Public License as 00007 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 General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 #include <stdarg.h> 00037 #include <cmplrs/host.h> 00038 00039 #ifdef MFEF77_C 00040 /* include these only if support for mfef77 ftn->c is needed */ 00041 #include <libftn.h> 00042 00043 long double __qmax(int argcnt, ...) 00044 { 00045 long double arg, maxarg; 00046 va_list ap; 00047 00048 va_start(ap, argcnt); 00049 maxarg = va_arg(ap, double); 00050 while (--argcnt > 0) { 00051 arg = va_arg(ap, double); 00052 if (arg > maxarg) maxarg = arg; 00053 } /* while */ 00054 va_end(ap); 00055 return maxarg; 00056 } /* __qmax */ 00057 00058 long double __qmin(int argcnt, ...) 00059 { 00060 long double arg, minarg; 00061 va_list ap; 00062 00063 va_start(ap, argcnt); 00064 minarg = va_arg(ap, double); 00065 while (--argcnt > 0) { 00066 arg = va_arg(ap, double); 00067 if (arg < minarg) minarg = arg; 00068 } /* while */ 00069 va_end(ap); 00070 return minarg; 00071 } /* __qmin */ 00072 00073 struct _cpx_float _cpx_make_float_from_long_double(struct _cpx_long_double q) 00074 { 00075 struct _cpx_float t; 00076 t.r = q.r; 00077 t.i = q.i; 00078 return t; 00079 } /* _cpx_make_float_from_long_double */ 00080 00081 struct _cpx_double _cpx_make_double_from_long_double(struct _cpx_long_double q) 00082 { 00083 struct _cpx_double t; 00084 t.r = q.r; 00085 t.i = q.i; 00086 return t; 00087 } /* _cpx_make_double_from_long_double */ 00088 00089 int _xeq_long_double(struct _cpx_long_double a, struct _cpx_long_double b) 00090 { 00091 return a.r == b.r && a.i == b.i; 00092 } /* _xeq_long_double */ 00093 00094 int _xne_long_double(struct _cpx_long_double a, struct _cpx_long_double b) 00095 { 00096 return a.r != b.r || a.i != b.i; 00097 } /* _xne_long_double */ 00098 00099 struct _cpx_long_double _cpx_long_double(long double r, long double i) 00100 { 00101 struct _cpx_long_double t; 00102 t.r = r; 00103 t.i = i; 00104 return t; 00105 } /* _cpx_long_double */ 00106 00107 struct _cpx_long_double _cpx_make_long_double_from_float(struct _cpx_float f) 00108 { 00109 struct _cpx_long_double t; 00110 t.r = f.r; 00111 t.i = f.i; 00112 return t; 00113 } /* _cpx_make_long_double_from_float */ 00114 00115 struct _cpx_long_double _cpx_make_long_double_from_double(struct _cpx_double d) 00116 { 00117 struct _cpx_long_double t; 00118 t.r = d.r; 00119 t.i = d.i; 00120 return t; 00121 } /* _cpx_make_long_double_from_double */ 00122 00123 struct _cpx_long_double _xnegate_long_double(struct _cpx_long_double a) 00124 { 00125 struct _cpx_long_double t; 00126 t.r = -a.r; 00127 t.i = -a.i; 00128 return t; 00129 } /* _xnegate_long_double */ 00130 00131 struct _cpx_long_double _xadd_long_double(struct _cpx_long_double a, struct _cpx_long_double b) 00132 { 00133 struct _cpx_long_double t; 00134 t.r = a.r + b.r; 00135 t.i = a.i + b.i; 00136 return t; 00137 } /* _xadd_long_double */ 00138 00139 struct _cpx_long_double _xsubtract_long_double(struct _cpx_long_double a, struct _cpx_long_double b) 00140 { 00141 struct _cpx_long_double t; 00142 t.r = a.r - b.r; 00143 t.i = a.i - b.i; 00144 return t; 00145 } /* _xsubtract_long_double */ 00146 00147 struct _cpx_long_double _xmultiply_long_double(struct _cpx_long_double a, struct _cpx_long_double b) 00148 { 00149 struct _cpx_long_double t; 00150 t.r = a.r*b.r - a.i*b.i; 00151 t.i = a.i*b.r + a.r*b.i; 00152 return t; 00153 } /* _xmultiply_long_double */ 00154 00155 struct _cpx_long_double _xdivide_long_double(struct _cpx_long_double a, struct _cpx_long_double b) 00156 { 00157 struct _cpx_long_double t; 00158 long double d = b.r*b.r+b.i*b.i; 00159 t.r = (a.r*b.r+a.i*b.i)/d; 00160 t.i = (a.i*b.r-a.r*b.i)/d; 00161 return t; 00162 } /* _xdivide_long_double */ 00163 00164 /* Hack alert: The complex exponentation functions take a pointer to the 00165 result as the first parameter. Since c_gen_be.c doesn't realize it's 00166 a complex exponentiation until it's already put out the left hand side 00167 of the assignment statement, it was easiest to just code these stub 00168 routines to call the real functions. */ 00169 00170 struct _cpx_long_double pow_cqi_stub(struct _cpx_long_double *a, int *b) 00171 { 00172 struct _cpx_long_double temp; 00173 __pow_cqi(&temp,a,b); 00174 return temp; 00175 } 00176 00177 struct _cpx_long_double pow_cql_stub(struct _cpx_long_double *a, long long *b) 00178 { 00179 struct _cpx_long_double temp; 00180 __pow_cql(&temp,a,b); 00181 return temp; 00182 } 00183 00184 struct _cpx_long_double pow_cq_stub(struct _cpx_long_double *a, struct _cpx_long_double *b) 00185 { 00186 struct _cpx_long_double temp; 00187 __cq_pow(&temp,a,b); 00188 return temp; 00189 } 00190 #endif /* MFEF77_C */ 00191