module.c

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 static char USMID[] = "\n@(#)5.0_pl/sources/module.c    5.17    09/30/99 15:47:54\n";
00037 
00038 # include "defines.h"           /* Machine dependent ifdefs */
00039 
00040 # include "host.m"              /* Host machine dependent macros.*/
00041 # include "host.h"              /* Host machine dependent header.*/
00042 # include "target.m"            /* Target machine dependent macros.*/
00043 # include "target.h"            /* Target machine dependent header.*/
00044 
00045 # include "globals.m"
00046 # include "tokens.m"
00047 # include "sytb.m"  
00048 # include "p_globals.m"  
00049 # include "debug.m"
00050 # include "module.m"
00051 
00052 # include "globals.h"
00053 # include "tokens.h"
00054 # include "sytb.h"
00055 # include "p_globals.h"
00056 # include "module.h"
00057 
00058 # include <ar.h>
00059 
00060 # include <sys/types.h>
00061 # include <sys/stat.h>
00062 
00063 # include <dirent.h>
00064 
00065 # include <errno.h>
00066 
00067 # if defined(GENERATE_WHIRL) && defined(_MODULE_TO_DOT_o)
00068 # include <fcntl.h>
00069 # include <libelf.h>
00070 # include <sys/elf.h>
00071 
00072   /* These are the originator string and .note type this program removes  */
00073   /* from files.                                                          */
00074 
00075 # define NOTE_ORIG_NAME  "Cray Research, Incorporated\0"
00076 # define NOTE_ORGNAM_LEN 28
00077 # define NOTE_TYPE        1
00078 
00079 # elif defined(_TARGET_OS_SOLARIS) && defined(_MODULE_TO_DOT_o)
00080 # include <fcntl.h>
00081 # include <libelf.h>
00082 # include <sys/elf_SPARC.h>
00083 
00084   /* These are the originator string and .note type this program removes  */
00085   /* from files.                                                          */
00086 
00087 # define NOTE_ORIG_NAME  "Cray Research, Incorporated\0"
00088 # define NOTE_ORGNAM_LEN 28
00089 # define NOTE_TYPE        1
00090 # endif
00091 
00092 # if !defined(AR_HDR_SIZE)
00093 # define        AR_HDR_SIZE     sizeof(ar_hdr_type)
00094 # endif
00095 
00096 /******************************************************************************\
00097 |*                                                                            *|
00098 |* Notes if a new field is added to the symbol tables.                        *|
00099 |*                                                                            *|
00100 |*   1) Add it to the appropriate set_mod_link_tbl_for ... routine            *|
00101 |*      This routine sets the KEEP_ME and IDX flags in the mod link table     *|
00102 |*      so that the table entry gets kept during compression.                 *|
00103 |*                                                                            *|
00104 |*   2) Add it to update_idxs_in_attr_entry or compress_tbls for non attr     *|
00105 |*      fields.  These routines do the actual compression and reset the       *|
00106 |*      fields.  compress_tbls calls update_idxs_in_attr_entry.               *|
00107 |*                                                                            *|
00108 |*   3) Add it to update_new_idxs_after_input.  This routine sets the indexes *|
00109 |*      after a module is read in.  When a module is in a file, all the table *|
00110 |*      indexes are 1 based.  When it is read in, each new table is           *|
00111 |*      concatenated to the existing table, so all the indexs need the table  *|
00112 |*      size before reading added to the index.  This is generally the        *|
00113 |*      location to correct for symbol table changes.                         *|
00114 |*                                                                            *|
00115 \******************************************************************************/
00116 
00117 
00118 /******************************************************************************\
00119 |*                                                                            *|
00120 |* Steps for compressing tables.  (Both partial and full compressions.)       *|
00121 |*                                                                            *|
00122 |*   These routines allow for full and partial compressions.  (See #2 to      *|
00123 |*   set indexes for a partial compression.  A full compression is everything *|
00124 |*   in a table.  A partial compression starts at a given index in a table    *|
00125 |*   and goes to the end of a table.  These routines will not do a compression*|
00126 |*   in the middle of a table.                                                *|
00127 |*                                                                            *|
00128 |*   1) Allocate the mod_link_tbl.  This table is allocated so that it is as  *|
00129 |*      big as the largest symbol/ir table.  If between marking the entries   *|
00130 |*      in the mod_link_tbl and the actual compression, any tables grow       *|
00131 |*      always make sure the mod_link_tbl size is still big enough to cover   *|
00132 |*      the new entries.  No matter what table is being compressed, the mod_  *|
00133 |*      link_tbl must be allocated as large as the largest table.             *|
00134 |*                                                                            *|
00135 |*   2) Set the zeroth entries in the mod_link_tbl to one less than the       *|
00136 |*      starting index for compression.  If this is a full compression, then  *|
00137 |*      they should be set to 0.  Anything in a table past this index is      *|
00138 |*      subject to compression.                                               *|
00139 |*                                                                            *|
00140 |*   3) Call set_mod_link_tbl_for_attr  each attr entry that needs to be kept.*|
00141 |*      If this is a partial compression, this only needs to be called for    *|
00142 |*      those attr entries in the part of the attr table to be compressed.    *|
00143 |*      This routine calls set_mod_link_tbl routines for other tables.  If the*|
00144 |*      local name table is to be compressed, these entries will have to be   *|
00145 |*      marked.  (See create_mod_info_tbl for how this is done for a full     *|
00146 |*      compression.)  This routine marks each table entry that needs to be   *|
00147 |*      kept in the mod_link_tbl, with its current index.  That way if the    *|
00148 |*      item being compressed points into a part of the table not being       *|
00149 |*      compressed, it will get the correct index out of the mod_link_tbl.    *|
00150 |*                                                                            *|
00151 |*   4) Call assign_new_idxs.  It will start at the point of compression for  *|
00152 |*      each table.  If the mod_link_tbl is set for that entry, it will be    *|
00153 |*      given a new index.  (The new index for a table starts at the index    *|
00154 |*      where compression starts and is incremented each time a table entry   *|
00155 |*      is kept.)  The new index is put into the mod_link_tbl for the entry.  *|
00156 |*                                                                            *|
00157 |*   5) Call compress_tbls to move the table entries to their new index spots.*|
00158 |*      This is where actual compression takes place.  As the entries are     *|
00159 |*      being moved, all their links are updated with the correct links from  *|
00160 |*      the mod_link_tbl.                                                     *|
00161 |*                                                                            *|
00162 |*   Example:  Compress the attr_tbl starting at index 65.  attr_tbl_idx = 70 *|
00163 |*             Entries  66, 68 and 70 are to be kept.                         *|
00164 |*             1) Allocate mod_link_tbl as large as the largest table.        *|
00165 |*             2) ML_AT_IDX(0) = 64  (65 - one)                               *|
00166 |*                The rest of the tables mod_link_tbl[0] entries are set to   *|
00167 |*                the current table indexes so that no other table compresses.*|
00168 |*             3) Call set_mod_link_tbl_for_attr for attr entries 66, 68 & 70.*|
00169 |*             4) Call assign_new_idxs.       Old Idx        New Idx          *|
00170 |*                                              66             65             *|
00171 |*                                              68             66             *|
00172 |*                                              70             67             *|
00173 |*             5) Call compress_tbls which moves the attr tbl entries.        *|
00174 |*                attr_tbl_idx is set to 67.                                  *|
00175 |*                                                                            *|
00176 |*   NOTE:  compress_tbls and assign_new_idxs will go through all the tables, *|
00177 |*      so in the above example, any references to attrs 66, 68 and 70 will   *|
00178 |*      be reset.  If there are references to attrs 67 or 69, these           *|
00179 |*      references will be set to NULL_IDX.  This is where alot of bugs are   *|
00180 |*      found during module processing.  Full compressions are done when      *|
00181 |*      files are written out for modules or inlining.  Partial compressions  *|
00182 |*      are done when files for module or inlining are read in and also for   *|
00183 |*      interface block compression.                                          *|
00184 |*                                                                            *|
00185 |*                                                                            *|
00186 \******************************************************************************/
00187 
00188 extern  boolean is_directory(char *);
00189 
00190 /*****************************************************************\
00191 |* function prototypes of static functions declared in this file *|
00192 \*****************************************************************/
00193 static  void    allocate_mod_link_tbl (int);
00194 static  void    assign_new_idxs (boolean);
00195 static  void    assign_new_idxs_after_input (int);
00196 static  void    check_ir_for_attrs (int);
00197 static  void    check_il_for_attrs (int);
00198 static  void    compress_tbls (int, boolean);
00199 static  void    compress_type_tbl (int);
00200 # if 0
00201 static  void    create_module_list_from_str_pool (void);
00202 # endif
00203 
00204 # if defined(_TARGET_OS_SOLARIS) && defined(_MODULE_TO_DOT_o)
00205 static  boolean do_elf_notes_section(Elf_Data *, int, int);
00206 static  boolean do_elf_object(Elf *, Elf32_Ehdr *, int, int);
00207 # endif
00208 
00209 /* # if defined(_DEBUG) */
00210 static  void    dump_pdt(FILE *);
00211 static  void    print_mod_tbl(void);
00212 /* # endif */
00213 
00214 static  void    find_files_in_directory(int);
00215 static  void    merge_interfaces (int, int);
00216 static  void    not_visible_semantics (int, int, int);
00217 static  int     ntr_file_in_fp_tbl(int, char *, int);
00218 static  FILE   *open_module_file (int, int);
00219 static  void    process_procs_for_inlining (int);
00220 static  boolean read_in_module_tbl (int, int, FILE *, char *);
00221 static  boolean read_module_tbl_header (int, int, FILE *);
00222 static  boolean read_sytb_from_module_file(int, FILE *, char *);
00223 static  boolean rename_only_semantics (int, boolean);
00224 static  boolean resolve_attr(int);
00225 static  void    resolve_all_components(int, int);
00226 static  void    resolve_used_modules (int);
00227 static  void    set_attr_flds_for_output (void);
00228 static  void    set_mod_link_tbl_for_attr (int);
00229 static  void    set_mod_link_tbl_for_bd (int);
00230 static  void    set_mod_link_tbl_for_cn (int);
00231 static  void    set_mod_link_tbl_for_ir (int);
00232 static  void    set_mod_link_tbl_for_il (int);
00233 static  void    set_mod_link_tbl_for_typ (int);
00234 static  boolean srch_ar_file_for_module_tbl (int, int *, int, FILE *);
00235 static  boolean srch_for_module_tbl (int, int *, int, int, FILE *);
00236 static  void    update_idxs_in_attr_entry (int, int);
00237 static  void    update_intrinsic (int);
00238 
00239 # if defined(_TARGET_OS_SOLARIS) && defined(_MODULE_TO_DOT_o)
00240 static  boolean srch_elf_file_for_module_tbl(int, int);
00241 # endif
00242 
00243 static char * module_suffix_fix = ".mod-whirl";
00244 
00245 
00246 /***********************************\
00247 |* Globals used only in this file  *|
00248 \***********************************/
00249 
00250 static  boolean alternate_entry;
00251 static  boolean count_derived_types;
00252 static  boolean only_update_new_tbl_entries;
00253 static  boolean inline_search;
00254 static  int     list_of_modules_in_module;
00255 static  long    mod_file_end_offset;
00256 static  long    num_module_derived_types;
00257 static  int     save_const_pool_idx;
00258 static  int     save_const_tbl_idx;
00259 static  boolean search_for_duplicate_attrs;
00260 
00261 extern  char    compiler_gen_date[];
00262 
00263 /******************************************************************************\
00264 |*                                                                            *|
00265 |* Description:                                                               *|
00266 |*      This routine enters a rename and/or only name for a USE statement     *|
00267 |*      into the rename only table.  All entries are kept in sorted order.    *|
00268 |*      Rename entries actually get two entries in the table.  The original   *|
00269 |*      name entry is the sorted one.  The new name entry is indexed off the  *|
00270 |*      original name entry.  The whole list of renames/only entries is       *|
00271 |*      indexed by ATP_USE_LIST for the module.                               *|
00272 |*                                                                            *|
00273 |* Input parameters:                                                          *|
00274 |*      module_idx - The attr index for the module specified in the use stmt. *|
00275 |*      ro_idx     - The new name index if this is a rename entry.   (This    *|
00276 |*                   routine is called to enter the new name first.  The ro   *|
00277 |*                   index is returned.  Then it is called again with the     *|
00278 |*                   original name and the ro index.  An entry is made for    *|
00279 |*                   the original name and the rename entry is hung off of it.*|
00280 |*      rename_entry -> TRUE if this is the new name.  It doesn't need to be  *|
00281 |*                      sorted or added to the list.                          *|
00282 |*                                                                            *|
00283 |* Output parameters:                                                         *|
00284 |*      NONE                                                                  *|
00285 |*                                                                            *|
00286 |* Returns:                                                                   *|
00287 |*      ro_idx just entered.                                                  *|
00288 |*                                                                            *|
00289 \******************************************************************************/
00290 int  make_ro_entry(int          module_idx,
00291                    int          ro_idx,
00292                    boolean      rename_entry)
00293 
00294 {
00295    int          cmp_idx;
00296    int          matched;
00297    int          np_idx;
00298    int          prev_idx;
00299 
00300 
00301    TRACE (Func_Entry, "make_ro_entry", NULL);
00302 
00303    if (ro_idx == NULL_IDX) {
00304       ++rename_only_tbl_idx;
00305       CHECK_TBL_ALLOC_SIZE(rename_only_tbl, rename_only_tbl_idx);
00306 
00307       ro_idx = rename_only_tbl_idx;
00308 
00309       CLEAR_TBL_NTRY(rename_only_tbl, ro_idx);
00310 
00311       NTR_NAME_POOL(TOKEN_ID(token).words, TOKEN_LEN(token), np_idx);
00312 
00313       RO_LINE_NUM(ro_idx)       = TOKEN_LINE(token);
00314       RO_COLUMN_NUM(ro_idx)     = TOKEN_COLUMN(token);
00315       RO_NAME_LEN(ro_idx)       = TOKEN_LEN(token);
00316       RO_NAME_IDX(ro_idx)       = np_idx;
00317    }
00318 
00319    if (rename_entry) {   /* Do not sort - assume it is a rename entry */
00320       RO_RENAME_NAME(ro_idx)    = TRUE;
00321    }
00322    else {  /* Find a sorted spot for it */
00323       RO_RENAME_NAME(ro_idx)    = FALSE;
00324 
00325       if (ATP_USE_LIST(module_idx) == NULL_IDX) {
00326          ATP_USE_LIST(module_idx) = ro_idx;
00327       }
00328       else {
00329          cmp_idx        = ATP_USE_LIST(module_idx);
00330          prev_idx       = NULL_IDX;
00331 
00332          for (;;) {
00333             matched = compare_names(RO_NAME_LONG(cmp_idx),
00334                                     RO_NAME_LEN(cmp_idx),
00335                                     TOKEN_ID(token).words,
00336                                     TOKEN_LEN(token));
00337 
00338             if (matched >= 0) {  
00339 
00340                /* Name in table is same or greater than new name.  Add the */
00341                /* new name before the current index.                       */
00342 
00343                RO_NEXT_IDX(ro_idx) = cmp_idx;
00344 
00345                if (prev_idx == NULL_IDX) {
00346                   ATP_USE_LIST(module_idx) = ro_idx;
00347                }
00348                else {
00349                   RO_NEXT_IDX(prev_idx) = ro_idx;
00350                }
00351                break;
00352             }
00353             else {
00354                prev_idx = cmp_idx;
00355                cmp_idx  = RO_NEXT_IDX(cmp_idx);
00356 
00357                if (cmp_idx == NULL_IDX) {  /* Add at end */
00358                   RO_NEXT_IDX(prev_idx) = ro_idx;
00359                   break;
00360                }
00361             }
00362          }
00363       }
00364    }
00365 
00366    TRACE (Func_Exit, "make_ro_entry", NULL);
00367 
00368    return(ro_idx);
00369 
00370 }   /* make_ro_entry */
00371 
00372 /******************************************************************************\
00373 |*                                                                            *|
00374 |* Description:                                                               *|
00375 |*      Search the renames table to see if this new name exists already.      *|
00376 |*      This would happen if the same name was used to rename something twice.*|
00377 |*      If it is found, RO_DUPLICATE_RENAME is set for both entries.  Errors  *|
00378 |*      will be issued during use_stmt_semantics.                             *|
00379 |*                                                                            *|
00380 |* Input parameters:                                                          *|
00381 |*      rename_idx -> The ro index for the name to search for.                *|
00382 |*                                                                            *|
00383 |* Output parameters:                                                         *|
00384 |*      NONE                                                                  *|
00385 |*                                                                            *|
00386 |* Returns:                                                                   *|
00387 |*      NOTHING                                                               *|
00388 |*                                                                            *|
00389 \******************************************************************************/
00390 void    check_for_duplicate_renames(int         rename_idx)
00391 
00392 {
00393    int          ro_idx;
00394 
00395 
00396    TRACE (Func_Entry, "check_for_duplicate_renames", NULL);
00397 
00398    for (ro_idx = 1; ro_idx < rename_only_tbl_idx; ro_idx++) {
00399 
00400       if (RO_RENAME_NAME(ro_idx) &&
00401           (compare_names(RO_NAME_LONG(rename_idx),
00402                          RO_NAME_LEN(rename_idx),
00403                          RO_NAME_LONG(ro_idx),
00404                          RO_NAME_LEN(ro_idx)) == 0) && ro_idx != rename_idx) {
00405         //         RO_DUPLICATE_RENAME(rename_idx)      = TRUE;
00406         //         RO_DUPLICATE_RENAME(ro_idx)          = TRUE;
00407          break;
00408       }
00409    }
00410 
00411    TRACE (Func_Exit, "check_for_duplicate_renames", NULL);
00412 
00413    return;
00414 
00415 }   /* check_for_duplicate_renames */
00416 
00417 /******************************************************************************\
00418 |*                                                                            *|
00419 |* Description:                                                               *|
00420 |*      Allocate and clear the module link table.  This is used for table     *|
00421 |*      compression.                                                          *|
00422 |*                                                                            *|
00423 |* Input parameters:                                                          *|
00424 |*      size -> Size to allocate.  If this is zero, we will calculate the     *|
00425 |*              size to allocate, by finding the largest table.               *|
00426 |*                                                                            *|
00427 |* Output parameters:                                                         *|
00428 |*      NONE                                                                  *|
00429 |*                                                                            *|
00430 |* Returns:                                                                   *|
00431 |*      NOTHING                                                               *|
00432 |*                                                                            *|
00433 \******************************************************************************/
00434 static  void allocate_mod_link_tbl(int          size)
00435 
00436 {
00437    long         *idx;
00438    long          new_size;
00439 
00440 
00441    TRACE (Func_Entry, "allocate_mod_link_tbl", NULL);
00442 
00443    if (size == 0) {
00444 
00445       /* Find the largest table and allocate the mod link table to this size. */
00446 
00447       new_size = (attr_tbl_idx > bounds_tbl_idx)? attr_tbl_idx : bounds_tbl_idx;
00448       new_size = (new_size > const_tbl_idx)     ? new_size : const_tbl_idx;
00449       new_size = (new_size > const_pool_idx)    ? new_size : const_pool_idx;
00450       new_size = (new_size > loc_name_tbl_idx)  ? new_size : loc_name_tbl_idx;
00451       new_size = (new_size > name_pool_idx)     ? new_size : name_pool_idx;
00452       new_size = (new_size > sec_name_tbl_idx)  ? new_size : sec_name_tbl_idx;
00453       new_size = (new_size > stor_blk_tbl_idx)  ? new_size : stor_blk_tbl_idx;
00454       new_size = (new_size > type_tbl_idx)      ? new_size : type_tbl_idx;
00455       new_size = (new_size > ir_tbl_idx)        ? new_size : ir_tbl_idx;
00456       new_size = (new_size > ir_list_tbl_idx)   ? new_size : ir_list_tbl_idx;
00457       new_size = (new_size > sh_tbl_idx)        ? new_size : sh_tbl_idx;
00458    }
00459    else {
00460       new_size  = size;
00461    }
00462 
00463    new_size++;          /* Do not use entry 0, so increase size by 1 */
00464 
00465    CHECK_TBL_ALLOC_SIZE(mod_link_tbl, new_size);
00466    mod_link_tbl_idx     = mod_link_tbl_size - 1;
00467 
00468    idx = ((long *) (&mod_link_tbl[0]));
00469 
00470    memset(idx, 0, mod_link_tbl_size * NUM_ML_WDS * TARGET_BYTES_PER_WORD);
00471 
00472    TRACE (Func_Exit, "allocate_mod_link_tbl", NULL);
00473 
00474    return;
00475 
00476 }  /* allocate_mod_link_tbl */
00477 
00478 /******************************************************************************\
00479 |*                                                                            *|
00480 |* Description:                                                               *|
00481 |*                                                                            *|
00482 |* Input parameters:                                                          *|
00483 |*      NONE                                                                  *|
00484 |*                                                                            *|
00485 |* Output parameters:                                                         *|
00486 |*      NONE                                                                  *|
00487 |*                                                                            *|
00488 |* Returns:                                                                   *|
00489 |*      NOTHING                                                               *|
00490 |*                                                                            *|
00491 \******************************************************************************/
00492 extern  void    create_mod_info_file(void)
00493 {
00494                 int              ga_idx=0;
00495                 FILE            *fp_file_ptr;
00496                 int              fp_idx                 = NULL_IDX;
00497                 int              idx;
00498                 int              length;
00499                 long            *mod_idx;
00500                 int              module_attr_idx;
00501                 int              name_idx;
00502                 long_type        offset;
00503    static       int              preinline_fp_idx       = NULL_IDX;
00504                 long            *ptr;
00505                 int              wd_len;
00506 
00507 # if defined(_MODULE_TO_DOT_M) || defined(_MODULE_TO_DOT_o)
00508                 char            *mod_name_ptr;
00509                 char            *src_name_ptr;
00510 # endif
00511 
00512 # if defined(_MODULE_TO_DOT_M)
00513                 FILE            *fp_file_ptr;
00514    static       int              m_file_fp_idx          = NULL_IDX;
00515 # endif
00516 
00517 
00518    TRACE (Func_Entry, "create_mod_info_file", NULL);
00519 
00520    module_attr_idx = SCP_ATTR_IDX(MAIN_SCP_IDX);
00521 
00522    /* The module is a global name, so it was entered into the global name   */
00523    /* table during parse_module_stmt.  The global name table entry contains */
00524    /* an index to the file path entry for this module, so that if we have   */
00525    /* a USE statement referencing the module during this compilation, we    */
00526    /* can find it in the file quickly by using the offset in its file path  */
00527    /* table entry.  We can also use it to detect duplicate modules.         */
00528 
00529    if (!srch_global_name_tbl(AT_OBJ_NAME_PTR(module_attr_idx),
00530                              AT_NAME_LEN(module_attr_idx),
00531                              &name_idx)) {
00532 
00533       if (num_prog_unit_errors == 0) {
00534          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1250, Internal,
00535                   AT_DEF_COLUMN(module_attr_idx),
00536                   AT_OBJ_NAME_PTR(module_attr_idx));
00537       }
00538       else if (ATP_PGM_UNIT(module_attr_idx) == Module ||
00539                !AT_DCL_ERR(module_attr_idx)) {
00540          ntr_global_name_tbl(module_attr_idx, NULL_IDX, name_idx);
00541       }
00542       else {  /* Error in attr for function name. - Bypass */
00543          ga_idx         = NULL_IDX;
00544          name_idx       = NULL_IDX;
00545       }
00546    }
00547 
00548    if (name_idx != NULL_IDX) {
00549       ga_idx    = GN_ATTR_IDX(name_idx);
00550 
00551       if (GA_OBJ_CLASS(ga_idx) == Common_Block) {
00552          ga_idx = GAC_PGM_UNIT_IDX(ga_idx);
00553 
00554          if (ga_idx == NULL_IDX && num_prog_unit_errors == 0) {
00555             PRINTMSG(AT_DEF_LINE(module_attr_idx), 1250, Internal,
00556                      AT_DEF_COLUMN(module_attr_idx),
00557                      AT_OBJ_NAME_PTR(module_attr_idx));
00558          }
00559          else {  /* Name must have been in error situation.  Make an entry. */
00560             ntr_global_name_tbl(module_attr_idx, NULL_IDX, name_idx);
00561             ga_idx      = GN_ATTR_IDX(name_idx);
00562          }
00563       }
00564    }
00565 
00566    if (num_prog_unit_errors > 0) {
00567 
00568       if (ga_idx != NULL_IDX && GAP_FP_IDX(ga_idx) != NULL_IDX) {
00569 
00570          /* We already have a module by this name and have created a mod */
00571          /* file for it.  Set SCP_IN_ERR so we don't write out a another */
00572          /* module table.  We would never find this one, because the     */
00573          /* search would always hit the first one.                       */
00574 
00575          SCP_IN_ERR(MAIN_SCP_IDX) = TRUE;
00576       }
00577 
00578       AT_DCL_ERR(module_attr_idx)    = TRUE;
00579 
00580       if (ATP_PGM_UNIT(module_attr_idx) == Module) {
00581          PRINTMSG(AT_DEF_LINE(module_attr_idx), 855, Error,
00582                   AT_DEF_COLUMN(module_attr_idx),
00583                   AT_OBJ_NAME_PTR(module_attr_idx));
00584 
00585          if (SCP_IN_ERR(MAIN_SCP_IDX)) {
00586             return;
00587          }
00588       }
00589       else {  /* Inline information file */
00590          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1322, Error,
00591                   AT_DEF_COLUMN(module_attr_idx),
00592                   AT_OBJ_NAME_PTR(module_attr_idx));
00593       }
00594    }
00595 
00596    offset = 0;
00597 
00598    /* If we are in a preinline compile, everything goes out to the       */
00599    /* preinline_file including modules.                                  */
00600 
00601    if (dump_flags.preinline) {
00602 
00603       if (preinline_fp_idx != NULL_IDX) {
00604          fp_idx         = preinline_fp_idx;
00605          fp_file_ptr    = fopen(FP_NAME_PTR(fp_idx), "ab");
00606          offset         = ftell(fp_file_ptr);
00607          fclose(fp_file_ptr);
00608       }
00609       else {
00610          TBL_REALLOC_CK(file_path_tbl, 1);
00611          CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
00612 
00613          fp_idx                         = file_path_tbl_idx;      
00614          preinline_fp_idx               = fp_idx;
00615          FP_NAME_LEN(fp_idx)            = strlen(preinline_file);
00616          FP_NAME_IDX(fp_idx)            = str_pool_idx + 1;
00617          FP_SRCH_THE_FILE(fp_idx)       = FALSE;
00618          length                         = WORD_LEN(FP_NAME_LEN(fp_idx));
00619 
00620          /* We do not do inlining in a preinline   */
00621          /* compile, so this, can just be File_Fp. */
00622 
00623          FP_CLASS(fp_idx)               = File_Fp;
00624 
00625          TBL_REALLOC_CK(str_pool, length);
00626 
00627          ptr = (long *) (&str_pool[FP_NAME_IDX(fp_idx)].name_long);
00628 
00629          memset(ptr, 0, length * TARGET_BYTES_PER_WORD);
00630 
00631          strcpy(FP_NAME_PTR(fp_idx), preinline_file);
00632 
00633          /* We do not do inlining in a preinline compile so always    */
00634          /* put this on the module path in case it contains a module. */
00635 
00636          FP_NEXT_FILE_IDX(fp_idx) = module_path_idx;
00637       }
00638    }
00639 
00640    /* This creates a name for the module output file.  These are not     */
00641    /* true temp files because they need to last beyond the frontend.     */
00642 
00643    /* There are three naming schemes: _MODULE_TO_DOT_o, _MODULE_TO_DOT_M */
00644    /* and module to .mod (-em). If it is DOT_o, temp files are created   */
00645    /* for each module called .file.module.m.  The file names are passed  */
00646    /* thru the interface, where the backend puts the files where it      */
00647    /* wants.  If the file ends with .m, the backend must clean the file  */
00648    /* up.  If it ends with .mn, the frontend must remove the file.       */
00649    /* If DOT_M, the modules are all put in the same file.M file.  If     */
00650    /* .mod), the modules are each put to a file called modulename.mod.   */
00651 
00652    /* How the commandline option and defines work together:  If -dm is   */
00653    /* specified then either _MODULE_TO_DOT_M or _MODULE_TO_DOT_o         */
00654    /* is the default.                                                    */
00655 
00656    if (on_off_flags.module_to_mod) {
00657 
00658       if (fp_idx == NULL_IDX) {
00659 
00660          /* Create module.mod for the name. */
00661          /* Also, check to see if user specified a dir for the .mod files. */
00662 
00663          if (cmd_line_flags.mod_out_path) {
00664             strcpy(&(mod_file_name[0]), mod_out_path);
00665             strcat(mod_file_name, "/");
00666             strcat(mod_file_name, AT_OBJ_NAME_PTR(module_attr_idx));
00667          }
00668          else {
00669             strcpy(&(mod_file_name[0]), AT_OBJ_NAME_PTR(module_attr_idx));
00670          }
00671          strcat(mod_file_name, module_suffix_fix);
00672          TBL_REALLOC_CK(file_path_tbl, 1);
00673          CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
00674 
00675          fp_idx                   = file_path_tbl_idx;      
00676          FP_NEXT_FILE_IDX(fp_idx) = (ATP_PGM_UNIT(module_attr_idx) != Module) ? 
00677                                      inline_path_idx : module_path_idx;
00678          FP_NAME_LEN(fp_idx)      = strlen(mod_file_name);
00679          FP_NAME_IDX(fp_idx)      = str_pool_idx + 1;
00680          FP_SRCH_THE_FILE(fp_idx) = FALSE;
00681          length                   = WORD_LEN(FP_NAME_LEN(fp_idx));
00682          FP_CLASS(fp_idx)         = File_Fp;
00683 
00684          TBL_REALLOC_CK(str_pool, length);
00685 
00686          for (idx = FP_NAME_IDX(fp_idx); idx <= str_pool_idx; idx++) {        
00687             str_pool[idx].name_long = 0;
00688          }
00689 
00690          strcpy(FP_NAME_PTR(fp_idx), mod_file_name);
00691       }
00692    }
00693    else { /* Default to MODULE_TO_DOT_o or MODULE_TO_DOT_M */
00694 
00695 # if defined(_MODULE_TO_DOT_o)
00696 
00697       if (fp_idx == NULL_IDX) {
00698          mod_file_name[0]       = '.';
00699          mod_name_ptr   = &(mod_file_name[1]);
00700          src_name_ptr   = strrchr (src_file, SLASH);
00701          src_name_ptr   = (src_name_ptr == NULL) ? src_file : src_name_ptr+1;
00702 
00703          while (*mod_name_ptr++ = *src_name_ptr++);
00704 
00705          /* This returns a pointer to the last */
00706          /* occurence of dot in the file name  */
00707 
00708          src_name_ptr = strrchr (mod_file_name, DOT);
00709 
00710          if (src_name_ptr != NULL && 
00711              (EQUAL_STRS(src_name_ptr, ".f") ||
00712               EQUAL_STRS(src_name_ptr, ".f90"))){
00713              src_name_ptr++;
00714          }
00715          else {                  /* Just append module.m on */
00716              strcpy(src_name_ptr, ".");
00717              src_name_ptr++;
00718          }
00719 
00720          TBL_REALLOC_CK(file_path_tbl, 1);
00721 
00722          strncpy(src_name_ptr, 
00723                  AT_OBJ_NAME_PTR(module_attr_idx), 
00724                  AT_NAME_LEN(module_attr_idx));
00725 
00726          src_name_ptr   += AT_NAME_LEN(module_attr_idx);
00727 
00728          /* KAY - Use for running the frontend alone. */
00729 
00730 # if 0
00731          strcpy(src_name_ptr, ".m");      /* Backend will delete this. */
00732 # endif
00733 
00734          strcpy(src_name_ptr, ".mn");     /* Backend will not delete this. */
00735 
00736          TBL_REALLOC_CK(file_path_tbl, 1);
00737          CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
00738 
00739          fp_idx                   = file_path_tbl_idx;      
00740          FP_NEXT_FILE_IDX(fp_idx) = (ATP_PGM_UNIT(module_attr_idx) != Module) ? 
00741                                      inline_path_idx : module_path_idx;
00742          FP_NAME_LEN(fp_idx)      = strlen(mod_file_name);
00743          FP_NAME_IDX(fp_idx)      = str_pool_idx + 1;
00744          FP_SRCH_THE_FILE(fp_idx) = FALSE;
00745          length                   = WORD_LEN(FP_NAME_LEN(fp_idx));
00746          FP_CLASS(fp_idx)         = File_Fp;
00747 
00748          /* This file will be read up and copied by the backend.  It will be  */
00749          /* deleted by the backend (if suffix is .m) or the frontend if       */
00750          /* suffix if the file name suffix is .mn.                            */
00751 
00752          FP_TMP_FILE(fp_idx)    = TRUE;
00753 
00754          TBL_REALLOC_CK(str_pool, length);
00755 
00756          ptr = (long *) (&str_pool[FP_NAME_IDX(fp_idx)].name_long);
00757 
00758          memset(ptr, 0, length * TARGET_BYTES_PER_WORD);
00759 
00760          strcpy(FP_NAME_PTR(fp_idx), mod_file_name);
00761 
00762          if (num_prog_unit_errors == 0 && !dump_flags.no_module_output) {
00763 
00764             /* Send file name through interface to be put into the .o file. */
00765    
00766             FP_OUTPUT_TO_O(fp_idx)      = cmd_line_flags.binary_output;
00767          }
00768       }
00769 
00770 # elif defined(_MODULE_TO_DOT_M)
00771 
00772       if (fp_idx != NULL_IDX) {
00773 
00774          /* intentionally blank */
00775 
00776       }
00777       else if (m_file_fp_idx != NULL_IDX) {
00778          fp_idx         = m_file_fp_idx;
00779          fp_file_ptr    = fopen(FP_NAME_PTR(fp_idx), "ab");
00780          offset         = ftell(fp_file_ptr);
00781          fclose(fp_file_ptr);
00782       }
00783       else {
00784          mod_name_ptr   = &(mod_file_name[0]);
00785          src_name_ptr   = strrchr (src_file, SLASH);
00786          src_name_ptr   = (src_name_ptr == NULL) ? src_file : src_name_ptr+1;
00787 
00788          while (*mod_name_ptr++ = *src_name_ptr++);
00789 
00790          /* This returns a pointer to the last */
00791          /* occurence of dot in the file name  */
00792 
00793          src_name_ptr = strrchr (mod_file_name, DOT);
00794 
00795          if (src_name_ptr != NULL && 
00796              (EQUAL_STRS(src_name_ptr, ".f") ||
00797               EQUAL_STRS(src_name_ptr, ".f90"))){
00798             src_name_ptr++;
00799          }
00800          else {                  /* Just append module.m on */
00801             strcpy(src_name_ptr, ".");
00802             src_name_ptr++;
00803          }
00804 
00805          strcpy(src_name_ptr, "M");
00806 
00807          TBL_REALLOC_CK(file_path_tbl, 1);
00808          CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
00809 
00810          fp_idx                   = file_path_tbl_idx;      
00811          FP_NEXT_FILE_IDX(fp_idx) = (ATP_PGM_UNIT(module_attr_idx) != Module) ? 
00812                                    inline_path_idx : module_path_idx;
00813          FP_NAME_LEN(fp_idx)      = strlen(mod_file_name);
00814          FP_NAME_IDX(fp_idx)      = str_pool_idx + 1;
00815          FP_SRCH_THE_FILE(fp_idx) = FALSE;
00816          length                   = WORD_LEN(FP_NAME_LEN(fp_idx));
00817          FP_CLASS(fp_idx)         = File_Fp;
00818 
00819          TBL_REALLOC_CK(str_pool, length);
00820 
00821          for (idx = FP_NAME_IDX(fp_idx); idx <= str_pool_idx; idx++) {        
00822             str_pool[idx].name_long = 0;
00823          }
00824 
00825          strcpy(FP_NAME_PTR(fp_idx), mod_file_name);
00826 
00827          m_file_fp_idx  = fp_idx;
00828          fp_file_ptr    = fopen(mod_file_name, "wb");
00829          fclose(fp_file_ptr);
00830       }
00831 # endif
00832    }
00833 
00834    /* Keep track of the file index for the first module written out.  This */
00835    /* will get updated with a directory listing all modules in this file.  */
00836 
00837    if (ATP_PGM_UNIT(module_attr_idx) == Module) {
00838 
00839       if (module_path_idx == NULL_IDX) {
00840          module_path_idx        = fp_idx;
00841       }
00842    }
00843    else if (inline_path_idx == NULL_IDX && !dump_flags.preinline) {
00844       inline_path_idx           = fp_idx;
00845    }
00846 
00847    /* Create an entry for the module being written out.  fp_idx  */
00848    /* is the file path table index for the file entry.           */
00849 
00850    TBL_REALLOC_CK(file_path_tbl, 1);
00851    CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
00852 
00853    /* Put this module at the top of the list. */
00854 
00855    FP_MODULE_IDX(file_path_tbl_idx)     = FP_MODULE_IDX(fp_idx);
00856    FP_MODULE_IDX(fp_idx)                = file_path_tbl_idx;
00857 
00858    FP_NAME_LEN(file_path_tbl_idx)       = AT_NAME_LEN(module_attr_idx);
00859    FP_NAME_IDX(file_path_tbl_idx)       = str_pool_idx + 1;
00860    FP_OFFSET(file_path_tbl_idx)         = offset;
00861    FP_FILE_IDX(file_path_tbl_idx)       = fp_idx;     /* Link to file entry */
00862    FP_CLASS(file_path_tbl_idx)          = Current_Compile_Fp;
00863 
00864    mod_idx                              = &(mit_header.wd[0]);
00865 
00866    for (idx=0; idx < sizeof(mit_header_type) / TARGET_BYTES_PER_WORD; idx++) {
00867       *mod_idx = 0;
00868        mod_idx++;
00869    }
00870    if (ga_idx != NULL_IDX) {
00871       GAP_FP_IDX(ga_idx)        = file_path_tbl_idx;
00872    }
00873    name_idx             = AT_NAME_IDX(module_attr_idx);
00874    wd_len               = WORD_LEN(AT_NAME_LEN(module_attr_idx));
00875    mod_idx              = MD_NAME_LONG;
00876    MD_NAME_LEN          = AT_NAME_LEN(module_attr_idx);
00877 
00878    TBL_REALLOC_CK(str_pool, wd_len);
00879 
00880    for (idx = FP_NAME_IDX(file_path_tbl_idx); idx <= str_pool_idx; idx++) {
00881       *mod_idx                  = name_pool[name_idx].name_long;
00882       str_pool[idx].name_long   = name_pool[name_idx].name_long;
00883       name_idx++;
00884       mod_idx++;
00885    }
00886 
00887    SCP_FILE_PATH_IDX(curr_scp_idx)      = fp_idx;
00888 
00889    TRACE (Func_Exit, "create_mod_info_file", NULL);
00890 
00891    return;
00892 
00893 }  /* create_mod_info_file */
00894 
00895 /******************************************************************************\
00896 |*                                                                            *|
00897 |* Description:                                                               *|
00898 |*      Create the module link table, which is used to output the module      *|
00899 |*      information table.                                                    *|
00900 |*                                                                            *|
00901 |* Input parameters:                                                          *|
00902 |*      NONE                                                                  *|
00903 |*                                                                            *|
00904 |* Output parameters:                                                         *|
00905 |*      NONE                                                                  *|
00906 |*                                                                            *|
00907 |* Returns:                                                                   *|
00908 |*      NOTHING                                                               *|
00909 |*                                                                            *|
00910 \******************************************************************************/
00911 void  create_mod_info_tbl(void)
00912 
00913 {
00914    int          attr_idx;
00915    int          name_idx;
00916 
00917 
00918    TRACE (Func_Entry, "create_mod_info_tbl", NULL);
00919 
00920    if (dump_flags.preinline && num_prog_unit_errors > 0) {
00921 
00922       /* Do not write out any tables.  Just the mod header. */
00923 
00924       return;
00925    }
00926 
00927    allocate_mod_link_tbl(0);  /* Determine size from longest table. */
00928 
00929    /* global flag used to tell set_mod_link_tbl_for_attr */
00930    /* that it should check all attrs for duplicates.     */
00931 
00932    search_for_duplicate_attrs   = FALSE;  /* Do not search */
00933 
00934    for (name_idx = SCP_LN_FW_IDX(MAIN_SCP_IDX) + 1;
00935         name_idx < SCP_LN_LW_IDX(MAIN_SCP_IDX); 
00936         name_idx++) {
00937 
00938       attr_idx = LN_ATTR_IDX(name_idx);
00939 
00940       if (attr_idx == SCP_ATTR_IDX(MAIN_SCP_IDX)) {
00941          KEEP_ATTR(attr_idx);
00942          ML_LN_KEEP_ME(name_idx)        =  TRUE;
00943          ML_LN_IDX(name_idx)            =  name_idx;
00944       }
00945       else if (AT_PRIVATE(attr_idx) || AT_OBJ_CLASS(attr_idx) == Label) {
00946 
00947          /* If object is PRIVATE, the name must not go into the name table.  */
00948          /* Also, Labels do not go out for the module itself.                */
00949 
00950       }
00951       else if (IS_STMT_ENTITY(attr_idx)) {
00952 
00953          /* This item is only used as the loop control variable in    */
00954          /* an implied-do.  It is only in the scope of the implied-do */
00955          /* and should not be written out to the module file.         */
00956       }
00957       else if (AT_OBJ_CLASS(attr_idx) == Data_Obj &&
00958                ATD_SYMBOLIC_CONSTANT(attr_idx) &&
00959                ATD_CLASS(attr_idx) == Constant) {
00960 
00961          /* N$PES was specified as a constant.  Do not output the actual     */
00962          /* constant to the module.  It should have been replaced all over.  */
00963       }
00964       else if (AT_USE_ASSOCIATED(attr_idx) &&
00965                AT_OBJ_CLASS(attr_idx) == Pgm_Unit &&
00966                ATP_PGM_UNIT(attr_idx) == Module) {
00967 
00968          /* This module has been use associated into this scope.  We do not */
00969          /* want the name in the local name table, although we do want to   */
00970          /* have the attribute entry for the module go out.                 */
00971       }
00972       else if (!ML_AT_KEEP_ME(attr_idx)) {
00973 
00974          /* if ML_AT_KEEP_ME is set, this attr entry has been processed. */
00975          /* It got processed because it was indexed to by another attr.  */
00976          /* (For example:  A derived type.)  Check to see if we need to  */
00977          /* keep the local name or not in the next else clause.          */
00978 
00979          if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit &&
00980              ATP_PROC(attr_idx) == Module_Proc &&
00981              !AT_USE_ASSOCIATED(attr_idx)) {
00982 
00983             /* This is a module procedure declared during this       */
00984             /* compilation.  We need to resolve out any duplicate    */
00985             /* attrs that were used to describe the interface for    */
00986             /* the module procedure.  An example of a duplicate is   */
00987             /* if the same module is USEd in the module and the      */
00988             /* module procedure.  If a type from the module is used  */
00989             /* to describe the module procedure interface, then      */
00990             /* there will be duplicate attrs for the derived type.   */
00991             /* This mechanism resolves them to the same attr.        */
00992 
00993             search_for_duplicate_attrs  = TRUE;
00994          }
00995 
00996          KEEP_ATTR(attr_idx);
00997          ML_LN_KEEP_ME(name_idx)        = TRUE;
00998          ML_LN_IDX(name_idx)            = name_idx;
00999          search_for_duplicate_attrs     = FALSE;
01000       }
01001       else {
01002          ML_LN_KEEP_ME(name_idx)        = TRUE;
01003          ML_LN_IDX(name_idx)            = name_idx;
01004 
01005          /* This name gets included because of a link with another attr. */
01006          /* Can be a derived type, function result, CRI pointee, ect...  */
01007          /* Its attr_idx has already been marked as being needed.        */
01008       }
01009    }
01010 
01011    TRACE (Func_Exit, "create_mod_info_tbl", NULL);
01012 
01013    return;
01014 
01015 }   /* create_mod_info_tbl */
01016 
01017 /******************************************************************************\
01018 |*                                                                            *|
01019 |* Description:                                                               *|
01020 |*      Clear these fields in the attr entry, before it is written out to the *|
01021 |*      module file.                                                          *|
01022 |*                                                                            *|
01023 |* Input parameters:                                                          *|
01024 |*      NONE                                                                  *|
01025 |*                                                                            *|
01026 |* Output parameters:                                                         *|
01027 |*      NONE                                                                  *|
01028 |*                                                                            *|
01029 |* Returns:                                                                   *|
01030 |*      NOTHING                                                               *|
01031 |*                                                                            *|
01032 \******************************************************************************/
01033 static void  set_attr_flds_for_output()
01034 
01035 {
01036    int          attr_idx;
01037 
01038 
01039    TRACE (Func_Entry, "set_attr_flds_for_output", NULL);
01040 
01041    for (attr_idx = 1; attr_idx <= attr_tbl_idx; attr_idx++) {
01042 
01043       if (AT_ORIG_NAME_IDX(attr_idx) == NULL_IDX) {
01044          AT_ORIG_NAME_IDX(attr_idx) = AT_NAME_IDX(attr_idx);
01045          AT_ORIG_NAME_LEN(attr_idx) = AT_NAME_LEN(attr_idx);
01046       }
01047 
01048       switch (AT_OBJ_CLASS(attr_idx)) {
01049       case Data_Obj:
01050 
01051          if (ATD_CLASS(attr_idx) == Compiler_Tmp) {
01052             ATD_TMP_GEN_ZERO(attr_idx)          = FALSE;
01053          }
01054 
01055          if (ATD_CLASS(attr_idx) == Dummy_Argument && ATD_SF_DARG(attr_idx)) {
01056             ATD_SF_ARG_IDX(attr_idx)    = NULL_IDX;
01057             ATD_SF_LINK(attr_idx)       = NULL_IDX;
01058          }
01059          break;
01060 
01061       case Pgm_Unit:
01062          ATP_SCP_IDX(attr_idx)                  = NULL_IDX;
01063 
01064          if (ATP_PGM_UNIT(attr_idx) == Module) {
01065             ATP_MODULE_STR_IDX(attr_idx)        = NULL_IDX;
01066          }
01067          else if (ATP_PROC(attr_idx) == Intrin_Proc) {
01068             ATP_INTERFACE_IDX(attr_idx)         = NULL_IDX;
01069          }
01070          break;
01071 
01072       case Derived_Type:
01073          AT_DEFINED(attr_idx)                   = FALSE;
01074          ATT_CIF_DT_ID(attr_idx)                = 0;
01075          ATT_SCP_IDX(attr_idx)                  = NULL_IDX;
01076          break;
01077 
01078       case Label:  /* Do not clear AT_DEFINED here. */
01079          break;
01080 
01081       case Interface:
01082          ATI_HAS_NON_MOD_PROC(attr_idx)         = FALSE;
01083          break;
01084 
01085       case Stmt_Func:
01086       case Namelist_Grp:
01087          break;
01088 
01089       }  /* End switch */
01090    }  /* End for */
01091 
01092 
01093    TRACE (Func_Exit, "set_attr_flds_for_output", NULL);
01094 
01095    return;
01096 
01097 }   /* set_attr_flds_for_output */
01098 
01099 /******************************************************************************\
01100 |*                                                                            *|
01101 |* Description:                                                               *|
01102 |*      All these attr entries must be included in the entries that will be   *|
01103 |*      compressed.  Mark this attr and everything it links to, as being      *|
01104 |*      saved during the compression.                                         *|
01105 |*                                                                            *|
01106 |* Input parameters:                                                          *|
01107 |*      attr_idx   -> Index of attribute to process.                          *|
01108 |*                                                                            *|
01109 |* Output parameters:                                                         *|
01110 |*      NONE                                                                  *|
01111 |*                                                                            *|
01112 |* Returns:                                                                   *|
01113 |*      NOTHING                                                               *|
01114 |*                                                                            *|
01115 \******************************************************************************/
01116 static  void  set_mod_link_tbl_for_attr(int     attr_idx)
01117 
01118 {
01119    int          bd_idx;
01120    int          il_idx;
01121    int          save_duplicate_attr_flag;
01122    int          sb_idx;
01123    int          sh_idx;
01124    int          sn_idx;
01125 
01126 
01127    TRACE (Func_Entry, "set_mod_link_tbl_for_attr", NULL);
01128 
01129    if (ML_AT_KEEP_ME(attr_idx)) {
01130 
01131       /* All the links for this attr have been set, plus */
01132       /* resolve_attr has been called, if need be.       */
01133 
01134       return;
01135    }
01136 
01137    if ((ML_AT_SEARCH_ME(attr_idx) ||
01138        search_for_duplicate_attrs) && !ML_AT_SEARCHED(attr_idx)) {
01139 
01140       if (AT_MODULE_IDX(attr_idx) != NULL_IDX) {
01141          AT_REFERENCED(AT_MODULE_IDX(attr_idx)) = Referenced;
01142       }
01143 
01144       if (resolve_attr(attr_idx)) {
01145 
01146          /* If resolve_attr returns TRUE, this object is in this scope  */
01147          /* already.  Do not set any links for this attr.  We will use  */
01148          /* the attr that is already in this scope.  Mark the attr      */
01149          /* resolved to, so that it gets kept.                          */
01150        
01151          KEEP_ATTR(ML_AT_IDX(attr_idx));
01152          return;
01153       }
01154    }
01155 
01156    if (ML_AT_IDX(attr_idx) != NULL_IDX && ML_AT_IDX(attr_idx) != attr_idx) {
01157 
01158       /* This attr is being replaced by the attr in ML_AT_IDX.  */
01159       /* Keep the attr in ML_AT_IDX.                            */
01160 
01161       KEEP_ATTR(ML_AT_IDX(attr_idx));
01162       return;
01163    }
01164 
01165    ML_AT_KEEP_ME(attr_idx)              = TRUE;
01166    ML_AT_IDX(attr_idx)                  = attr_idx;
01167    ML_NP_KEEP_ME(AT_NAME_IDX(attr_idx)) = TRUE;
01168    ML_NP_IDX(AT_NAME_IDX(attr_idx))     = AT_NAME_IDX(attr_idx);
01169    ML_NP_LEN(AT_NAME_IDX(attr_idx))     = AT_NAME_LEN(attr_idx);
01170 
01171    if (AT_ORIG_NAME_IDX(attr_idx) != NULL_IDX) {
01172       ML_NP_KEEP_ME(AT_ORIG_NAME_IDX(attr_idx)) = TRUE;
01173       ML_NP_IDX(AT_ORIG_NAME_IDX(attr_idx))     = AT_ORIG_NAME_IDX(attr_idx);
01174       ML_NP_LEN(AT_ORIG_NAME_IDX(attr_idx))     = AT_ORIG_NAME_LEN(attr_idx);
01175    }
01176 
01177    if (AT_ATTR_LINK(attr_idx) != NULL_IDX && !AT_IGNORE_ATTR_LINK(attr_idx)) {
01178       KEEP_ATTR(AT_ATTR_LINK(attr_idx));
01179    }
01180 
01181    if (AT_MODULE_IDX(attr_idx) != NULL_IDX) {
01182       KEEP_ATTR(AT_MODULE_IDX(attr_idx));
01183    }
01184 
01185    switch (AT_OBJ_CLASS(attr_idx)) {
01186    case Data_Obj:
01187 
01188 # if defined(COARRAY_FORTRAN)
01189       bd_idx    = ATD_PE_ARRAY_IDX(attr_idx);
01190 
01191       if (bd_idx != NULL_IDX && !ML_BD_KEEP_ME(bd_idx)) {
01192          set_mod_link_tbl_for_bd(bd_idx);
01193       }
01194 # endif
01195 
01196       bd_idx    = ATD_RESHAPE_ARRAY_IDX(attr_idx);
01197 
01198       if (bd_idx != NULL_IDX && !ML_BD_KEEP_ME(bd_idx)) {
01199          set_mod_link_tbl_for_bd(bd_idx);
01200       }
01201 
01202       bd_idx    = ATD_ARRAY_IDX(attr_idx);
01203       sb_idx    = ATD_STOR_BLK_IDX(attr_idx);
01204 
01205       if (bd_idx != NULL_IDX && !ML_BD_KEEP_ME(bd_idx)) {
01206          set_mod_link_tbl_for_bd(bd_idx);
01207       }
01208 
01209       bd_idx    = ATD_DISTRIBUTION_IDX(attr_idx);
01210 
01211       if (bd_idx != NULL_IDX && !ML_BD_KEEP_ME(bd_idx)) {
01212          set_mod_link_tbl_for_bd(bd_idx);
01213       }
01214 
01215       if (sb_idx != NULL_IDX) {
01216          ML_SB_KEEP_ME(sb_idx)                  = TRUE;
01217          ML_SB_IDX(sb_idx)                      = sb_idx;
01218          ML_NP_KEEP_ME(SB_NAME_IDX(sb_idx))     = TRUE;
01219          ML_NP_IDX(SB_NAME_IDX(sb_idx))         = SB_NAME_IDX(sb_idx);
01220          ML_NP_LEN(SB_NAME_IDX(sb_idx))         = SB_NAME_LEN(sb_idx);
01221 
01222          if (SB_FIRST_ATTR_IDX(sb_idx) != NULL_IDX) {
01223             KEEP_ATTR(SB_FIRST_ATTR_IDX(sb_idx));
01224          }
01225 
01226          switch (SB_LEN_FLD(sb_idx)) {
01227          case AT_Tbl_Idx:
01228             KEEP_ATTR(SB_LEN_IDX(sb_idx));
01229             break;
01230 
01231          case CN_Tbl_Idx:
01232             KEEP_CN(SB_LEN_IDX(sb_idx));
01233             break;
01234 
01235          case IR_Tbl_Idx:
01236             KEEP_IR(SB_LEN_IDX(sb_idx));
01237             break;
01238 
01239          case IL_Tbl_Idx:
01240             set_mod_link_tbl_for_il(SB_LEN_IDX(sb_idx));
01241             break;
01242          }
01243 
01244          if (SB_MODULE_IDX(sb_idx) != NULL_IDX) {
01245             KEEP_ATTR(SB_MODULE_IDX(sb_idx));
01246          }
01247       }
01248 
01249       switch (ATD_CLASS(attr_idx)) {
01250       case CRI__Pointee:
01251          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01252          KEEP_ATTR(ATD_PTR_IDX(attr_idx));
01253          break;
01254 
01255       case Dummy_Argument:
01256 
01257          if (!ATD_INTRIN_DARG(attr_idx)) {
01258             set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01259          }
01260          break;
01261 
01262       case Constant:
01263          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01264 
01265          if (ATD_FLD(attr_idx) == CN_Tbl_Idx) {
01266             KEEP_CN(ATD_CONST_IDX(attr_idx));
01267          }
01268          else {
01269 
01270             /* If we are resolving attrs, we do not search for this tmp   */
01271             /* attr because its name is the same as the constant.  These  */
01272             /* two are a pair so we do not need to do a seperate search.  */
01273 
01274             ML_AT_SEARCHED(ATD_CONST_IDX(attr_idx))     = TRUE;
01275             KEEP_ATTR(ATD_CONST_IDX(attr_idx));
01276          }
01277          break;
01278 
01279       case Compiler_Tmp:
01280 
01281          if (ATD_NEXT_MEMBER_IDX(attr_idx) != NULL_IDX) {
01282             KEEP_ATTR(ATD_NEXT_MEMBER_IDX(attr_idx));
01283          }
01284 
01285          if (ATD_DEFINING_ATTR_IDX(attr_idx) != NULL_IDX) {
01286             KEEP_ATTR(ATD_DEFINING_ATTR_IDX(attr_idx));
01287          }
01288 
01289          if (ATD_AUTOMATIC(attr_idx)) {
01290             KEEP_ATTR(ATD_AUTO_BASE_IDX(attr_idx));
01291          }
01292          else if (ATD_OFFSET_ASSIGNED(attr_idx)) {
01293 
01294             switch (ATD_OFFSET_FLD(attr_idx)) {
01295             case AT_Tbl_Idx:
01296                KEEP_ATTR(ATD_OFFSET_IDX(attr_idx));
01297                break;
01298             case CN_Tbl_Idx:
01299                KEEP_CN(ATD_OFFSET_IDX(attr_idx));
01300                break;
01301             case IR_Tbl_Idx:
01302                KEEP_IR(ATD_OFFSET_IDX(attr_idx));
01303                break;
01304             case IL_Tbl_Idx:
01305                set_mod_link_tbl_for_il(ATD_OFFSET_IDX(attr_idx));
01306                break;
01307             }
01308          }
01309 
01310          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01311 
01312          switch (ATD_FLD(attr_idx)) {
01313          case CN_Tbl_Idx:
01314             KEEP_CN(ATD_TMP_IDX(attr_idx));
01315             break;
01316 
01317          case AT_Tbl_Idx:
01318             KEEP_ATTR(ATD_TMP_IDX(attr_idx));
01319             break;
01320 
01321          case IL_Tbl_Idx:
01322             set_mod_link_tbl_for_il(ATD_TMP_IDX(attr_idx));
01323             break;
01324 
01325          case IR_Tbl_Idx:
01326             KEEP_IR(ATD_TMP_IDX(attr_idx));
01327             break;
01328          }
01329          break;
01330 
01331       case Function_Result:
01332 
01333          if (ATD_OFFSET_ASSIGNED(attr_idx)) {
01334 
01335             switch (ATD_OFFSET_FLD(attr_idx)) {
01336             case AT_Tbl_Idx:
01337                KEEP_ATTR(ATD_OFFSET_IDX(attr_idx));
01338                break;
01339             case CN_Tbl_Idx:
01340                KEEP_CN(ATD_OFFSET_IDX(attr_idx));
01341                break;
01342             case IR_Tbl_Idx:
01343                KEEP_IR(ATD_OFFSET_IDX(attr_idx));
01344                break;
01345             case IL_Tbl_Idx:
01346                set_mod_link_tbl_for_il(ATD_OFFSET_IDX(attr_idx));
01347                break;
01348             }
01349          }
01350          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01351          break;
01352         
01353 
01354       case Struct_Component:
01355 
01356          switch (ATD_OFFSET_FLD(attr_idx)) {
01357          case AT_Tbl_Idx:
01358             KEEP_ATTR(ATD_CPNT_OFFSET_IDX(attr_idx));
01359             break;
01360          case CN_Tbl_Idx:
01361             KEEP_CN(ATD_CPNT_OFFSET_IDX(attr_idx));
01362             break;
01363          case IR_Tbl_Idx:
01364             KEEP_IR(ATD_CPNT_OFFSET_IDX(attr_idx));
01365             break;
01366          case IL_Tbl_Idx:
01367             set_mod_link_tbl_for_il(ATD_CPNT_OFFSET_IDX(attr_idx));
01368             break;
01369          }
01370 
01371          if (ATD_CPNT_INIT_IDX(attr_idx) != NULL_IDX) {
01372 
01373             switch (ATD_FLD(attr_idx)) {
01374             case AT_Tbl_Idx:
01375                KEEP_ATTR(ATD_CPNT_INIT_IDX(attr_idx));
01376                break;
01377             case CN_Tbl_Idx:
01378                KEEP_CN(ATD_CPNT_INIT_IDX(attr_idx));
01379                break;
01380             case IR_Tbl_Idx:
01381                KEEP_IR(ATD_CPNT_INIT_IDX(attr_idx));
01382                break;
01383             case IL_Tbl_Idx:
01384                set_mod_link_tbl_for_il(ATD_CPNT_INIT_IDX(attr_idx));
01385                break;
01386             }
01387          }
01388 
01389          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01390          KEEP_ATTR(ATD_DERIVED_TYPE_IDX(attr_idx));
01391          break;
01392 
01393       case Variable:
01394 
01395          if (ATD_DATA_INIT(attr_idx)) {
01396 
01397             if (ATD_FLD(attr_idx) == NO_Tbl_Idx) {
01398                /* Intentionally blank */
01399             }
01400             else if (ATD_FLD(attr_idx) == AT_Tbl_Idx) {
01401 
01402                /* If we are resolving attrs, we do not search for this tmp   */
01403                /* attr because its name is the same as the variable.  These  */
01404                /* two are a pair so we do not need to do a seperate search.  */
01405 
01406                ML_AT_SEARCHED(ATD_VARIABLE_TMP_IDX(attr_idx))   = TRUE;
01407                KEEP_ATTR(ATD_VARIABLE_TMP_IDX(attr_idx));
01408             }
01409             else if (ATD_FLD(attr_idx) == IL_Tbl_Idx) {
01410 
01411                /* See previous note. */
01412 
01413                il_idx = ATD_VARIABLE_TMP_IDX(attr_idx);
01414 
01415                while (il_idx != NULL_IDX) {
01416    
01417                   if (IL_FLD(il_idx) == AT_Tbl_Idx) {
01418                      ML_AT_SEARCHED(IL_IDX(il_idx)) = TRUE;
01419                   }
01420                   il_idx = IL_NEXT_LIST_IDX(il_idx);
01421                }
01422 
01423                set_mod_link_tbl_for_il(ATD_VARIABLE_TMP_IDX(attr_idx));
01424             }
01425          }
01426          else if (ATD_FLD(attr_idx) == AT_Tbl_Idx) {
01427             KEEP_ATTR(ATD_VARIABLE_TMP_IDX(attr_idx));
01428          }
01429 
01430          if (ATD_NEXT_MEMBER_IDX(attr_idx) != NULL_IDX) {
01431             KEEP_ATTR(ATD_NEXT_MEMBER_IDX(attr_idx));
01432          }
01433 
01434          if (ATD_ASSIGN_TMP_IDX(attr_idx) != NULL_IDX) {
01435             KEEP_ATTR(ATD_ASSIGN_TMP_IDX(attr_idx));
01436          }
01437 
01438          if (ATD_AUTOMATIC(attr_idx)) {
01439             KEEP_ATTR(ATD_AUTO_BASE_IDX(attr_idx));
01440          }
01441          else if (ATD_OFFSET_ASSIGNED(attr_idx)) {
01442 
01443             switch (ATD_OFFSET_FLD(attr_idx)) {
01444             case AT_Tbl_Idx:
01445                KEEP_ATTR(ATD_OFFSET_IDX(attr_idx));
01446                break;
01447             case CN_Tbl_Idx:
01448                KEEP_CN(ATD_OFFSET_IDX(attr_idx));
01449                break;
01450             case IR_Tbl_Idx:
01451                KEEP_IR(ATD_OFFSET_IDX(attr_idx));
01452                break;
01453             case IL_Tbl_Idx:
01454                set_mod_link_tbl_for_il(ATD_OFFSET_IDX(attr_idx));
01455                break;
01456             }
01457          }
01458 
01459          /* Intentional fall through */
01460 
01461       default:
01462 
01463          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01464          break;
01465       }
01466       break;
01467 
01468 
01469    case Pgm_Unit:
01470 
01471       ML_NP_KEEP_ME(ATP_EXT_NAME_IDX(attr_idx)) = TRUE;
01472       ML_NP_IDX(ATP_EXT_NAME_IDX(attr_idx))     = ATP_EXT_NAME_IDX(attr_idx);
01473       ML_NP_LEN(ATP_EXT_NAME_IDX(attr_idx))     = ATP_EXT_NAME_LEN(attr_idx);
01474 
01475       if (ATP_PGM_UNIT(attr_idx) == Module) {
01476 
01477          if (ATP_MOD_PATH_LEN(attr_idx) > 0) {
01478             ML_NP_KEEP_ME(ATP_MOD_PATH_IDX(attr_idx)) = TRUE;
01479             ML_NP_IDX(ATP_MOD_PATH_IDX(attr_idx)) = ATP_MOD_PATH_IDX(attr_idx);
01480             ML_NP_LEN(ATP_MOD_PATH_IDX(attr_idx)) = ATP_MOD_PATH_LEN(attr_idx);
01481          }
01482       }
01483       else {
01484 
01485          if (ATP_RSLT_IDX(attr_idx) != NULL_IDX) {
01486             KEEP_ATTR(ATP_RSLT_IDX(attr_idx));
01487          }
01488 
01489          if (ATP_NUM_DARGS(attr_idx) > 0) {
01490 
01491             for (sn_idx = ATP_FIRST_IDX(attr_idx); 
01492                  sn_idx < (ATP_FIRST_IDX(attr_idx) + ATP_NUM_DARGS(attr_idx));
01493                  sn_idx++) {
01494 
01495                ML_SN_KEEP_ME(sn_idx)    = TRUE;
01496                ML_SN_IDX(sn_idx)        = sn_idx;
01497 
01498                KEEP_ATTR(SN_ATTR_IDX(sn_idx));
01499             }
01500          }
01501 
01502          /* This flag works for all 3 uses of this routine.             */
01503 
01504          /* 1) It is called when a use statement is processed.          */
01505          /*    ATP_MAY_INLINE will be set for all procedures            */
01506          /*    coming from the module that carry IR/SH with them.       */
01507          /* 2) During interface processing, if there are any use        */
01508          /*    associated procedures, they will have the mod            */
01509          /*    inlinable flag set correctly.  If they are not, they     */
01510          /*    will not have the mod inlinable flag set.                */
01511          /* 3) During processing, to send module info out, only those   */
01512          /*    procedures that have the mod inlinable flag set, go out. */
01513 
01514          if (ATP_MAY_INLINE(attr_idx)) {
01515 
01516             /* This is the body of the module/internal procedure.  We   */
01517             /* do not want to search for duplicate attrs here.  If we   */
01518             /* do, we get things confused because of host association.  */
01519 
01520             save_duplicate_attr_flag    = search_for_duplicate_attrs;
01521             search_for_duplicate_attrs  = FALSE;
01522             sh_idx                      = ATP_FIRST_SH_IDX(attr_idx);
01523 
01524             while (sh_idx != NULL_IDX) {
01525                ML_SH_KEEP_ME(sh_idx)    = TRUE;
01526                ML_SH_IDX(sh_idx)        = sh_idx;
01527 
01528                if (SH_IR_IDX(sh_idx) != NULL_IDX) {
01529                   KEEP_IR(SH_IR_IDX(sh_idx));
01530                }
01531                sh_idx                   = SH_NEXT_IDX(sh_idx);
01532             }
01533 
01534             if (ATP_PROC(attr_idx) != Dummy_Proc &&
01535                 ATP_PROC(attr_idx) != Intrin_Proc) {
01536 
01537                if (ATP_PARENT_IDX(attr_idx) != NULL_IDX) {
01538                   KEEP_ATTR(ATP_PARENT_IDX(attr_idx));
01539                }
01540             }
01541             search_for_duplicate_attrs  = save_duplicate_attr_flag;
01542          }
01543          else if (ATP_PROC(attr_idx) != Intrin_Proc) {
01544             ATP_FIRST_SH_IDX(attr_idx)  = NULL_IDX;
01545          }
01546       }
01547       break;
01548 
01549    case Label:
01550 
01551       if (ATL_CLASS(attr_idx) == Lbl_Format) {
01552          KEEP_ATTR(ATL_PP_FORMAT_TMP(attr_idx));
01553          KEEP_ATTR(ATL_FORMAT_TMP(attr_idx));
01554       }
01555       else if (ATL_DIRECTIVE_LIST(attr_idx) != NULL_IDX) {
01556          set_mod_link_tbl_for_il(ATL_DIRECTIVE_LIST(attr_idx));
01557       }
01558 
01559       if (ATL_NEXT_ASG_LBL_IDX(attr_idx) != NULL_IDX) {
01560          KEEP_ATTR(ATL_NEXT_ASG_LBL_IDX(attr_idx));
01561       }
01562       break;
01563 
01564    case Interface:
01565       set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01566 
01567       /* During resolve_attrs we do not search for interface names.  */
01568       /* We cannot gurantee they are the same because of merging.    */
01569 
01570       if (ATI_PROC_IDX(attr_idx) != NULL_IDX) {
01571 
01572          /* If we are resolving attrs, we do not search for this proc */
01573          /* attr because it has the same name as the interface name.  */
01574 
01575          ML_AT_SEARCHED(ATI_PROC_IDX(attr_idx)) = TRUE;
01576       }
01577 
01578       sn_idx = ATI_FIRST_SPECIFIC_IDX(attr_idx);
01579 
01580       while (sn_idx != NULL_IDX) {
01581          ML_SN_KEEP_ME(sn_idx)  = TRUE;
01582          ML_SN_IDX(sn_idx)      = sn_idx;
01583          KEEP_ATTR(SN_ATTR_IDX(sn_idx));
01584          sn_idx                 = SN_SIBLING_LINK(sn_idx);
01585       }
01586       break;
01587 
01588    case Derived_Type:
01589 
01590       switch (ATT_STRUCT_BIT_LEN_FLD(attr_idx)) {
01591       case AT_Tbl_Idx:
01592          KEEP_ATTR(ATT_STRUCT_BIT_LEN_IDX(attr_idx));
01593          break;
01594 
01595       case CN_Tbl_Idx:
01596          KEEP_CN(ATT_STRUCT_BIT_LEN_IDX(attr_idx));
01597          break;
01598 
01599       case IR_Tbl_Idx:
01600          KEEP_IR(ATT_STRUCT_BIT_LEN_IDX(attr_idx));
01601          break;
01602 
01603       case IL_Tbl_Idx:
01604          set_mod_link_tbl_for_il(ATT_STRUCT_BIT_LEN_IDX(attr_idx));
01605          break;
01606       }
01607 
01608       sn_idx                    = ATT_FIRST_CPNT_IDX(attr_idx);
01609 
01610       while (sn_idx != NULL_IDX) {
01611          ML_SN_KEEP_ME(sn_idx)  = TRUE;
01612          ML_SN_IDX(sn_idx)      = sn_idx;
01613 
01614          /* We do not resolve components, because the name are not unique. */
01615 
01616          ML_AT_SEARCHED(SN_ATTR_IDX(sn_idx)) = TRUE;
01617          KEEP_ATTR(SN_ATTR_IDX(sn_idx));
01618          sn_idx = SN_SIBLING_LINK(sn_idx);
01619       }
01620       break;
01621 
01622    case Namelist_Grp:
01623       sn_idx = ATN_FIRST_NAMELIST_IDX(attr_idx);
01624 
01625       while (sn_idx != NULL_IDX) {
01626          ML_SN_KEEP_ME(sn_idx)  = TRUE;
01627          ML_SN_IDX(sn_idx)      = sn_idx;
01628          KEEP_ATTR (SN_ATTR_IDX(sn_idx));
01629          sn_idx                 = SN_SIBLING_LINK(sn_idx);
01630       }
01631 
01632       if (ATN_NAMELIST_DESC(attr_idx) != NULL_IDX) {
01633          KEEP_ATTR(ATN_NAMELIST_DESC(attr_idx));
01634       }
01635       break;
01636 
01637 
01638    case Stmt_Func:
01639       set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01640 
01641       if (ATP_NUM_DARGS(attr_idx) > 0) {
01642 
01643          for (sn_idx = ATP_FIRST_IDX(attr_idx); 
01644               sn_idx < (ATP_FIRST_IDX(attr_idx) +ATP_NUM_DARGS(attr_idx));
01645               sn_idx++) {
01646 
01647             ML_SN_KEEP_ME(sn_idx)       = TRUE;
01648             ML_SN_IDX(sn_idx)           = sn_idx;
01649             KEEP_ATTR(SN_ATTR_IDX(sn_idx));
01650          }
01651       }
01652 
01653       switch (ATS_SF_FLD(attr_idx)) {
01654       case CN_Tbl_Idx:
01655          KEEP_CN(ATS_SF_IDX(attr_idx));
01656          break;
01657 
01658       case AT_Tbl_Idx:
01659          KEEP_ATTR(ATS_SF_IDX(attr_idx));
01660          break;
01661 
01662       case IL_Tbl_Idx:
01663          set_mod_link_tbl_for_il(ATS_SF_IDX(attr_idx));
01664          break;
01665 
01666       case IR_Tbl_Idx:
01667          KEEP_IR(ATS_SF_IDX(attr_idx));
01668          break;
01669       }
01670       break;
01671 
01672    }  /* End switch */
01673 
01674    TRACE (Func_Exit, "set_mod_link_tbl_for_attr ", NULL);
01675 
01676    return;
01677 
01678 }   /* set_mod_link_tbl_for_attr  */
01679 
01680 /******************************************************************************\
01681 |*                                                                            *|
01682 |* Description:                                                               *|
01683 |*      Set fields in the module link table for BD.                           *|
01684 |*                                                                            *|
01685 |* Input parameters:                                                          *|
01686 |*      bd_idx      => Index to set link fields for.                          *|
01687 |*                                                                            *|
01688 |* Output parameters:                                                         *|
01689 |*      NONE                                                                  *|
01690 |*                                                                            *|
01691 |* Returns:                                                                   *|
01692 |*      NOTHING                                                               *|
01693 |*                                                                            *|
01694 \******************************************************************************/
01695 static  void  set_mod_link_tbl_for_bd(int       bd_idx)
01696 
01697 {
01698    int          dim;
01699 
01700 
01701    TRACE (Func_Entry, "set_mod_link_tbl_for_bd ", NULL);
01702 
01703    ML_BD_KEEP_ME(bd_idx)        = TRUE;
01704    ML_BD_IDX(bd_idx)            = bd_idx;
01705 
01706    if (BD_DIST_NTRY(bd_idx)) {
01707 
01708       for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
01709 
01710          if (BD_CYCLIC_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01711             KEEP_CN(BD_CYCLIC_IDX(bd_idx, dim));
01712          }
01713          else if (BD_CYCLIC_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01714             KEEP_ATTR(BD_CYCLIC_IDX(bd_idx, dim));
01715          }
01716 
01717          if (BD_ONTO_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01718             KEEP_CN(BD_ONTO_IDX(bd_idx, dim));
01719          }
01720          else if (BD_ONTO_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01721             KEEP_ATTR(BD_ONTO_IDX(bd_idx, dim));
01722          }
01723       }
01724    }
01725    else if (BD_ARRAY_CLASS(bd_idx) != Deferred_Shape) {
01726 
01727       if (BD_LEN_FLD(bd_idx) == CN_Tbl_Idx) {
01728          KEEP_CN(BD_LEN_IDX(bd_idx));
01729       }
01730       else if (BD_LEN_FLD(bd_idx) == AT_Tbl_Idx) {
01731          KEEP_ATTR(BD_LEN_IDX(bd_idx));
01732       }
01733 
01734       for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
01735 
01736          if (BD_LB_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01737             KEEP_CN(BD_LB_IDX(bd_idx, dim));
01738          }
01739          else if (BD_LB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01740             KEEP_ATTR(BD_LB_IDX(bd_idx, dim));
01741          }
01742 
01743          if (BD_UB_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01744             KEEP_CN(BD_UB_IDX(bd_idx, dim));
01745          }
01746          else if (BD_UB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01747             KEEP_ATTR(BD_UB_IDX(bd_idx, dim));
01748          }
01749 
01750          if (BD_XT_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01751             if (BD_XT_IDX(bd_idx, dim)) {
01752               KEEP_CN(BD_XT_IDX(bd_idx, dim));
01753             }
01754          }
01755          else if (BD_XT_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01756             KEEP_ATTR(BD_XT_IDX(bd_idx, dim));
01757          }
01758 
01759          if (BD_SM_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01760             KEEP_CN(BD_SM_IDX(bd_idx, dim));
01761          }
01762          else if (BD_SM_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01763             KEEP_ATTR(BD_SM_IDX(bd_idx, dim));
01764          }
01765       }
01766    }
01767 
01768    TRACE (Func_Exit, "set_mod_link_tbl_for_bd ", NULL);
01769 
01770    return;
01771 
01772 }   /* set_mod_link_tbl_for_bd  */
01773 
01774 /******************************************************************************\
01775 |*                                                                            *|
01776 |* Description:                                                               *|
01777 |*      Set fields in the module link table for IR.                           *|
01778 |*                                                                            *|
01779 |* Input parameters:                                                          *|
01780 |*      ir_idx      => Index to set link fields for.                          *|
01781 |*                                                                            *|
01782 |* Output parameters:                                                         *|
01783 |*      NONE                                                                  *|
01784 |*                                                                            *|
01785 |* Returns:                                                                   *|
01786 |*      NOTHING                                                               *|
01787 |*                                                                            *|
01788 \******************************************************************************/
01789 static  void  set_mod_link_tbl_for_ir(int       ir_idx)
01790 
01791 {
01792 
01793    TRACE (Func_Entry, "set_mod_link_tbl_for_ir", NULL);
01794 
01795    if (ML_IR_KEEP_ME(ir_idx)) {
01796       return;
01797    }
01798 
01799    ML_IR_KEEP_ME(ir_idx)        = TRUE;
01800    ML_IR_IDX(ir_idx)            = ir_idx;
01801 
01802    set_mod_link_tbl_for_typ(IR_TYPE_IDX(ir_idx));
01803 
01804    switch (IR_FLD_L(ir_idx)) {
01805    case CN_Tbl_Idx:
01806       KEEP_CN(IR_IDX_L(ir_idx));
01807       break;
01808 
01809    case AT_Tbl_Idx:
01810       KEEP_ATTR(IR_IDX_L(ir_idx));
01811       break;
01812 
01813    case IR_Tbl_Idx:
01814       KEEP_IR(IR_IDX_L(ir_idx));
01815       break;
01816 
01817    case IL_Tbl_Idx:
01818       set_mod_link_tbl_for_il(IR_IDX_L(ir_idx));
01819       break;
01820 
01821    case NO_Tbl_Idx:
01822    case SH_Tbl_Idx:
01823       break;
01824    }
01825 
01826    switch (IR_FLD_R(ir_idx)) {
01827    case CN_Tbl_Idx:
01828       KEEP_CN(IR_IDX_R(ir_idx));
01829       break;
01830 
01831    case AT_Tbl_Idx:
01832       KEEP_ATTR(IR_IDX_R(ir_idx));
01833       break;
01834 
01835    case IR_Tbl_Idx:
01836       KEEP_IR(IR_IDX_R(ir_idx));
01837       break;
01838 
01839    case IL_Tbl_Idx:
01840       set_mod_link_tbl_for_il(IR_IDX_R(ir_idx));
01841       break;
01842 
01843    case NO_Tbl_Idx:
01844    case SH_Tbl_Idx:
01845       break;
01846    }
01847    
01848    TRACE (Func_Exit, "set_mod_link_tbl_for_ir", NULL);
01849 
01850    return;
01851 
01852 }   /* set_mod_link_tbl_for_ir */
01853 
01854 /******************************************************************************\
01855 |*                                                                            *|
01856 |* Description:                                                               *|
01857 |*      Set fields in the module link table for IL.                           *|
01858 |*                                                                            *|
01859 |* Input parameters:                                                          *|
01860 |*      list_idx    => Index to set link fields for.                          *|
01861 |*                                                                            *|
01862 |* Output parameters:                                                         *|
01863 |*      NONE                                                                  *|
01864 |*                                                                            *|
01865 |* Returns:                                                                   *|
01866 |*      NOTHING                                                               *|
01867 |*                                                                            *|
01868 \******************************************************************************/
01869 static  void  set_mod_link_tbl_for_il(int       list_idx)
01870 
01871 {
01872 
01873    TRACE (Func_Entry, "set_mod_link_tbl_for_il", NULL);
01874 
01875    if (ML_IL_KEEP_ME(list_idx)) {
01876       return;
01877    }
01878 
01879    while (list_idx != NULL_IDX) {
01880       ML_IL_KEEP_ME(list_idx)   = TRUE;
01881       ML_IL_IDX(list_idx)       = list_idx;
01882 
01883       switch (IL_FLD(list_idx)) {
01884          case CN_Tbl_Idx:
01885             KEEP_CN(IL_IDX(list_idx));
01886             break;
01887 
01888          case AT_Tbl_Idx:
01889             KEEP_ATTR(IL_IDX(list_idx));
01890             break;
01891 
01892          case IR_Tbl_Idx:
01893             KEEP_IR(IL_IDX(list_idx));
01894             break;
01895 
01896          case IL_Tbl_Idx:
01897             set_mod_link_tbl_for_il(IL_IDX(list_idx));
01898             break;
01899 
01900          case NO_Tbl_Idx:
01901          case SH_Tbl_Idx:
01902             break;
01903       }
01904       list_idx = IL_NEXT_LIST_IDX(list_idx);
01905    }
01906    
01907    TRACE (Func_Exit, "set_mod_link_tbl_for_il", NULL);
01908 
01909    return;
01910 
01911 }   /* set_mod_link_tbl_for_il */
01912 
01913 /******************************************************************************\
01914 |*                                                                            *|
01915 |* Description:                                                               *|
01916 |*      Set fields in the module link table for a constant table entry.       *|
01917 |*                                                                            *|
01918 |* Input parameters:                                                          *|
01919 |*      cn_idx => Index of constant table entry to have links set.            *|
01920 |*                                                                            *|
01921 |* Output parameters:                                                         *|
01922 |*      NONE                                                                  *|
01923 |*                                                                            *|
01924 |* Returns:                                                                   *|
01925 |*      NOTHING                                                               *|
01926 |*                                                                            *|
01927 \******************************************************************************/
01928 static  void  set_mod_link_tbl_for_cn(int       cn_idx)
01929 
01930 {
01931    size_offset_type     len;
01932    long                 length;
01933    int                  type_idx;
01934 
01935 
01936    TRACE (Func_Entry, "set_mod_link_tbl_for_cn", NULL);
01937 
01938    /* KAY - TEMPORARY - REPLACE WITH INTERNAL ERROR               */
01939    /*       If cn_idx is NULL, it should be an internal situation */
01940 
01941    if (cn_idx == NULL_IDX) {
01942       PRINTMSG(stmt_start_line, 626, Internal, stmt_start_col,
01943                "non zero cn_idx",
01944                "set_mod_link_tbl_for_cn");
01945    }
01946 
01947    if (!ML_CN_KEEP_ME(cn_idx)) {
01948       ML_CN_KEEP_ME(cn_idx)     = TRUE;
01949       ML_CN_IDX(cn_idx)         = cn_idx;
01950       type_idx                  = CN_TYPE_IDX(cn_idx);
01951 
01952       set_mod_link_tbl_for_typ(type_idx);
01953 
01954       switch (TYP_TYPE(type_idx)) {
01955       case Typeless:
01956          length = (long) (CN_EXTRA_ZERO_WORD(cn_idx) ?
01957                               STORAGE_WORD_SIZE(TYP_BIT_LEN(type_idx)) + 1 :
01958                               STORAGE_WORD_SIZE(TYP_BIT_LEN(type_idx)));
01959          break;
01960 
01961       case Character:
01962          len.idx        = TYP_IDX(type_idx);
01963          len.fld        = CN_Tbl_Idx;
01964 
01965          BYTES_TO_WORDS(len, TARGET_BITS_PER_WORD);
01966 
01967          if (len.fld == CN_Tbl_Idx) {
01968             length = (long) CN_INT_TO_C(len.idx);  /* KAYKAY */
01969          }
01970          else {
01971             length = (long) F_INT_TO_C(len.constant, TYP_LINEAR(len.type_idx));
01972          }
01973          length = CN_EXTRA_ZERO_WORD(cn_idx) ? length + 1: length;
01974          break;
01975 
01976 # if defined(_TARGET_OS_MAX)
01977       case Complex:
01978          if (TYP_LINEAR(type_idx) == Complex_4) {
01979 
01980             /* Complex_4 constants are stored in two words on t3e */
01981 
01982             length = 2;
01983          }
01984          else {
01985             length = TARGET_BITS_TO_WORDS(
01986                   storage_bit_size_tbl[TYP_LINEAR(CN_TYPE_IDX(cn_idx))]);
01987          }
01988          break;
01989 # endif
01990 
01991       default:
01992          length = TARGET_BITS_TO_WORDS(
01993                   storage_bit_size_tbl[TYP_LINEAR(CN_TYPE_IDX(cn_idx))]);
01994          break;
01995       }
01996 
01997       ML_CP_LEN(CN_POOL_IDX(cn_idx))            = length;
01998       ML_CP_KEEP_ME(CN_POOL_IDX(cn_idx))        = TRUE;
01999       ML_CP_IDX(CN_POOL_IDX(cn_idx))            = CN_POOL_IDX(cn_idx);
02000 
02001 # if defined(_HOST32) 
02002 
02003       if (DALIGN_TEST_CONDITION(type_idx)) {
02004           ML_CP_DALIGN_ME(CN_POOL_IDX(cn_idx))  = TRUE;
02005       }
02006 
02007 # endif
02008    }
02009 
02010    TRACE (Func_Exit, "set_mod_link_tbl_for_cn", NULL);
02011 
02012    return;
02013 
02014 }   /* set_mod_link_tbl_for_cn */
02015 
02016 /******************************************************************************\
02017 |*                                                                            *|
02018 |* Description:                                                               *|
02019 |*      Set fields in the module link table for TYP.                          *|
02020 |*                                                                            *|
02021 |* Input parameters:                                                          *|
02022 |*      typ_idx     => Index to set link fields for.                          *|
02023 |*                                                                            *|
02024 |* Output parameters:                                                         *|
02025 |*      NONE                                                                  *|
02026 |*                                                                            *|
02027 |* Returns:                                                                   *|
02028 |*      NOTHING                                                               *|
02029 |*                                                                            *|
02030 \******************************************************************************/
02031 static  void  set_mod_link_tbl_for_typ(int      typ_idx)
02032 
02033 {
02034    int          attr_idx;
02035 
02036 
02037    TRACE (Func_Entry, "set_mod_link_tbl_for_typ", NULL);
02038 
02039    if (typ_idx != NULL_IDX && !ML_TYP_KEEP_ME(typ_idx)) {
02040       ML_TYP_KEEP_ME(typ_idx)   = TRUE;
02041       ML_TYP_IDX(typ_idx)       = typ_idx;
02042 
02043       if (TYP_TYPE(typ_idx) == Character) {
02044 
02045          if (TYP_FLD(typ_idx) == CN_Tbl_Idx) {
02046             KEEP_CN(TYP_IDX(typ_idx));
02047          }
02048          else if (TYP_FLD(typ_idx) == AT_Tbl_Idx) {
02049             KEEP_ATTR(TYP_IDX(typ_idx));
02050          }
02051       }
02052       else if (TYP_TYPE(typ_idx) == Structure) {
02053          attr_idx = TYP_IDX(typ_idx);
02054    
02055          while (AT_ATTR_LINK(attr_idx) != NULL_IDX) {
02056             attr_idx = AT_ATTR_LINK(attr_idx);
02057          }
02058    
02059          TYP_IDX(typ_idx) = attr_idx;
02060 
02061          KEEP_ATTR(attr_idx);
02062       }
02063    }
02064 
02065    TRACE (Func_Exit, "set_mod_link_tbl_for_typ", NULL);
02066 
02067    return;
02068 
02069 }  /* set_mod_link_tbl_for_typ */
02070 
02071 /******************************************************************************\
02072 |*                                                                            *|
02073 |* Description:                                                               *|
02074 |*      Go through the module link table, assigning new indexes to all        *|
02075 |*      entries that must be left in the compressed tables.                   *|
02076 |*      The zeroth entry of the mod link table contains the index to start    *|
02077 |*      for each of the tables.  This is the mod link index to start with     *|
02078 |*      and the tbl index to start assigning with.                            *|
02079 |*                                                                            *|
02080 |* Input parameters:                                                          *|
02081 |*      NONE                                                                  *|
02082 |*                                                                            *|
02083 |* Output parameters:                                                         *|
02084 |*      NONE                                                                  *|
02085 |*                                                                            *|
02086 |* Returns:                                                                   *|
02087 |*      NOTHING                                                               *|
02088 |*                                                                            *|
02089 \******************************************************************************/
02090 static void  assign_new_idxs(boolean    resolving_duplicates)
02091 
02092 {
02093    int          at_new_tbl_idx  = ML_AT_IDX(0) + 1;
02094    int          bd_new_tbl_idx  = ML_BD_IDX(0) + 1;
02095    int          cn_new_tbl_idx  = ML_CN_IDX(0) + 1;
02096    int          cp_new_tbl_idx  = ML_CP_IDX(0) + 1;
02097    int          end_idx;
02098    int          idx;
02099    int          il_new_tbl_idx  = ML_IL_IDX(0) + 1;
02100    int          ir_new_tbl_idx  = ML_IR_IDX(0) + 1;
02101    int          ln_new_tbl_idx  = ML_LN_IDX(0) + 1;
02102    int          mod_idx;
02103    int          new_idx;
02104    int          np_new_tbl_idx  = ML_NP_IDX(0) + 1;
02105    int          sb_new_tbl_idx  = ML_SB_IDX(0) + 1;
02106    int          sh_new_tbl_idx  = ML_SH_IDX(0) + 1;
02107    int          sn_new_tbl_idx  = ML_SN_IDX(0) + 1;
02108    int          typ_new_tbl_idx = ML_TYP_IDX(0)+ 1;
02109 
02110 
02111    /* All the ML_xx_IDX(0) are the last used indexes for the tables */
02112 
02113 
02114    TRACE (Func_Entry, "assign_new_idxs", NULL);
02115 
02116    if (save_const_tbl_idx != NULL_IDX) {
02117 
02118       /* We are processing an incoming module.  We have left room */
02119       /* for a copy of the full constant table and constant pool. */
02120 
02121       end_idx           = const_tbl_idx;
02122       const_tbl_idx     = save_const_tbl_idx;
02123       const_pool_idx    = save_const_pool_idx;
02124 
02125   Pragma("_CRI ivdep")        
02126 
02127       for (mod_idx = 1; mod_idx < cn_new_tbl_idx; mod_idx++) {
02128          ML_CN_IDX(mod_idx)     = mod_idx;
02129       }
02130 
02131   Pragma("_CRI ivdep")        
02132 
02133       for (mod_idx = 1; mod_idx < cp_new_tbl_idx; mod_idx++) {
02134          ML_CP_IDX(mod_idx)     = mod_idx;
02135       }
02136 
02137       for (mod_idx = cn_new_tbl_idx; mod_idx <= end_idx; mod_idx++) {
02138 
02139          if (ML_CN_KEEP_ME(mod_idx)) {
02140             new_idx             = ntr_const_tbl(CN_TYPE_IDX(mod_idx),
02141                                                 CN_EXTRA_ZERO_WORD(mod_idx),
02142                                                 &CN_CONST(mod_idx));
02143             ML_CN_IDX(mod_idx)  = new_idx;
02144          }
02145       }
02146 
02147       ML_CN_IDX(0)      = const_tbl_idx;
02148       ML_CP_IDX(0)      = const_pool_idx;
02149    }
02150 
02151   Pragma("_CRI ivdep")        
02152    for (mod_idx = 1; mod_idx < at_new_tbl_idx; mod_idx++) {
02153       ML_AT_IDX(mod_idx)                = mod_idx;
02154       ML_AT_COMPRESSED_IDX(mod_idx)     = TRUE;
02155       ML_AT_KEEP_ME(mod_idx)            = TRUE;
02156    }
02157 
02158    if (resolving_duplicates) {
02159 
02160       for (mod_idx = at_new_tbl_idx; mod_idx <= attr_tbl_idx; mod_idx++) {
02161 
02162          if (ML_AT_KEEP_ME(mod_idx)) {
02163             ML_AT_IDX(mod_idx)                  = at_new_tbl_idx;
02164             ML_AT_COMPRESSED_IDX(mod_idx)       = TRUE;
02165             at_new_tbl_idx++;
02166          }
02167          else if (ML_AT_IDX(mod_idx) != mod_idx && 
02168                   ML_AT_IDX(mod_idx) != NULL_IDX) {
02169 
02170             /* This attr has been resolved to another attr.  Find out if    */
02171             /* any attr in this chain needs to be kept.  If the attr does   */
02172             /* not need to be kept, just skip to the next attr.             */
02173 
02174             idx = mod_idx;
02175 
02176             /* Search until we find the attr that gets kept in this chain.  */
02177             /* If ML_AT_KEEP_ME is set, we've found the attr that gets kept */
02178             /* in the chain.  If ML_AT_COMPRESSED_IDX is set, this attr in  */
02179             /* the chain has already been changed to index to its new       */
02180             /* compressed index.  Following is an example of how this can   */
02181             /* happen:     ML_AT_IDX(344) = 1268.  ML_AT_KEEP_ME(1268) = T  */
02182             /* We enter this code with 344.  After this code sequence,      */
02183             /* ML_AT_IDX(1268) = 344, ML_AT_KEEP_ME(1268) = FALSE.          */
02184             /* ML_AT_IDX(344) = 20 (The new compressed index.)              */
02185             /* ML_AT_KEEP_ME(344) = TRUE.  ML_AT_COMPRESSED_IDX(344) = TRUE.*/
02186             /*                                                              */
02187             /* We enter this code with 1268.  After this code sequence,     */
02188             /* ML_AT_IDX(1268) = 20 and ML_AT_COMPRESSED_IDX(1268) = TRUE.  */
02189             /*                                                              */
02190             /* Now, suppose we also have ML_AT_IDX(3000) = 1268.            */
02191             /* We enter this code with 3000.  We will do the following loop,*/
02192             /* but will stop at 1268, because it already has its compressed */
02193             /* index.  We will then use that index.  So in conclusion,      */
02194             /* attrs 3000, 1268 and 344 are all the same.  What we want is  */
02195             /* just one copy of this attr at index 20, when compression is  */
02196             /* finished.                                                    */
02197 
02198             while (idx != NULL_IDX &&
02199                    !ML_AT_KEEP_ME(idx) &&
02200                    !ML_AT_COMPRESSED_IDX(idx)) {
02201                idx = ML_AT_IDX(idx);
02202             }
02203 
02204             if (idx > mod_idx) {
02205 
02206                /* The duplicate attr being kept has not been assigned a new */
02207                /* index yet.  Switch the attrs that are being kept, since   */
02208                /* we are ready to assign a new index to this attr.          */
02209 
02210                /* Since these are the same thing - switch the actual info   */
02211                /* in the attr, so that all information about which entries  */
02212                /* in which tables should be kept will remain okay.          */
02213 
02214                COPY_ATTR_NTRY(AT_WORK_IDX, mod_idx);
02215                COPY_ATTR_NTRY(mod_idx, idx);
02216                COPY_ATTR_NTRY(idx, AT_WORK_IDX);
02217 
02218                ML_AT_KEEP_ME(idx)       = FALSE;
02219                ML_AT_KEEP_ME(mod_idx)   = TRUE;
02220 
02221                /* Set the higher duplicate attr ML_AT_IDX to lower duplicate */
02222                /* attr index.  When the higher duplicate attr comes up, it   */
02223                /* will fall through here but take the else clause instead of */
02224                /* this clause.  That will get its ML_AT_IDX set correctly.   */
02225                /* We cannot set ML_AT_IDX directly, because when the higher  */
02226                /* attr comes through, it won't know that its ML_AT_IDX has   */
02227                /* already been adjusted.                                     */
02228 
02229                ML_AT_IDX(idx)                   = mod_idx;
02230                ML_AT_IDX(mod_idx)               = at_new_tbl_idx;
02231                ML_AT_COMPRESSED_IDX(mod_idx)    = TRUE;
02232                at_new_tbl_idx++;
02233             }
02234             else if (idx != NULL_IDX) {
02235                ML_AT_IDX(mod_idx)               = ML_AT_IDX(idx);
02236                ML_AT_COMPRESSED_IDX(mod_idx)    = TRUE;
02237             }
02238          }
02239       }
02240    }
02241    else {
02242 
02243   Pragma("_CRI ivdep")        
02244       for (mod_idx = at_new_tbl_idx; mod_idx <= attr_tbl_idx; mod_idx++) {
02245 
02246          if (ML_AT_KEEP_ME(mod_idx)) {
02247             ML_AT_IDX(mod_idx)  = at_new_tbl_idx;
02248             at_new_tbl_idx++;
02249          }
02250       }
02251    }
02252 
02253   Pragma("_CRI ivdep")        
02254    for (mod_idx = 1; mod_idx < bd_new_tbl_idx; mod_idx++) {
02255       ML_BD_IDX(mod_idx)        = mod_idx;
02256    }
02257 
02258   Pragma("_CRI ivdep")        
02259    for (mod_idx = bd_new_tbl_idx; mod_idx <= bounds_tbl_idx; mod_idx++) {
02260 
02261       if (ML_BD_KEEP_ME(mod_idx)) {
02262          ML_BD_IDX(mod_idx)     = bd_new_tbl_idx;
02263          bd_new_tbl_idx         = bd_new_tbl_idx + BD_NTRY_SIZE(mod_idx);
02264       }
02265    }
02266 
02267    if (save_const_tbl_idx == NULL_IDX) {
02268 
02269   Pragma("_CRI ivdep")        
02270       for (mod_idx = 1; mod_idx < cn_new_tbl_idx; mod_idx++) {
02271          ML_CN_IDX(mod_idx)     = mod_idx;
02272       }
02273    
02274   Pragma("_CRI ivdep")        
02275       for (mod_idx = cn_new_tbl_idx; mod_idx <= const_tbl_idx; mod_idx++) {
02276    
02277          if (ML_CN_KEEP_ME(mod_idx)) {
02278             ML_CN_IDX(mod_idx)  = cn_new_tbl_idx;
02279             cn_new_tbl_idx++;
02280          }
02281       }
02282 
02283   Pragma("_CRI ivdep")        
02284       for (mod_idx = 1; mod_idx < cp_new_tbl_idx; mod_idx++) {
02285          ML_CP_IDX(mod_idx)     = mod_idx;
02286       }
02287 
02288       end_idx = const_pool_idx;
02289 
02290       for (mod_idx = cp_new_tbl_idx; mod_idx <= end_idx; mod_idx++) {
02291 
02292          if (ML_CP_KEEP_ME(mod_idx)) {
02293 
02294 # if defined(_HOST32)
02295    
02296             if (ML_CP_DALIGN_ME(mod_idx)) {
02297 
02298                while ((((long)&const_pool[cp_new_tbl_idx]) % 8) != 0) {
02299                   cp_new_tbl_idx++;
02300                   TBL_REALLOC_CK(const_pool, 1);
02301                }
02302    
02303                if (const_pool_idx > mod_link_tbl_idx) {
02304                   idx = mod_link_tbl_idx;
02305                   TBL_REALLOC_CK(mod_link_tbl, const_pool_idx);
02306    
02307                   for (; idx <= mod_link_tbl_idx; idx++) {
02308                      CLEAR_TBL_NTRY(mod_link_tbl, idx);
02309                   }
02310                }
02311    
02312             }
02313    
02314 # endif
02315             ML_CP_IDX(mod_idx)  = cp_new_tbl_idx;
02316             cp_new_tbl_idx              += ML_CP_LEN(mod_idx);
02317          }
02318       }
02319    }
02320 
02321   Pragma("_CRI ivdep")        
02322    for (mod_idx = 1; mod_idx < il_new_tbl_idx; mod_idx++) {
02323       ML_IL_IDX(mod_idx)        = mod_idx;
02324    }
02325 
02326   Pragma("_CRI ivdep")        
02327    for (mod_idx = il_new_tbl_idx; mod_idx <= ir_list_tbl_idx; mod_idx++) {
02328 
02329       if (ML_IL_KEEP_ME(mod_idx)) {
02330          ML_IL_IDX(mod_idx) = il_new_tbl_idx;
02331          il_new_tbl_idx++;
02332       }
02333    }
02334 
02335   Pragma("_CRI ivdep")        
02336    for (mod_idx = 1; mod_idx < ir_new_tbl_idx; mod_idx++) {
02337       ML_IR_IDX(mod_idx)        = mod_idx;
02338    }
02339 
02340   Pragma("_CRI ivdep")        
02341    for (mod_idx = ir_new_tbl_idx; mod_idx <= ir_tbl_idx; mod_idx++) {
02342 
02343       if (ML_IR_KEEP_ME(mod_idx)) {
02344          ML_IR_IDX(mod_idx) = ir_new_tbl_idx;
02345          ir_new_tbl_idx++;
02346       }
02347    }
02348 
02349   Pragma("_CRI ivdep")        
02350    for (mod_idx = 1; mod_idx < ln_new_tbl_idx; mod_idx++) {
02351       ML_LN_IDX(mod_idx)        = mod_idx;
02352    }
02353 
02354   Pragma("_CRI ivdep")        
02355    for (mod_idx = ln_new_tbl_idx; mod_idx <= loc_name_tbl_idx; mod_idx++) {
02356 
02357       if (ML_LN_KEEP_ME(mod_idx)) {
02358          ML_LN_IDX(mod_idx) = ln_new_tbl_idx;
02359          ln_new_tbl_idx++;
02360       }
02361    }
02362 
02363   Pragma("_CRI ivdep")        
02364    for (mod_idx = 1; mod_idx < np_new_tbl_idx; mod_idx++) {
02365       ML_NP_IDX(mod_idx)        = mod_idx;
02366    }
02367 
02368   Pragma("_CRI ivdep")        
02369    for (mod_idx = np_new_tbl_idx; mod_idx <= name_pool_idx; mod_idx++) {
02370 
02371       if (ML_NP_KEEP_ME(mod_idx)) {
02372          ML_NP_IDX(mod_idx)     = np_new_tbl_idx;
02373          ML_NP_LEN(mod_idx)     = WORD_LEN(ML_NP_LEN(mod_idx));
02374          np_new_tbl_idx         += ML_NP_LEN(mod_idx);
02375       }
02376    }
02377 
02378   Pragma("_CRI ivdep")        
02379    for (mod_idx = 1; mod_idx < sb_new_tbl_idx; mod_idx++) {
02380       ML_SB_IDX(mod_idx)        = mod_idx;
02381    }
02382 
02383   Pragma("_CRI ivdep")        
02384    for (mod_idx = sb_new_tbl_idx; mod_idx <= stor_blk_tbl_idx; mod_idx++) {
02385 
02386       if (ML_SB_KEEP_ME(mod_idx)) {
02387          ML_SB_IDX(mod_idx)     = sb_new_tbl_idx;
02388          sb_new_tbl_idx++;
02389       }
02390    }
02391 
02392   Pragma("_CRI ivdep")        
02393    for (mod_idx = 1; mod_idx < sn_new_tbl_idx; mod_idx++) {
02394       ML_SN_IDX(mod_idx)        = mod_idx;
02395    }
02396 
02397   Pragma("_CRI ivdep")        
02398    for (mod_idx = sn_new_tbl_idx; mod_idx <= sec_name_tbl_idx; mod_idx++) {
02399 
02400       if (ML_SN_KEEP_ME(mod_idx)) {
02401          ML_SN_IDX(mod_idx)     = sn_new_tbl_idx;
02402          sn_new_tbl_idx++;
02403       }
02404    }
02405 
02406   Pragma("_CRI ivdep")        
02407    for (mod_idx = 1; mod_idx < sh_new_tbl_idx; mod_idx++) {
02408       ML_SH_IDX(mod_idx)        = mod_idx;
02409    }
02410 
02411   Pragma("_CRI ivdep")        
02412    for (mod_idx = sh_new_tbl_idx; mod_idx <= sh_tbl_idx; mod_idx++) {
02413 
02414       if (ML_SH_KEEP_ME(mod_idx)) {
02415          ML_SH_IDX(mod_idx)     = sh_new_tbl_idx;
02416          sh_new_tbl_idx++;
02417       }
02418    }
02419 
02420   Pragma("_CRI ivdep")        
02421    for (mod_idx = 1; mod_idx < typ_new_tbl_idx; mod_idx++) {
02422       ML_TYP_IDX(mod_idx)       = mod_idx;
02423    }
02424 
02425    /* Assigning typ indexes is handled in compress_typ_table */
02426 
02427    TRACE (Func_Exit, "assign_new_idxs", NULL);
02428 
02429    return;
02430 
02431 }   /* assign_new_idxs */
02432 
02433 /******************************************************************************\
02434 |*                                                                            *|
02435 |* Description:                                                               *|
02436 |*      This moves the tables, writing over entries that should be compressed *|
02437 |*      out.                                                                  *|
02438 |*                                                                            *|
02439 |* Input parameters:                                                          *|
02440 |*      al_idx -> Index to start checking attr_list_tbl for updating the      *|
02441 |*                AL_ATTR_IDX.                                                *|
02442 |*                                                                            *|
02443 |* Output parameters:                                                         *|
02444 |*      NONE                                                                  *|
02445 |*                                                                            *|
02446 |* Returns:                                                                   *|
02447 |*      NOTHING                                                               *|
02448 |*                                                                            *|
02449 \******************************************************************************/
02450 static void  compress_tbls(int          al_idx,
02451                            boolean      from_interface)
02452 {
02453    int          at_idx;
02454    int          bd_idx;
02455    int          cn_idx;
02456    int          cp_idx;
02457    int          dim;
02458    int          end_idx;
02459    int          idx;
02460    int          il_idx;
02461    int          ir_idx;
02462    int          ln_idx;
02463    int          mod_idx;
02464    int          np_idx;
02465    int          sb_idx;
02466    int          sh_idx;
02467    int          sn_idx;
02468    int          start_idx;
02469    int          typ_idx;
02470 
02471 # if 0
02472    int          end_old_idx;
02473    int          start_old_idx;
02474 # endif
02475 
02476 
02477    TRACE (Func_Entry, "compress_tbls", NULL);
02478 
02479    /* The zeroth entry in the module link table contains the starting index   */
02480    /* for each table.  This allows partial compression at the end of tables.  */
02481    /* After this field is saved, clear these entries.  They must be NULL_IDX  */
02482    /* so that if a field has NULL_IDX in it, it will not change.   All other  */
02483    /* fields are required to be set correctly or they will end up NULL.       */
02484 
02485    at_idx = ML_AT_IDX(0);
02486    bd_idx = ML_BD_IDX(0);
02487    cn_idx = ML_CN_IDX(0);
02488    cp_idx = ML_CP_IDX(0);
02489    il_idx = ML_IL_IDX(0);
02490    ir_idx = ML_IR_IDX(0);
02491    ln_idx = ML_LN_IDX(0);
02492    np_idx = ML_NP_IDX(0);
02493    sb_idx = ML_SB_IDX(0);
02494    sh_idx = ML_SH_IDX(0);
02495    sn_idx = ML_SN_IDX(0);
02496    typ_idx= ML_TYP_IDX(0);
02497 
02498    CLEAR_TBL_NTRY(mod_link_tbl, NULL_IDX);
02499 
02500    /* Compresses the type table, by sharing duplicate entries */
02501    /* and collapsing out unneeded type entries.               */
02502 
02503    compress_type_tbl(typ_idx);
02504 
02505    if (!only_update_new_tbl_entries) {
02506       update_idxs_in_attr_entry(1,at_idx);
02507    }
02508 
02509    start_idx    = at_idx+1;
02510 
02511 # if 0
02512    mod_idx      = start_idx;
02513 
02514    do {
02515 
02516       while (mod_idx <= attr_tbl_idx && !ML_AT_KEEP_ME(mod_idx)) {
02517          mod_idx++;
02518       }
02519 
02520       if (mod_idx <= attr_tbl_idx) {
02521          start_old_idx  = mod_idx;
02522 
02523          while (mod_idx <= attr_tbl_idx && ML_AT_KEEP_ME(mod_idx)) {
02524             mod_idx++;
02525          }
02526 
02527          end_old_idx    = mod_idx - 1;
02528          ++at_idx;
02529 
02530          if (start_old_idx != at_idx) {
02531             (void) memmove ((void *) &attr_tbl[at_idx],
02532                             (void *) &attr_tbl[start_old_idx],
02533                             (end_old_idx - start_old_idx +1) * NUM_AT_WDS * 8);
02534          }
02535          at_idx        += end_old_idx - start_old_idx;
02536                          
02537          /* The last one checked is either too high   */
02538          /* or has !ML_AT_KEEP_ME set.  Skip past it. */
02539 
02540          ++mod_idx;
02541       }
02542    }
02543    while (mod_idx <= attr_tbl_idx);
02544 
02545 # endif
02546 
02547    for (mod_idx = start_idx; mod_idx <= attr_tbl_idx; mod_idx++) {
02548 
02549       if (ML_AT_KEEP_ME(mod_idx)) {
02550          ++at_idx;
02551          COPY_ATTR_NTRY(at_idx, mod_idx);
02552       }
02553    }
02554 
02555    update_idxs_in_attr_entry(start_idx, at_idx);
02556 
02557    if (count_derived_types) {
02558 
02559       for (mod_idx = start_idx; mod_idx <= at_idx; mod_idx++) {
02560          if (AT_OBJ_CLASS(mod_idx) == Derived_Type) {
02561             num_module_derived_types++;
02562          }
02563       }
02564    }
02565 
02566    /* mod_idx   = (only_update_new_tbl_entries) ? bd_idx + 1 : 1; */
02567    mod_idx      = 1;
02568 
02569    while (mod_idx <= bd_idx && BD_NTRY_SIZE(mod_idx)!= 0) {
02570 
02571 /* for some reason some deferred shape array BD_NTRY_SIZE(mod_idx)
02572    is 0; need to read the code
02573    fzhao
02574  */
02575 
02576       if (!BD_USED_NTRY(mod_idx)) {  /* Entry from the free list */
02577          BD_NEXT_FREE_NTRY(mod_idx)     = ML_BD_IDX(BD_NEXT_FREE_NTRY(mod_idx));
02578          mod_idx = mod_idx + BD_NTRY_SIZE(mod_idx);
02579       }
02580       else if (BD_DIST_NTRY(mod_idx)) {
02581 
02582          for (dim = 1; dim <= BD_RANK(mod_idx); dim++) {
02583 
02584             if (BD_CYCLIC_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02585                BD_CYCLIC_IDX(mod_idx, dim) = 
02586                                   ML_CN_IDX(BD_CYCLIC_IDX(mod_idx, dim));
02587             }
02588             else if (BD_CYCLIC_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02589                BD_CYCLIC_IDX(mod_idx, dim) = 
02590                                   ML_AT_IDX(BD_CYCLIC_IDX(mod_idx, dim));
02591             }
02592 
02593             if (BD_ONTO_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02594                BD_ONTO_IDX(mod_idx, dim) = 
02595                                   ML_CN_IDX(BD_ONTO_IDX(mod_idx, dim));
02596             }
02597             else if (BD_ONTO_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02598                BD_ONTO_IDX(mod_idx, dim) = 
02599                                   ML_AT_IDX(BD_ONTO_IDX(mod_idx, dim));
02600             }
02601          }
02602          mod_idx = mod_idx + BD_RANK(mod_idx) + 1;  /* 1 for header */
02603       }
02604       else if (BD_ARRAY_CLASS(mod_idx) != Deferred_Shape) {
02605 
02606          if (BD_LEN_FLD(mod_idx) == CN_Tbl_Idx) {
02607             BD_LEN_IDX(mod_idx) = ML_CN_IDX(BD_LEN_IDX(mod_idx));
02608          }
02609          else if (BD_LEN_FLD(mod_idx) == AT_Tbl_Idx) {
02610             BD_LEN_IDX(mod_idx) = ML_AT_IDX(BD_LEN_IDX(mod_idx));
02611          }
02612 
02613          for (dim = 1; dim <= BD_RANK(mod_idx); dim++) {
02614 
02615             if (BD_LB_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02616                BD_LB_IDX(mod_idx, dim) = ML_CN_IDX(BD_LB_IDX(mod_idx, dim));
02617             }
02618             else if (BD_LB_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02619                BD_LB_IDX(mod_idx, dim) = ML_AT_IDX(BD_LB_IDX(mod_idx, dim));
02620             }
02621 
02622             if (BD_UB_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02623                BD_UB_IDX(mod_idx, dim) = ML_CN_IDX(BD_UB_IDX(mod_idx, dim));
02624             }
02625             else if (BD_UB_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02626                BD_UB_IDX(mod_idx, dim) = ML_AT_IDX(BD_UB_IDX(mod_idx, dim));
02627             }
02628 
02629             if (BD_XT_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02630                BD_XT_IDX(mod_idx, dim) = ML_CN_IDX(BD_XT_IDX(mod_idx, dim));
02631             }
02632             else if (BD_XT_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02633                BD_XT_IDX(mod_idx, dim) = ML_AT_IDX(BD_XT_IDX(mod_idx, dim));
02634             }
02635 
02636             if (BD_SM_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02637                BD_SM_IDX(mod_idx, dim) = ML_CN_IDX(BD_SM_IDX(mod_idx, dim));
02638             }
02639             else if (BD_SM_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02640                BD_SM_IDX(mod_idx, dim) = ML_AT_IDX(BD_SM_IDX(mod_idx, dim));
02641             }
02642          }
02643          mod_idx = mod_idx + BD_RANK(mod_idx) + 1;  /* 1 for header */
02644       }
02645       else {
02646         if (BD_NTRY_SIZE(mod_idx) == 0) {
02647            /* eraxxon & fzhao: fix for bug #76 */
02648            mod_idx = mod_idx + BD_RANK(mod_idx) + 1;
02649         }
02650         else {
02651            mod_idx++;
02652         }
02653       }
02654    }
02655 
02656    start_idx    = bd_idx+1;
02657 
02658    for (mod_idx = start_idx; mod_idx <= bounds_tbl_idx; mod_idx++) {
02659 
02660       if (ML_BD_KEEP_ME(mod_idx)) {
02661          ++bd_idx;
02662          COPY_BD_NTRY(bd_idx, mod_idx);
02663 
02664          if (BD_DIST_NTRY(bd_idx) ||
02665              BD_ARRAY_CLASS(bd_idx) != Deferred_Shape) {
02666 
02667             bd_idx = bd_idx + BD_RANK(bd_idx);
02668          }
02669       }
02670    }
02671 
02672    for (mod_idx = start_idx; mod_idx <= bd_idx; mod_idx++) {
02673 
02674       if (BD_DIST_NTRY(mod_idx)) {
02675 
02676          for (dim = 1; dim <= BD_RANK(mod_idx); dim++) {
02677 
02678             if (BD_CYCLIC_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02679                BD_CYCLIC_IDX(mod_idx, dim) =
02680                                   ML_CN_IDX(BD_CYCLIC_IDX(mod_idx, dim));
02681             }
02682             else if (BD_CYCLIC_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02683                BD_CYCLIC_IDX(mod_idx, dim) =
02684                                   ML_AT_IDX(BD_CYCLIC_IDX(mod_idx, dim));
02685             }
02686 
02687             if (BD_ONTO_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02688                BD_ONTO_IDX(mod_idx, dim) =
02689                                   ML_CN_IDX(BD_ONTO_IDX(mod_idx, dim));
02690             }
02691             else if (BD_ONTO_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02692                BD_ONTO_IDX(mod_idx, dim) =
02693                                   ML_AT_IDX(BD_ONTO_IDX(mod_idx, dim));
02694             }
02695          }
02696          mod_idx = mod_idx + BD_RANK(mod_idx);
02697       }
02698       else if (BD_ARRAY_CLASS(mod_idx) != Deferred_Shape) {
02699 
02700          if (BD_LEN_FLD(mod_idx) == CN_Tbl_Idx) {
02701             BD_LEN_IDX(mod_idx) = ML_CN_IDX(BD_LEN_IDX(mod_idx));
02702          }
02703          else if (BD_LEN_FLD(mod_idx) == AT_Tbl_Idx) {
02704             BD_LEN_IDX(mod_idx) = ML_AT_IDX(BD_LEN_IDX(mod_idx));
02705          }
02706 
02707          for (dim = 1; dim <= BD_RANK(mod_idx); dim++) {
02708 
02709             if (BD_LB_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02710                BD_LB_IDX(mod_idx, dim) = ML_CN_IDX(BD_LB_IDX(mod_idx, dim));
02711             }
02712             else if (BD_LB_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02713                BD_LB_IDX(mod_idx, dim) = ML_AT_IDX(BD_LB_IDX(mod_idx, dim));
02714             }
02715 
02716             if (BD_UB_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02717                BD_UB_IDX(mod_idx, dim) = ML_CN_IDX(BD_UB_IDX(mod_idx, dim));
02718             }
02719             else if (BD_UB_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02720                BD_UB_IDX(mod_idx, dim) = ML_AT_IDX(BD_UB_IDX(mod_idx, dim));
02721             }
02722 
02723             if (BD_XT_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02724                BD_XT_IDX(mod_idx, dim) = ML_CN_IDX(BD_XT_IDX(mod_idx, dim));
02725             }
02726             else if (BD_XT_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02727                BD_XT_IDX(mod_idx, dim) = ML_AT_IDX(BD_XT_IDX(mod_idx, dim));
02728             }
02729 
02730             if (BD_SM_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02731                BD_SM_IDX(mod_idx, dim) = ML_CN_IDX(BD_SM_IDX(mod_idx, dim));
02732             }
02733             else if (BD_SM_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02734                BD_SM_IDX(mod_idx, dim) = ML_AT_IDX(BD_SM_IDX(mod_idx, dim));
02735             }
02736          }
02737          mod_idx = mod_idx + BD_RANK(mod_idx);
02738       }
02739    }
02740 
02741    start_idx    = cn_idx+1;
02742 
02743   Pragma("_CRI ivdep")        
02744    for (mod_idx = cn_idx+1; mod_idx <= const_tbl_idx; mod_idx++) {
02745 
02746       if (ML_CN_KEEP_ME(mod_idx)) {
02747          const_tbl[++cn_idx]    = const_tbl[mod_idx];
02748       }
02749    }
02750 
02751 # if defined(_DEBUG)
02752    for (mod_idx = 1; mod_idx <= const_tbl_idx; mod_idx++) {
02753 
02754       if (CN_POOL_IDX(mod_idx) == NULL_IDX) {
02755          PRINTMSG(stmt_start_line, 1349, Internal, 0, mod_idx);
02756       }
02757    }
02758 # endif
02759 
02760 
02761    for (mod_idx = 1; mod_idx <= cn_idx; mod_idx++) {
02762       CN_TYPE_IDX(mod_idx)      = ML_TYP_IDX(CN_TYPE_IDX(mod_idx));
02763       CN_POOL_IDX(mod_idx)      = ML_CP_IDX(CN_POOL_IDX(mod_idx));
02764    }
02765 
02766    for (mod_idx = cp_idx+1; mod_idx <= const_pool_idx; mod_idx++) {
02767 
02768       if (ML_CP_KEEP_ME(mod_idx)) {
02769 
02770 # if defined(_HOST32) 
02771 
02772          if (ML_CP_DALIGN_ME(mod_idx)) {
02773             cp_idx = ML_CP_IDX(mod_idx) - 1;
02774          }
02775 # endif
02776 
02777          for (idx = 0; idx < ML_CP_LEN(mod_idx); idx++) {
02778             const_pool[++cp_idx]        = const_pool[mod_idx+idx];
02779          }
02780       }
02781    }
02782 
02783    for (mod_idx = (from_interface || !only_update_new_tbl_entries) ?
02784                   1 : (il_idx+1); mod_idx <= il_idx; mod_idx++) {
02785       IL_NEXT_LIST_IDX(mod_idx) = ML_IL_IDX(IL_NEXT_LIST_IDX(mod_idx));
02786 
02787       if (!IL_ARG_DESC_VARIANT(mod_idx)) {
02788          IL_PREV_LIST_IDX(mod_idx) = ML_IL_IDX(IL_PREV_LIST_IDX(mod_idx));
02789       }
02790 
02791       switch (IL_FLD(mod_idx)) {
02792       case CN_Tbl_Idx:
02793          IL_IDX(mod_idx) = ML_CN_IDX(IL_IDX(mod_idx));
02794          break;
02795 
02796       case AT_Tbl_Idx:
02797          IL_IDX(mod_idx) = ML_AT_IDX(IL_IDX(mod_idx));
02798          break;
02799       
02800       case IL_Tbl_Idx:
02801          IL_IDX(mod_idx) = ML_IL_IDX(IL_IDX(mod_idx));
02802          break;
02803 
02804       case IR_Tbl_Idx:
02805          IL_IDX(mod_idx) = ML_IR_IDX(IL_IDX(mod_idx));
02806          break;
02807       }
02808    }
02809 
02810    start_idx    = il_idx + 1;
02811 
02812    for (mod_idx = start_idx; mod_idx <= ir_list_tbl_idx; mod_idx++) {
02813 
02814       if (ML_IL_KEEP_ME(mod_idx)) {
02815          ir_list_tbl[++il_idx]          = ir_list_tbl[mod_idx];
02816       }
02817    }
02818 
02819    for (mod_idx = start_idx; mod_idx <= il_idx; mod_idx++) {
02820       IL_NEXT_LIST_IDX(mod_idx) = ML_IL_IDX(IL_NEXT_LIST_IDX(mod_idx));
02821 
02822       if (!IL_ARG_DESC_VARIANT(mod_idx)) {
02823          IL_PREV_LIST_IDX(mod_idx) = ML_IL_IDX(IL_PREV_LIST_IDX(mod_idx));
02824       }
02825 
02826       switch (IL_FLD(mod_idx)) {
02827       case CN_Tbl_Idx:
02828          IL_IDX(mod_idx) = ML_CN_IDX(IL_IDX(mod_idx));
02829          break;
02830 
02831       case AT_Tbl_Idx:
02832          IL_IDX(mod_idx) = ML_AT_IDX(IL_IDX(mod_idx));
02833          break;
02834       
02835       case IL_Tbl_Idx:
02836          IL_IDX(mod_idx) = ML_IL_IDX(IL_IDX(mod_idx));
02837          break;
02838 
02839       case IR_Tbl_Idx:
02840          IL_IDX(mod_idx) = ML_IR_IDX(IL_IDX(mod_idx));
02841          break;
02842       }
02843    }
02844 
02845    for (mod_idx = (from_interface || !only_update_new_tbl_entries) ?
02846                   1 : (ir_idx + 1); mod_idx <= ir_idx; mod_idx++) {
02847       IR_TYPE_IDX(mod_idx)      = ML_TYP_IDX(IR_TYPE_IDX(mod_idx));
02848 
02849       switch (IR_FLD_L(mod_idx)) {
02850       case CN_Tbl_Idx:
02851          IR_IDX_L(mod_idx) = ML_CN_IDX(IR_IDX_L(mod_idx));
02852          break;
02853 
02854       case AT_Tbl_Idx:
02855          IR_IDX_L(mod_idx) = ML_AT_IDX(IR_IDX_L(mod_idx));
02856          break;
02857          
02858       case IL_Tbl_Idx:
02859          IR_IDX_L(mod_idx) = ML_IL_IDX(IR_IDX_L(mod_idx));
02860          break;
02861 
02862       case IR_Tbl_Idx:
02863          IR_IDX_L(mod_idx) = ML_IR_IDX(IR_IDX_L(mod_idx));
02864          break;
02865       }
02866 
02867       switch (IR_FLD_R(mod_idx)) {
02868       case CN_Tbl_Idx:
02869          IR_IDX_R(mod_idx) = ML_CN_IDX(IR_IDX_R(mod_idx));
02870          break;
02871 
02872       case AT_Tbl_Idx:
02873          IR_IDX_R(mod_idx) = ML_AT_IDX(IR_IDX_R(mod_idx));
02874          break;
02875          
02876       case IL_Tbl_Idx:
02877          IR_IDX_R(mod_idx) = ML_IL_IDX(IR_IDX_R(mod_idx));
02878          break;
02879 
02880       case IR_Tbl_Idx:
02881          IR_IDX_R(mod_idx) = ML_IR_IDX(IR_IDX_R(mod_idx));
02882          break;
02883       }
02884    }
02885 
02886    start_idx = ir_idx+1;
02887 
02888    for (mod_idx = start_idx; mod_idx <= ir_tbl_idx; mod_idx++) {
02889 
02890       if (ML_IR_KEEP_ME(mod_idx)) {
02891          ir_tbl[++ir_idx]       = ir_tbl[mod_idx];
02892       }
02893    }
02894 
02895    for (mod_idx = start_idx; mod_idx <= ir_idx; mod_idx++) {
02896       IR_TYPE_IDX(mod_idx)      = ML_TYP_IDX(IR_TYPE_IDX(mod_idx));
02897 
02898       switch (IR_FLD_L(mod_idx)) {
02899       case CN_Tbl_Idx:
02900          IR_IDX_L(mod_idx) = ML_CN_IDX(IR_IDX_L(mod_idx));
02901          break;
02902 
02903       case AT_Tbl_Idx:
02904          IR_IDX_L(mod_idx) = ML_AT_IDX(IR_IDX_L(mod_idx));
02905          break;
02906       
02907       case IL_Tbl_Idx:
02908          IR_IDX_L(mod_idx) = ML_IL_IDX(IR_IDX_L(mod_idx));
02909          break;
02910 
02911       case IR_Tbl_Idx:
02912          IR_IDX_L(mod_idx) = ML_IR_IDX(IR_IDX_L(mod_idx));
02913          break;
02914       }
02915 
02916       switch (IR_FLD_R(mod_idx)) {
02917       case CN_Tbl_Idx:
02918          IR_IDX_R(mod_idx) = ML_CN_IDX(IR_IDX_R(mod_idx));
02919          break;
02920 
02921       case AT_Tbl_Idx:
02922          IR_IDX_R(mod_idx) = ML_AT_IDX(IR_IDX_R(mod_idx));
02923          break;
02924       
02925       case IL_Tbl_Idx:
02926          IR_IDX_R(mod_idx) = ML_IL_IDX(IR_IDX_R(mod_idx));
02927          break;
02928 
02929       case IR_Tbl_Idx:
02930          IR_IDX_R(mod_idx) = ML_IR_IDX(IR_IDX_R(mod_idx));
02931          break;
02932       }
02933    }
02934 
02935    start_idx    = ln_idx+1;
02936 
02937    for (mod_idx = start_idx; mod_idx <= loc_name_tbl_idx; mod_idx++) {
02938 
02939       if (ML_LN_KEEP_ME(mod_idx)) {
02940          loc_name_tbl[++ln_idx] = loc_name_tbl[mod_idx];
02941       }
02942    }
02943 
02944    for (mod_idx = start_idx; mod_idx <= ln_idx; mod_idx++) {
02945 
02946      if (LN_ATTR_IDX(mod_idx) != NULL_IDX) {
02947         LN_ATTR_IDX(mod_idx)    = ML_AT_IDX(LN_ATTR_IDX(mod_idx));
02948         LN_NAME_IDX(mod_idx)    = AT_NAME_IDX(LN_ATTR_IDX(mod_idx));
02949         LN_NAME_LEN(mod_idx)    = AT_NAME_LEN(LN_ATTR_IDX(mod_idx));
02950      }
02951      else {
02952         LN_NAME_IDX(mod_idx)    = ML_NP_IDX(LN_NAME_IDX(mod_idx));
02953      }
02954    }
02955 
02956    for (mod_idx = np_idx+1; mod_idx <= name_pool_idx; mod_idx++) {
02957 
02958       if (ML_NP_KEEP_ME(mod_idx)) {
02959 
02960          for (idx = 0; idx < ML_NP_LEN(mod_idx); idx++) {
02961             name_pool[++np_idx].name_long = name_pool[mod_idx+idx].name_long;
02962          }
02963       }
02964    }
02965 
02966    /* for (mod_idx = (only_update_new_tbl_entries) ? (sb_idx + 1) : 1; */
02967    for (mod_idx = 1; mod_idx <= sb_idx; mod_idx++) {
02968       SB_NAME_IDX(mod_idx)              = ML_NP_IDX(SB_NAME_IDX(mod_idx));
02969       SB_MODULE_IDX(mod_idx)            = ML_AT_IDX(SB_MODULE_IDX(mod_idx));
02970 
02971       if (SB_FIRST_ATTR_IDX(mod_idx) != NULL_IDX) {
02972          SB_FIRST_ATTR_IDX(mod_idx) = ML_AT_IDX(SB_FIRST_ATTR_IDX(mod_idx));
02973       }
02974 
02975       switch (SB_LEN_FLD(mod_idx)) {
02976       case AT_Tbl_Idx:
02977          SB_LEN_IDX(mod_idx)            = ML_AT_IDX(SB_LEN_IDX(mod_idx));
02978          break;
02979      
02980       case CN_Tbl_Idx:
02981          SB_LEN_IDX(mod_idx)            = ML_CN_IDX(SB_LEN_IDX(mod_idx));
02982          break;
02983 
02984       case IL_Tbl_Idx:
02985          SB_LEN_IDX(mod_idx)            = ML_IL_IDX(SB_LEN_IDX(mod_idx));
02986          break;
02987 
02988       case IR_Tbl_Idx:
02989          SB_LEN_IDX(mod_idx)            = ML_IR_IDX(SB_LEN_IDX(mod_idx));
02990          break;
02991       }
02992    }
02993 
02994    start_idx = sb_idx + 1;
02995 
02996    for (mod_idx = start_idx; mod_idx <= stor_blk_tbl_idx; mod_idx++) {
02997 
02998       if (ML_SB_KEEP_ME(mod_idx)) {
02999          stor_blk_tbl[++sb_idx]         = stor_blk_tbl[mod_idx];
03000       }
03001    }
03002 
03003    for (mod_idx = start_idx; mod_idx <= sb_idx; mod_idx++) {
03004       SB_NAME_IDX(mod_idx)              = ML_NP_IDX(SB_NAME_IDX(mod_idx));
03005       SB_MODULE_IDX(mod_idx)            = ML_AT_IDX(SB_MODULE_IDX(mod_idx));
03006 
03007       if (SB_FIRST_ATTR_IDX(mod_idx) != NULL_IDX) {
03008          SB_FIRST_ATTR_IDX(mod_idx) = ML_AT_IDX(SB_FIRST_ATTR_IDX(mod_idx));
03009       }
03010 
03011       switch (SB_LEN_FLD(mod_idx)) {
03012       case AT_Tbl_Idx:
03013          SB_LEN_IDX(mod_idx)            = ML_AT_IDX(SB_LEN_IDX(mod_idx));
03014          break;
03015      
03016       case CN_Tbl_Idx:
03017          SB_LEN_IDX(mod_idx)            = ML_CN_IDX(SB_LEN_IDX(mod_idx));
03018          break;
03019 
03020       case IL_Tbl_Idx:
03021          SB_LEN_IDX(mod_idx)            = ML_IL_IDX(SB_LEN_IDX(mod_idx));
03022          break;
03023 
03024       case IR_Tbl_Idx:
03025          SB_LEN_IDX(mod_idx)            = ML_IR_IDX(SB_LEN_IDX(mod_idx));
03026          break;
03027       }
03028    }
03029 
03030    for (mod_idx = (from_interface || !only_update_new_tbl_entries) ?
03031                   1 : (sh_idx + 1); mod_idx <= sh_idx; mod_idx++) {
03032       SH_NEXT_IDX(mod_idx)              = ML_SH_IDX(SH_NEXT_IDX(mod_idx));
03033       SH_PREV_IDX(mod_idx)              = ML_SH_IDX(SH_PREV_IDX(mod_idx));
03034       SH_IR_IDX(mod_idx)                = ML_IR_IDX(SH_IR_IDX(mod_idx));
03035 
03036       if (SH_STMT_TYPE(mod_idx) != Statement_Num_Stmt) {
03037          SH_PARENT_BLK_IDX(mod_idx)     = ML_SH_IDX(SH_PARENT_BLK_IDX(mod_idx));
03038       }
03039    }
03040 
03041    start_idx = sh_idx + 1;
03042 
03043    for (mod_idx = start_idx; mod_idx <= sh_tbl_idx; mod_idx++) {
03044 
03045       if (ML_SH_KEEP_ME(mod_idx)) {
03046          sh_tbl[++sh_idx]               = sh_tbl[mod_idx];
03047       }
03048    }
03049 
03050 
03051    for (mod_idx = start_idx; mod_idx <= sh_idx; mod_idx++) {
03052       SH_NEXT_IDX(mod_idx)              = ML_SH_IDX(SH_NEXT_IDX(mod_idx));
03053       SH_PREV_IDX(mod_idx)              = ML_SH_IDX(SH_PREV_IDX(mod_idx));
03054       SH_IR_IDX(mod_idx)                = ML_IR_IDX(SH_IR_IDX(mod_idx));
03055 
03056       if (SH_STMT_TYPE(mod_idx) != Statement_Num_Stmt) {
03057          SH_PARENT_BLK_IDX(mod_idx)     = ML_SH_IDX(SH_PARENT_BLK_IDX(mod_idx));
03058       }
03059    }
03060 
03061    /* Need SN_NAME_LEN because of renames situations. */
03062 
03063    /* for (mod_idx = (only_update_new_tbl_entries) ? (sn_idx+1) : 1;  */
03064    for (mod_idx = 1; mod_idx <= sn_idx; mod_idx++) {
03065       SN_ATTR_IDX(mod_idx)      = ML_AT_IDX(SN_ATTR_IDX(mod_idx));
03066       SN_NAME_IDX(mod_idx)      = AT_NAME_IDX(SN_ATTR_IDX(mod_idx));
03067       SN_NAME_LEN(mod_idx)      = AT_NAME_LEN(SN_ATTR_IDX(mod_idx));
03068       SN_SIBLING_LINK(mod_idx)  = ML_SN_IDX(SN_SIBLING_LINK(mod_idx));
03069    }
03070 
03071    start_idx = sn_idx + 1;
03072 
03073    for (mod_idx = start_idx; mod_idx <= sec_name_tbl_idx; mod_idx++) {
03074 
03075       if (ML_SN_KEEP_ME(mod_idx)) {
03076          sec_name_tbl[++sn_idx]         = sec_name_tbl[mod_idx];
03077       }
03078    }
03079 
03080    for (mod_idx = start_idx; mod_idx <= sec_name_tbl_idx; mod_idx++) {
03081       SN_ATTR_IDX(mod_idx)              = ML_AT_IDX(SN_ATTR_IDX(mod_idx));
03082       SN_NAME_IDX(mod_idx)              = AT_NAME_IDX(SN_ATTR_IDX(mod_idx));
03083       SN_NAME_LEN(mod_idx)              = AT_NAME_LEN(SN_ATTR_IDX(mod_idx));
03084       SN_SIBLING_LINK(mod_idx)          = ML_SN_IDX(SN_SIBLING_LINK(mod_idx));
03085    }
03086 
03087    attr_tbl_idx         = at_idx;
03088    attr_aux_tbl_idx     = at_idx;
03089    bounds_tbl_idx       = bd_idx;
03090    const_tbl_idx        = cn_idx;
03091    const_pool_idx       = cp_idx;
03092    loc_name_tbl_idx     = ln_idx;
03093    ir_list_tbl_idx      = il_idx;
03094    ir_tbl_idx           = ir_idx;
03095    name_pool_idx        = np_idx;
03096    stor_blk_tbl_idx     = sb_idx;
03097    sec_name_tbl_idx     = sn_idx;
03098    sh_tbl_idx           = sh_idx;
03099 
03100    /* If this is a partial compression, the only entries added to the */
03101    /* attr_list_tbl must point to new attributes coming in during USE */
03102    /* processing.                                                     */
03103 
03104    for (mod_idx = al_idx+1; mod_idx <= attr_list_tbl_idx; mod_idx++) {
03105       
03106 # if defined(_DEBUG)
03107      end_idx    = ML_AT_IDX(AL_ATTR_IDX(mod_idx));
03108 
03109      if (!AL_FREE(mod_idx) &&
03110           AL_ATTR_IDX(mod_idx) != NULL_IDX &&
03111          !ML_AT_KEEP_ME(AL_ATTR_IDX(mod_idx)) &&
03112          !ML_AT_COMPRESSED_IDX(AL_ATTR_IDX(mod_idx))) {
03113 
03114 
03115         /* This attr is not being kept.  It should have been cleared. */
03116 
03117         PRINTMSG(stmt_start_line, 1321, Internal, 0, mod_idx, 
03118                  AL_ATTR_IDX(mod_idx));
03119      }
03120 
03121 # endif
03122 
03123       AL_ATTR_IDX(mod_idx) = ML_AT_IDX(AL_ATTR_IDX(mod_idx));
03124    }
03125 
03126    mod_idx = SCP_HN_FW_IDX(curr_scp_idx) + 1;
03127    end_idx = SCP_HN_LW_IDX(curr_scp_idx);
03128 
03129    while (mod_idx < end_idx) {
03130 
03131       if (!ML_AT_KEEP_ME(HN_ATTR_IDX(mod_idx))) {
03132 
03133          if (!ML_AT_COMPRESSED_IDX(HN_ATTR_IDX(mod_idx))) {
03134             remove_hidden_name_ntry(mod_idx);
03135             end_idx = SCP_HN_LW_IDX(curr_scp_idx);
03136          }
03137       }
03138       mod_idx++;
03139    }
03140 
03141 
03142    for (mod_idx = SCP_HN_FW_IDX(curr_scp_idx) + 1;
03143         mod_idx < SCP_HN_LW_IDX(curr_scp_idx); mod_idx++) {
03144       HN_ATTR_IDX(mod_idx)      = ML_AT_IDX(HN_ATTR_IDX(mod_idx));
03145       HN_NAME_IDX(mod_idx)      = ML_NP_IDX(HN_NAME_IDX(mod_idx));
03146    }
03147 
03148    /* This updates the scp attr index, but be careful, because        */
03149    /* everything else in the scope table could be bad pointers.       */
03150 
03151    SCP_ATTR_IDX(curr_scp_idx) = ML_AT_IDX(SCP_ATTR_IDX(curr_scp_idx));
03152 
03153    TRACE (Func_Exit, "compress_tbls", NULL);
03154 
03155    return;
03156 
03157 }   /* compress_tbls */
03158 
03159 /******************************************************************************\
03160 |*                                                                            *|
03161 |* Description:                                                               *|
03162 |*                                                                            *|
03163 |* Input parameters:                                                          *|
03164 |*      NONE                                                                  *|
03165 |*                                                                            *|
03166 |* Output parameters:                                                         *|
03167 |*      NONE                                                                  *|
03168 |*                                                                            *|
03169 |* Returns:                                                                   *|
03170 |*      NOTHING                                                               *|
03171 |*                                                                            *|
03172 \******************************************************************************/
03173 static  void  update_idxs_in_attr_entry(int     start_idx,
03174                                         int     end_idx)
03175 {
03176    int          at_idx;
03177 
03178 
03179    TRACE (Func_Entry, "update_idxs_in_attr_entry", NULL);
03180 
03181    for (at_idx  = start_idx; at_idx <= end_idx; at_idx++) {
03182 
03183    if (!AT_IGNORE_ATTR_LINK(at_idx)) {
03184        AT_ATTR_LINK(at_idx)     = ML_AT_IDX(AT_ATTR_LINK(at_idx));
03185    }
03186 
03187    AT_NAME_IDX(at_idx)          = ML_NP_IDX(AT_NAME_IDX(at_idx));
03188    AT_ORIG_NAME_IDX(at_idx)     = ML_NP_IDX(AT_ORIG_NAME_IDX(at_idx));
03189    AT_MODULE_IDX(at_idx)        = ML_AT_IDX(AT_MODULE_IDX(at_idx));
03190 
03191    switch (AT_OBJ_CLASS(at_idx)) {
03192    case Data_Obj:
03193       ATD_ARRAY_IDX(at_idx)        = ML_BD_IDX(ATD_ARRAY_IDX(at_idx));
03194       ATD_DISTRIBUTION_IDX(at_idx) = ML_BD_IDX(ATD_DISTRIBUTION_IDX(at_idx));
03195       ATD_STOR_BLK_IDX(at_idx)     = ML_SB_IDX(ATD_STOR_BLK_IDX(at_idx));
03196       ATD_RESHAPE_ARRAY_IDX(at_idx)= ML_BD_IDX(ATD_RESHAPE_ARRAY_IDX(at_idx));
03197 
03198 # if defined(COARRAY_FORTRAN)
03199       ATD_PE_ARRAY_IDX(at_idx)     = ML_BD_IDX(ATD_PE_ARRAY_IDX(at_idx));
03200 # endif
03201 
03202       switch (ATD_CLASS(at_idx)) {
03203       case Function_Result:
03204 
03205          if (ATD_OFFSET_ASSIGNED(at_idx)) {
03206 
03207             switch (ATD_OFFSET_FLD(at_idx)) {
03208             case AT_Tbl_Idx:
03209                ATD_OFFSET_IDX(at_idx) = ML_AT_IDX(ATD_OFFSET_IDX(at_idx));
03210                break;
03211 
03212             case CN_Tbl_Idx:
03213                ATD_OFFSET_IDX(at_idx) = ML_CN_IDX(ATD_OFFSET_IDX(at_idx));
03214                break;
03215 
03216             case IR_Tbl_Idx:
03217                ATD_OFFSET_IDX(at_idx) = ML_IR_IDX(ATD_OFFSET_IDX(at_idx));
03218                break;
03219 
03220             case IL_Tbl_Idx:
03221                ATD_OFFSET_IDX(at_idx) = ML_IL_IDX(ATD_OFFSET_IDX(at_idx));
03222                break;
03223             }
03224          }
03225 
03226          ATD_TYPE_IDX(at_idx)   = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03227          ATD_FUNC_IDX(at_idx)   = ML_AT_IDX(ATD_FUNC_IDX(at_idx));
03228          break;
03229 
03230 
03231       case Constant:
03232 
03233          ATD_TYPE_IDX(at_idx)   = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03234 
03235          switch (ATD_FLD(at_idx)) {
03236          case AT_Tbl_Idx:
03237             ATD_CONST_IDX(at_idx) = ML_AT_IDX(ATD_CONST_IDX(at_idx));
03238             break;
03239  
03240          default:
03241             ATD_CONST_IDX(at_idx) = ML_CN_IDX(ATD_CONST_IDX(at_idx));
03242             break;
03243          }
03244          break;
03245 
03246 
03247       case CRI__Pointee:
03248          ATD_TYPE_IDX(at_idx)   = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03249          ATD_PTR_IDX(at_idx)    = ML_AT_IDX(ATD_PTR_IDX(at_idx));
03250          break;
03251 
03252       case Compiler_Tmp:
03253 
03254          ATD_NEXT_MEMBER_IDX(at_idx)  = ML_AT_IDX(ATD_NEXT_MEMBER_IDX(at_idx));
03255          ATD_DEFINING_ATTR_IDX(at_idx)=ML_AT_IDX(ATD_DEFINING_ATTR_IDX(at_idx));
03256 
03257          if (ATD_AUTOMATIC(at_idx)) {
03258             ATD_AUTO_BASE_IDX(at_idx) = ML_AT_IDX(ATD_AUTO_BASE_IDX(at_idx));
03259          }
03260          else if (ATD_OFFSET_ASSIGNED(at_idx)) {
03261 
03262             switch (ATD_OFFSET_FLD(at_idx)) {
03263             case AT_Tbl_Idx:
03264                ATD_OFFSET_IDX(at_idx) = ML_AT_IDX(ATD_OFFSET_IDX(at_idx));
03265                break;
03266 
03267             case CN_Tbl_Idx:
03268                ATD_OFFSET_IDX(at_idx) = ML_CN_IDX(ATD_OFFSET_IDX(at_idx));
03269                break;
03270 
03271             case IR_Tbl_Idx:
03272                ATD_OFFSET_IDX(at_idx) = ML_IR_IDX(ATD_OFFSET_IDX(at_idx));
03273                break;
03274 
03275             case IL_Tbl_Idx:
03276                ATD_OFFSET_IDX(at_idx) = ML_IL_IDX(ATD_OFFSET_IDX(at_idx));
03277                break;
03278             }
03279          }
03280 
03281          ATD_TYPE_IDX(at_idx)   = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03282 
03283          switch (ATD_FLD(at_idx)) {
03284          case CN_Tbl_Idx:
03285             ATD_TMP_IDX(at_idx)   = ML_CN_IDX(ATD_TMP_IDX(at_idx));
03286             break;
03287 
03288          case AT_Tbl_Idx:
03289             ATD_TMP_IDX(at_idx)   = ML_AT_IDX(ATD_TMP_IDX(at_idx));
03290             break;
03291 
03292          case IR_Tbl_Idx:
03293             ATD_TMP_IDX(at_idx)   = ML_IR_IDX(ATD_TMP_IDX(at_idx));
03294             break;
03295 
03296          case IL_Tbl_Idx:
03297             ATD_TMP_IDX(at_idx)   = ML_IL_IDX(ATD_TMP_IDX(at_idx));
03298             break;
03299          }
03300          break;
03301 
03302 
03303       case Dummy_Argument:
03304 
03305          if (!ATD_INTRIN_DARG(at_idx)) {
03306             ATD_TYPE_IDX(at_idx)        = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03307          }
03308          break;
03309 
03310 
03311       case Struct_Component:
03312 
03313          switch (ATD_OFFSET_FLD(at_idx)) {
03314          case AT_Tbl_Idx:
03315             ATD_CPNT_OFFSET_IDX(at_idx) =ML_AT_IDX(ATD_CPNT_OFFSET_IDX(at_idx));
03316             break;
03317 
03318          case CN_Tbl_Idx:
03319             ATD_CPNT_OFFSET_IDX(at_idx) =ML_CN_IDX(ATD_CPNT_OFFSET_IDX(at_idx));
03320             break;
03321 
03322          case IR_Tbl_Idx:
03323             ATD_CPNT_OFFSET_IDX(at_idx) =ML_IR_IDX(ATD_CPNT_OFFSET_IDX(at_idx));
03324             break;
03325 
03326          case IL_Tbl_Idx:
03327             ATD_CPNT_OFFSET_IDX(at_idx) =ML_IL_IDX(ATD_CPNT_OFFSET_IDX(at_idx));
03328             break;
03329          }
03330 
03331          switch (ATD_FLD(at_idx)) {
03332          case AT_Tbl_Idx:
03333             ATD_CPNT_INIT_IDX(at_idx)   = ML_AT_IDX(ATD_CPNT_INIT_IDX(at_idx));
03334             break;
03335 
03336          case CN_Tbl_Idx:
03337             ATD_CPNT_INIT_IDX(at_idx)   = ML_CN_IDX(ATD_CPNT_INIT_IDX(at_idx));
03338             break;
03339 
03340          case IR_Tbl_Idx:
03341             ATD_CPNT_INIT_IDX(at_idx)   = ML_IR_IDX(ATD_CPNT_INIT_IDX(at_idx));
03342             break;
03343 
03344          case IL_Tbl_Idx:
03345             ATD_CPNT_INIT_IDX(at_idx)   = ML_IL_IDX(ATD_CPNT_INIT_IDX(at_idx));
03346             break;
03347          }
03348          ATD_TYPE_IDX(at_idx)         = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03349          ATD_DERIVED_TYPE_IDX(at_idx) = ML_AT_IDX(ATD_DERIVED_TYPE_IDX(at_idx));
03350          break;
03351 
03352 
03353       case Variable:
03354 
03355          switch (ATD_FLD(at_idx)) {
03356          case AT_Tbl_Idx:
03357             ATD_VARIABLE_TMP_IDX(at_idx) =
03358                          ML_AT_IDX(ATD_VARIABLE_TMP_IDX(at_idx));
03359             break;
03360 
03361          case IL_Tbl_Idx:
03362             ATD_VARIABLE_TMP_IDX(at_idx) =
03363                          ML_IL_IDX(ATD_VARIABLE_TMP_IDX(at_idx));
03364             break;
03365          }
03366 
03367          ATD_ASSIGN_TMP_IDX(at_idx)   = ML_AT_IDX(ATD_ASSIGN_TMP_IDX(at_idx));
03368          ATD_NEXT_MEMBER_IDX(at_idx)  = ML_AT_IDX(ATD_NEXT_MEMBER_IDX(at_idx));
03369 
03370          if (ATD_AUTOMATIC(at_idx)) {
03371             ATD_AUTO_BASE_IDX(at_idx) = ML_AT_IDX(ATD_AUTO_BASE_IDX(at_idx));
03372          }
03373          else if (ATD_OFFSET_ASSIGNED(at_idx)) {
03374 
03375             switch (ATD_OFFSET_FLD(at_idx)) {
03376             case AT_Tbl_Idx:
03377                ATD_OFFSET_IDX(at_idx) = ML_AT_IDX(ATD_OFFSET_IDX(at_idx));
03378                break;
03379 
03380             case CN_Tbl_Idx:
03381                ATD_OFFSET_IDX(at_idx) = ML_CN_IDX(ATD_OFFSET_IDX(at_idx));
03382                break;
03383 
03384             case IR_Tbl_Idx:
03385                ATD_OFFSET_IDX(at_idx) = ML_IR_IDX(ATD_OFFSET_IDX(at_idx));
03386                break;
03387 
03388             case IL_Tbl_Idx:
03389                ATD_OFFSET_IDX(at_idx) = ML_IL_IDX(ATD_OFFSET_IDX(at_idx));
03390                break;
03391             }
03392          }
03393 
03394          /* Intentional fall through */
03395 
03396       default:
03397          ATD_TYPE_IDX(at_idx)   = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03398          break;
03399 
03400       }  /* End switch */
03401       break;
03402 
03403    case Pgm_Unit:
03404 
03405       if (ATP_PGM_UNIT(at_idx) == Module) {
03406          ATP_MOD_PATH_IDX(at_idx) = ML_NP_IDX(ATP_MOD_PATH_IDX(at_idx));
03407       }
03408       else {
03409          ATP_RSLT_IDX(at_idx)   = ML_AT_IDX(ATP_RSLT_IDX(at_idx));
03410          ATP_FIRST_IDX(at_idx)  = ML_SN_IDX(ATP_FIRST_IDX(at_idx));
03411 
03412          if (ATP_PROC(at_idx) != Intrin_Proc && ATP_PROC(at_idx) != Dummy_Proc){
03413             ATP_FIRST_SH_IDX(at_idx)= ML_SH_IDX(ATP_FIRST_SH_IDX(at_idx));
03414             ATP_PARENT_IDX(at_idx)  = ML_AT_IDX(ATP_PARENT_IDX(at_idx));
03415          }
03416       }
03417 
03418       ATP_EXT_NAME_IDX(at_idx)  = ML_NP_IDX(ATP_EXT_NAME_IDX(at_idx));
03419       break;
03420 
03421    case Label:
03422 
03423       ATL_NEXT_ASG_LBL_IDX(at_idx) = ML_AT_IDX(ATL_NEXT_ASG_LBL_IDX(at_idx));
03424 
03425       if (AT_DEFINED(at_idx)) {
03426          ATL_DEF_STMT_IDX(at_idx)  = ML_SH_IDX(ATL_DEF_STMT_IDX(at_idx));
03427       }
03428 
03429       if (ATL_CLASS(at_idx) == Lbl_Format) {
03430          ATL_PP_FORMAT_TMP(at_idx) = ML_AT_IDX(ATL_PP_FORMAT_TMP(at_idx));
03431          ATL_FORMAT_TMP(at_idx)    = ML_AT_IDX(ATL_FORMAT_TMP(at_idx));
03432       }
03433       else {
03434          ATL_DIRECTIVE_LIST(at_idx)= ML_IL_IDX(ATL_DIRECTIVE_LIST(at_idx));
03435 
03436          if (ATL_CLASS(at_idx) == Lbl_User) {
03437             ATL_BLK_STMT_IDX(at_idx)  = ML_SH_IDX(ATL_BLK_STMT_IDX(at_idx));
03438          }
03439       }
03440       break;
03441 
03442 
03443    case Derived_Type:
03444 
03445       if (ATT_STRUCT_BIT_LEN_IDX(at_idx) != NULL_IDX) {
03446 
03447          switch (ATT_STRUCT_BIT_LEN_FLD(at_idx)) {
03448          case CN_Tbl_Idx:
03449             ATT_STRUCT_BIT_LEN_IDX(at_idx) = 
03450                                  ML_CN_IDX(ATT_STRUCT_BIT_LEN_IDX(at_idx));
03451             break;
03452 
03453          case AT_Tbl_Idx:
03454             ATT_STRUCT_BIT_LEN_IDX(at_idx) = 
03455                                  ML_AT_IDX(ATT_STRUCT_BIT_LEN_IDX(at_idx));
03456             break;
03457 
03458          case IL_Tbl_Idx:
03459             ATT_STRUCT_BIT_LEN_IDX(at_idx) = 
03460                                  ML_IL_IDX(ATT_STRUCT_BIT_LEN_IDX(at_idx));
03461             break;
03462 
03463          case IR_Tbl_Idx:
03464             ATT_STRUCT_BIT_LEN_IDX(at_idx) = 
03465                                  ML_IR_IDX(ATT_STRUCT_BIT_LEN_IDX(at_idx));
03466             break;
03467 
03468          case NO_Tbl_Idx:
03469             ATT_STRUCT_BIT_LEN_FLD(at_idx) = CN_Tbl_Idx;
03470             ATT_STRUCT_BIT_LEN_IDX(at_idx) = 
03471                                  ML_CN_IDX(ATT_STRUCT_BIT_LEN_IDX(at_idx));
03472             break;
03473          }
03474       }
03475 
03476       ATT_FIRST_CPNT_IDX(at_idx)        = ML_SN_IDX(ATT_FIRST_CPNT_IDX(at_idx));
03477       break;
03478 
03479    case Interface:
03480 
03481       ATI_FIRST_SPECIFIC_IDX(at_idx) =ML_SN_IDX(ATI_FIRST_SPECIFIC_IDX(at_idx));
03482       ATI_PROC_IDX(at_idx)              = ML_AT_IDX(ATI_PROC_IDX(at_idx));
03483       ATD_TYPE_IDX(at_idx)              = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03484       break;
03485 
03486    case Namelist_Grp:
03487 
03488       ATN_FIRST_NAMELIST_IDX(at_idx) =ML_SN_IDX(ATN_FIRST_NAMELIST_IDX(at_idx));
03489       ATN_LAST_NAMELIST_IDX(at_idx)  = ML_SN_IDX(ATN_LAST_NAMELIST_IDX(at_idx));
03490 
03491       if (ATN_NAMELIST_DESC(at_idx) != NULL_IDX) {
03492          ATN_NAMELIST_DESC(at_idx)   = ML_AT_IDX(ATN_NAMELIST_DESC(at_idx));
03493       }
03494       break;
03495 
03496    case Stmt_Func:
03497 
03498       ATD_TYPE_IDX(at_idx) = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03499       ATP_FIRST_IDX(at_idx) = ML_SN_IDX(ATP_FIRST_IDX(at_idx));
03500 
03501       switch (ATS_SF_FLD(at_idx)) {
03502       case CN_Tbl_Idx:
03503          ATS_SF_IDX(at_idx) = ML_CN_IDX(ATS_SF_IDX(at_idx));
03504          break;
03505 
03506       case AT_Tbl_Idx:
03507          ATS_SF_IDX(at_idx) = ML_AT_IDX(ATS_SF_IDX(at_idx));
03508          break;
03509 
03510       case IR_Tbl_Idx:
03511          ATS_SF_IDX(at_idx) = ML_IR_IDX(ATS_SF_IDX(at_idx));
03512          break;
03513 
03514       case IL_Tbl_Idx:
03515          ATS_SF_IDX(at_idx) = ML_IL_IDX(ATS_SF_IDX(at_idx));
03516          break;
03517       }
03518       break;
03519    }  /* End switch */
03520    }  /* End For */
03521 
03522    TRACE (Func_Exit, "update_idxs_in_attr_entry", NULL);
03523 
03524    return;
03525 
03526 }   /* update_idxs_in_attr_entry */
03527 
03528 /******************************************************************************\
03529 |*                                                                            *|
03530 |* Description:                                                               *|
03531 |*                                                                            *|
03532 |* Input parameters:                                                          *|
03533 |*      NONE                                                                  *|
03534 |*                                                                            *|
03535 |* Output parameters:                                                         *|
03536 |*      NONE                                                                  *|
03537 |*                                                                            *|
03538 |* Returns:                                                                   *|
03539 |*      NOTHING                                                               *|
03540 |*                                                                            *|
03541 \******************************************************************************/
03542 extern  void  output_mod_info_file(void)
03543 
03544 {
03545    int           al_idx;
03546    int           idx;
03547    int           module_attr_idx;
03548    FILE         *mod_file_ptr           = NULL;
03549    long         *mod_idx;
03550    int           name_idx;
03551    int           sb_idx;
03552    int           wd_len;
03553 
03554 
03555    TRACE (Func_Entry, "output_mod_info_file", NULL);
03556 
03557    module_attr_idx      = SCP_ATTR_IDX(curr_scp_idx);
03558 
03559    if (dump_flags.preinline) {  /* Append these files */
03560       mod_file_ptr = fopen(FP_NAME_PTR(SCP_FILE_PATH_IDX(curr_scp_idx)), "ab");
03561    }
03562    else if (on_off_flags.module_to_mod) {
03563       mod_file_ptr = fopen(FP_NAME_PTR(SCP_FILE_PATH_IDX(curr_scp_idx)), "wb");
03564    }
03565    else {
03566 
03567 #     if defined(_MODULE_TO_DOT_M)      /* These are all appended */
03568          mod_file_ptr = fopen(FP_NAME_PTR(SCP_FILE_PATH_IDX(curr_scp_idx)),
03569                               "ab");
03570 #     else
03571          mod_file_ptr = fopen(FP_NAME_PTR(SCP_FILE_PATH_IDX(curr_scp_idx)),
03572                               "wb");
03573 #     endif
03574    }
03575 
03576    SCP_FILE_PATH_IDX(curr_scp_idx) = NULL_IDX;
03577 
03578    if (ATP_PGM_UNIT(module_attr_idx) == Module) {
03579       ATP_MOD_PATH_IDX(module_attr_idx) = NULL_IDX;
03580       ATP_MOD_PATH_LEN(module_attr_idx) = 0;
03581    }
03582 
03583    if (mod_file_ptr == NULL) {
03584       PRINTMSG(AT_DEF_LINE(module_attr_idx), 1665, Error,
03585                AT_DEF_COLUMN(module_attr_idx),
03586                AT_OBJ_NAME_PTR(module_attr_idx),
03587                FP_NAME_PTR(SCP_FILE_PATH_IDX(curr_scp_idx)));
03588       goto EXIT;
03589    }
03590 
03591    MD_PDT_HDR_TYPE              = COMPILER_INFO_TABLE_TYPE;
03592    MD_VERSION_NUM               = MD_CURRENT_VERSION;
03593    MD_TARGET                    = target_os;
03594    MD_ENABLE_DOUBLE_PRECISION   = on_off_flags.enable_double_precision;
03595    MD_DEFAULT_INTEGER_TYPE      = INTEGER_DEFAULT_TYPE;
03596    MD_HAS_ERRORS                = (num_prog_unit_errors > 0);
03597    MD_DALIGN                    = cmd_line_flags.dalign;
03598    MD_CF77TYPES                 = cmd_line_flags.s_cf77types;
03599    MD_DEFAULT32                 = cmd_line_flags.s_default32;
03600    MD_DEFAULT64                 = cmd_line_flags.s_default64;
03601    MD_FLOAT64                   = cmd_line_flags.s_float64;
03602 
03603    MD_NEW_CONST_TBL             = TRUE;
03604 
03605    /* At this point, if we're outputing for inlining we need to check for   */
03606    /* alternate entries.  If they exist, an md_header_descriptor is written */
03607    /* out for each.  The actual tables for the alternate entry follow in    */
03608    /* main entry and can can be found by reading the 026 table until the    */
03609    /* next main entry is found.                                             */
03610 
03611    if (ATP_MAY_INLINE(SCP_ATTR_IDX(MAIN_SCP_IDX)) && 
03612        SCP_ENTRY_IDX(MAIN_SCP_IDX) != NULL_IDX) {
03613       al_idx            = SCP_ENTRY_IDX(MAIN_SCP_IDX);
03614       MD_ALTERNATE_ENTRY= TRUE;
03615       MD_PDT_HDR_LEN    = sizeof(mit_header_type)/TARGET_BYTES_PER_WORD;
03616 
03617 # if defined(_HOST32) && defined(_TARGET64)
03618 
03619       /* PDT size must be in 64 bit increment sizes. */
03620 
03621       MD_PDT_HDR_LEN = (MD_PDT_HDR_LEN + 1) / 2;
03622 # endif
03623 
03624       while (al_idx != NULL_IDX) {
03625          name_idx       = AT_NAME_IDX(AL_ATTR_IDX(al_idx));
03626          MD_NAME_LEN    = AT_NAME_LEN(AL_ATTR_IDX(al_idx));
03627          wd_len         = WORD_LEN(MD_NAME_LEN);
03628          mod_idx        = MD_NAME_LONG;
03629 
03630          for (idx = 0; idx < wd_len; idx++) {
03631             *mod_idx    = name_pool[name_idx].name_long;
03632             name_idx++;
03633             mod_idx++;
03634          }
03635 
03636          fwrite(&mit_header, sizeof(mit_header_type), 1, mod_file_ptr);
03637          al_idx         = AL_NEXT_IDX(al_idx);
03638       }
03639 
03640       /* Reset the original name in the header. */
03641 
03642       name_idx          = AT_NAME_IDX(module_attr_idx);
03643       MD_NAME_LEN       = AT_NAME_LEN(module_attr_idx);
03644       wd_len            = WORD_LEN(MD_NAME_LEN);
03645       mod_idx           = MD_NAME_LONG;
03646 
03647       for (idx = 0; idx < wd_len; idx++) {
03648          *mod_idx       = name_pool[name_idx].name_long;
03649          name_idx++;
03650          mod_idx++;
03651       }
03652    }
03653 
03654    MD_ALTERNATE_ENTRY           = FALSE;
03655 
03656    if (dump_flags.preinline && num_prog_unit_errors > 0) {
03657 
03658       /* Do not write out any tables.  Just a header with error set. */
03659 
03660       attr_tbl_idx      = NULL_IDX;
03661       attr_aux_tbl_idx  = NULL_IDX;
03662       bounds_tbl_idx    = NULL_IDX;
03663       const_tbl_idx     = NULL_IDX;
03664       const_pool_idx    = NULL_IDX;
03665       ir_tbl_idx        = NULL_IDX;
03666       ir_list_tbl_idx   = NULL_IDX;
03667       loc_name_tbl_idx  = NULL_IDX;
03668       name_pool_idx     = NULL_IDX;
03669       sec_name_tbl_idx  = NULL_IDX;
03670       stor_blk_tbl_idx  = NULL_IDX;
03671       type_tbl_idx      = NULL_IDX;
03672       sh_tbl_idx        = NULL_IDX;
03673    }
03674    else {
03675 
03676       /* Do not write out any tables.  Just the mod header. */
03677 
03678       /* In error situations, module_attr_idx may not be in the local name    */
03679       /* table so it has to be specifically included for output.  This module */
03680       /* output is only used to finish this compilation because of errors.    */
03681 
03682       ML_AT_IDX(module_attr_idx)        = module_attr_idx;
03683 
03684       /* assign_new_idxs needs to have ML_AT_IDX(0) = NULL_IDX, ML_BD_IDX(0)  */
03685       /* = NULL_IDX -  ect..  The zeroth entry of the mod link table contains */
03686       /* the index to start compression at for each table.  When compressing  */
03687       /* tables for module output, everything gets compressed, so the zeroth  */
03688       /* entry should be all zeros to signify that everything gets compressed.*/
03689       /* The zeroth entry is set to all NULL_IDX's when the table is allocated*/
03690 
03691       /* Resolve duplicate attr idxs in mod link table.         */
03692 
03693       save_const_pool_idx       = NULL_IDX;
03694       save_const_tbl_idx        = NULL_IDX;
03695 
03696       /* If we're not creating a preinline file and if MODINLINE is not on    */
03697       /* for this module, then we will not be writing out the SH table, so    */
03698       /* set ML_SH_IDX equal to sh_tbl_idx, so we do nothing in assign_new..  */
03699       /* Then clear sh_tbl_idx and ML_SH_IDX so we do nothing in compress_..  */
03700 
03701       if (!ATP_MAY_INLINE(SCP_ATTR_IDX(MAIN_SCP_IDX))) {
03702          ML_SH_IDX(0)   = sh_tbl_idx;  /* SH table not needed.  */
03703          assign_new_idxs(TRUE);
03704          ML_SH_IDX(0)   = NULL_IDX;
03705          sh_tbl_idx     = NULL_IDX;
03706       }
03707       else {
03708          assign_new_idxs(TRUE);
03709       }
03710 
03711       /* Do table compression, but do not update the attribute entries in the */
03712       /* attr_list_tbl.  Stop updating from happening, by passing the last    */
03713       /* used index in attr_list_tbl.  compress_tbls goes through the attr    */
03714       /* list table starting at the entry past the entry passed in.           */
03715 
03716       num_module_derived_types  = 0;  /* Not used - clear to prevent overflow */
03717       count_derived_types       = FALSE;
03718       compress_tbls(attr_list_tbl_idx, FALSE); 
03719 
03720       /* module_attr_idx may have been moved during compression. */
03721 
03722       module_attr_idx           = ML_AT_IDX(module_attr_idx);
03723 
03724       /* Certain flds in the attr table need to be cleared, such as line      */
03725       /* numbers cif ids, the referenced flag ect..                           */
03726       /* Also, if alternate entries, reset ATP_FIRST_SH_IDX to the main       */
03727       /* entry's ATP_FIRST                                                    */
03728 
03729       set_attr_flds_for_output();
03730 
03731       /* Any bounds table free list is destroyed. */
03732 
03733       BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX)       = NULL_IDX;
03734 
03735       /* Set ATP_SCP_ALIVE for the module attr, so that it can be recognized  */
03736       /* when the module is read in again.  ATP_SCP_ALIVE is turned off for   */
03737       /* everything after the semantic pass in s_driver.                      */
03738 
03739       ATP_SCP_ALIVE(module_attr_idx)    = TRUE;
03740 
03741       for (sb_idx       = 1; sb_idx <= stor_blk_tbl_idx; sb_idx++) {
03742          SB_CIF_SYMBOL_ID(sb_idx)    = NULL_IDX;
03743       }
03744    }
03745 
03746    /* Note on table sizes.  tbl_idx is the last used item in the table.       */
03747    /* The 0th entry should not be written out to the module info table,       */
03748    /* so using tbl_idx as the size of the table to write out is correct.      */
03749    /* That is also why when the tables are written they start at [1].         */
03750 
03751    MD_TBL_TYPE(Attr_Tbl)        = Attr_Tbl;
03752    MD_NUM_ENTRIES(Attr_Tbl)     = attr_tbl_idx;
03753    MD_TBL_TYPE(Bounds_Tbl)      = Bounds_Tbl;
03754    MD_NUM_ENTRIES(Bounds_Tbl)   = bounds_tbl_idx;
03755    MD_TBL_TYPE(Const_Tbl)       = Const_Tbl;
03756    MD_NUM_ENTRIES(Const_Tbl)    = const_tbl_idx;
03757    MD_TBL_TYPE(Const_Pool)      = Const_Pool;
03758    MD_NUM_ENTRIES(Const_Pool)   = const_pool_idx;
03759    MD_TBL_TYPE(Ir_Tbl)          = Ir_Tbl;
03760    MD_NUM_ENTRIES(Ir_Tbl)       = ir_tbl_idx;
03761    MD_TBL_TYPE(Ir_List_Tbl)     = Ir_List_Tbl;
03762    MD_NUM_ENTRIES(Ir_List_Tbl)  = ir_list_tbl_idx;
03763    MD_TBL_TYPE(Loc_Name_Tbl)    = Loc_Name_Tbl;
03764    MD_NUM_ENTRIES(Loc_Name_Tbl) = loc_name_tbl_idx;
03765    MD_TBL_TYPE(Name_Pool)       = Name_Pool;
03766    MD_NUM_ENTRIES(Name_Pool)    = name_pool_idx;
03767    MD_TBL_TYPE(Sec_Name_Tbl)    = Sec_Name_Tbl;
03768    MD_NUM_ENTRIES(Sec_Name_Tbl) = sec_name_tbl_idx;
03769    MD_TBL_TYPE(Stor_Blk_Tbl)    = Stor_Blk_Tbl;
03770    MD_NUM_ENTRIES(Stor_Blk_Tbl) = stor_blk_tbl_idx;
03771    MD_TBL_TYPE(Type_Tbl)        = Type_Tbl;
03772    MD_NUM_ENTRIES(Type_Tbl)     = type_tbl_idx;
03773    MD_TBL_TYPE(Sh_Tbl)          = Sh_Tbl;
03774    MD_NUM_ENTRIES(Sh_Tbl)       = sh_tbl_idx;
03775 
03776    MD_PDT_HDR_LEN               = (attr_tbl_idx * NUM_AT_WDS) +
03777                                   (bounds_tbl_idx * NUM_BD_WDS) +
03778                                   (const_tbl_idx * NUM_CN_WDS) +
03779                                   (const_pool_idx * NUM_CP_WDS) +
03780                                   (ir_list_tbl_idx * NUM_IL_WDS) +
03781                                   (ir_tbl_idx * NUM_IR_WDS) +
03782                                   (loc_name_tbl_idx * NUM_LN_WDS) +
03783                                   (name_pool_idx * NUM_NP_WDS) +
03784                                   (sec_name_tbl_idx * NUM_SN_WDS) +
03785                                   (stor_blk_tbl_idx * NUM_SB_WDS) +
03786                                   (type_tbl_idx * NUM_TYP_WDS) +
03787                                   (sh_tbl_idx * NUM_SH_WDS) +
03788                                   (MD_TBL_BYTE_SIZE/TARGET_BYTES_PER_WORD) +
03789                                   ((sizeof(mit_descriptor_type) / 
03790                                       TARGET_BYTES_PER_WORD) * Num_Of_Tbls);
03791 
03792 /* KAY */
03793 
03794    /* PDT size must be in 64 bit increment sizes. */
03795 
03796 # if defined(_HOST32) && defined(_TARGET64)
03797    MD_PDT_HDR_LEN = (MD_PDT_HDR_LEN + 1) / 2;
03798 # endif
03799 
03800    fwrite(&mit_header, sizeof(mit_header_type), 1, mod_file_ptr);
03801 
03802    fwrite(&mit_descriptor[1], 
03803           sizeof(mit_descriptor_type),
03804           Num_Of_Tbls,
03805           mod_file_ptr);
03806 
03807    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, name_pool);
03808    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, loc_name_tbl);
03809    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, attr_tbl);
03810    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, bounds_tbl);
03811    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, const_tbl);
03812    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, const_pool);
03813    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, sec_name_tbl);
03814    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, stor_blk_tbl);
03815    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, type_tbl);
03816    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, ir_tbl);
03817    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, ir_list_tbl);
03818    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, sh_tbl);
03819 
03820    fflush(mod_file_ptr);
03821    fclose(mod_file_ptr);
03822 
03823    const_tbl_idx++;  /* Adjust so it is set to next available index */
03824 
03825 EXIT:
03826 
03827    TBL_FREE(mod_link_tbl);
03828 
03829    TRACE (Func_Exit, "output_mod_info_file", NULL);
03830 
03831    return;
03832 
03833 }  /* output_mod_info_file */
03834 
03835 /******************************************************************************\
03836 |*                                                                            *|
03837 |* Description:                                                               *|
03838 |*                                                                            *|
03839 |* Input parameters:                                                          *|
03840 |*      NONE                                                                  *|
03841 |*                                                                            *|
03842 |* Output parameters:                                                         *|
03843 |*      NONE                                                                  *|
03844 |*                                                                            *|
03845 |* Returns:                                                                   *|
03846 |*      NOTHING                                                               *|
03847 |*                                                                            *|
03848 \******************************************************************************/
03849 void    use_stmt_semantics(void)
03850                                 
03851 {
03852    int           al_idx;
03853    int           attr_idx;
03854    int           attr_list_free_list;
03855    int           bd_idx;
03856    int           host_attr_idx;
03857    int           host_name_idx;
03858    int           interface_list;
03859    int           ln_idx;  
03860    int           match;
03861    int           module_attr_idx;
03862    int           module_list_idx;
03863    int           name_idx;
03864    int           new_name_idx;
03865    int           new_sn_idx;
03866    int           save_attr_list_tbl_idx;
03867    int           srch_attr_idx;
03868    int           start_ln_idx;
03869    boolean       use_only;
03870    int           use_ir_idx;
03871    int           ro_idx;
03872    boolean       error_break=0;
03873 
03874    TRACE (Func_Entry, "use_stmt_semantics", NULL);
03875 
03876    /* global flag used to tell set_mod_link_tbl_for_attr */
03877    /* that it should check all attrs for duplicates.     */
03878    /* This refers to search_for_duplicate_attrs          */
03879 
03880    list_of_modules_in_module    = NULL_IDX;
03881    module_list_idx              = SCP_USED_MODULE_LIST(curr_scp_idx);
03882    attr_list_free_list          = AL_NEXT_IDX(NULL_IDX);
03883    interface_list               = NULL_IDX;
03884 
03885    keep_module_procs = (opt_flags.inline_lvl > Inline_Lvl_0) ||
03886                         ATP_MAY_INLINE(SCP_ATTR_IDX(MAIN_SCP_IDX));
03887 
03888    /* Find the last module on the list.  This is really the first module   */
03889    /* specified on a USE list.  This way we get the ordering correct, plus */
03890    /* since we are backing up the list and the list is extended at the     */
03891    /* bottom, we don't end up trying to process the newly added indirectly */
03892    /* referenced modules.  The list is extended in resolve_used_modules.   */
03893    /* All modules that are indirectly brought in during USE association    */
03894    /* are added to this list.  This helps get messages issued correctly    */
03895    /* and keeps CIF happy.  See resolve_used_modules for more details.     */
03896    /* All the modules specified on the USE statement are specifed on this  */
03897    /* list first, because these are the attr indexes we want to use.       */
03898 
03899    while (AL_NEXT_IDX(module_list_idx) != NULL_IDX) {
03900       module_list_idx   = AL_NEXT_IDX(module_list_idx);
03901    }
03902 
03903    while (module_list_idx != NULL_IDX) {
03904       error_break=0;  
03905       module_attr_idx                   = AL_ATTR_IDX(module_list_idx);
03906       only_update_new_tbl_entries       = TRUE;
03907 
03908       /* For next iteration */
03909 
03910       module_list_idx   = AL_PREV_MODULE_IDX(module_list_idx); 
03911 
03912       if (ATP_IMPLICIT_USE_MODULE(module_attr_idx)) {
03913 
03914          /* Need to generate the Use_Opr - Have a curr_stmt_sh - use it */
03915 
03916         /* Generate IR for this USE statement.  Need to keep the attr so that */
03917         /* it can be passed thru the PDGCS interface during IR conversion.    */
03918         /* Do not need pass2 semantics for this statement.                    */
03919 
03920         NTR_IR_TBL(use_ir_idx);
03921         IR_OPR(use_ir_idx)              = Use_Opr;
03922         IR_TYPE_IDX(use_ir_idx)         = TYPELESS_DEFAULT_TYPE;
03923         IR_LINE_NUM(use_ir_idx)         = stmt_start_line;
03924         IR_COL_NUM(use_ir_idx)          = stmt_start_col;
03925         IR_IDX_L(use_ir_idx)            = module_attr_idx;
03926         IR_FLD_L(use_ir_idx)            = AT_Tbl_Idx;
03927         IR_LINE_NUM_L(use_ir_idx)       = stmt_start_line;
03928         IR_COL_NUM_L(use_ir_idx)        = stmt_start_col;
03929 
03930         gen_sh(Before,
03931                Use_Stmt,
03932                stmt_start_line,
03933                stmt_start_col,
03934                FALSE,
03935                FALSE,
03936                TRUE); /* Compiler gen'd */
03937 
03938         SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx))    = TRUE;
03939         SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx))        = use_ir_idx;
03940       }
03941 
03942       if (on_off_flags.issue_ansi_messages ||
03943           GET_MESSAGE_TBL(message_warning_tbl, 953) ||
03944           GET_MESSAGE_TBL(message_error_tbl, 953)) {
03945 
03946          /* Non standard to let a module have the same name as a local */
03947          /* entity in a parent scope.  Don't issue if the entity in    */
03948          /* parent scope is a module.  This means we are using the     */
03949          /* module in several scopes and is legal and standard.        */
03950 
03951          srch_attr_idx = srch_host_sym_tbl(AT_OBJ_NAME_PTR(module_attr_idx),
03952                                            AT_NAME_LEN(module_attr_idx),
03953                                            &name_idx,
03954                                            FALSE);
03955 
03956          if (srch_attr_idx !=