changed lint flags, use ms_ego, changed allocation strategy for loops

This commit is contained in:
ceriel 1990-12-18 11:14:34 +00:00
parent 41ca723d96
commit 335377da7a
9 changed files with 57 additions and 51 deletions

View file

@ -7,7 +7,7 @@ SHR=../share
LDFLAGS=-i LDFLAGS=-i
CPPFLAGS=-DVERBOSE -DNOTCOMPACT CPPFLAGS=-DVERBOSE -DNOTCOMPACT
CFLAGS=$(CPPFLAGS) -O CFLAGS=$(CPPFLAGS) -O
LINTFLAGS=-hbac LINTFLAGS=-hbu
CFILES=\ CFILES=\
ra.c ra_items.c ra_lifet.c ra_allocl.c ra_profits.c \ ra.c ra_items.c ra_lifet.c ra_allocl.c ra_profits.c \

View file

@ -437,29 +437,29 @@ print_items(items,p)
item_p item; item_p item;
interv_p iv; interv_p iv;
printf("BEGIN PROCEDURE %d\n",p->p_id); fprintf(stderr, "BEGIN PROCEDURE %d\n",p->p_id);
for (t = 0; t < NRITEMTYPES;t++) { for (t = 0; t < NRITEMTYPES;t++) {
for (item = items[t]; item != (item_p) 0;item = item->it_next) { for (item = items[t]; item != (item_p) 0;item = item->it_next) {
printf("\nitemtype = %s\n",str_types[t]); fprintf(stderr, "\nitemtype = %s\n",str_types[t]);
if (t == GLOBL_ADDR) { if (t == GLOBL_ADDR) {
printf("id of external = %d\n", fprintf(stderr, "id of external = %d\n",
item->i_t.it_obj->o_id); item->i_t.it_obj->o_id);
} else { } else {
printf("offset = %ld\n", fprintf(stderr, "offset = %ld\n",
item->i_t.it_off); item->i_t.it_off);
} }
printf("regtype = %s\n",str_regtypes[item->it_regtype]); fprintf(stderr, "regtype = %s\n",str_regtypes[item->it_regtype]);
printf("size = %d\n",item->it_size); fprintf(stderr, "size = %d\n",item->it_size);
printf("#usages = %d\n", Lnrelems(item->it_usage)); fprintf(stderr, "#usages = %d\n", Lnrelems(item->it_usage));
printf("lifetime = {"); fprintf(stderr, "lifetime = {");
for (iv = item->it_lives; iv != (interv_p) 0; for (iv = item->it_lives; iv != (interv_p) 0;
iv = iv->i_next) { iv = iv->i_next) {
printf("(%d,%d) ",iv->i_start,iv->i_stop); fprintf(stderr, "(%d,%d) ",iv->i_start,iv->i_stop);
} }
printf("} \n"); fprintf(stderr, "} \n");
} }
} }
printf("END PROCEDURE %d\n\n",p->p_id); fprintf(stderr, "END PROCEDURE %d\n\n",p->p_id);
} }
@ -490,6 +490,7 @@ print_allocs(list)
fprintf(stderr,"#usages(static) = %d\n",al->al_susecount); fprintf(stderr,"#usages(static) = %d\n",al->al_susecount);
fprintf(stderr,"#usages(dyn) = %d\n",al->al_dusecount); fprintf(stderr,"#usages(dyn) = %d\n",al->al_dusecount);
fprintf(stderr,"#inits = %d\n",Lnrelems(al->al_inits)); fprintf(stderr,"#inits = %d\n",Lnrelems(al->al_inits));
fprintf(stderr,"isloop = %d\n",al->al_isloop);
fprintf(stderr,"timespan = {"); fprintf(stderr,"timespan = {");
for (iv = al->al_timespan; iv != (interv_p) 0; for (iv = al->al_timespan; iv != (interv_p) 0;
iv = iv->i_next) { iv = iv->i_next) {
@ -523,8 +524,8 @@ stat_regusage(list)
for (x = list; x != (alloc_p) 0; x = x->al_next) { for (x = list; x != (alloc_p) 0; x = x->al_next) {
regs_needed[x->al_regtype]++; regs_needed[x->al_regtype]++;
} }
/* printf("data regs:%d\n",regs_needed[reg_any]); */ /* fprintf(stderr, "data regs:%d\n",regs_needed[reg_any]); */
/* printf("address regs:%d\n",regs_needed[reg_pointer]); */ /* fprintf(stderr, "address regs:%d\n",regs_needed[reg_pointer]); */
} }
@ -538,7 +539,7 @@ statistics(items)
int t,r; int t,r;
int cnt; int cnt;
printf("\nSTATISTICS\n"); fprintf(stderr, "\nSTATISTICS\n");
for (r = 0; r <= reg_float; r++) cnt_regtypes[r] = 0; for (r = 0; r <= reg_float; r++) cnt_regtypes[r] = 0;
for (t = 0; t < NRITEMTYPES;t++) { for (t = 0; t < NRITEMTYPES;t++) {
cnt = 0; cnt = 0;
@ -549,9 +550,9 @@ statistics(items)
} }
next = item->it_next; next = item->it_next;
} }
printf("#%s = %d\n",str_types[t],cnt); fprintf(stderr, "#%s = %d\n",str_types[t],cnt);
} }
for (r = 0; r <= reg_float; r++) { for (r = 0; r <= reg_float; r++) {
printf("#%s = %d\n",str_regtypes[r],cnt_regtypes[r]); fprintf(stderr, "#%s = %d\n",str_regtypes[r],cnt_regtypes[r]);
} }
} }

