2 static char rcsid[] = "$Id: tes.c,v 1.6 1994/06/24 10:41:04 ceriel Exp $";
5 * This file contains the main part of the top element size computation phase.
7 * Author: Hans van Eck.
24 extern char *pop_push[];
25 extern char flow_tab[];
27 #define NON_CONTINUABLE(i) (flow_tab[i]&JUMP)
28 #define ISABRANCH(i) (flow_tab[i]&HASLABEL)
29 #define ISCONDBRANCH(i) (flow_tab[i]&CONDBRA)
31 #define INSTR(lnp) (lnp->l_instr & BMASK)
32 #define TYPE(lnp) lnp->l_optyp
33 #define SHORT(lnp) lnp->l_a.la_short
34 #define MINI(lnp) ((lnp->l_optyp & BMASK) - Z_OPMINI)
36 #define IS_MINI(lnp) (lnp->l_optyp >= OPMINI)
37 #define IS_LOC(l) (l!=(line_p) 0 && INSTR(l)==op_loc && IS_MINI(l))
40 static int stacktop = 0;
52 for (lp = pseudos; lp != (line_p)0; lp = lp->l_next) {
56 if (lp->l_optyp == OPLIST) {
57 register arg_p ap = lp->l_a.la_arg;
59 while (ap != (arg_p) 0) {
60 if (ap->a_typ == ARGNUM) {
61 assign_label(ap->a_a.a_np->n_repl);
65 } else if (lp->l_optyp == OPNUMLAB)
66 assign_label(lp->l_a.la_np->n_repl);
75 register instr = INSTR(lnp);
76 register int arg, argdef;
79 if (instr == op_lab) {
83 if (instr < sp_fmnem || instr > sp_lmnem) {
87 if (state == NOTREACHED) return; /* What else ? */
94 if (TYPE(lnp) == OPSHORT) {
96 if (arg < wordsize) arg = wordsize;
98 } else if (IS_MINI(lnp)) {
100 if (arg > 0 && arg < wordsize) arg = wordsize;
101 if (arg < 0 && -arg < wordsize) arg = -wordsize;
107 case 'w': stacktop = wordsize; break;
108 case 'd': stacktop = wordsize * 2; break;
109 case 'p': stacktop = pointersize; break;
111 if (argdef == FALSE || instr == op_ass) {
120 if (arg < wordsize) arg = wordsize;
129 if (arg < wordsize) arg = wordsize;
143 * When the last argument was negative, the element size
144 * must be negated. This is to catch 'asp -4'.
146 if (neg) stacktop = -stacktop;
149 if (stacktop < 0) stacktop = 0;
151 if (ISABRANCH(instr)) do_inst_label(lnp);
152 if (NON_CONTINUABLE(instr)) {
159 register num_p label;
161 if (label->n_flags & NUMSET) {
162 if (state == NOTREACHED || stacktop > label->n_size) {
163 stacktop = label->n_size;
164 } else if ( stacktop < label->n_size) {
165 label->n_size = stacktop;
168 label->n_size = stacktop;
169 label->n_flags |= NUMSET;
173 do_inst_label(lnp) /* (re-)install a label */
176 num_p label = lnp->l_a.la_np->n_repl;
177 int instr = INSTR(lnp);
181 if (instr == op_lab) {
182 if (state == NOTREACHED) {
184 label->n_flags |= NUMFALLTHROUGH;
186 } else if (ISCONDBRANCH(instr)) { /* conditional branch */
187 label->n_flags |= NUMCOND;