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 /* Mapping of types - basic type and alignment used as index */ 00036 00037 #define ALIGNS 5 00038 #define align_index(x) (al_off[x>>3]) 00039 #define basic_index(x) (x) 00040 #define alignment_to_align(x) (al_off[x]) 00041 00042 00043 static const INT16 al_off[17]= {0, /* align 0 */ 00044 0, /* align 8 bits */ 00045 1, /* align 16 bits */ 00046 0, 00047 2, /* align 32 bits */ 00048 0,0,0, 00049 3, /* align 64 bits */ 00050 0,0,0,0,0,0,0, 00051 4 /* align 128 bits */ 00052 }; 00053 00054 static const STRING alstr[ALIGNS-1]= { 00055 ".align1", /* align 8 bits */ 00056 ".align2", /* align 16 bits */ 00057 ".align4", /* align 32 bits */ 00058 ".align8", /* align 64 bits */ 00059 }; 00060 00061 static const STRING logstr[ALIGNS-1]= { ".log.1",".log.2",".log.4",".log.8" } ; 00062 00063 static TY_IDX unaligned_type [MTYPE_LAST+1][ALIGNS]; 00064 static TY_IDX basic_logical_ty[NUM_LOG_KINDS][ALIGNS]; 00065 00066 static const TYPE_ID Mtypes[ALIGNS][Vector_Mask+1] = { 00067 { 00068 MTYPE_V, 00069 MTYPE_I1, /* Logical */ 00070 MTYPE_U1, /* Typeless */ 00071 MTYPE_V, /* Void */ 00072 MTYPE_I1, /* Char_Fortran */ 00073 MTYPE_I1, /* Char_C */ 00074 MTYPE_I1, /* Structure */ 00075 MTYPE_I1, /* Union */ 00076 MTYPE_I1, /* Integral */ 00077 MTYPE_F4, /* Floating_Pt */ 00078 MTYPE_C4, /* Complex */ 00079 MTYPE_I1, /* CRI_Pointer */ 00080 MTYPE_I1, /* CRI_Pointer_Char*/ 00081 MTYPE_I1, /* BT_func_ptr */ 00082 MTYPE_V /* Vector_Mask */ 00083 },{ 00084 MTYPE_V, 00085 MTYPE_I2, /* Logical */ 00086 MTYPE_U2, /* Typeless */ 00087 MTYPE_V, /* Void */ 00088 MTYPE_I2, /* Char_Fortran */ 00089 MTYPE_I2, /* Char_C */ 00090 MTYPE_I2, /* Structure */ 00091 MTYPE_I2, /* Union */ 00092 MTYPE_I2, /* Integral */ 00093 MTYPE_F4, /* Floating_Pt */ 00094 MTYPE_C4, /* Complex */ 00095 MTYPE_I2, /* CRI_Pointer */ 00096 MTYPE_I2, /* CRI_Pointer_Char*/ 00097 MTYPE_I2, /* BT_func_ptr */ 00098 MTYPE_V /* Vector_Mask */ 00099 00100 },{ 00101 MTYPE_V, 00102 MTYPE_I4, /* Logical */ 00103 MTYPE_U4, /* Typeless */ 00104 MTYPE_V, /* Void */ 00105 MTYPE_I4, /* Char_Fortran */ 00106 MTYPE_I4, /* Char_C */ 00107 MTYPE_I4, /* Structure */ 00108 MTYPE_I4, /* Union */ 00109 MTYPE_I4, /* Integral */ 00110 MTYPE_F4, /* Floating_Pt */ 00111 MTYPE_C4, /* Complex */ 00112 MTYPE_I4, /* CRI_Pointer */ 00113 MTYPE_I4, /* CRI_Pointer_Char*/ 00114 MTYPE_I4, /* BT_func_ptr */ 00115 MTYPE_V /* Vector_Mask */ 00116 },{ 00117 MTYPE_V, 00118 MTYPE_I8, /* Logical */ 00119 MTYPE_U8, /* Typeless */ 00120 MTYPE_V, /* Void */ 00121 MTYPE_I8, /* Char_Fortran */ 00122 MTYPE_I8, /* Char_C */ 00123 MTYPE_I8, /* Structure */ 00124 MTYPE_I8, /* Union */ 00125 MTYPE_I8, /* Integral */ 00126 MTYPE_F8, /* Floating_Pt */ 00127 MTYPE_C8, /* Complex */ 00128 MTYPE_I8, /* CRI_Pointer */ 00129 MTYPE_I8, /* CRI_Pointer_Char*/ 00130 MTYPE_I8, /* BT_func_ptr */ 00131 MTYPE_V /* Vector_Mask */ 00132 },{ 00133 MTYPE_V, 00134 MTYPE_I8, /* Logical */ 00135 MTYPE_U8, /* Typeless */ 00136 MTYPE_V, /* Void */ 00137 MTYPE_I8, /* Char_Fortran */ 00138 MTYPE_I8, /* Char_C */ 00139 MTYPE_I8, /* Structure */ 00140 MTYPE_I8, /* Union */ 00141 MTYPE_I8, /* Integral */ 00142 MTYPE_FQ, /* Floating_Pt */ 00143 MTYPE_CQ, /* Complex */ 00144 MTYPE_I8, /* CRI_Pointer */ 00145 MTYPE_I8, /* CRI_Pointer_Char*/ 00146 MTYPE_I8, /* BT_func_ptr */ 00147 MTYPE_V /* Vector_Mask */ 00148 }} ; 00149 00150 00151 /* local definitions */ 00152 00153 #define MAX_ALIGN 16 00154 00155 00156 /* 00157 * variables used to build array types 00158 * fei_array_dimen adds a bound on each 00159 * pass. 00160 * decl_bounds - the details of the bounds 00161 * top_of_decl_bounds - # of axes. 00162 * ty_dim1 - base type of array 00163 * last_bitsize - size of last axis. 00164 * 00165 */ 00166 00167 static ARB_HANDLE decl_bounds; 00168 static INT32 top_of_decl_bounds = ANULL ; 00169 static INT32 co_top_decl_bounds = ANULL ; 00170 00171 static TY_IDX ty_dim1 ; 00172 static INT64 last_bitsize; 00173 00174 /* structure used to hold distribution info for DISTRIBUTED arrays */ 00175 /* decl_distribution - the distribution kind (BLOCK, STAR, etc...) 00176 decl_cyclic_val - args for CYCLIC 00177 decl_onto - the corresponding ONTO arg (0=star) 00178 00179 top_of_decl_bounds is used as a bound for this array 00180 decl_is_distributed - is set depending on which directive is used 00181 distribute_onto - set to TRUE if this distribute has an ONTO clause 00182 00183 decl_distribute_pragmas - set to a list of distribute pragmas generated 00184 00185 */ 00186 00187 static DISTRIBUTE_TYPE decl_distribution[MAX_ARY_DIMS]; 00188 static union { 00189 WN *wn; 00190 INT val; 00191 } decl_cyclic_val[MAX_ARY_DIMS]; 00192 static WN *decl_onto[MAX_ARY_DIMS]; 00193 static WN_PRAGMA_ID decl_distributed_pragma_id; 00194 static BOOL distribute_onto; 00195 WN *decl_distribute_pragmas; 00196 00197 /* 00198 * definitions of the dope vector entries 00199 * names, offsets,sizes, type-ids. n32/64 00200 * versions, hence two tables for each. 00201 * 00202 * bounds are defined similarly below. 00203 * 00204 */ 00205 00206 static const STRING dope_name [DOPE_NM] = { 00207 "base", 00208 "el_len", 00209 "assoc", 00210 "ptr_alloc", 00211 "p_or_a", 00212 "a_contig", 00213 "unused_1", 00214 "num_dims", 00215 "type_code", 00216 "orig_base", 00217 "orig_size", 00218 }; 00219 00220 static const int dope_bofst[DOPE_NM] = { 00221 0,0,0,1,2,4,5,29,0,0,0 00222 }; 00223 00224 static const int dope_bsize[DOPE_NM] = { 00225 0,0,1,1,2,1,56,3,64,0,0 00226 }; 00227 00228 static TYPE_ID *dope_btype; 00229 static INT *dope_offset; 00230 00231 00232 static TYPE_ID dope_btype_64[DOPE_NM] = { 00233 MTYPE_U8,MTYPE_I8,MTYPE_U4, 00234 MTYPE_U4,MTYPE_U4,MTYPE_U4, 00235 MTYPE_U8,MTYPE_U4, 00236 MTYPE_U8,MTYPE_U8, 00237 MTYPE_I8 00238 }; 00239 00240 static int dope_offset_64 [DOPE_NM] = { 00241 ADDR_OFFSET,8,16,16,16,16,16,20,24,32,40 00242 }; 00243 00244 00245 static TYPE_ID dope_btype_32[DOPE_NM] = { 00246 MTYPE_U4,MTYPE_I4,MTYPE_U4, 00247 MTYPE_U4,MTYPE_U4,MTYPE_U4, 00248 MTYPE_U8,MTYPE_U4, 00249 MTYPE_U8,MTYPE_U4, 00250 MTYPE_I4 00251 }; 00252 00253 static int dope_offset_32 [DOPE_NM] = { 00254 ADDR_OFFSET,4,8,8,8,8,8,12,16,24,28 00255 }; 00256 00257 static const STRING bound_name [BOUND_NM] = { 00258 "lb", 00259 "ext", 00260 "str_m", 00261 } ; 00262 00263 00264 /* 00265 * descriptor type name - used to distinguish dope 00266 * structs from other structs. see cwh_types_is_dope 00267 * 00268 */ 00269 00270 static const char * const dope_str = ".dope." ; 00271 static const char * const dope_invariant_str = ".flds." ; 00272 #define DOPENM_LEN 6 00273 00274 /* is this a base type that a global, shared descriptor */ 00275 /* TY could be created for? Logicals can't be shared with */ 00276 /* integers, so they need another 'table' which is tacked */ 00277 /* onto the entries for the other mtypes */ 00278 00279 #define IS_SHARED_DOPE_BASE(ty) (TY_kind(ty) == KIND_SCALAR && !TY_is_character(ty)) 00280 #define NUM_LOGICAL_DOPE_TYPES 4 00281 #define NUM_DOPE_TYPES MTYPE_LAST + 1 + NUM_LOGICAL_DOPE_TYPES 00282 #define LOGICAL_OFFSET(bt) (MTYPE_LAST + (bt - MTYPE_I1 + 1)) 00283 00284 00285 /* 00286 * These are used for sizing dope vectors 00287 * They are set in cwh_addr.c, in cwh_addr_init_target 00288 */ 00289 00290 TY_IDX DOPE_bound_ty; 00291 INT32 DOPE_bound_sz; 00292 INT32 DOPE_dim_offset; 00293 INT32 DOPE_sz; 00294 00295 00296 00297 /* logical 4 byte ty, for general use */ 00298 00299 TY_IDX logical4_ty; 00300 00301 00302 /* 00303 * structure and stack to deal with nested derived types 00304 * dty - TY of enclosing KIND_STRUCT 00305 * dty_last - last FLD processed by fei_member 00306 * ncompos - number of components 00307 * seq - is sequence derived type 00308 */ 00309 00310 typedef struct { 00311 TY_IDX dty ; 00312 FLD_IDX dty_last ; 00313 INT32 ncompos ; 00314 BOOL seq ; 00315 BOOL hosted ; 00316 } dtype_t ; 00317 00318 static INT32 dtype_stk_size = 0; 00319 static dtype_t *dtype_stk=NULL; 00320 static INT32 dtype_top = -1 ; 00321 00322 #define STK_SIZE_CHANGE 100; 00323 00324 /* 00325 Namelist definitions 00326 */ 00327 00328 /* Length of fields for holding namelist/variable names. */ 00329 #define NL_Name_Length 36 00330 00331 /* How much space does an mtype take in memory? */ 00332 #define MTYPE_MemorySize(x) (MTYPE_size_min(x) >> 3) 00333 00334 00335 /* 00336 * Sizes/offsets for our structures for 32/64-bit compiles. The 00337 * NL_Table_Index variable chooses between the two. 00338 * 00339 */ 00340 00341 #define ALIGN_Dims 0 00342 #define OFFSET_Dims_ndims 1 00343 #define OFFSET_Dims_nels 2 00344 #define OFFSET_Dims_baseoff 3 00345 #define OFFSET_Dims_span 4 00346 #define ALIGN_Nlentry 5 00347 #define OFFSET_Nlentry_varname 6 00348 #define OFFSET_Nlentry_varaddr 7 00349 #define OFFSET_Nlentry_type 8 00350 #define OFFSET_Nlentry_dimp 9 00351 #define SIZE_Nlentry 10 00352 #define ALIGN_Namelist 11 00353 #define OFFSET_Namelist_nlname 12 00354 #define OFFSET_Namelist_nlvnames 13 00355 00356 static INT NL_Table_Index; 00357 00358 static WN_OFFSET NL_Tables[][2] = { 00359 /* ALIGN_Dims */ 4, 8, 00360 /* OFFSET_Dims_ndims */ 0, 0, 00361 /* OFFSET_Dims_nels */ 4, 8, 00362 /* OFFSET_Dims_baseoff */ 8, 16, 00363 /* OFFSET_Dims_span */ 12, 24, 00364 /* ALIGN_Nlentry */ 4, 8, 00365 /* OFFSET_Nlentry_varname */ 0, 0, 00366 /* OFFSET_Nlentry_varaddr */ 36, 40, 00367 /* OFFSET_Nlentry_type */ 40, 48, 00368 /* OFFSET_Nlentry_dimp */ 44, 56, 00369 /* SIZE_Nlentry */ 48, 64, 00370 /* ALIGN_Namelist */ 4, 8, 00371 /* OFFSET_Namelist_nlname */ 0, 0, 00372 /* OFFSET_Namelist_nlvnames */ 36, 40 00373 }; 00374 00375 00376 #define GET_HOST_SYMTAB ((SYMTAB_level(Current_Symtab) == 1) ? Current_Symtab : SYMTAB_parent(Current_Symtab)) 00377 00378 00379 /* ty_idx of last TY created. So it can be deleted */ 00380 00381 static TY_IDX Last_TY_Created = 0 ; 00382 00383 /* the FE cannot guarantee components of hosted derived type */ 00384 /* are marked hosted, hence we retain a context */ 00385 00386 static BOOL in_hosted_dtype = FALSE ; 00387 00388 00389 00390 /* forward references */ 00391 00392 static FLD_HANDLE cwh_types_fld_util(char* name_string, TY_IDX fld_ty, OFFSET_64 offset, BOOL global) ; 00393 static void cwh_types_fill_type(INT32 flag_bits, TYPE *t, TY_IDX ty) ; 00394 static TY_IDX cwh_types_dim_struct_TY(void); 00395 static TY_IDX cwh_types_dim_TY(INT32 num_dims) ; 00396 static void cwh_types_push_dtype(dtype_t d) ; 00397 static dtype_t cwh_types_pop_dtype(void) ; 00398 static ST * cwh_types_formal_util(TY_IDX ty) ; 00399 static BOOL cwh_types_in_dtype(void) ; 00400 static TY_IDX cwh_types_mk_namelist_item_TY(void) ; 00401 static TY_IDX cwh_types_mk_unique_pointer_TY(TY_IDX ty, BOOL host) ; 00402 static TY_IDX cwh_types_mk_misaligned_TY(TY_IDX ty, mUINT16 alignment) ; 00403 00404 static TY_IDX cwh_types_mk_array_TY(ARB_HANDLE bounds,INT16 n,TY_IDX base, INT64 size); 00405 static TY_IDX cwh_types_mk_basic_TY (BASIC_TYPE, INTPTR size, mUINT16 alignment) ; 00406 static TY_IDX cwh_types_mk_struct(INT64 size, INT32 align, FLD_HANDLE list,char *name) ; 00407 static TY_IDX cwh_types_shared_dope(FLD_HANDLE list,int ndims, BOOL is_ptr); 00408 static TY_IDX cwh_types_mk_dope_invariant_TY(void); 00409 static TY_IDX cwh_types_new_TY(BOOL global,INT32 align) ; 00410 static ST * cwh_types_make_bounds_ST(void) ;