1 /* Read and display a SUIF version 1.x file (or a set of SUIF version 1.x
4 /* Copyright (c) 1994 Stanford University
8 This software is provided under the terms described in
9 the "suif_copyright.h" include file. */
11 #include <suif_copyright.h>
13 #define RCS_BASE_FILE printsuif_cc
19 "$Id: printsuif.cc,v 1.2 1999/08/25 03:27:38 brm Exp $")
21 INCLUDE_SUIF_COPYRIGHT
25 static boolean
delete_dummy_srcs(instruction
*, operand
*r
, void *);
28 int main(int argc
, char *argv
[])
30 boolean ftn_mode
= FALSE
;
31 boolean exp_trees
= TRUE
;
34 start_suif(argc
, argv
);
36 /* check for command-line arguments */
38 while ((*argv
!= NULL
) && (**argv
== '-')) {
39 if (!strcmp(*argv
, "-ftn")) {
41 } else if (!strcmp(*argv
, "-no-exprs")) {
43 } else if (!strcmp(*argv
, "-raw")) {
44 /* set the library's raw_syms flag (if TRUE the symtab
45 lookup_sym_id and lookup_type_id methods will create dummy
46 sym_nodes/type_nodes for unknown ids) */
47 _suif_raw_syms
= TRUE
;
48 } else if (!strcmp(*argv
, "-mach")) {
50 } else if (!strcmp(*argv
, "-print-flat")) {
51 _suif_flat_annotes
= TRUE
;
52 } else if (!strcmp(*argv
, "-no-types")) {
53 _suif_no_types
= TRUE
;
54 } else if (!strcmp(*argv
, "-no-symtabs")) {
55 _suif_no_symtabs
= TRUE
;
61 if (argc
< 1) usage();
65 if (!_suif_raw_syms
) {
67 fileset
->add_file(*argv
, NULL
);
71 in_stream
*is
= new in_stream(lexicon
->enter(*argv
)->sp
);
74 printf("******************** FILE %s ********************\n",
77 global_symtab
*syms
= new global_symtab(is
->name());
80 /* read and print the file as a list of instructions */
81 while ((i
= instruction::read(is
, syms
, NULL
))) {
83 i
->src_map(delete_dummy_srcs
, NULL
);
93 if (!_suif_raw_syms
) {
96 /* print the target machine parameters */
97 target
.print(stdout
, 2);
98 fputs("\n\n", stdout
);
101 if (!_suif_no_symtabs
) {
102 printf(" ****************** GLOBALS ******************\n");
103 fileset
->globals()->print(stdout
, 2);
104 fputs("\n\n", stdout
);
107 fileset
->reset_iter();
109 while ((fse
= fileset
->next_file())) {
110 printf(" ****************** FILE %s ******************",
112 if (fse
->are_annotations()) fse
->print_annotes(stdout
, 2);
113 if (!_suif_no_symtabs
) {
115 fse
->symtab()->print(stdout
, 2);
121 fse
->reset_proc_iter();
122 while ((psym
= fse
->next_proc())) {
123 fputs("\n\n", stdout
);
124 psym
->read_proc(exp_trees
, ftn_mode
);
125 psym
->block()->print(stdout
, 2);
129 fputs("\n\n", stdout
);
141 fprintf(stderr
, "Usage: printsuif [flags] suif1_files\n");
142 fprintf(stderr
, "Flags:\n");
143 fprintf(stderr
, "\t-ftn\t\tFortran mode; use call-by-ref params\n");
144 fprintf(stderr
, "\t-no-symtabs\tdon't print the symbol tables\n");
145 fprintf(stderr
, "\t-no-types\tomit instruction result types\n");
146 fprintf(stderr
, "\t-no-exprs\tuse flat instruction lists\n");
147 fprintf(stderr
, "\t-print-flat\tprint annotations as flat immed lists\n");
148 fprintf(stderr
, "\t-raw\t\tprint raw instruction list for debugging\n");
149 fprintf(stderr
, "\t-mach\t\tshow the target machine parameters\n");
155 delete_dummy_srcs (instruction
*, operand
*r
, void *)
159 delete r
->instr()->parent();