Added a priority associated with each phase. Paths with the highest
authorkeie <none@none>
Fri, 5 Oct 1984 13:34:38 +0000 (13:34 +0000)
committerkeie <none@none>
Fri, 5 Oct 1984 13:34:38 +0000 (13:34 +0000)
total priority have preference.

util/ack/rmach.c
util/ack/scan.c
util/ack/trans.h

index d5bdda8..4fcc05e 100644 (file)
@@ -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++ ) {
index 94f61ab..9165537 100644 (file)
@@ -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_ocount<ocount : last_ocount>ocount ) ) ) {
+            last_pcount<pcount ||              /* Better priority */
+            ( last_pcount==pcount &&           /* Same prio, and */
+               ( last_ncount>ncount ||              /* Shorter nec. path */
+                 (last_ncount==ncount &&            /* Same nec. path, optimize?*/
+                   (Optflag? last_ocount<ocount : last_ocount>ocount ))))) {
                /* 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;
        }
 }
 
index 5a96e7e..30b9e96 100644 (file)
@@ -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 */