Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifdef USE_PCH
00053 #include "common_com_pch.h"
00054 #endif
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
00082
00083
00084
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
00119
00120
00121
00122
00123
00124
00125
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
00161
00162
00163
00164
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
00187
00188
00189
00190
00191
00192
00193
00194
00195 BOOL
00196 Is_Float_Type ( TY_IDX ty )
00197 {
00198 TYPE_ID tid;
00199
00200
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
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 BOOL
00235 Similar_BE_Types ( TY_IDX t1_idx, TY_IDX t2_idx )
00236 {
00237
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
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
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 BOOL
00293 Equivalent_Types (TY_IDX t1, TY_IDX t2, QUAL_CHECK consider_qualifiers)
00294 {
00295
00296
00297 if ( t1 == t2 )
00298 return TRUE;
00299
00300 const TY& ty1 = Ty_Table[t1];
00301 const TY& ty2 = Ty_Table[t2];
00302
00303
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;
00349 }
00350 }
00351
00352
00353 #ifndef MONGOOSE_BE
00354 #endif
00355