ack/util/ego/cs/cs_debug.c

151 lines
3.1 KiB
C
Raw Normal View History

1994-06-24 11:31:16 +00:00
/* $Id$ */
1987-03-09 19:15:41 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
1984-11-26 13:43:22 +00:00
#include <stdio.h>
1991-03-05 12:16:17 +00:00
#include <em_spec.h>
1984-11-26 13:43:22 +00:00
#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_debug.h"
1984-11-26 13:43:22 +00:00
#include "cs_entity.h"
#ifdef VERBOSE
extern char em_mnem[]; /* The mnemonics of the EM instructions. */
2018-02-05 21:09:30 +00:00
STATIC void showinstr(line_p lnp)
1984-11-26 13:43:22 +00:00
{
/* Makes the instruction in `lnp' human readable. Only lines that
* can occur in expressions that are going to be eliminated are
* properly handled.
*/
2018-06-05 00:20:46 +00:00
if (INSTR(lnp) < sp_fmnem || INSTR(lnp) > sp_lmnem) {
1984-11-26 13:43:22 +00:00
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");
}
void SHOWOCCUR(occur_p ocp)
1984-11-26 13:43:22 +00:00
{
/* 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
2018-02-05 21:09:30 +00:00
void SHOWAVAIL(avail_p avp)
1984-11-26 13:43:22 +00:00
{
/* 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);
}
2018-02-05 21:09:30 +00:00
void OUTAVAILS(void)
1984-11-26 13:43:22 +00:00
{
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"
};
2018-02-05 21:09:30 +00:00
void OUTENTITIES(void)
1984-11-26 13:43:22 +00:00
{
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");
}
}
#endif /* TRACE */