View file

@ -8,10 +8,6 @@
* *
*/ */
/* TEMPORARY: should be put in ../../../h/em_mes.h: */
#define ms_liv 9
#define ms_ded 10
#define INFINITE 10000 #define INFINITE 10000
#define NRREGTYPES (reg_float+1) #define NRREGTYPES (reg_float+1)

View file

@ -59,7 +59,7 @@ STATIC count_usage(p,item,nrloops,sloopcnt,dloopcnt)
for (li = Lfirst(loops); li != (Lindex) 0; li=Lnext(li,loops)) { for (li = Lfirst(loops); li != (Lindex) 0; li=Lnext(li,loops)) {
l = (loop_p) Lelem(li); l = (loop_p) Lelem(li);
sloopcnt[l->lp_id]++; sloopcnt[l->lp_id]++;
dloopcnt[l->lp_id] += dloopcnt[l->lp_id] +=
(IS_FIRM(u->t_bblock) ? loop_scale(lev) : 1); (IS_FIRM(u->t_bblock) ? loop_scale(lev) : 1);
} }
} }
@ -293,13 +293,15 @@ STATIC allocs_of_item(p,item,loops,sloopcnt,dloopcnt,alloc_list_p)
insert_alloc(wholeproc, alloc_list_p); insert_alloc(wholeproc, alloc_list_p);
for (li = Lfirst(loops); li != (Lindex) 0; li = Lnext(li,loops)) { for (li = Lfirst(loops); li != (Lindex) 0; li = Lnext(li,loops)) {
lp = (loop_p) Lelem(li); lp = (loop_p) Lelem(li);
if (sloopcnt[lp->lp_id] != 0 && !updates_needed(lp,item)) { if (sloopcnt[lp->lp_id] != 0 && !updates_needed(lp,item)
&& !((header = lp->LP_HEADER) == (bblock_p) 0 &&
MUST_INIT(item,lp->lp_entry))) {
/* Item is used within loop, so consider loop /* Item is used within loop, so consider loop
* as a timespan during which item may be put in * as a timespan during which item may be put in
* a register. * a register.
*/
if ((header = lp->LP_HEADER) == (bblock_p) 0 && if ((header = lp->LP_HEADER) == (bblock_p) 0 &&
MUST_INIT(item,lp->lp_entry)) continue; MUST_INIT(item,lp->lp_entry)) continue;
*/
lt = loop_lifetime(lp); lt = loop_lifetime(lp);
susecount = sloopcnt[lp->lp_id]; susecount = sloopcnt[lp->lp_id];
dusecount = dloopcnt[lp->lp_id]; dusecount = dloopcnt[lp->lp_id];
@ -314,6 +316,12 @@ STATIC allocs_of_item(p,item,loops,sloopcnt,dloopcnt,alloc_list_p)
loop_inits(lp,item,header),wholeproc, loop_inits(lp,item,header),wholeproc,
TRUE,FALSE), TRUE,FALSE),
alloc_list_p); alloc_list_p);
} else if (sloopcnt[lp->lp_id] != 0) {
/* I confess: this is a hack. I didn't expect the
* Spanish inquisition.
*/
if (wholeproc->al_dusecount < dloopcnt[lp->lp_id])
wholeproc->al_dusecount = dloopcnt[lp->lp_id];
} }
} }
} }

