From b5fa0675b6a188c88f73a4b5bc12c09a382a943e Mon Sep 17 00:00:00 2001 From: keie Date: Fri, 5 Oct 1984 13:34:38 +0000 Subject: [PATCH] Added a priority associated with each phase. Paths with the highest total priority have preference. --- util/ack/rmach.c | 4 ++++ util/ack/scan.c | 23 +++++++++++++++-------- util/ack/trans.h | 1 + 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/util/ack/rmach.c b/util/ack/rmach.c index d5bdda8a4..4fcc05e96 100644 --- a/util/ack/rmach.c +++ b/util/ack/rmach.c @@ -52,6 +52,7 @@ static char rcs_dmach[] = RCS_DMACH ; #define OPT "optimizer" #define LINKER "linker" #define COMBINER "combiner" +#define PRIO "priority" #define RUNT "rts" #define NEEDT "need" #define CALL "callname" @@ -182,6 +183,9 @@ intrf() { if ( new->t_combine ) twice=YES ; new->t_combine= YES ; } else + if ( strcmp(ty_name,PRIO)==0 ) { + new->t_priority= atoi(bol) ; + } else if ( strcmp(ty_name,PROP)==0 ) { /* Obsolete by now, to be removed */ for ( ptr=bol ; *ptr ; ptr++ ) { diff --git a/util/ack/scan.c b/util/ack/scan.c index 94f61ab17..9165537f8 100644 --- a/util/ack/scan.c +++ b/util/ack/scan.c @@ -43,6 +43,9 @@ enum f_path getpath(first) register trf **first ; { /******************** data used only while scanning *******************/ +static int last_pcount; /* The added priority of + the best path so far */ + static int last_ncount; /* The # of non-optimizing transformations in the best path sofar */ @@ -138,20 +141,21 @@ try(f_scan,suffix) list_elem *f_scan; char *suffix; { scan_found() { register list_elem *scan; - int ncount, ocount ; + int ncount, ocount, pcount ; suf_found= 1; #ifdef DEBUG if ( debug>=3 ) vprint("Scan found\n") ; #endif /* Gather data used in comparison */ - ncount=0; ocount=0; + ncount=0; ocount=0; pcount=0; scanlist(l_first(tr_list),scan) { if (t_cont(*scan)->t_scan) { #ifdef DEBUG if ( debug>=4 ) vprint("%s-",t_cont(*scan)->t_name) ; #endif if( t_cont(*scan)->t_optim ) ocount++ ;else ncount++ ; + pcount += t_cont(*scan)->t_priority ; } } #ifdef DEBUG @@ -160,14 +164,17 @@ scan_found() { /* Is this transformation better then any found yet ? */ #ifdef DEBUG if ( debug>=3 ) { - vprint("old n:%d, o:%d - new n:%d, o:%d\n", - last_ncount,last_ocount,ncount,ocount) ; + vprint("old n:%d, o:%d, p:%d - new n:%d, o:%d, p:%d\n", + last_ncount,last_ocount,last_pcount, + ncount,ocount,pcount) ; } #endif if ( last_ncount== -1 || /* None found yet */ - last_ncount>ncount || /* Shorter nec. path */ - (last_ncount==ncount && /* Same nec. path, optimize?*/ - (Optflag? last_ocountocount ) ) ) { + last_pcountncount || /* Shorter nec. path */ + (last_ncount==ncount && /* Same nec. path, optimize?*/ + (Optflag? last_ocountocount ))))) { /* Yes it is */ #ifdef DEBUG if ( debug>=3 ) vprint("Better\n"); @@ -175,7 +182,7 @@ scan_found() { scanlist(l_first(tr_list),scan) { t_cont(*scan)->t_bscan=t_cont(*scan)->t_scan; } - last_ncount=ncount; last_ocount=ocount; + last_ncount=ncount; last_ocount=ocount; last_pcount=pcount; } } diff --git a/util/ack/trans.h b/util/ack/trans.h index 5a96e7ea3..30b9e9632 100644 --- a/util/ack/trans.h +++ b/util/ack/trans.h @@ -30,6 +30,7 @@ struct transform { int t_linker:1 ; /* The linker usurps all unrecognized flags */ int t_do:1 ; /* Is in a path to execute */ int t_blocked:1 ; /* An input file could not be produced */ + short t_priority ; /* Importance of including phase in scan */ list_head t_inputs ; /* The input 'path's of a combiner */ char *t_origname ; /* The basename of the output file */ trf *t_next ; /* The transformation to be executed next */ -- 2.34.1