Go to the first, previous, next, last section, table of contents.
This pass will print all the array instructions of a program.
#include <stdlib.h> #include <suif1.h> void do_instr(instruction * instr) { if(instr->format() == inf_array) instr->print(); for(int i=0; i<instr->num_srcs(); i++) { operand op(instr->src_op(i)); if(op.is_instr()) do_instr(op.instr()); } } void each_tree_node(tree_node * tn, void * x) { if(tn->kind() == TREE_INSTR) { tree_instr * ti = (tree_instr *)tn; instruction * inst = ti->instr(); do_instr(inst); } } void do_proc(tree_proc * tp) { proc_sym * psym = tp->proc(); printf("%s \n", psym->name()); tp->map(each_tree_node, NULL); } main(int argc, char * argv[]) { start_suif(argc, argv); suif_proc_iter(argc, argv, do_proc); }
TARGET = prog2 LIBS = -lsuif1 SRCS = prog2.cc OBJS = prog2.o all: prog2 install-bin: install-prog include $(SUIFHOME)/Makefile.std
Let's use the following input file:
double A[10000]; double B[100][100]; test1(int IU, int JU, int KU) { int i, j, k; for(i=0; i<IU; i++) for(j=0; j<JU; j++) { for(k=8; k<KU; k++) A[k] = A[k-8]; B[i][j] = B[i+1][j] + A[i]; } for(i=0; i<IU; i++) for(j=0; j<JU; j++) B[i][j] = B[i][j] + B[i+1][j]; } test2( int KU) { int k; for(k=8; k<KU; k++) A[k] = A[1] + A[k] + A[k-8]; }
csh> prog2 input2.spd test1 16: array t:g37 (p.32) e1+0, size(64), index(test1.k), bound(e2) 17: e1: ldc t:g36 (p.32) <.A,0> 18: e2: ldc t:g4 (i.32) 10000 19: array t:g37 (p.32) e1+0, size(64), index(e2), bound(e3) 20: e1: ldc t:g36 (p.32) <.A,0> 21: e2: sub t:g17 (i.32) test1.k, e4 22: e4: ldc t:g17 (i.32) 8 23: e3: ldc t:g4 (i.32) 10000 32: array t:g37 (p.32) e1+0, size(64), index(test1.i, test1.j), bound(e2, e3) 33: e1: ldc t:g38 (p.32) <.B,0> 34: e2: ldc t:g4 (i.32) 100 35: e3: ldc t:g4 (i.32) 100 38: array t:g37 (p.32) e1+0, size(64), index(e2, test1.j), bound(e3, e4) 39: e1: ldc t:g38 (p.32) <.B,0> 40: e2: add t:g17 (i.32) test1.i, e5 41: e5: ldc t:g17 (i.32) 1 42: e3: ldc t:g4 (i.32) 100 43: e4: ldc t:g4 (i.32) 100 45: array t:g37 (p.32) e1+0, size(64), index(test1.i), bound(e2) 46: e1: ldc t:g36 (p.32) <.A,0> 47: e2: ldc t:g4 (i.32) 10000 70: array t:g37 (p.32) e1+0, size(64), index(test1.i, test1.j), bound(e2, e3) 71: e1: ldc t:g38 (p.32) <.B,0> 72: e2: ldc t:g4 (i.32) 100 73: e3: ldc t:g4 (i.32) 100 76: array t:g37 (p.32) e1+0, size(64), index(test1.i, test1.j), bound(e2, e3) 77: e1: ldc t:g38 (p.32) <.B,0> 78: e2: ldc t:g4 (i.32) 100 79: e3: ldc t:g4 (i.32) 100 81: array t:g37 (p.32) e1+0, size(64), index(e2, test1.j), bound(e3, e4) 82: e1: ldc t:g38 (p.32) <.B,0> 83: e2: add t:g17 (i.32) test1.i, e5 84: e5: ldc t:g17 (i.32) 1 85: e3: ldc t:g4 (i.32) 100 86: e4: ldc t:g4 (i.32) 100 test2 8: array t:g37 (p.32) e1+0, size(64), index(test2.k), bound(e2) 9: e1: ldc t:g36 (p.32) <.A,0> 10: e2: ldc t:g4 (i.32) 10000 14: array t:g37 (p.32) e1+0, size(64), index(e2), bound(e3) 15: e1: ldc t:g36 (p.32) <.A,0> 16: e2: ldc t:g17 (i.32) 1 17: e3: ldc t:g4 (i.32) 10000 19: array t:g37 (p.32) e1+0, size(64), index(test2.k), bound(e2) 20: e1: ldc t:g36 (p.32) <.A,0> 21: e2: ldc t:g4 (i.32) 10000 23: array t:g37 (p.32) e1+0, size(64), index(e2), bound(e3) 24: e1: ldc t:g36 (p.32) <.A,0> 25: e2: sub t:g17 (i.32) test2.k, e4 26: e4: ldc t:g17 (i.32) 8 27: e3: ldc t:g4 (i.32) 10000
Go to the first, previous, next, last section, table of contents.