Added a priority associated with each phase. Paths with the highest

total priority have preference.
This commit is contained in:
keie 1984-10-05 13:34:38 +00:00
parent 8e680a6467
commit b5fa0675b6
3 changed files with 20 additions and 8 deletions

View file

@ -52,6 +52,7 @@ static char rcs_dmach[] = RCS_DMACH ;
#define OPT "optimizer" #define OPT "optimizer"
#define LINKER "linker" #define LINKER "linker"
#define COMBINER "combiner" #define COMBINER "combiner"
#define PRIO "priority"
#define RUNT "rts" #define RUNT "rts"
#define NEEDT "need" #define NEEDT "need"
#define CALL "callname" #define CALL "callname"
@ -182,6 +183,9 @@ intrf() {
if ( new->t_combine ) twice=YES ; if ( new->t_combine ) twice=YES ;
new->t_combine= YES ; new->t_combine= YES ;
} else } else
if ( strcmp(ty_name,PRIO)==0 ) {
new->t_priority= atoi(bol) ;
} else
if ( strcmp(ty_name,PROP)==0 ) { if ( strcmp(ty_name,PROP)==0 ) {
/* Obsolete by now, to be removed */ /* Obsolete by now, to be removed */
for ( ptr=bol ; *ptr ; ptr++ ) { for ( ptr=bol ; *ptr ; ptr++ ) {

View file

@ -43,6 +43,9 @@ enum f_path getpath(first) register trf **first ; {
/******************** data used only while scanning *******************/ /******************** 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 static int last_ncount; /* The # of non-optimizing transformations
in the best path sofar */ in the best path sofar */
@ -138,20 +141,21 @@ try(f_scan,suffix) list_elem *f_scan; char *suffix; {
scan_found() { scan_found() {
register list_elem *scan; register list_elem *scan;
int ncount, ocount ; int ncount, ocount, pcount ;
suf_found= 1; suf_found= 1;
#ifdef DEBUG #ifdef DEBUG
if ( debug>=3 ) vprint("Scan found\n") ; if ( debug>=3 ) vprint("Scan found\n") ;
#endif #endif
/* Gather data used in comparison */ /* Gather data used in comparison */
ncount=0; ocount=0; ncount=0; ocount=0; pcount=0;
scanlist(l_first(tr_list),scan) { scanlist(l_first(tr_list),scan) {
if (t_cont(*scan)->t_scan) { if (t_cont(*scan)->t_scan) {
#ifdef DEBUG #ifdef DEBUG
if ( debug>=4 ) vprint("%s-",t_cont(*scan)->t_name) ; if ( debug>=4 ) vprint("%s-",t_cont(*scan)->t_name) ;
#endif #endif
if( t_cont(*scan)->t_optim ) ocount++ ;else ncount++ ; if( t_cont(*scan)->t_optim ) ocount++ ;else ncount++ ;
pcount += t_cont(*scan)->t_priority ;
} }
} }
#ifdef DEBUG #ifdef DEBUG
@ -160,14 +164,17 @@ scan_found() {
/* Is this transformation better then any found yet ? */ /* Is this transformation better then any found yet ? */
#ifdef DEBUG #ifdef DEBUG
if ( debug>=3 ) { if ( debug>=3 ) {
vprint("old n:%d, o:%d - new n:%d, o:%d\n", vprint("old n:%d, o:%d, p:%d - new n:%d, o:%d, p:%d\n",
last_ncount,last_ocount,ncount,ocount) ; last_ncount,last_ocount,last_pcount,
ncount,ocount,pcount) ;
} }
#endif #endif
if ( last_ncount== -1 || /* None found yet */ if ( last_ncount== -1 || /* None found yet */
last_ncount>ncount || /* Shorter nec. path */ last_pcount<pcount || /* Better priority */
(last_ncount==ncount && /* Same nec. path, optimize?*/ ( last_pcount==pcount && /* Same prio, and */
(Optflag? last_ocount<ocount : last_ocount>ocount ) ) ) { ( last_ncount>ncount || /* Shorter nec. path */
(last_ncount==ncount && /* Same nec. path, optimize?*/
(Optflag? last_ocount<ocount : last_ocount>ocount ))))) {
/* Yes it is */ /* Yes it is */
#ifdef DEBUG #ifdef DEBUG
if ( debug>=3 ) vprint("Better\n"); if ( debug>=3 ) vprint("Better\n");
@ -175,7 +182,7 @@ scan_found() {
scanlist(l_first(tr_list),scan) { scanlist(l_first(tr_list),scan) {
t_cont(*scan)->t_bscan=t_cont(*scan)->t_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;
} }
} }

View file

@ -30,6 +30,7 @@ struct transform {
int t_linker:1 ; /* The linker usurps all unrecognized flags */ int t_linker:1 ; /* The linker usurps all unrecognized flags */
int t_do:1 ; /* Is in a path to execute */ int t_do:1 ; /* Is in a path to execute */
int t_blocked:1 ; /* An input file could not be produced */ 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 */ list_head t_inputs ; /* The input 'path's of a combiner */
char *t_origname ; /* The basename of the output file */ char *t_origname ; /* The basename of the output file */
trf *t_next ; /* The transformation to be executed next */ trf *t_next ; /* The transformation to be executed next */