View file

@ -41,5 +41,5 @@ time_p cons_time(l,b)
short loop_scale(lev) short loop_scale(lev)
short lev; short lev;
{ {
return (lev == 0 ? 1 : (lev > 3 ? 20 : 5 * lev)); return (lev == 0 ? 1 : (lev > 3 ? 32 : 8 * lev));
} }

View file

@ -19,15 +19,19 @@
#include "../../../h/em_spec.h" #include "../../../h/em_spec.h"
#include "../../../h/em_pseu.h" #include "../../../h/em_pseu.h"
#include "../../../h/em_reg.h" #include "../../../h/em_reg.h"
#include "../../../h/em_mes.h"
#include "../../../h/em_ego.h"
#include "ra.h" #include "ra.h"
#include "ra_aux.h" #include "ra_aux.h"
#include "ra_items.h" #include "ra_items.h"
#include "ra_lifet.h" #include "ra_lifet.h"
#define MSG_OFF(l) aoff(ARG(l),1) #define MSG_OFF(l) aoff(ARG(l),2)
#define is_livemsg(l) (INSTR(l) == ps_mes && aoff(ARG(l),0) == ms_liv) #define is_livemsg(l) (INSTR(l) == ps_mes && aoff(ARG(l),0) == ms_ego && \
#define is_deadmsg(l) (INSTR(l) == ps_mes && aoff(ARG(l),0) == ms_ded) aoff(ARG(l),1) == ego_live)
#define is_deadmsg(l) (INSTR(l) == ps_mes && aoff(ARG(l),0) == ms_ego && \
aoff(ARG(l),1) == ego_dead)
build_lifetimes(items) build_lifetimes(items)
item_p items[]; item_p items[];

View file

@ -107,26 +107,19 @@ STATIC bool room_for(alloc,packed)
STATIC alloc_p best_alloc(unpacked,packed,time_opt) STATIC alloc_p best_alloc(unpacked,packed,time_opt)
alloc_p unpacked,packed; alloc_p unpacked,packed;
bool time_opt; bool time_opt; /* now unused */
{ {
/* Find the next best candidate */ /* Find the next best candidate */
register alloc_p x,best; register alloc_p x,best;
bool loops_only;
for (loops_only = time_opt; ; loops_only = FALSE) { best = unpacked; /* dummy */
/* If we're optimizing execution time, we first
* consider loops. for (x = unpacked->al_next; x != (alloc_p) 0; x = x->al_next) {
*/ if (x->al_profits > best->al_profits &&
best = unpacked; /* dummy */ room_for(x,packed)) {
for (x = unpacked->al_next; x != (alloc_p) 0; x = x->al_next) { best = x;
if ((!loops_only || x->al_isloop) &&
x->al_profits > best->al_profits &&
room_for(x,packed)) {
best = x;
}
} }
if (best != unpacked || !loops_only) break;
} }
return (best == unpacked ? (alloc_p) 0 : best); return (best == unpacked ? (alloc_p) 0 : best);
} }

View file

