Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
cwh_intrin.i
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 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 
00037 /********************************************************
00038 This is a table indexed by Fortran type which contains 
00039 the INTRINSIC numbers for all of the intrinsics. 
00040 
00041 The table is indexed by type and intrinsic, with 
00042 the types and intrinsics defined using the special enumerated types 
00043 (to do the mappings properly)
00044 
00045 ********************************************************/
00046 
00047 typedef enum {
00048         t_I1=0,
00049         t_I2=1,
00050         t_I4=2,
00051         t_I8=3,
00052         t_F4=4,
00053         t_F8=5,
00054         t_FQ=6,
00055         t_C4=7,
00056         t_C8=8,
00057         t_CQ=9,
00058         t_LAST=10,
00059         t_BAD = t_LAST
00060 } t_enum;
00061 
00062 
00063 typedef enum {
00064 i_abs,
00065 i_acos,
00066 i_ashift,
00067 i_asin,
00068 i_atan,
00069 i_atan2,
00070 i_complex,
00071 i_conjg,
00072 i_cos,
00073 i_cosh,
00074 i_exp,
00075 i_exponent,
00076 i_fraction,
00077 i_ieee_int,
00078 i_ibits,
00079 i_imag,
00080 i_ishftc,
00081 i_log,
00082 i_log10,
00083 i_mod,
00084 i_modulo,
00085 i_near,
00086 i_nextafter,
00087 i_pos_diff,
00088 i_round,
00089 i_rrspace,
00090 i_scale,
00091 i_set_exponent,
00092 i_sign_xfer,
00093 i_sin,
00094 i_sinh,
00095 i_space,
00096 i_sqrt,
00097 i_tan,
00098 i_tanh,
00099 i_trunc,
00100 i_acosd,
00101 i_asind,
00102 i_atand,
00103 i_atan2d,
00104 i_cosd,
00105 i_sind,
00106 i_tand,
00107 i_LAST
00108 } i_enum;
00109 
00110 
00111 typedef struct {
00112    INTRINSIC I;
00113    OPCODE    O;
00114 } intopc;
00115 
00116 /* Accessor macros */
00117 #define WOP(x) {INTRINSIC_NONE,OPC_##x}
00118 #define IOP(x) {INTRN_##x,OPCODE_UNKNOWN}
00119 #define NOWI   {INTRINSIC_NONE,OPCODE_UNKNOWN}
00120 #define GET_WOP(x) ((x).O)
00121 #define GET_IOP(x) ((x).I)
00122 
00123 /* Predefined stuff */
00124 #define NOINT NOWI,NOWI,NOWI,NOWI
00125 #define NOREAL NOWI,NOWI,NOWI
00126 #define NOCMPX NOWI,NOWI,NOWI
00127 #define NOTIMP NOINT,NOREAL,NOCMPX
00128 
00129 #define IREALS(x) IOP(F4##x),IOP(F8##x),IOP(FQ##x)
00130 #define ICMPXS(x) IOP(C4##x),IOP(C8##x),IOP(CQ##x)
00131 #define IINTS(x)  IOP(I1##x),IOP(I2##x),IOP(I4##x),IOP(I8##x)
00132 #define WREALS(x) WOP(F4##x),WOP(F8##x),WOP(FQ##x)
00133 #define WCMPXS(x) WOP(C4##x),WOP(C8##x),WOP(CQ##x)
00134 #define WINTS(x)  WOP(I4##x),WOP(I4##x),WOP(I4##x),WOP(I8##x)
00135 
00136 
00137 /* Intrinsic table */
00138 
00139 typedef struct {
00140         char *iname;
00141         intopc ops[t_LAST];
00142 } itab_entry;
00143 
00144 
00145 #define GET_ITAB_WOP(intr,ty) GET_WOP(intrinsic_lookup[intr].ops[t_from_mtype(ty)])
00146 #define GET_ITAB_IOP(intr,ty) GET_IOP(intrinsic_lookup[intr].ops[t_from_mtype(ty)])
00147 
00148 itab_entry intrinsic_lookup[i_LAST] = {
00149 
00150 {"abs",{ WINTS(ABS),WREALS(ABS),IOP(F4C4ABS),IOP(F8C8ABS),IOP(FQCQABS)}},
00151 {"acos",{ NOINT,IREALS(ACOS),NOCMPX }},
00152 {"ashift",{ WINTS(ASHR),NOREAL, NOCMPX }},  /* See if this is true (7/1/96) */
00153 {"asin",{ NOINT,IREALS(ASIN),NOCMPX }},
00154 {"atan",{ NOINT,IREALS(ATAN),NOCMPX }},
00155 {"atan2", { NOINT,IREALS(ATAN2),NOCMPX }},
00156 {"complex",{ NOINT, NOREAL, WCMPXS(COMPLEX) }}, 
00157 {"conjg",{ NOINT,NOREAL,ICMPXS(CONJG) }},
00158 {"cos",{ NOINT,IREALS(COS),ICMPXS(COS) }},
00159 {"cosh",{ NOINT,IREALS(COSH),NOCMPX }},
00160 {"exp",{ NOINT, IREALS(EXP),ICMPXS(EXP) }},
00161 {"exponent",{ NOINT, IREALS(EXPONENT), NOCMPX }}, /* Special */
00162 {"fraction",{ NOINT, IREALS(FRACTION), NOCMPX }}, 
00163 {"ieee_int",{ IINTS(IEEE_INT), IREALS(IEEE_INT), NOCMPX }},
00164 {"ibits",{ IINTS(BITS), NOREAL, NOCMPX }},
00165 {"imag",{ NOINT, WREALS(IMAGPART), NOCMPX }},
00166 {"ishftc",{ IOP(I4SHFTC),IOP(I4SHFTC),IOP(I4SHFTC),IOP(I8SHFTC), NOREAL, NOCMPX }},
00167 {"log",{ NOINT, IREALS(LOG), ICMPXS(LOG) }},
00168 {"log10",{ NOINT, IREALS(LOG10), NOCMPX }},
00169 {"mod",{ WINTS(REM), IREALS(MOD), NOCMPX }},
00170 {"modulo",{ WINTS(MOD), IREALS(MODULO), NOCMPX }},
00171 {"near",{ NOINT, IREALS(NEAREST), NOCMPX }},
00172 {"nextafter",{ NOINT, IREALS(NEXTAFTER), NOCMPX }},
00173 {"pos_diff",{ IINTS(DIM), IREALS(DIM), NOCMPX }},
00174 {"round",{ NOINT, IREALS(ANINT),NOCMPX }},
00175 {"rrspace",{ NOINT, IREALS(RRSPACING), NOCMPX }},
00176 {"scale",{ NOINT, IREALS(SCALE), NOCMPX }},
00177 {"set_exponent",{ NOINT, IREALS(SET_EXPONENT), NOCMPX }},
00178 {"sign_xfer",{ IINTS(SIGN),IREALS(SIGN),NOCMPX }},
00179 {"sin",{ NOINT, IREALS(SIN), ICMPXS(SIN) }},
00180 {"sinh",{ NOINT, IREALS(SINH), NOCMPX }},
00181 {"space",{ NOINT, IREALS(SPACING), NOCMPX }},
00182 {"sqrt",{ NOINT, WREALS(SQRT), WCMPXS(SQRT) }},
00183 {"tan",{ NOINT, IREALS(TAN), NOCMPX }},
00184 {"tanh",{ NOINT, IREALS(TANH), NOCMPX }},
00185 {"trunc",{ NOINT, IREALS(AINT),NOCMPX }},
00186 {"acosd",{ NOINT,IREALS(ACOSD),NOCMPX }},
00187 {"asind",{ NOINT,IREALS(ASIND),NOCMPX }},
00188 {"atand",{ NOINT,IREALS(ATAND),NOCMPX }},
00189 {"atan2d", { NOINT,IREALS(ATAN2D),NOCMPX }},
00190 {"cosd",{ NOINT,IREALS(COSD), NOCMPX }},
00191 {"sind",{ NOINT, IREALS(SIND), NOCMPX }},
00192 {"tand",{ NOINT, IREALS(TAND), NOCMPX }},
00193 };
00194 
00195 
00196 /* method of argumemt passing */
00197 
00198 enum pb_method { p_VALUE, p_REF } ;
00199 
00200 static WN * cwh_intrin_build(WN **k, INTRINSIC intr,TYPE_ID bt, INT numargs) ;
00201 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines