LDFLAGS=-i
CPPFLAGS=-DVERBOSE -DNOTCOMPACT
CFLAGS=$(CPPFLAGS) -O
-LINTFLAGS=-hbac
+LINTFLAGS=-hbu
CFILES=\
ra.c ra_items.c ra_lifet.c ra_allocl.c ra_profits.c \
item_p item;
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 (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) {
- printf("id of external = %d\n",
+ fprintf(stderr, "id of external = %d\n",
item->i_t.it_obj->o_id);
} else {
- printf("offset = %ld\n",
+ fprintf(stderr, "offset = %ld\n",
item->i_t.it_off);
}
- printf("regtype = %s\n",str_regtypes[item->it_regtype]);
- printf("size = %d\n",item->it_size);
- printf("#usages = %d\n", Lnrelems(item->it_usage));
- printf("lifetime = {");
+ fprintf(stderr, "regtype = %s\n",str_regtypes[item->it_regtype]);
+ fprintf(stderr, "size = %d\n",item->it_size);
+ fprintf(stderr, "#usages = %d\n", Lnrelems(item->it_usage));
+ fprintf(stderr, "lifetime = {");
for (iv = item->it_lives; iv != (interv_p) 0;
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);
}
fprintf(stderr,"#usages(static) = %d\n",al->al_susecount);
fprintf(stderr,"#usages(dyn) = %d\n",al->al_dusecount);
fprintf(stderr,"#inits = %d\n",Lnrelems(al->al_inits));
+ fprintf(stderr,"isloop = %d\n",al->al_isloop);
fprintf(stderr,"timespan = {");
for (iv = al->al_timespan; iv != (interv_p) 0;
iv = iv->i_next) {
for (x = list; x != (alloc_p) 0; x = x->al_next) {
regs_needed[x->al_regtype]++;
}
- /* printf("data regs:%d\n",regs_needed[reg_any]); */
- /* printf("address regs:%d\n",regs_needed[reg_pointer]); */
+ /* fprintf(stderr, "data regs:%d\n",regs_needed[reg_any]); */
+ /* fprintf(stderr, "address regs:%d\n",regs_needed[reg_pointer]); */
}
int t,r;
int cnt;
- printf("\nSTATISTICS\n");
+ fprintf(stderr, "\nSTATISTICS\n");
for (r = 0; r <= reg_float; r++) cnt_regtypes[r] = 0;
for (t = 0; t < NRITEMTYPES;t++) {
cnt = 0;
}
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++) {
- printf("#%s = %d\n",str_regtypes[r],cnt_regtypes[r]);
+ fprintf(stderr, "#%s = %d\n",str_regtypes[r],cnt_regtypes[r]);
}
}
*
*/
-/* TEMPORARY: should be put in ../../../h/em_mes.h: */
-#define ms_liv 9
-#define ms_ded 10
-
#define INFINITE 10000
#define NRREGTYPES (reg_float+1)
for (li = Lfirst(loops); li != (Lindex) 0; li=Lnext(li,loops)) {
l = (loop_p) Lelem(li);
sloopcnt[l->lp_id]++;
- dloopcnt[l->lp_id] +=
+ dloopcnt[l->lp_id] +=
(IS_FIRM(u->t_bblock) ? loop_scale(lev) : 1);
}
}
insert_alloc(wholeproc, alloc_list_p);
for (li = Lfirst(loops); li != (Lindex) 0; li = Lnext(li,loops)) {
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
* as a timespan during which item may be put in
* a register.
- */
if ((header = lp->LP_HEADER) == (bblock_p) 0 &&
MUST_INIT(item,lp->lp_entry)) continue;
+ */
lt = loop_lifetime(lp);
susecount = sloopcnt[lp->lp_id];
dusecount = dloopcnt[lp->lp_id];
loop_inits(lp,item,header),wholeproc,
TRUE,FALSE),
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];
}
}
}
short loop_scale(lev)
short lev;
{
- return (lev == 0 ? 1 : (lev > 3 ? 20 : 5 * lev));
+ return (lev == 0 ? 1 : (lev > 3 ? 32 : 8 * lev));
}
#include "../../../h/em_spec.h"
#include "../../../h/em_pseu.h"
#include "../../../h/em_reg.h"
+#include "../../../h/em_mes.h"
+#include "../../../h/em_ego.h"
#include "ra.h"
#include "ra_aux.h"
#include "ra_items.h"
#include "ra_lifet.h"
-#define MSG_OFF(l) aoff(ARG(l),1)
-#define is_livemsg(l) (INSTR(l) == ps_mes && aoff(ARG(l),0) == ms_liv)
-#define is_deadmsg(l) (INSTR(l) == ps_mes && aoff(ARG(l),0) == ms_ded)
+#define MSG_OFF(l) aoff(ARG(l),2)
+#define is_livemsg(l) (INSTR(l) == ps_mes && aoff(ARG(l),0) == ms_ego && \
+ 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)
item_p items[];
STATIC alloc_p best_alloc(unpacked,packed,time_opt)
alloc_p unpacked,packed;
- bool time_opt;
+ bool time_opt; /* now unused */
{
/* Find the next best candidate */
register alloc_p x,best;
- bool loops_only;
-
- for (loops_only = time_opt; ; loops_only = FALSE) {
- /* If we're optimizing execution time, we first
- * consider loops.
- */
- best = unpacked; /* dummy */
- for (x = unpacked->al_next; x != (alloc_p) 0; x = x->al_next) {
- if ((!loops_only || x->al_isloop) &&
- x->al_profits > best->al_profits &&
- room_for(x,packed)) {
- best = x;
- }
+
+ best = unpacked; /* dummy */
+
+ for (x = unpacked->al_next; x != (alloc_p) 0; x = x->al_next) {
+ if (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);
}
* R A _ P R O F I T S . C
*/
+#include <stdio.h>
#include "../share/types.h"
#include "../share/debug.h"
#include "../share/lset.h"
*time_out = (m == (cond_p) 0 ? -1 : map_value(m,off,TRUE));
*space_out = (m == (cond_p) 0 ? -1 : map_value(m,off,FALSE));
/*
- printf("itemtyp = %d, localtyp = %d off = %ld\n",itemtyp,localtyp,off);
- printf("ALLOCSCORE = (%d,%d)\n",*time_out,*space_out);
+ fprintf(stderr,"itemtyp = %d, localtyp = %d off = %ld\n",itemtyp,localtyp,off);
+ fprintf(stderr,"ALLOCSCORE = (%d,%d)\n",*time_out,*space_out);
*/
}
*time_out = (m == (cond_p) 0 ? 1000 : map_value(m,off,TRUE));
*space_out = (m == (cond_p) 0 ? 1000 : map_value(m,off,FALSE));
/*
- printf("itemtyp = %d, localtyp = %d off = %ld\n",itemtyp,localtyp,off);
- printf("OPEN_COST = (%d,%d)\n",*time_out,*space_out);
+ fprintf(stderr,"itemtyp = %d, localtyp = %d off = %ld\n",itemtyp,localtyp,off);
+ fprintf(stderr,"OPEN_COST = (%d,%d)\n",*time_out,*space_out);
*/
}
*time_out = index_value(regsav_cost,n,TRUE);
*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);
*/
}
#include "../../../h/em_spec.h"
#include "../../../h/em_pseu.h"
#include "../../../h/em_mes.h"
+#include "../../../h/em_ego.h"
#include "../../../h/em_reg.h"
#include "ra.h"
#include "ra_interv.h"
for (b = p->p_start; b != (bblock_p) 0; b = b->b_next) {
for (l = b->b_start; l != (line_p) 0; l = next) {
next = l->l_next;
- if ( INSTR(l) == ps_mes &&
- ((m = aoff(ARG(l),0)) == ms_liv || m == ms_ded)) {
- /* remove live/dead messages */
- rm_line(l,b);
+ if (INSTR(l) == ps_mes
+ && aoff(ARG(l),0) == ms_ego
+ && ((m = aoff(ARG(l),1)) == ego_live
+ || m == ego_dead)) {
+ /* remove live/dead messages */
+ rm_line(l,b);
}
}
}