/* out.c * last revised at 15, Nov. 1994 * * Copyright (C) 1994, All rights reserved. * written by Gyudong Kim(chilly@iclab.snu.ac.kr) * */ #include "findhier.h" extern struct branch *trees; extern struct names *vacancy; extern char *myname; extern int WARN; extern int NORMAL; extern int specified; extern int topspecified; extern char *target; extern char *topcell; extern char *targ; extern char *top; extern int mode; extern int onlytop; extern int depth; extern int numberformat; extern int interactive; extern FILE *OUTPUT; static int branch_depth(bran) struct branch *bran; { int max = 0; int j; struct branch *tmpb; if (bran->offspring == NULL) return(0); push(bran->name); for(tmpb=bran->offspring;tmpb!=NULL;tmpb=tmpb->next) { if (check(tmpb->name)) continue; j = branch_depth(tmpb); if (j>max) max = j; } pop(); return(max+1); } /* * recursive output routine */ int out_branch(bran,level) struct branch *bran; int level; { int i; struct branch *tmpb; if (level > depth) return 0; for(i=0;iname); switch (numberformat) { case 'n': (void)fprintf(OUTPUT,"\n"); break; case 'f': (void)fprintf(OUTPUT," : %d\n",level); break; case 'r': (void)fprintf(OUTPUT," : %d\n",branch_depth(bran)); break; default: /* cannot be here! */ break; } if (bran->offspring == NULL) return 0; push(bran->name); i=0; for(tmpb=bran->offspring;tmpb!=NULL;tmpb=tmpb->next) { if (check(tmpb->name)) continue; i |= out_branch(tmpb,level+1); } pop(); return(i); } int dangling() { struct names *tmpn; FILE *targf; if (vacancy==NULL) { if (OUTPUT==stdout) targf = (interactive) ? OUTPUT : stderr ; else targf = (interactive) ? stderr : OUTPUT ; (void)fprintf(targf, "No dangling cell found.\n"); return 1; } for(tmpn=vacancy;tmpn!=NULL;tmpn=tmpn->next) { (void)fprintf(OUTPUT,"%s\n",tmpn->name); } return 0; } static int max_depth() { int max,i; struct branch *tmp; if (trees==NULL) return(-1); max = 0; for(tmp=trees;tmp!=NULL;tmp=tmp->next) { i = branch_depth(tmp); if (i>max) max=i; } WARN = 0; return(max); } void listing() { struct branch *tmp; int max; int j; max = max_depth(); j = 0; for(tmp=trees;tmp!=NULL;tmp=tmp->next) j++; if (j) (void)fprintf(OUTPUT,"possibly top cell listing\n"); for(tmp=trees;tmp!=NULL;tmp=tmp->next) { if (branch_depth(tmp)!=max) continue; (void)out_branch(tmp,0); j--; } if (j>0) (void)fprintf(OUTPUT,"possibly unused cell listing\n"); for(tmp=trees;tmp!=NULL;tmp=tmp->next) { if (branch_depth(tmp)!=max) (void)out_branch(tmp,0); } if (vacancy!=NULL) (void)fprintf(OUTPUT,"missing cell listing\n"); (void)dangling(); } void top_list() { struct branch *tmp; int max; max = max_depth(); for(tmp=trees;tmp!=NULL;tmp=tmp->next) { if (onlytop==1) if (branch_depth(tmp)!=max) continue; (void)fprintf(OUTPUT,"%s\n",tmp->name); } } void out_graph() { if (specified) targ = global(target,"Main"); if (topspecified || mode == 'i' || mode == 'x') top = global(topcell,"Main"); if (!specified && !onlytop && !mode) listing(); else if (!NORMAL) (void)reverse(); else if (!onlytop && mode) switch (mode) { case (int)'x': case (int)'i': (void)included(); break; case (int)'d': (void)dangling(); break; default: break; } else if (onlytop==1 || onlytop==2) top_list(); else (void)out_branch(find_top(targ),0); } /* out.c */