From ae5dded36f14f7749db66c57bccdc6b3f412e9a2 Mon Sep 17 00:00:00 2001 From: ceriel Date: Thu, 31 Jan 1991 15:17:04 +0000 Subject: [PATCH] simplified 'tes' mechanism --- util/opt/alloc.c | 10 ---------- util/opt/alloc.h | 1 - util/opt/process.c | 1 - util/opt/proinf.h | 3 ++- util/opt/reg.c | 15 ++++++++------- util/opt/tes.c | 38 +++++++------------------------------- util/opt/tes.h | 12 ------------ 7 files changed, 17 insertions(+), 63 deletions(-) diff --git a/util/opt/alloc.c b/util/opt/alloc.c index fee07b9da..8687eb66f 100644 --- a/util/opt/alloc.c +++ b/util/opt/alloc.c @@ -172,16 +172,6 @@ oldnum(lp) num_p lp; { oldcore((short *) lp,sizeof(num_t)); } -lblst_p newlblst() { - - return((lblst_p) newcore(sizeof(lblst_t))); -} - -oldlblst(lbp) lblst_p lbp; { - - oldcore((short *) lbp, sizeof(lblst_t)); -} - offset *newrom() { return((offset *) newcore(MAXROM*sizeof(offset))); diff --git a/util/opt/alloc.h b/util/opt/alloc.h index 547771167..788fd9c8f 100644 --- a/util/opt/alloc.h +++ b/util/opt/alloc.h @@ -8,7 +8,6 @@ extern line_p newline(); extern offset *newrom(); extern sym_p newsym(); extern num_p newnum(); -extern lblst_p newlblst(); extern arg_p newarg(); extern argb_p newargb(); extern reg_p newreg(); diff --git a/util/opt/process.c b/util/opt/process.c index ccf86caef..9f860f0d9 100644 --- a/util/opt/process.c +++ b/util/opt/process.c @@ -104,7 +104,6 @@ symknown() { cleanlocals() { register num_p *npp,np,tp; - delete_labels(); for (npp = curpro.numhash; npp < &curpro.numhash[NNUMHASH]; npp++) { np = *npp; while (np != (num_p) 0) { diff --git a/util/opt/proinf.h b/util/opt/proinf.h index 8638e9013..ae18c4b53 100644 --- a/util/opt/proinf.h +++ b/util/opt/proinf.h @@ -10,7 +10,7 @@ struct num { unsigned n_jumps; num_p n_repl; short n_flags; - lblst_p n_lst_elt; + short n_size; /* size of element on top at this label */ line_p n_line; }; @@ -22,6 +22,7 @@ struct num { #define NUMSCAN 000020 #define NUMSET 000040 #define NUMCOND 000100 +#define NUMFALLTHROUGH 000200 #define NNUMHASH 37 extern num_p numlookup(); diff --git a/util/opt/reg.c b/util/opt/reg.c index cbe8a3617..a040dd450 100644 --- a/util/opt/reg.c +++ b/util/opt/reg.c @@ -80,18 +80,19 @@ outregs() { /* outtes() handles the output of the top elt. messages */ outtes() { - register lblst_p lp = est_list; + register num_p *npp, np; - while(lp != NULL) { - if ((lp->ll_size != 0) && !(lp->ll_num->n_flags & NUMCOND)) { + for (npp=curpro.numhash;npp< &curpro.numhash[NNUMHASH]; npp++) { + for (np = *npp; np != (num_p) 0; np=np->n_next) { + if (! (np->n_flags & NUMSET) || np->n_size == 0 || + (np->n_flags & NUMCOND)) continue; outinst(ps_mes); outoff((offset)ms_tes); - outoff((offset)lp->ll_num->n_number); - outoff((offset)lp->ll_size); - outoff((offset)lp->ll_fallthrough); + outoff((offset)np->n_number); + outoff((offset)np->n_size); + outoff((offset)((np->n_flags & NUMFALLTHROUGH) ? 1 : 0)); outinst(sp_cend); } - lp = lp->ll_next; } } diff --git a/util/opt/tes.c b/util/opt/tes.c index 5a53151d2..355042a51 100644 --- a/util/opt/tes.c +++ b/util/opt/tes.c @@ -28,8 +28,6 @@ extern char flow_tab[]; #define ISABRANCH(i) (flow_tab[i]&HASLABEL) #define ISCONDBRANCH(i) (flow_tab[i]&CONDBRA) -lblst_p est_list = NULL; - #define INSTR(lnp) (lnp->l_instr & BMASK) #define TYPE(lnp) lnp->l_optyp #define PREV(lnp) lnp->l_prev @@ -46,7 +44,6 @@ init_state() { stacktop = 0; state = KNOWN; - est_list = NULL; } tes_pseudos() @@ -161,37 +158,17 @@ line_p lnp; } } -delete_labels() -{ - register lblst_p tmp; - - while ((tmp = est_list) != NULL) { - est_list = est_list->ll_next; - oldlblst(tmp); - } -} - assign_label(label) -num_p label; +register num_p label; { - register lblst_p lst_elt; - if (label->n_flags & NUMSET) { - lst_elt = label->n_lst_elt; - if (state == NOTREACHED || stacktop > lst_elt->ll_size) { - stacktop = lst_elt->ll_size; - } else if ( stacktop < lst_elt->ll_size) { - lst_elt->ll_size = stacktop; + if (state == NOTREACHED || stacktop > label->n_size) { + stacktop = label->n_size; + } else if ( stacktop < label->n_size) { + label->n_size = stacktop; } } else { - lst_elt = newlblst(); - lst_elt->ll_next = est_list; - lst_elt->ll_num = label; - lst_elt->ll_size = stacktop; - - est_list = lst_elt; - - label->n_lst_elt = lst_elt; + label->n_size = stacktop; label->n_flags |= NUMSET; } } @@ -206,9 +183,8 @@ line_p lnp; if (instr == op_lab) { if (state == NOTREACHED) { - label->n_lst_elt->ll_fallthrough = FALSE; } else { - label->n_lst_elt->ll_fallthrough = TRUE; + label->n_flags |= NUMFALLTHROUGH; } } else if (ISCONDBRANCH(instr)) { /* conditional branch */ label->n_flags |= NUMCOND; diff --git a/util/opt/tes.h b/util/opt/tes.h index c96b2795c..9523b6b65 100644 --- a/util/opt/tes.h +++ b/util/opt/tes.h @@ -3,18 +3,6 @@ */ /* $Header$ */ -typedef struct label_list *lblst_p; - -struct label_list { - lblst_p ll_next; /* pointer to next label in the list */ - num_p ll_num; /* pointer to label definition */ - short ll_size; /* size of the element on top at this label */ - char ll_fallthrough; /* is the label reached by fallthrough ? */ -}; - -typedef struct label_list lblst_t; - -extern lblst_p est_list; extern int state; #define KNOWN 1 #define NOTREACHED 2 -- 2.34.1