/*********************************************************************/ /* modified on 12.23 1995 for HPF */ /* PACT */ /*********************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #if defined(STDC_HEADERS) && (STDC_HEADERS==1) #include #include #else #include #endif #include "tags.h" # include "typedef.h" # include "bif.h" # include "ll.h" # include "symb.h" # include "dep.h" #include "dep_struct.h" static FILE *fd; /* * External variables/functions referenced */ extern int debug_m; #define FOLLOW_BIF_POINTER_TO_ID(VAR) \ (bf_ptr->entry.Template.VAR? bf_ptr-> entry.Template.VAR->id: -1) #define FOLLOW_LL_POINTER_TO_ID(VAR) \ (ll_ptr-> entry.Template.VAR? ll_ptr-> entry.Template.VAR->id: -1) #define FOLLOW_SYMB_POINTER_1_TO_ID(VAR) \ (sy_ptr->VAR? sy_ptr->VAR->id: -1) #define FOLLOW_SYMB_POINTER_2_TO_ID(VAR) \ (sy_ptr->entry.VAR? sy_ptr->entry.VAR->id: -1) #define FOLLOW_TYPE_POINTER_TO_ID(VAR) \ (ty_ptr->entry.VAR? ty_ptr->entry.VAR->id: -1) #define FOLLOW_DEP_TO_ID(VAR) \ (dep->VAR? dep->VAR->id: -1) char *tag[1000]; /*------------------------------------------------------* * is_blank * * checks if string is all blanks * * (BW) * *------------------------------------------------------*/ static int is_blank (buf) char *buf; { int i; char ch; for (i=0; i<(int)strlen(buf); i++){ if (buf[i] != ' ') return 0; } return 1; } /*------------------------------------------------------* * replace_1 * * replaces all occurrences of -1 in the string * * by -- (BW) * *------------------------------------------------------*/ static void replace_1 (buf) char *buf; { char ch; int flag,flag1; ch = *buf; flag = 0; while (ch != '\0') { if (ch == '/') flag1 = 1; if (ch == '-') flag ++; if (ch == '1' && flag == 1){ flag = 2; } if (ch == ' ') flag1 = 0; if (ch == '1' && flag == 2 && flag1 == 1){ flag = 0; } if (ch == ' ' && flag > 0) flag = 0; if (ch == '>' && flag == 1) flag = 0; /* for 100-B */ if (flag >= 2) *buf = '-'; else *buf = ch; buf++; ch = *buf; } } /*------------------------------------------------------* * replace_2 * * Dele all num_blobs; n2 = f->num_bfnds; n3 = f->num_llnds; n4 = f->num_symbs; n5 = f->num_types; n6 = f->num_label; n7 = f->global_bfnd->id; n8 = f->num_dep; n9 = f->num_cmnt; n10= f->num_files; if (debug_m) fprintf(fd,"
");

        fprintf(fd,"\n #blob  #bfnd  #llnd  #symb      #type  #labl  GblBf #deps  #cmnt  #file\n");
        fprintf(fd,"-------------------------------------------------------------------------\n");
        fprintf(fd,"%5d  %5d  %5d  %5d      %5d %5d  %5d  %5d  %5d  %5d",
               n1, n2, n3, n4, n5, n6, n7, n8, n9, n10);

        if (debug_m)
            fprintf(fd,"

"); fprintf(fd,"\n\n"); } /*------------------------------------------------------* * write_blob_list * * * * dump the blob list with the given head * *------------------------------------------------------*/ static void write_blob_list(head,ch) PTR_BLOB head; char ch; { register PTR_BLOB bl_ptr; int i; char str[512]; fprintf(fd," %8s%c:", " ",ch); if (debug_m) { str[0] = '\0'; i=0; for (bl_ptr = head; bl_ptr; bl_ptr = bl_ptr->next) {/* fprintf(fd,"
%5d-B ", bl_ptr->ref->id,bl_ptr->ref->id); */ i++; sprintf(str,"%s%5d-B ",str,bl_ptr->ref->id,bl_ptr->ref->id); if (i==12) { i=0; replace_4(str); fprintf(fd,"%s\n %10s",str, " "); str[0] = '\0'; } } if (i<12) { replace_4(str); fprintf(fd,"%s",str); } } else { i=0; for (bl_ptr = head; bl_ptr; bl_ptr = bl_ptr->next) { fprintf(fd,"%5d-B ", bl_ptr->ref->id); i++; if (i==12) { i=0; fprintf(fd,"\n %10s", " "); } } } fprintf(fd," --\n"); } /*------------------------------------------------------* * write_bif_node * * * * routines to print one bif node * *------------------------------------------------------*/ static void write_bif_node(bf_ptr) PTR_BFND bf_ptr; { int n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17; char *nstr; n1 = bf_ptr->id; n2 = bf_ptr->variant; n3 = bf_ptr->control_parent ? bf_ptr->control_parent->id : -1; n4 = FOLLOW_BIF_POINTER_TO_ID(bf_ptr1); n5 = FOLLOW_BIF_POINTER_TO_ID(cmnt_ptr); n6 = FOLLOW_BIF_POINTER_TO_ID(symbol); n7 = FOLLOW_BIF_POINTER_TO_ID(ll_ptr1); n8 = FOLLOW_BIF_POINTER_TO_ID(ll_ptr2); n9 = FOLLOW_BIF_POINTER_TO_ID(ll_ptr3); n10 = FOLLOW_BIF_POINTER_TO_ID(dep_ptr1); n11 = FOLLOW_BIF_POINTER_TO_ID(dep_ptr2); n12 = bf_ptr->label? bf_ptr->label->id: -1; n13 = FOLLOW_BIF_POINTER_TO_ID(lbl_ptr); n14 = bf_ptr->g_line; n15 = bf_ptr->l_line; /* n16 = bf_ptr->filename->id; modified by zheng.gb */ n16 = (u_short) (bf_ptr->filename? bf_ptr->filename->id: 0); nstr = bf_ptr->filename?bf_ptr->filename->name:""; n17 = (bf_ptr->thread)? bf_ptr->thread->id: -1; if (debug_m) my_fprintf_0_m(fd,"%3d-B %3d %3d-B %3d %3d-C %3d-S %4d-E %4d-E %4d-E %4d %4d %4d-L %3d %3d %4d %5d-F %5d-B %12s\n", n1, n1, n2, n3, n3, n4, n5, n5, n6, n6, n7, n7, n8, n8, n9, n9, n10, n11, n12, n12, n13, n14, n15, nstr, n14, n16, n17, tag[bf_ptr->variant]); else my_fprintf_0(fd,"%3d-B %3d %3d-B %3d %3d-C %3d-S %4d-E %4d-E %4d-E %4d %4d %4d-L %3d %3d %4d %5d-F %5d-B %12s\n", n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, tag[bf_ptr->variant]); write_blob_list(bf_ptr->entry.Template.bl_ptr1,'L'); write_blob_list(bf_ptr->entry.Template.bl_ptr2,'R'); print_decl_specs(bf_ptr->decl_specs); } /*------------------------------------------------------* * write_bif_nodes * * * * routines to print bif nodes * *------------------------------------------------------*/ static void write_bif_nodes(f) PTR_FILE f; { register PTR_BFND bf_ptr; if (debug_m) fprintf(fd, "

***BIF NODES***

\n
\n");
	else
             fprintf(fd, "***BIF NODES***\n\n");

        fprintf(fd,"  id  var  cp   bp1  cmnt  sym    lp1    lp2    lp3    dp1  dp2   lab  lbl glin llin  file  thread\n");

	for (bf_ptr = f->head_bfnd; bf_ptr; bf_ptr = bf_ptr->thread)
		write_bif_node(bf_ptr);

        if (debug_m)
             fprintf(fd,"

\n"); } /*------------------------------------------------------* * write_ll_node * * * * print out one low level node * *------------------------------------------------------*/ static void write_ll_node(ll_ptr) PTR_LLND ll_ptr; { int n1, n2, n3; n1 = ll_ptr->id; n2 = ll_ptr->variant; n3 = ll_ptr->type ? ll_ptr->type->id : -1; if (debug_m) my_fprintf_1_m1(fd,"%5d-E %5d %5d-T ", n1, n1, n2, n3, n3); else my_fprintf_1(fd,"%5d-E %5d %5d-T ", n1, n2, n3); switch (ll_ptr->variant) { /*** This add for HPF 1 ***/ /*** This add for HPF 2 ***/ case (INT_VAL): fprintf(fd,"%23d", ll_ptr->entry.ival); break; case (DOUBLE_VAL): case (FLOAT_VAL): fprintf(fd,"%23s", ll_ptr->entry.string_val); break; case (BOOL_VAL): fprintf(fd,"%23s", ll_ptr->entry.bval ? ".T" : ".F"); break; case (CHAR_VAL): fprintf(fd,"%22c%c", '.', ll_ptr->entry.cval); break; /* modified by zheng.gb */ case BINARY_VAL: case OCTN_VAL: case HEX_VAL: case (STMT_STR): case (KEYWORD_VAL): case (STRING_VAL): fprintf(fd," \"%s\" ", ll_ptr->entry.string_val); break; /** case (RANGE_OP): Modify for HPF **/ case (UPPER_OP): case (LOWER_OP): n1 = ll_ptr->entry.array_op.symbol ? ll_ptr->entry.array_op.symbol->id : -1; n2 = ll_ptr->entry.array_op.dim; if (debug_m) my_fprintf_4_m(fd,"%11d-S", n1, n1); else my_fprintf_4(fd,"%11d-S", n1); fprintf(fd," %5d", n2); break; case (LABEL_REF): /* add by zheng.gb */ case (ERR_LABEL): case (END_LABEL): /* n1 = FOLLOW_LL_POINTER_TO_ID(symbol); */ /** n1 = ll_ptr->entry.label_list.lab_ptr->id; **/ /* Modify for HPF */ n1 = ll_ptr->entry.label_ref.lab_ptr->id; fprintf(fd," %5d-L %1s", n1, " "); break; /*** This add for HPF 1 ***/ case LABEL_LIST: /* modified by zheng.gb */ n1 = ll_ptr->entry.label_list_s.lab_ptr ? ll_ptr->entry.label_list_s.lab_ptr->id : 0; n2 = FOLLOW_LL_POINTER_TO_ID(ll_ptr1); n3 = FOLLOW_LL_POINTER_TO_ID(ll_ptr2); if (debug_m) my_fprintf_1_m2(fd,"%5d-S %5d-E %5d-E", n1, n1, n2, n2, n3, n3); else my_fprintf_1(fd,"%5d-S %5d-E %5d-E", n1, n2, n3); break; /*** This add for HPF 2 ***/ case (ARITH_ASSGN_OP): /* New added for VPC++ */ n1 = (int) ll_ptr->entry.Template.symbol; n2 = FOLLOW_LL_POINTER_TO_ID(ll_ptr1); n3 = FOLLOW_LL_POINTER_TO_ID(ll_ptr2); if (debug_m) my_fprintf_1_m2(fd,"%5d-S %5d-E %5d-E", n1, n1, n2, n2, n3, n3); else my_fprintf_1(fd,"%5d-S %5d-E %5d-E", n1, n2, n3); break; default: n1 = FOLLOW_LL_POINTER_TO_ID(symbol); n2 = FOLLOW_LL_POINTER_TO_ID(ll_ptr1); n3 = FOLLOW_LL_POINTER_TO_ID(ll_ptr2); if (debug_m) my_fprintf_1_m2(fd,"%5d-S %5d-E %5d-E", n1, n1, n2, n2, n3, n3); else my_fprintf_1(fd,"%5d-S %5d-E %5d-E", n1, n2, n3); } fprintf(fd,"%30s\n", tag[ll_ptr->variant]); } /*------------------------------------------------------* * write_ll_nodes * * * * dump low level nodes * *------------------------------------------------------*/ static void write_ll_nodes(f) PTR_FILE f; { register PTR_LLND ll_ptr; if(debug_m) fprintf(fd,"

***L0W-LEVEL NODES***

\n
\n");
        else
        	fprintf(fd,"***L0W-LEVEL NODES***\n\n");

       	fprintf(fd,"    id    var    type    symb    ll1     ll2                     tag...\n");
	for (ll_ptr = f->head_llnd; ll_ptr; ll_ptr = ll_ptr->thread)
		write_ll_node(ll_ptr);

        if (debug_m)
             fprintf(fd,"

\n"); } /*------------------------------------------------------* * write_symb_node * * * * print out one symbol node * *------------------------------------------------------*/ static void write_symb_node(sy_ptr) PTR_SYMB sy_ptr; { int n1, n2, n3, n4, n5, n6, n7, n8,n9, n10; char *s1; char no_name [3]; no_name[0] = no_name[1] = '-'; no_name[2] = '\0'; n1 = sy_ptr->id; n2 = sy_ptr->variant; n3 = FOLLOW_SYMB_POINTER_1_TO_ID(type); n4 = sy_ptr->attr; n5 = FOLLOW_SYMB_POINTER_1_TO_ID(next_symb); n6 = sy_ptr->scope? sy_ptr->scope->id: -1; s1 = sy_ptr->ident; if(strlen(s1)==0 || is_blank(s1)==1) s1 = no_name; if (debug_m) my_fprintf_2_m(fd,"%4d-S %4d %4d-T %4d %4d-S %4d-B %14s ", n1, n1, n2, n3, n3, n4, n5, n5, n6, n6, s1); else my_fprintf_2(fd,"%4d-S %4d %4d-T %4d %4d-S %4d-B %14s ", n1, n2, n3, n4, n5, n6, s1); switch (sy_ptr->variant) { case DEFAULT: case TYPE_NAME: fprintf(fd,"%35s", " "); break; case CONST_NAME: n1 = FOLLOW_SYMB_POINTER_2_TO_ID(Template.const_value); fprintf(fd,"value=%17d", n1); break; case ENUM_NAME: case FIELD_NAME: n1 = sy_ptr->entry.field.tag; n2 = FOLLOW_SYMB_POINTER_2_TO_ID(field.next); n3 = FOLLOW_SYMB_POINTER_2_TO_ID(field.base_name); /** Modify for HPF 1 n4 = FOLLOW_SYMB_POINTER_2_TO_ID(field.declared_name); NEW ADDED FOR VPC */ /** Modify for HPF 2 n5 = FOLLOW_SYMB_POINTER_2_TO_ID(field.restricted_bit); NEW for VPC++ */ if (debug_m) my_fprintf_1_m3(fd,"tag=%5d nxt=%5d-S base=%5d-S ", n1, n2, n2, n3, n3); else my_fprintf_1(fd,"tag=%5d nxt=%5d-S base=%5d-S ", n1, n2, n3); /** Modify for HPF 3 my_fprintf_5(fd, " dec_name=%10d-S restr=%5d-E ", n4,n5); **/ break; case VARIABLE_NAME: n1 = sy_ptr->entry.var_decl.local; n2 = FOLLOW_SYMB_POINTER_2_TO_ID(var_decl.next_in); n3 = FOLLOW_SYMB_POINTER_2_TO_ID(var_decl.next_out); /* added by zheng.gb 1996/11/27 */ n4 = FOLLOW_SYMB_POINTER_2_TO_ID(var_decl.hpfattr); if (debug_m) my_fprintf_1_m4(fd,"local=%4d nxt_in=%4d-S nxt_out=%4d-S hpfattr=%4d-E", n1, n2, n2, n3, n3, n4 ,n4); else my_fprintf_3(fd,"local=%4d nxt_in=%4d-S nxt_out=%4d-S hpfattr=%d-E", n1, n2, n3, n4); break; case PROGRAM_NAME: n1 = FOLLOW_SYMB_POINTER_2_TO_ID(prog_decl.symb_list); n2 = FOLLOW_SYMB_POINTER_2_TO_ID(prog_decl.prog_hedr); if (debug_m) my_fprintf_5_m1(fd,"symb_lst=%11d-S prog_hedr=%5d-B", n1, n1, n2, n2); else my_fprintf_5(fd,"symb_lst=%11d-S prog_hedr=%5d-B", n1, n2); break; case PROCESS_NAME: case PROCEDURE_NAME: case FUNCTION_NAME: n1 = sy_ptr->entry.proc_decl.num_input; n2 = sy_ptr->entry.proc_decl.num_output; n3 = sy_ptr->entry.proc_decl.num_io; n4 = FOLLOW_SYMB_POINTER_2_TO_ID(proc_decl.in_list); n5 = FOLLOW_SYMB_POINTER_2_TO_ID(proc_decl.out_list); n6 = FOLLOW_SYMB_POINTER_2_TO_ID(proc_decl.symb_list); n7 = FOLLOW_SYMB_POINTER_2_TO_ID(proc_decl.proc_hedr); fprintf(fd,"n_in=%5d n_out=%5d n_io=%5d\n", n1, n2, n3); if (debug_m) my_fprintf_3_m2 (fd, " in_l=%5d-S out_l=%5d-S sy_l=%5d-S p_hdr=%5d-B", n4, n4, n5, n5, n6, n6, n7, n7); else my_fprintf_3 (fd, " in_l=%5d-S out_l=%5d-S sy_l=%5d-S p_hdr=%5d-B", n4, n5, n6, n7); break; case MEMBER_FUNC: /* NEW ADDED FOR VPC */ n1 = sy_ptr->entry.member_func.num_input; n2 = sy_ptr->entry.member_func.num_output; n3 = sy_ptr->entry.member_func.num_io; n4 = FOLLOW_SYMB_POINTER_2_TO_ID(member_func.in_list); n5 = FOLLOW_SYMB_POINTER_2_TO_ID(member_func.out_list); n6 = FOLLOW_SYMB_POINTER_2_TO_ID(member_func.symb_list); n7 = FOLLOW_SYMB_POINTER_2_TO_ID(member_func.func_hedr); n8 = FOLLOW_SYMB_POINTER_2_TO_ID(member_func.next); n9 = FOLLOW_SYMB_POINTER_2_TO_ID(member_func.base_name); n10 = FOLLOW_SYMB_POINTER_2_TO_ID(member_func.declared_name); fprintf(fd,"n_in=%5d n_out=%5d n_io=%5d\n", n1, n2, n3); if (debug_m) my_fprintf_3_m2(fd, " in_l=%10d-S out_l=%5d-S sy_l=%5d-S f_hdr=%5d-B \n", n4,n4,n5,n5,n6,n6,n7,n7); else my_fprintf_3(fd, " in_l=%10d-S out_l=%5d-S sy_l=%5d-S f_hdr=%5d-B \n", n4,n5,n6,n7); if (debug_m) my_fprintf_1_m2(fd, " m_nxt=%5d-S b_name=%5d-S dec_name=%5d-S ", n8, n8, n9, n9, n10, n10); else my_fprintf_1(fd, " m_nxt=%5d-S b_name=%5d-S dec_name=%5d-S ", n8, n9, n10); break; /* case VARIANT_FIELD : n1 = sy_ptr->entry.field.tag; n2 = FOLLOW_SYMB_POINTER_2_TO_ID(variant_field.next); n3 = FOLLOW_SYMB_POINTER_2_TO_ID(variant_field.base_name); n4 = sy_ptr->entry.variant_field.variant_list->id; my_fprintf_3(fd,"f.tag=%5d f.nxt=%5d-S b_name=%5d-S vl_id=%5d-E", n1, n2, n3, n4); break; */ default: fprintf(fd,"%37s", " "); break; } fprintf(fd,"%18s\n", tag[sy_ptr->variant]); } /*------------------------------------------------------* * write_symb_nodes * * * * dump symbol table * *------------------------------------------------------*/ static void write_symb_nodes(f) PTR_FILE f; { register PTR_SYMB sy_ptr; if(debug_m) fprintf(fd,"

***SYMBOL NODES***

\n
\n");
        else
              fprintf(fd,"***SYMBOL NODES***\n\n");

	fprintf(fd,"   id   var   type  attr  next   scope  variable-name\n");
	for (sy_ptr = f->head_symb; sy_ptr; sy_ptr = sy_ptr->thread)
		write_symb_node(sy_ptr);

        if (debug_m)
             fprintf(fd,"

\n"); } /*------------------------------------------------------* * write_type_node * * * * print out one type node * *------------------------------------------------------*/ static void write_type_node(ty_ptr) PTR_TYPE ty_ptr; { int n1, n2, n3; int n4, n5, n6; /* NEW ADDED FOR VPC */ char buf[33]; n1 = ty_ptr->id; n2 = ty_ptr->variant; n3 = ty_ptr->name ? ty_ptr->name->id : -1; n4 = (int) FOLLOW_TYPE_POINTER_TO_ID(Template.ranges); if (debug_m) my_fprintf_3_m1(fd,"%4d-T %4d %4d-S %4d ", n1, n1, n2, n3, n3, n4); else my_fprintf_3(fd,"%4d-T %4d %4d-S %4d ", n1, n2, n3, n4); switch (ty_ptr->variant) { case DEFAULT: case T_INT: case T_FLOAT: case T_DOUBLE: case T_VOID : /* NEW ADDED FOR VPC */ case T_CHAR: case T_BOOL: case T_STRING: case T_COMPLEX: case T_DCOMPLEX: case T_ENUM_FIELD: fprintf(fd,"%46s", " "); break; /** Modify for HPF 1 **/ /** case T_SUBRANGE: n1 = FOLLOW_TYPE_POINTER_TO_ID(subrange.base_type); n2 = FOLLOW_TYPE_POINTER_TO_ID(subrange.lower); n3 = FOLLOW_TYPE_POINTER_TO_ID(subrange.upper); my_fprintf_1(fd,"base_t=%5d-T lo=%5d-E up=%5d-E", n1, n2, n3); break; **/ /** Modify for HPF 2 **/ case T_ARRAY: n1 = ty_ptr->entry.ar_decl.num_dimensions; n2 = FOLLOW_TYPE_POINTER_TO_ID(ar_decl.base_type); n3 = FOLLOW_TYPE_POINTER_TO_ID(ar_decl.ranges); if (debug_m) my_fprintf_1_m3(fd,"dim=%5d base_t=%5d-T rngs=%5d-E ", n1, n2, n2, n3, n3); else my_fprintf_1(fd,"dim=%5d base_t=%5d-T rngs=%5d-E ", n1, n2, n3); break; /* modified by zheng.gb */ case T_KIND: n1 = FOLLOW_TYPE_POINTER_TO_ID(kind_decl.base_type); n2 = FOLLOW_TYPE_POINTER_TO_ID(kind_decl.kindexp); if (debug_m) my_fprintf_5_m1(fd,"base_t=%5d-T kindexp=%5d-E ", n1, n1, n2, n2); else my_fprintf_5(fd,"base_t=%5d-T kindexp=%5d-E ", n1, n2); break; /** Modify for HPF 1 **/ /** case T_LIST: n1 = FOLLOW_TYPE_POINTER_TO_ID(base_type); my_fprintf_4(fd,"base_t=%17d-T", n1); break; **/ /** Modify for HPF 2 **/ case T_RECORD: n1 = ty_ptr->entry.re_decl.num_fields; n2 = FOLLOW_TYPE_POINTER_TO_ID(re_decl.first); /* add by zheng.gb 1997/3/18 */ n3 = ty_ptr->entry.re_decl.mapped_flag; if (debug_m) my_fprintf_5_m2(fd,"n_flds=%11d first=%5d-S", n1, n2, n2); else /*my_fprintf_5(fd,"n_flds=%11d first=%5d-S", n1, n2);*/ my_fprintf_1(fd,"n_flds=%11d first=%5d-S mapped=%11d", n1, n2,n3); break; /** Modify for HPF 1 **/ /** NEW ADDED FOR VPC case T_DESCRIPT: n1 = ty_ptr->entry.descriptive.signed_flag ; n2 = ty_ptr->entry.descriptive.long_short_flag; n3 = ty_ptr->entry.descriptive.mod_flag ; n4 = ty_ptr->entry.descriptive.storage_flag ; n5 = ty_ptr->entry.descriptive.access_flag ; n6 = ty_ptr->entry.descriptive.base_type? ty_ptr->entry.descriptive.base_type->id:-1 ; fprintf(fd,"sgned=%5d mod_flg=%5d",n1,n3); print_ls_flg(n2); fprintf(fd," sto_flg=%10d",n4); print_accs_flg(n5); my_fprintf_4(fd," base_t=%5d-T",n6); break; **/ /** Modify for HPF 2 **/ case T_POINTER : /* NEW ADDED FOR VPC */ n1 = FOLLOW_TYPE_POINTER_TO_ID(Template.base_type); n2 = ty_ptr->entry.Template.dummy1 ; /* indirect level */ n3 = ty_ptr->entry.Template.dummy5; if (debug_m) my_fprintf_4_m(fd,"base_t=%5d-T ", n1,n1); else my_fprintf_4(fd,"base_t=%5d-T ", n1); fprintf(fd,"ind_lev=%3d ", n2); print_ls_flg(n3); fprintf(fd,"%68s"," "); break; case T_REFERENCE : /* added by BW */ n1 = FOLLOW_TYPE_POINTER_TO_ID(Template.base_type); n2 = ty_ptr->entry.Template.dummy1 ; /* indirect level */ n3 = ty_ptr->entry.Template.dummy5; if (debug_m) my_fprintf_4_m(fd,"base_t=%5d-T ", n1, n1); else my_fprintf_4(fd,"base_t=%5d-T ", n1); fprintf(fd,"ind_lev=%3d ", n2); print_ls_flg(n3); fprintf(fd,"%68s"," "); break; case T_FUNCTION: /* NEW ADDED FOR VPC */ n1 = FOLLOW_TYPE_POINTER_TO_ID(Template.base_type); if (debug_m) my_fprintf_4_m(fd,"base_t=%11d-T", n1, n1); else my_fprintf_4(fd,"base_t=%17d-T", n1); break; /** Modify for HPF 1 **/ /** NEW ADDED FOR VPC case T_DERIVED_TYPE : n1 = FOLLOW_TYPE_POINTER_TO_ID(derived_type.symbol); my_fprintf_4(fd,"der_typ=%7d-S ", n1); break; case T_MEMBER_POINTER: n1 = FOLLOW_TYPE_POINTER_TO_ID(col_decl.collection_name); n2 = FOLLOW_TYPE_POINTER_TO_ID(col_decl.base_type); my_fprintf_5(fd,"class name= %5d-S value type = %5d-T", n1, n2); break; case T_DERIVED_COLLECTION: n1 = FOLLOW_TYPE_POINTER_TO_ID(col_decl.collection_name); n2 = FOLLOW_TYPE_POINTER_TO_ID(col_decl.base_type); my_fprintf_5(fd,"base class= %5d-S arg type = %5d-T", n1, n2); break; case T_ENUM: case T_UNION: case T_STRUCT: case T_CLASS : case T_DERIVED_CLASS : n1 = ty_ptr->entry.derived_class.num_fields; n2 = FOLLOW_TYPE_POINTER_TO_ID(derived_class.first); n3 = FOLLOW_TYPE_POINTER_TO_ID(derived_class.original_class); my_fprintf_1(fd,"num_flds=%5d first=%5d-S parent=%5d-B ", n1, n2, n3); break; **/ /** Modify for HPF 2 **/ default: fprintf(fd, "%46s", " "); break; } fprintf(fd,"%21s\n", tag[ty_ptr->variant]); } /*------------------------------------------------------* * write_type_nodes * *------------------------------------------------------*/ static void write_type_nodes(f) PTR_FILE f; { PTR_TYPE ty_ptr; if(debug_m) fprintf(fd,"

***TYPE NODES***

\n
\n");
        else
               fprintf(fd,"***TYPE NODES***\n\n");

	fprintf(fd,"   id   var   name length\n");
	for (ty_ptr = f->head_type; ty_ptr; ty_ptr = ty_ptr->thread)
		write_type_node(ty_ptr);
        fprintf(fd, "\n  bits set:   0 syn/protected,  1 shared/public,  2 private,  3 future,  4 virtual,\n");
        fprintf(fd, "                5 inline,  6 unsigned,  7 signed,  8 short,  9 long,  10 volatile,\n");
        fprintf(fd, "                11 const,  12 typedef,  13 extern,  14 friend,  15 static,  16 register,\n");
        fprintf(fd, "                17 auto,  18 global,  19 Sync,  20 atomic,  21 __private, 22 restrict\n"); 

        if (debug_m)
             fprintf(fd,"

\n"); } /*------------------------------------------------------* * write_label_node * *------------------------------------------------------*/ static void write_label_node(lb_ptr) PTR_LABEL lb_ptr; { int n1, n2, n4, n5; long n3; n1 = lb_ptr->id; n2 = (int)lb_ptr->stateno; n3 = lb_ptr->labtype; n4 = lb_ptr->statbody ? lb_ptr->statbody->id : -1; n5 = lb_ptr->label_name ? lb_ptr->label_name->id : -1 ; if (debug_m) my_fprintf_6_m(fd,"%5d-L %5d %5d %5d-B %5d-S \n", n1, n1, n2, n3, n4, n4, n5, n5); else my_fprintf_6(fd,"%5d-L %5d %5d %5d-B %5d-S \n", n1, n2, n3, n4,n5); } /*------------------------------------------------------* * write_label_nodes * *------------------------------------------------------*/ static void write_label_nodes(f) PTR_FILE f; { PTR_LABEL lb_ptr; if(debug_m) fprintf(fd,"

***LABEL NODES***

\n
\n");
        else
               fprintf(fd,"***LABEL NODES***\n\n");

	for (lb_ptr = f->head_lab; lb_ptr; lb_ptr = lb_ptr->next)
		write_label_node(lb_ptr);

        if (debug_m)
             fprintf(fd,"

\n"); } /*------------------------------------------------------* * write_comment_node * * * * print out one comment node * *------------------------------------------------------*/ static void write_comment_node(cm_ptr) PTR_CMNT cm_ptr; { int n1, n2, n3; char *s; n1 = cm_ptr->id; n2 = cm_ptr->type; n3 = cm_ptr->next ? cm_ptr->next->id : -1; s = cm_ptr->string; if(debug_m) my_fprintf_1_m1(fd,"%5d-C %5d %5d-C \n", n1, n1, n2, n3, n3); else my_fprintf_1(fd,"%5d-C %5d %5d-C \n", n1, n2, n3); fprintf(fd," %s\n", s); } /*------------------------------------------------------* * write_comment_nodes * *------------------------------------------------------*/ static void write_comment_nodes(f) PTR_FILE f; { PTR_CMNT cm_ptr; if(debug_m) fprintf(fd,"

***COMMENT NODES***

\n
\n");
	else
               fprintf(fd,"***COMMENT NODES***\n\n");

	for (cm_ptr = f->head_cmnt; cm_ptr; cm_ptr = cm_ptr->thread)
		write_comment_node(cm_ptr);

        if (debug_m)
             fprintf(fd,"

\n"); } /*------------------------------------------------------* * write_filename_nodes * *------------------------------------------------------*/ static void write_filename_nodes(f) PTR_FILE f; { PTR_FNAME filep; if(debug_m) { fprintf(fd,"

***FILENAME NODES***

\n
\n");
                 for (filep = f->head_file; filep; filep = filep->next)
                         fprintf(fd,"%5d-F %s.html\n", filep->id, filep->name, filep->name);
                 fprintf(fd,"

\n"); } else { fprintf(fd,"***FILENAME NODES***\n\n"); for (filep = f->head_file; filep; filep = filep->next) fprintf(fd,"%5d-F %s\n", filep->id, filep->name); } } /*------------------------------------------------------* * write_dep_node * * * * print out one dependence node * *------------------------------------------------------*/ static void write_dep_node(dep) PTR_DEP dep; { register int j; int n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11; n1 = dep->id; n2 = dep->type; n3 = FOLLOW_DEP_TO_ID(symbol); n4 = FOLLOW_DEP_TO_ID(from.stmt); n5 = FOLLOW_DEP_TO_ID(from.refer); n6 = FOLLOW_DEP_TO_ID(to.stmt); n7 = FOLLOW_DEP_TO_ID(to.refer); n8 = FOLLOW_DEP_TO_ID(from_fwd); n9 = FOLLOW_DEP_TO_ID(from_back); n10 = FOLLOW_DEP_TO_ID(to_fwd); n11 = FOLLOW_DEP_TO_ID(to_back); fprintf(fd,"%4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d", n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11); for (j = 0; j < MAX_DEP; j++) fprintf(fd," %2d", (int) dep->direct[j]); fprintf(fd,"\n"); } static char *sdeptype[] = { "Flow dependence", "Anti dependence", "Output dependence", " " }; /*------------------------------------------------------* * write_one_dep * * * * print out one dependence relation * *------------------------------------------------------*/ static void write_one_dep(dep) PTR_DEP dep; { int i; fprintf(fd," %-18s,", sdeptype[dep->type]); fprintf(fd," symb = %-5s,", dep->symbol ? dep->symbol->ident : " "); fprintf(fd," from node %2d(%2d) to node %2d(%2d), dir vector = ", dep->from.stmt->id,dep->from.refer->id,dep->to.stmt->id,dep->to.refer->id); for (i = 0; i <= MAX_LP_DEPTH; i++) fprintf(fd," %d", dep->direct[i]); fprintf(fd,".\n"); } /*--------------------------------------------------------* * write_dep_comments * * * * write out the dependence relations in readable formats * *--------------------------------------------------------*/ static void write_dep_comments(f) PTR_FILE f; { register PTR_DEP dep; if (!f->num_dep) return; fprintf(fd,"\n\n"); if(debug_m) fprintf(fd,"

The following %d dependence relations are found:

\n",f->num_dep);
	else
		fprintf(fd," The following %d dependence relations are found:\n",f->num_dep);

	for (dep = f->head_dep; dep && dep->id != -1; dep = dep->thread)
		write_one_dep(dep);

        if (debug_m)
             fprintf(fd,"

\n"); } /*------------------------------------------------------* * write_dep_nodes * *------------------------------------------------------*/ static void write_dep_nodes(f) PTR_FILE f; { register PTR_DEP dep; if (!f->num_dep) return; if(debug_m) fprintf(fd,"

***DEPENDENCE NODES***

\n
\n");
	else
        	fprintf(fd,"***DEPENDENCE NODES***\n\n");

	fprintf(fd,"  id type symb f-bf f-ll t-bf t-ll ffwd fbak tfwd tbak d-vec\n");
	for (dep = f->head_dep; dep && dep->id != -1; dep = dep->thread)
		write_dep_node(dep);

        if (debug_m)
             fprintf(fd,"

\n"); } int dump_nodes(f, name) PTR_FILE f; char *name; { #include "tagname.def" /* associate string with variant tags */ if (*name) { /* filename specified? */ if ((fd = fopen (name, "w")) == NULL) return -1; } else fd = stdout; if (debug_m) { fprintf(fd,"\n"); fprintf(fd,"\n"); fprintf(fd,"HPF program %s's AST dump file\n",f->head_file->name); fprintf(fd,"\n"); fprintf(fd,"\n"); fprintf(fd,"

Source is \"%s\"

\n", f->head_file->name,f->head_file->name); fprintf(fd,"
\n"); } else fprintf(fd,"Source is \"%s\"\n", f->head_file->name); write_sizes(f); fprintf(fd,"\n"); write_bif_nodes(f); fprintf(fd,"\n"); write_ll_nodes(f); fprintf(fd,"\n"); write_symb_nodes(f); fprintf(fd,"\n"); write_type_nodes(f); fprintf(fd,"\n"); write_label_nodes(f); fprintf(fd,"\n"); write_comment_nodes(f); fprintf(fd,"\n"); write_filename_nodes(f);fprintf(fd,"\n"); write_dep_nodes(f); write_dep_comments(f); if (debug_m) { fprintf(fd,"\n"); fprintf(fd,"\n"); } if (fd != stderr) return fclose(fd); return 0; }