1 /* $Id: show.c,v 1.13 1995/11/08 11:09:14 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
8 /* This program can be used to make the output of the 'cf' pass
9 * human readable. It will display either the procedure table,
10 * the datablock table, the basic block table or the EM text,
11 * depending on the flag that is passed as first argument.
31 #define space1() printf(" ")
32 char format[] = " %-11s%d\n";
33 char lformat[] = " %-11s%ld\n";
34 char sformat[] = " %-10s%s\n";
35 char dformat[] = " %-11s%d\n";
36 char oformat[] = " %-11s%ld\n";
40 FILE *f; /* input file */
43 #define getbyte() getc(f)
58 n = getshort() & 0xFFFF;
59 n |= ((offset) getshort() ) << 16;
66 /* Read an integer from the input file. This routine is
67 * only used when reading a bitvector-set. We expect an
68 * integer to be either a short or a long.
71 if (sizeof(int) == sizeof(short)) {
80 error(s,a) char *s,*a; {
82 fprintf(stderr,"error");
93 if (argc != 3 || argv[1][0] != '-') {
94 error("usage: %s -[ldpbc] filename",argv[0]);
96 if ((f = fopen(argv[2], "r")) == NULL) {
97 error("cannot open %s", argv[2]);
126 /* print a compact (bitvector) set */
133 /* # significant bits in bitvector */
143 for (j = 1; j <= sizeof(int)*8; j++) {
163 printf("total number of procs: %d\n\n",getshort());
169 printf(format,"id =",n);
170 printf(format,"flags1 =",b = getbyte());
171 if (b & PF_BODYSEEN) {
172 printf(format,"# labels =",getshort());
173 printf(lformat,"# locals =",getoff());
174 printf(lformat,"# formals =",getoff());
176 printf(" changed ="); showcset();
177 printf(format,"c_flags =",getshort());
178 printf(format,"u_flags =",getshort());
179 printf(" calling ="); showcset();
182 printf(" body not available\n");
188 char *pseudo[5] = {"hol", "bss", "rom", "con", "unknown" };
193 printf("total number of objects: %d\n\n",getshort());
200 printf(format,"id =",getshort());
201 printf(sformat,"pseudo =",
202 pseudo[(short) getbyte()]);
203 printf(lformat,"size =",getoff());
204 printf(format,"fragment =",getshort());
205 printf(format,"flags1 =",
211 printf(format,"id =",getshort());
213 printf(lformat,"size =",getoff());
215 printf(lformat,"offset =",getoff());
220 printf(lformat,"offset =",getoff());
227 /* The mnemonics of the EM instructions and pseudos */
230 extern char em_mnem[];
231 extern char em_pseu[];
232 char lab_mnem[] = "instrlab";
233 char sym_mnem[] = "datalab";
240 instr = (short) getbyte();
241 if (feof(f)) return FALSE;
242 if (instr >= sp_fmnem && instr <= sp_lmnem) {
243 s = &(em_mnem[(instr-sp_fmnem) *4]);
245 if (instr == op_lab) {
248 if (instr == ps_sym) {
251 s = &(em_pseu[(instr-sp_fpseu)*4]);
256 switch((short) getbyte()) {
259 printf(" %d", getshort());
262 printf(" $%d",getshort());
265 printf(" *%d",getshort());
268 printf(" %ld", getoff());
290 switch((short) getbyte()) {
292 printf(" %d", getshort());
295 printf(" $%d",getshort());
298 printf(" *%d",getshort());
301 printf(" %ld", getoff());
306 printf(" %d",getshort());
307 /* Fall through !! */
330 while (x = getshort()) {
341 /* basic block file */
349 printf("Declaration Unit:\n");
350 printf(dformat,"#instrs =",getshort());
354 printf("Control Flow Graph:\n");
355 printf("number of basic blocks: %d\n",n);
356 m = getshort(); /* #loops */
358 printf(" BASIC BLOCK\n");
359 printf(dformat,"id =",getshort());
360 printf(dformat,"# instrs =",getshort());
365 printf(dformat,"idom =",getshort());
368 printf(dformat,"flags =",getshort());
370 printf("number of loops: %d\n",m);
373 printf(dformat,"id =",getshort());
374 printf(dformat,"level =",getshort());
375 printf(dformat,"entry =",getshort());
376 printf(dformat,"end =",getshort());
391 printf("CALL %d\n",cnt++);
392 printf(format,"nestlevel =",t);
393 printf(format,"calling p. =",getshort());
394 printf(format,"call_id =",getshort());
395 printf(format,"called p. =",getshort());
396 printf(format,"looplevel =",getbyte());
397 printf(format,"flags =",getbyte());
398 printf(format,"ratio =",getshort());
407 printf(oformat,"size =",getoff());
408 printf(dformat,"inl =",getbyte());