Go to the previous, next section.

Example 1 - Print Procedure Names

This program is a SUIF pass that will print the procedure names of all the procedures in the input program.

prog1.cc

#include <stdlib.h>
#include "suif.h"

void do_proc(tree_proc * tp)
{
    proc_sym * psym = tp->proc();
    printf("%s \n", psym->name());
}

main(int argc, char * argv[])
{
    start_suif(argc, argv);
    suif_proc_iter(argc, argv, do_proc);
}

Makefile

TARGET = prog1
LIBS =		-lsuif -lm
SRCS =		prog1.cc
OBJS =		prog1.o

all:		prog1
install-bin:	install-prog

include $(SUIFHOME)/Makefile.std

Compiling the program

csh> gmake
g++ -c -g -Wall  -I/suif/suif/suifhome/include   prog1.cc
g++ -o prog1 -g -Wall  -I/suif/suif/suifhome/include   prog1.o suif_init.o \
                 -L/suif/suif/suifhome/mips-dec-ultrix/lib  -lsuif -lm prog_ver.cc
csh>

Testing the pass

Let's use the following input file:

input1.c

test1() {  }
test_program() {  }
foo() {  }
bar() {  }

Test session

csh> scc -V -.spd input1.c
CPP: /suif/suif/suifhome/mips-dec-ultrix/bin/cpp -D__SCC__ -D__LANGUAGE_C -D__unix 
-D__host_m ips -D__mips -D__MIPSEL   -I/suif/suif/suifhome/mips-dec-ultrix/include 
-nostdinc -I/usr/include input1.c /tmp/scc09665_0.i
SNOOT: /suif/suif/suifhome/mips-dec-ultrix/bin/snoot   /tmp/scc09665_0.i 
/tmp/scc09665_1.snt
PORKY_DEFAULTS: /suif/suif/suifhome/mips-dec-ultrix/bin/porky -defaults  
/tmp/scc09665_1.snt input1.spd
csh> prog1 input1.spd
test1
test_program
foo
bar
csh>

Go to the previous, next section.