simplified 'tes' mechanism
This commit is contained in:
parent
2a852dcff1
commit
ae5dded36f
7 changed files with 17 additions and 63 deletions
|
@ -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)));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue