1984-11-26 13:43:22 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "../../../h/em_spec.h"
|
|
|
|
#include "../share/types.h"
|
|
|
|
#include "../share/debug.h"
|
|
|
|
#include "../share/lset.h"
|
|
|
|
#include "cs.h"
|
|
|
|
#include "cs_aux.h"
|
|
|
|
#include "cs_avail.h"
|
|
|
|
#include "cs_entity.h"
|
|
|
|
|
|
|
|
#ifdef VERBOSE
|
|
|
|
|
|
|
|
extern char em_mnem[]; /* The mnemonics of the EM instructions. */
|
|
|
|
|
|
|
|
STATIC showinstr(lnp)
|
|
|
|
line_p lnp;
|
|
|
|
{
|
|
|
|
/* Makes the instruction in `lnp' human readable. Only lines that
|
|
|
|
* can occur in expressions that are going to be eliminated are
|
|
|
|
* properly handled.
|
|
|
|
*/
|
|
|
|
if (INSTR(lnp) < sp_fmnem && INSTR(lnp) > sp_lmnem) {
|
|
|
|
fprintf(stderr,"*** ?\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr,"%s", &em_mnem[4 * (INSTR(lnp)-sp_fmnem)]);
|
|
|
|
switch (TYPE(lnp)) {
|
|
|
|
case OPNO:
|
|
|
|
break;
|
|
|
|
case OPSHORT:
|
|
|
|
fprintf(stderr," %d", SHORT(lnp));
|
|
|
|
break;
|
|
|
|
case OPOBJECT:
|
|
|
|
fprintf(stderr," %d", OBJ(lnp)->o_id);
|
|
|
|
break;
|
|
|
|
case OPOFFSET:
|
1987-02-09 17:28:22 +00:00
|
|
|
fprintf(stderr," %ld", OFFSET(lnp));
|
1984-11-26 13:43:22 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf(stderr," ?");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fprintf(stderr,"\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
SHOWOCCUR(ocp)
|
|
|
|
occur_p ocp;
|
|
|
|
{
|
|
|
|
/* Shows all instructions in an occurrence. */
|
|
|
|
|
|
|
|
register line_p lnp, next;
|
|
|
|
|
|
|
|
if (verbose_flag) {
|
|
|
|
for (lnp = ocp->oc_lfirst; lnp != (line_p) 0; lnp = next) {
|
|
|
|
next = lnp == ocp->oc_llast ? (line_p) 0 : lnp->l_next;
|
|
|
|
|
|
|
|
showinstr(lnp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TRACE
|
|
|
|
|
|
|
|
SHOWAVAIL(avp)
|
|
|
|
avail_p avp;
|
|
|
|
{
|
|
|
|
/* Shows an available expression. */
|
|
|
|
showinstr(avp->av_found);
|
|
|
|
fprintf(stderr,"result %d,", avp->av_result);
|
|
|
|
fprintf(stderr,"occurred %d times\n", Lnrelems(avp->av_occurs) + 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
OUTAVAILS()
|
|
|
|
{
|
|
|
|
register avail_p ravp;
|
|
|
|
|
|
|
|
fprintf(stderr,"AVAILABLE EXPRESSIONS\n");
|
|
|
|
|
|
|
|
for (ravp = avails; ravp != (avail_p) 0; ravp = ravp->av_before) {
|
|
|
|
SHOWAVAIL(ravp);
|
|
|
|
fprintf(stderr,"\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC char *enkinds[] = {
|
|
|
|
"constant",
|
|
|
|
"local",
|
|
|
|
"external",
|
|
|
|
"indirect",
|
|
|
|
"offsetted",
|
|
|
|
"address of local",
|
|
|
|
"address of external",
|
|
|
|
"address of offsetted",
|
|
|
|
"address of local base",
|
|
|
|
"address of argument base",
|
|
|
|
"procedure",
|
|
|
|
"floating zero",
|
|
|
|
"array element",
|
|
|
|
"local base",
|
|
|
|
"heap pointer",
|
|
|
|
"ignore mask"
|
|
|
|
};
|
|
|
|
|
|
|
|
OUTENTITIES()
|
|
|
|
{
|
|
|
|
register Lindex i;
|
|
|
|
|
|
|
|
fprintf(stderr,"ENTITIES\n");
|
|
|
|
for (i = Lfirst(entities); i != (Lindex) 0; i = Lnext(i, entities)) {
|
|
|
|
register entity_p rep = en_elem(i);
|
|
|
|
|
|
|
|
fprintf(stderr,"%s,", enkinds[rep->en_kind]);
|
1987-02-09 17:28:22 +00:00
|
|
|
fprintf(stderr,"size %ld,", rep->en_size);
|
1984-11-26 13:43:22 +00:00
|
|
|
fprintf(stderr,"valno %d,", rep->en_vn);
|
|
|
|
switch (rep->en_kind) {
|
|
|
|
case ENCONST:
|
1987-02-09 17:28:22 +00:00
|
|
|
fprintf(stderr,"$%ld\n", rep->en_val);
|
1984-11-26 13:43:22 +00:00
|
|
|
break;
|
|
|
|
case ENLOCAL:
|
|
|
|
case ENALOCAL:
|
1987-02-09 17:28:22 +00:00
|
|
|
fprintf(stderr,"%ld(LB)\n", rep->en_loc);
|
1984-11-26 13:43:22 +00:00
|
|
|
break;
|
|
|
|
case ENINDIR:
|
|
|
|
fprintf(stderr,"*%d\n", rep->en_ind);
|
|
|
|
break;
|
|
|
|
case ENOFFSETTED:
|
|
|
|
case ENAOFFSETTED:
|
1987-02-09 17:28:22 +00:00
|
|
|
fprintf(stderr,"%ld(%d)\n", rep->en_off, rep->en_base);
|
1984-11-26 13:43:22 +00:00
|
|
|
break;
|
|
|
|
case ENALOCBASE:
|
|
|
|
case ENAARGBASE:
|
1987-02-09 17:28:22 +00:00
|
|
|
fprintf(stderr,"%ld levels\n", rep->en_levels);
|
1984-11-26 13:43:22 +00:00
|
|
|
break;
|
|
|
|
case ENARRELEM:
|
|
|
|
fprintf(stderr,"%d[%d], ",rep->en_arbase,rep->en_index);
|
|
|
|
fprintf(stderr,"rom at %d\n", rep->en_adesc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fprintf(stderr,"\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX */
|
|
|
|
OUTTRACE(s, n)
|
|
|
|
char *s;
|
|
|
|
{
|
|
|
|
fprintf(stderr,"trace: ");
|
|
|
|
fprintf(stderr,s, n);
|
|
|
|
fprintf(stderr,"\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif TRACE
|