Next: Types, QualifiedTypes, and DataTypes
Up: An introduction to the
Previous: The overall structure
  Contents
Scoping and Global Symbols
The SUIF system captures the scoping information in the source
program by using a nesting of symbol tables. The two
SymbolTable fields in the FileSetBlock hold
the outermost scope:
- external_symbol_table holds the
symbols and types visible to the outside, and
- file_set_symbol_table holds the
symbols and types visible to the code in this file set.
The next level in the hierarchy are the
symbol_tables belonging to
FileBlocks. They contain all the symbols local to a
single file. For example, C static symbols will be placed in
this symbol table.
Figure 2:
Example 1 Output using the Suifprinter Style (a)
************* EXTERNALS *************
External Symbol Table
type:t0: bool 32 align:32
type:t1: void 0
type:t2: int signed:0 32 align:32
type:t3: int signed:1 32 align:32
type:t4: int signed:1 8 align:8
type:t5: int signed:0 8 align:8
type:t6: int signed:1 16 align:16
type:t7: int signed:0 16 align:16
type:t8: float 32 align:32
type:t9: float 64 align:32
type:t10: float 64 align:64
type:t11: qual of @t3:i.32 qualifications:<None>
var_sym:t12: "i" with t:@t11:q.(@t3:i.32) addrTaken:0
<None>
var_sym:t13: "l" with t:@t11:q.(@t3:i.32) addrTaken:0
<None>
var_sym:t14: "j" with t:@t11:q.(@t3:i.32) addrTaken:0
<None>
type:t15: array [(@t3:i.32) 0..(@t3:i.32) 2] of @t11:q.(@t3:i.32)
type:t16: qual of @t15:a[] qualifications:<None>
type:t17: ptr 32 align:32 to @t11:q.(@t3:i.32)
type:t18: qual of @t17:p.32 qualifications:<None>
type:t19: qual of @t3:i.32 qualifications:const
type:t20: Cfunc(@t18:q.(@t17:p.32), @t19:q.(@t3:i.32))
vararg:0 argknwn:1 algn:0 ret:@t3:i.32
proc_sym:t21: "proc" with t:@t20:f((@t3:i.32)()) addrTaken:0
<None>
type:t22: ptr 32 align:32 to @t16:q.(@t15:a[])
type:t23: array [(@t3:i.32) 0..(@t3:i.32) 0] of @t11:q.(@t3:i.32)
type:t24: qual of @t23:a[] qualifications:<None>
type:t25: ptr 32 align:32 to @t24:q.(@t23:a[])
************* GLOBALS *************
Global Symbol Table
<None>
|
|
Our sample program declares four variables in different ways. Each of
these has a different meaning in C. The first variable, i,
is declared extern. The second variable, l, is also
externally visible but is not declared extern. These are actually
different declarations in C with different semantics. The third
variable, j, is given an initial value. All three of these
variables are placed in the external symbol table, as they are all
visible outside of this SUIF file. The definition of j is
found in the definition block in a file block. Finally, the variable
a is declared static, and can thus be found in the symbol
table for the file block. There are no symbols in the file set symbol
table, the table containing objects that are visible across
compilation units that have been incorporated into this SUIF file but
which are not externally visible. This is because there are no such
symbols in C. If one was compiling a module in Ada which contained
child modules, then there might be entries in this symbol table.
One more thing needs to be observed about variable declarations. The
type of symbol, must be no more deeply nested than the declaration of
the variable. For the purposes of this rule, the file set symbol table
is considered to be nested inside the external symbol table.
Figure 3:
Example 1 Output using the Suifprinter Style (b)
************* FILE ex.cpp.cil *************
Annotes:
<None>
Symbol Table:
var_sym:t26: "a" with t:@t16:q.(@t15:a[]) addrTaken:1
<None>
Definition Block:
Variable Definitions:
@t13:(@t11:q.(@t3:i.32)) "l" =
@t14:(@t11:q.(@t3:i.32)) "j" = ExprVal: (@t3:i.32) 0
@t26:(@t16:q.(@t15:a[])) "a" =
Procedure Definitions:
PROC @t21:"proc"
<None>
Proc Symbol Table:
param_sym:t27: "k" with t:@t18:q.(@t17:p.32) addrTaken:0
<None>
param_sym:t28: "i" with t:@t19:q.(@t3:i.32) addrTaken:0
<None>
Definitions:
Variable Definitions:
<None>
Procedure Definitions:
<None>
Annotes:
<None>
Args:
@t27:(@t18:q.(@t17:p.32)) "k"
@t28:(@t19:q.(@t3:i.32)) "i"
Body:
STR <dst> = <src>
<dst>: (@t17:p.32) array <base> [ <idx> ]
<base>: (@t25:p.32) convert <exp>
<None>
<exp>: (@t22:p.32) SYMADDR @t26:(@t16:q.(@t15:a[])) "a"
<None>
<idx>: (@t3:i.32) @t28:(@t19:q.(@t3:i.32)) "i"
<src>: (@t3:i.32) <e1> add <e2>
<None>
<e1>: (@t3:i.32) LOADEXP <addr>
<addr>: (@t17:p.32) @t27:(@t18:q.(@t17:p.32)) "k"
<e2>: (@t3:i.32) @t14:(@t11:q.(@t3:i.32)) "j"
RET <retval>
<retval>: (@t3:i.32) @t14:(@t11:q.(@t3:i.32)) "j"
PROC END @t21:"proc"
Annotes:
<None>
|
|
Next: Types, QualifiedTypes, and DataTypes
Up: An introduction to the
Previous: The overall structure
  Contents
SUIF Nightly Build
2000-08-14