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 /* ==================================================================== 00037 * ==================================================================== 00038 * 00039 * 00040 * Revision history: 00041 * 26-May-89 - Original version of header. 00042 * 12-Jun-91 - Integrated from Josie 00043 * 00044 * Description: 00045 * 00046 * Map tree nodes to the types of the objects represented. 00047 * 00048 * ==================================================================== 00049 * ==================================================================== 00050 */ 00051 00052 #ifdef USE_PCH 00053 #include "common_com_pch.h" 00054 #endif /* USE_PCH */ 00055 #pragma hdrstop 00056 #include "defs.h" 00057 #include "config.h" 00058 #include "erglob.h" 00059 00060 #include "strtab.h" 00061 #include "stab.h" 00062 #include "opcode.h" 00063 #include "targ_const.h" 00064 #include "const.h" 00065 #include "wn_core.h" 00066 #include "ttype.h" 00067 00068 #ifdef FRONT_F90 00069 #include "wn.h" 00070 #include "wn_simp.h" 00071 #endif 00072 00073 TPDEF *Global_Tpdefs = NULL; 00074 00075 #ifdef FRONT_END_FORTRAN 00076 00077 TY *Fe_Type_Tbl_[FETYPE_LAST+1]; 00078 00079 /* ==================================================================== 00080 * 00081 * FE_Type_Name 00082 * 00083 * Return a printable (character string) representation of 00084 * the FETYPE number of input TY. 00085 * 00086 * ==================================================================== 00087 */ 00088 00089 char * 00090 FE_Type_Name ( TY *ty ) 00091 { 00092 if ( ty == NULL ) return "<null TY>"; 00093 if ( TY_kind(ty) != KIND_SCALAR ) return Kind_Name(TY_kind(ty)); 00094 00095 switch ( TY_fe_btype(ty) ) { 00096 case FETYPE_BAD: return "FETYPE_BAD"; 00097 case FETYPE_UNK: return "FETYPE_UNK"; 00098 case FETYPE_NONE: return "FETYPE_NONE"; 00099 case FETYPE_L1: return "FETYPE_L1"; 00100 case FETYPE_L2: return "FETYPE_L2"; 00101 case FETYPE_L4: return "FETYPE_L4"; 00102 case FETYPE_L8: return "FETYPE_L8"; 00103 case FETYPE_I1: return "FETYPE_I1"; 00104 case FETYPE_I2: return "FETYPE_I2"; 00105 case FETYPE_I4: return "FETYPE_I4"; 00106 case FETYPE_I8: return "FETYPE_I8"; 00107 case FETYPE_R4: return "FETYPE_R4"; 00108 case FETYPE_R8: return "FETYPE_R8"; 00109 case FETYPE_R16: return "FETYPE_R16"; 00110 case FETYPE_C8: return "FETYPE_C8"; 00111 case FETYPE_C16: return "FETYPE_C16"; 00112 case FETYPE_C32: return "FETYPE_C32"; 00113 case FETYPE_CH: return "FETYPE_CH"; 00114 } 00115 00116 return "<unknown scalar TY>"; 00117 } 00118 #endif /* FRONT_END_FORTRAN */ 00119 00120 00121 /* ==================================================================== 00122 * 00123 * TY *TY_Of_Expr (WN *expr) 00124 * 00125 * Return the ty for a whirl expression 00126 * 00127 * ==================================================================== 00128 */ 00129 00130 TY_IDX 00131 TY_Of_Expr (const WN *expr) 00132 { 00133 TY_IDX type; 00134 00135 switch (WN_operator(expr)) { 00136 case OPR_PARM: 00137 type = WN_ty(expr); 00138 break; 00139 case OPR_IDNAME: 00140 type = WN_type(expr); 00141 break; 00142 case OPR_MLOAD: 00143 type = TY_pointed (Ty_Table[WN_ty (expr)]); 00144 break; 00145 default: 00146 type = MTYPE_To_TY(WN_rtype(expr)); 00147 break; 00148 } 00149 00150 TYPE_ID mtype = TY_mtype (type); 00151 00152 if (MTYPE_is_complex (mtype)) 00153 return MTYPE_To_TY (mtype); 00154 00155 return type; 00156 } 00157 00158 /* ==================================================================== 00159 * 00160 * TY_Of_Parameter (WN *expr) 00161 * 00162 * Return the ty for a whirl expression , accounting for the 00163 * SCLASS_FORMAL_REF lie (in the context in which this routine is called 00164 * the formal ref will eventually be dereferenced) 00165 * 00166 * ==================================================================== 00167 */ 00168 TY_IDX 00169 TY_Of_Parameter (WN *expr) 00170 { 00171 TY_IDX type; 00172 00173 type = TY_Of_Expr (expr); 00174 00175 if ((WN_has_sym(expr))) { 00176 if (WN_sclass(expr) == SCLASS_FORMAL_REF) 00177 return Make_Pointer_Type(type); 00178 } 00179 00180 return type; 00181 } 00182 00183 00184 /* ==================================================================== 00185 * 00186 * Is_Float_Type / Is_Float_Node 00187 * 00188 * Determine whether the given type (the type of the object represented 00189 * by the given tree node) is a floating point type. For this purpose, 00190 * the Fortran complex types are considered floating point. 00191 * 00192 * ==================================================================== 00193 */ 00194 00195 BOOL 00196 Is_Float_Type ( TY_IDX ty ) 00197 { 00198 TYPE_ID tid; 00199 00200 /* Determine whether it's floating point: */ 00201 switch (TY_kind (ty)) { 00202 case KIND_SCALAR: 00203 tid = TY_mtype (ty); 00204 if (tid > 0 && tid <= MTYPE_LAST) 00205 return MTYPE_float(tid); 00206 break; 00207 00208 } 00209 return FALSE; 00210 } 00211 00212 00213 #ifndef MONGOOSE_BE 00214 /* ==================================================================== 00215 * 00216 * Similar_BE_Types 00217 * 00218 * Routine to compare two types. This routine should be called to 00219 * determine whether two TY records are equivalent from a back end 00220 * implementation point of view, i.e. whether they have the same bit 00221 * representation (TY_mtype). It ignores diffences of volatile and 00222 * const qualifiers. 00223 * 00224 * WARNING: This routine is currently used to decide whether a 00225 * field/member is of an appropriate type for use in struct/class 00226 * decomposition for parameter passing in registers. It is therefore 00227 * irrelevant how it behaves except for scalar and pointer types. If 00228 * other users are identified, those cases can be modified as 00229 * appropriate for the new users. 00230 * 00231 * ==================================================================== 00232 */ 00233 00234 BOOL 00235 Similar_BE_Types ( TY_IDX t1_idx, TY_IDX t2_idx ) 00236 { 00237 /* Do a quick check for identical types: */ 00238 if ( t1_idx == t2_idx ) 00239 return TRUE; 00240 00241 TY& t1 = Ty_Table [t1_idx]; 00242 TY& t2 = Ty_Table [t2_idx]; 00243 00244 /* Insist on valid kinds: */ 00245 if ( TY_kind(t1) == 0 || TY_kind(t2) == 0 ) 00246 return FALSE; 00247 00248 switch (TY_kind(t1)) { 00249 00250 case KIND_SCALAR: 00251 case KIND_POINTER: 00252 return TY_mtype(t1) == TY_mtype(t2) && 00253 TY_size(t1) == TY_size(t2); 00254 00255 default: 00256 return FALSE; 00257 } 00258 } 00259 #endif /* MONGOOSE_BE */ 00260 00261 /* ==================================================================== 00262 * 00263 * Equivalent_Types 00264 * 00265 * Routine to compare two types. This routine should be called to 00266 * determine whether two TY records are equivalent. 00267 * 00268 * There are several cases where comparing TY pointers directly 00269 * can yield FALSE even though the types are the same for purposes 00270 * of assignment or comparison. Using Equivalent_Types to compare 00271 * two types deals with all these cases. 00272 * 00273 * 1) If two types have the same machine representation (be type) 00274 * except that one is volatile, const or restrict qualified and 00275 * the other is not. Such differences between types should 00276 * usually be ignored by the back-end. (QUAL_IGNORE) 00277 * 00278 * 2) If two types have the same machine representation (be type) 00279 * but differ in the volatile, const and/or restrict qualifiers 00280 * AND this difference is significant to the back-end. 00281 * (QUAL_CONSIDER) 00282 * 00283 * 3) To the front-ends, there are more qualifiers which are important 00284 * to determining type equivalency. Only if these and the volatile, 00285 * const and restrict qualifiers are identical can the two types be 00286 * considered equivalent. (QUAL_FULL) 00287 * 00288 * ==================================================================== 00289 */ 00290 00291 00292 BOOL 00293 Equivalent_Types (TY_IDX t1, TY_IDX t2, QUAL_CHECK consider_qualifiers) 00294 { 00295 00296 /* Quick check for identical types: */ 00297 if ( t1 == t2 ) 00298 return TRUE; 00299 00300 const TY& ty1 = Ty_Table[t1]; 00301 const TY& ty2 = Ty_Table[t2]; 00302 00303 /* Insist on identical, valid, TY_kinds: */ 00304 if (TY_kind (ty1) != TY_kind (ty2) || TY_kind (ty1) == KIND_INVALID) 00305 return FALSE; 00306 00307 BOOL match_q = 00308 (consider_qualifiers == QUAL_IGNORE || 00309 ((TY_is_volatile (t1) == TY_is_volatile (t2) && 00310 TY_is_const (t1) == TY_is_const (t2) && 00311 TY_is_restrict (t1) == TY_is_restrict (t2)) && 00312 (consider_qualifiers != QUAL_FULL || 00313 (TY_align_exp (t1) == TY_align_exp (t2) && 00314 TY_is_character(ty1)==TY_is_character(ty2) && 00315 TY_is_logical(ty1)==TY_is_logical(ty2))))); 00316 00317 switch ( TY_kind (ty1)) { 00318 00319 case KIND_VOID: 00320 return match_q; 00321 00322 case KIND_SCALAR: 00323 return (TY_mtype (ty1) == TY_mtype (ty2) && 00324 TY_size (ty1) == TY_size (ty2) && 00325 match_q); 00326 00327 case KIND_POINTER: 00328 return match_q && Equivalent_Types (TY_pointed (ty1), 00329 TY_pointed (ty2), 00330 consider_qualifiers); 00331 00332 case KIND_FUNCTION: 00333 return match_q && Equivalent_Types (Tylist_Table[TY_tylist (ty1)], 00334 Tylist_Table[TY_tylist (ty2)], 00335 consider_qualifiers); 00336 00337 case KIND_ARRAY: 00338 return (match_q && 00339 Equivalent_Types (TY_etype (ty1), TY_etype (ty2), 00340 consider_qualifiers) && 00341 ARB_are_equivalent(TY_arb(ty1), TY_arb(ty2))); 00342 00343 case KIND_STRUCT: 00344 return TY_fld (ty1) == TY_fld (ty2) && match_q; 00345 00346 default: 00347 ErrMsg ( EC_Invalid_Case, "Equivalent_Types", __LINE__ ); 00348 return FALSE; /* not needed but silences return w/o value warnings */ 00349 } 00350 } // Equivalent_Types 00351 00352 00353 #ifndef MONGOOSE_BE 00354 #endif /* MONGOOSE_BE */ 00355