@ -8,6 +8,7 @@
* R A _ P R O F I T S . C * R A _ P R O F I T S . C
*/ */
#include <stdio.h>
#include "../share/types.h" #include "../share/types.h"
#include "../share/debug.h" #include "../share/debug.h"
#include "../share/lset.h" #include "../share/lset.h"
@ -96,8 +97,8 @@ allocscore(itemtyp,localtyp,size,off,totyp,time_out,space_out)
*time_out = (m == (cond_p) 0 ? -1 : map_value(m,off,TRUE)); *time_out = (m == (cond_p) 0 ? -1 : map_value(m,off,TRUE));
*space_out = (m == (cond_p) 0 ? -1 : map_value(m,off,FALSE)); *space_out = (m == (cond_p) 0 ? -1 : map_value(m,off,FALSE));
/* /*
printf("itemtyp = %d, localtyp = %d off = %ld\n",itemtyp,localtyp,off); fprintf(stderr,"itemtyp = %d, localtyp = %d off = %ld\n",itemtyp,localtyp,off);
printf("ALLOCSCORE = (%d,%d)\n",*time_out,*space_out); fprintf(stderr,"ALLOCSCORE = (%d,%d)\n",*time_out,*space_out);
*/ */
} }
@ -132,8 +133,8 @@ opening_cost(itemtyp,localtyp,off,time_out,space_out)
*time_out = (m == (cond_p) 0 ? 1000 : map_value(m,off,TRUE)); *time_out = (m == (cond_p) 0 ? 1000 : map_value(m,off,TRUE));
*space_out = (m == (cond_p) 0 ? 1000 : map_value(m,off,FALSE)); *space_out = (m == (cond_p) 0 ? 1000 : map_value(m,off,FALSE));
/* /*
printf("itemtyp = %d, localtyp = %d off = %ld\n",itemtyp,localtyp,off); fprintf(stderr,"itemtyp = %d, localtyp = %d off = %ld\n",itemtyp,localtyp,off);
printf("OPEN_COST = (%d,%d)\n",*time_out,*space_out); fprintf(stderr,"OPEN_COST = (%d,%d)\n",*time_out,*space_out);
*/ */
} }
@ -154,7 +155,7 @@ regsave_cost(regs,time_out,space_out)
*time_out = index_value(regsav_cost,n,TRUE); *time_out = index_value(regsav_cost,n,TRUE);
*space_out = index_value(regsav_cost,n,FALSE); *space_out = index_value(regsav_cost,n,FALSE);
/* /*
printf("REGSAVE COST, n=%d, (%d,%d)\n",n,*time_out,*space_out); fprintf(stderr,"REGSAVE COST, n=%d, (%d,%d)\n",n,*time_out,*space_out);
*/ */
} }

View file

@ -19,6 +19,7 @@
#include "../../../h/em_spec.h" #include "../../../h/em_spec.h"
#include "../../../h/em_pseu.h" #include "../../../h/em_pseu.h"
#include "../../../h/em_mes.h" #include "../../../h/em_mes.h"
#include "../../../h/em_ego.h"
#include "../../../h/em_reg.h" #include "../../../h/em_reg.h"
#include "ra.h" #include "ra.h"
#include "ra_interv.h" #include "ra_interv.h"
@ -434,10 +435,12 @@ rem_mes(p)
for (b = p->p_start; b != (bblock_p) 0; b = b->b_next) { for (b = p->p_start; b != (bblock_p) 0; b = b->b_next) {
for (l = b->b_start; l != (line_p) 0; l = next) { for (l = b->b_start; l != (line_p) 0; l = next) {
next = l->l_next; next = l->l_next;
if ( INSTR(l) == ps_mes && if (INSTR(l) == ps_mes
((m = aoff(ARG(l),0)) == ms_liv || m == ms_ded)) { && aoff(ARG(l),0) == ms_ego
/* remove live/dead messages */ && ((m = aoff(ARG(l),1)) == ego_live
rm_line(l,b); || m == ego_dead)) {
/* remove live/dead messages */
rm_line(l,b);
} }
} }
} }