Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
cwh_dst.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 typedef struct type_trans {
00036         DST_size_t size;
00037         char *name;
00038         DST_ATE_encoding encoding;
00039 } type_trans;   
00040 
00041 static DST_INFO_IDX base_types[MTYPE_LAST+5] =  
00042 {
00043 DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,    
00044 DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,    
00045 DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,    
00046 DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,
00047 DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,
00048 DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,DST_INVALID_INIT,
00049 DST_INVALID_INIT
00050 } ;
00051         
00052 static type_trans ate_types[] = {
00053  4, "BAD",       0,             
00054  4, "UNK",       0,                     /* bit */
00055  1, "INTEGER_1", DW_ATE_signed,         /* MTYPE_I1  */
00056  2, "INTEGER_2", DW_ATE_signed,         /* MTYPE_I2  */
00057  4, "INTEGER_4", DW_ATE_signed,         /* MTYPE_I4  */
00058  8, "INTEGER_8", DW_ATE_signed,         /* MTYPE_I8  */
00059  1, "INTEGER*1", DW_ATE_unsigned,       /* MTYPE_U1  */
00060  2, "INTEGER*2", DW_ATE_unsigned,       /* MTYPE_U2  */
00061  4, "INTEGER*4", DW_ATE_unsigned,       /* MTYPE_U4  */
00062  8, "INTEGER*8", DW_ATE_unsigned,       /* MTYPE_U8  */
00063  4, "REAL_4",    DW_ATE_float,          /* MTYPE_F4  */
00064  8, "REAL_8",    DW_ATE_float,          /* MTYPE_F8  */
00065  10,"UNK",       DW_ATE_float,          /* MTYPE_F10 */
00066  16,"REAL_16",   DW_ATE_float,          /* MTYPE_F16 */
00067  1 ,"CHAR" ,     DW_ATE_signed_char,    /* MTYPE_STR */
00068  16,"REAL_16",   DW_ATE_float,          /* MTYPE_FQ  */
00069  1, "UNK",       DW_ATE_unsigned_char,  /* MTYPE_M   */         
00070  8, "COMPLEX_4", DW_ATE_complex_float,  /* MTYPE_C4  */
00071  16,"COMPLEX_8", DW_ATE_complex_float,  /* MTYPE_C8  */
00072  32,"COMPLEX_16",DW_ATE_complex_float,  /* MTYPE_CQ  */
00073  1, "VOID",      0,                     /* MTYPE_V   */
00074  1, "LOGICAL_1", DW_ATE_boolean,        
00075  2, "LOGICAL_2", DW_ATE_boolean,        
00076  4, "LOGICAL_4", DW_ATE_boolean,        
00077  8, "LOGICAL_8", DW_ATE_boolean,        
00078 
00079 } ;
00080 
00081 
00082 static DST_INFO_IDX current_scope_idx = DST_INVALID_INIT; /* Current scope */
00083 static DST_INFO_IDX comp_unit_idx     = DST_INVALID_INIT; /* Compilation unit */
00084 
00085 static DST_FILE_IDX file_name_idx     = DST_INVALID_INIT; /* File names */
00086 static DST_DIR_IDX  incl_dir_idx      = DST_INVALID_INIT; /* Include directories */
00087 
00088 
00089 static char *current_working_dir ;
00090 static char *current_host_dir    ; 
00091 
00092 /* 
00093   For the list of directory names we maintain the following state.
00094 */
00095 
00096 #define DST_NAME_TABLE_SIZE 64  /* Increment size of the dir and file list */
00097 static char       **dir_list;
00098 static mUINT16      next_dir_idx = 0;
00099 static mUINT16      dir_list_size = 0;
00100 
00101 /*
00102   For the list of file names we maintain the following state.
00103 */
00104 static char       **file_list;
00105 static mUINT16      next_file_idx = 0;
00106 static mUINT16      file_list_size = 0;
00107 
00108 
00109 /*
00110   This is the ST which requires the DST. It's global
00111   o avoid propagating the ST through the type
00112   information, when the only reason to do so is to form
00113   a DW_AT_subrange locations for dope vectors. It's hoped
00114   that dwarf will be able to express the locations as 
00115   offsets into types, later. The boolean says this ST
00116   has a dope vector TY somewhere, so requires a separate
00117   DST entry, so the address and bounds can describe memory locations.
00118 
00119   Making_FLD_DST is a hack to distinguish a call to see if
00120   a recursive type has been processed and a call to create a new
00121   set subrange locations for a pointer array component. 
00122 
00123   These should go away, if DSTs in structs become more expressive.
00124 */
00125 
00126 ST * Top_ST ;
00127 BOOL Top_ST_has_dope ;
00128 BOOL Making_FLD_DST  ;
00129 /* 
00130    array of struct TYs & associated DST_INFO_IDXs 
00131    to control nested types.
00132 */
00133 
00134 typedef struct ty_dst {
00135         TY_IDX  ty ;
00136         DST_INFO_IDX idx ;
00137 } TYIDX ;
00138 
00139 #define STRUCT_DST_SIZE_CHANGE 512
00140 static  INT32   Struct_Current_Size = 0;
00141 static  TYIDX * Struct_DSTs =  NULL;
00142 static  INT32   Struct_Top = -1 ;
00143 
00144 /* 
00145    array of DST_INFO_IDXs of internal routines.
00146 */
00147 
00148 static DST_INFO_IDX * Inner_DSTs;
00149 
00150 #define INNER_DST_SIZE_CHANGE 128
00151 static  INT32      Inner_Current_Size = 0;
00152 static  INT32      Inner_Top = -1 ;
00153 
00154 enum str_knd { s_NONE, s_WORD, s_BYTE, s_TWO_BYTE, s_CHAR } ;
00155 
00156 static DST_FILE_IDX cwh_dst_enter_files(void) ;
00157 static DST_DIR_IDX  DST_write_directories(void) ;
00158 static DST_FILE_IDX DST_write_files(void) ;
00159 static void         DST_directory_of(char *file_path, char **dir_name, UINT32 *dir_length);
00160 static mUINT16      DST_get_ordinal_num(char    *the_name, 
00161                                         char  ***the_list, 
00162                                         mUINT16 *the_next, 
00163                                         mUINT16 *the_size) ;
00164 
00165 
00166 /* macros to indicate functions which are external */
00167 
00168 #define GET_NEXT_ELEMENT_ST(c,s) cwh_auxst_next_element(c,s,l_COMLIST)
00169 #define GET_NEXT_ALTENTRY(c,s)  cwh_auxst_next_element(c,s,l_ALTENTRY)
00170 #define GET_MODIFIED_NAME(s) cwh_auxst_stem_name(s)
00171 #define GET_NEXT_COMMON(p,c) cwh_auxst_next_element(p,c,l_DST_COMLIST)
00172 #define GET_NEXT_PARAMETER(p,c) cwh_auxst_next_element(p,c,l_DST_PARMLIST)
00173 #define IS_DOPE_TY(t) cwh_types_is_dope(t) 
00174 #define GET_DOPE_BASE_TY(t) cwh_types_dope_basic_TY(t)
00175 #define IS_ALTENTRY(s)  ST_auxst_is_altentry(s)
00176 #define GET_ST_LINENUM(s) cwh_auxst_srcpos_val(s)
00177 #define GET_DOPE_BOUNDS(t) cwh_types_dope_dims_FLD(t)
00178 #define GET_MAIN_ST() cwh_stab_main_ST()
00179 
00180 
00181 /* forward references */
00182 
00183 static DST_INFO_IDX   cwh_dst_basetype(TY_IDX ty) ;
00184 static DST_INFO_IDX   cwh_dst_mk_type(TY_IDX  ty) ;
00185 static DST_INFO_IDX   cwh_dst_mk_func(ST * st) ;
00186 static void           cwh_dst_mk_var(ST * st,DST_INFO_IDX parent);
00187 static void           cwh_dst_mk_const(ST * st,DST_INFO_IDX parent);
00188 static DST_INFO_IDX  cwh_dst_mk_subroutine_type(TY_IDX  ty);
00189 static char *cwh_dst_get_command_line_options(void); 
00190 static INT32         DST_set_assoc_idx(INT32 dummy, 
00191                                        DST_DW_tag tag, 
00192                                        DST_flag flag, 
00193                                        DST_ATTR_IDX iattr, 
00194                                        DST_INFO_IDX inode) ;
00195 static DST_INFO_IDX cwh_dst_array_type(TY_IDX ty) ;
00196 static DST_INFO_IDX cwh_dst_subrange(ARB_HANDLE ar)  ;
00197 static DST_INFO_IDX cwh_dst_member(FLD_HANDLE f,DST_INFO_IDX p) ;
00198 static DST_INFO_IDX cwh_dst_struct_type(TY_IDX ty) ;
00199 static DST_INFO_IDX cwh_dst_pointer_type(TY_IDX ty) ;
00200 static DST_INFO_IDX cwh_dst_mk_common(ST * st) ;
00201 static DST_INFO_IDX cwh_dst_mk_formal(ST * st) ;
00202 static DST_INFO_IDX cwh_dst_mk_variable(ST * st) ;
00203 static DST_INFO_IDX cwh_dst_mk_common_inclusion(ST * com, DST_IDX c) ;
00204 static BOOL         cwh_dst_is_character_TY(TY_IDX ty) ;
00205 static DST_INFO_IDX cwh_dst_substring_type(TY_IDX ty) ;
00206 static DST_INFO_IDX cwh_dst_dope_type(TY_IDX  ty, ST *st, mINT64 ofst, DST_INFO_IDX p, BOOL ptr, DST_INFO_IDX *dope_ty) ;
00207 static DST_INFO_IDX cwh_dst_mk_dope_bound(ST *dp, mINT64 offset,  DST_INFO_IDX t, DST_INFO_IDX p, BOOL comp);
00208 static void         cwh_dst_dope_bounds(TY_IDX  td, ST * st, mINT64 offset, DST_INFO_IDX aa, DST_INFO_IDX p, BOOL comp) ;
00209 static DST_INFO_IDX cwh_dst_struct_has_DST(TY_IDX ty) ;
00210 static void         cwh_dst_struct_set_DST(TY_IDX ty, DST_INFO_IDX i) ;
00211 static void         cwh_dst_struct_clear_DSTs(void);
00212 static BOOL         cwh_dst_has_dope(TY_IDX  ty) ;
00213 static void         cwh_dst_inner_add_DST(DST_INFO_IDX i) ;
00214 static void         cwh_dst_inner_clear_DSTs(void);
00215 static void         cwh_dst_inner_read_DSTs(DST_INFO_IDX parent);
00216 static enum str_knd cwh_dst_stride_kind(TY_IDX  ty) ;
00217 static void         cwh_dst_mk_MAIN(ST *mn,DST_INFO_IDX en_idx) ;
00218 static char         Get_ST_Id (ST_IDX st, INT *level, INT *index);
00219 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines