next up previous contents
Next: Scoping and Global Symbols Up: An introduction to the Previous: An introduction to the   Contents

The overall structure

The root node of a SUIF program representation is an instance of the FileSetBlock. It has one or more FileBlocks, each of which corresponds to a single compilation unit. Each FileBlock itself contains symbol tables and procedure definitions and so forth. While the program representation is a collection of objects which may point to each other, embedded within the graph is an ownership tree. That is, every object in a SUIF IR has precisely one owner. This IR tree is very useful, as it guarantees that all nodes are visited exactly once if in visiting a node we visit each of the objects it owns.

You can examine the structure of a program by using the print method provided by the SUIF system to get a textual version of the representation. Suppose you have a file called ex1.suif with the programming code:      extern int i;
     int l;
     int j = 0;
     static int a[3];
     int proc(int *k,const int i)
         a[i] = *k + j;
         return j;
By running

    suifdriver -e ``import basicnodes suifnodes; load ex1.suif; print -o ex1.out''
we get a print out in the file ex1.out, whose first 20 lines are shown in Figure 1.

Figure 1: Textual Representation of Example 1 (First 20 Lines)

The print function will traverse the ownership tree qin the representation and dump out all the information there is on the nodes. It prints out a node's class name (which includes the names of all the classes the node is derived from), its field names and their contents. If a field contains a SuifObjects the node owns, the printer will recursively print out the detailed information of the owned node. The output can be quite long as a result; for example, the textual representation of the short example above has over 500 lines.

The class names are shown in braces. The name of each class is output before the contents of that type's fields. When a class is derived, the name of the most derived class is printed, followed by the fields defined in that derivation, then the name of its parent, and its fields, and so on. So, in the above example, BooleanType is derived from NumericType which is derived from DataType which is derived from Type.

The print out is verbose but complete, making it a useful aid for understanding the structure of the representation. Once we are familiar with the structure, we would like to concentrate mainly on the contents. For that reason the SUIF system comes with an alternate printing style for all the basic nodes that display in the program in a more readable format. Simply import the suifprinter before printing the representation, and you will get the output shown in Figures 2 and  3.

next up previous contents
Next: Scoping and Global Symbols Up: An introduction to the Previous: An introduction to the   Contents
SUIF Nightly Build