Title: An Overview of the SUIF2 System
1An Overview of the SUIF2 System
- Monica Lam
- Stanford University
- http//suif.stanford.edu/
2Team Members
- Stanford University
- Monica Lam
- Gerald Aigner
- Gerald Cheong
- Amer Diwan
- David Heine
- Amy Lim
- Vladimir Livshits
- Virendra Mehta
- Brian Murphy
- Costa Sapuntzakis
- Hansel Wan
- Chris Wilson
- Harvard
- Michael Smith
- Erven Rohou
- Glenn Holloway
- Gang Chen
- Eric Feigin
- Nick Gloy
- Stuart Schechter
- Jason Simmons
- Omri Traub
- Cliff Young
- UCSB
- Urs Hoelzle
- Andrew Duncan
- Bogdan Cocosel
- Holger Kienle
- Kristian Kvilekval
- Kevin Ogorman
- Prashanth Ramdas
- Radu Rugina
- Andrew Rutz
- Portland Group
- David Moore
- Vince Shuster
- Deb Caruso
- David Wohlford
- Bob Scollard
3The SUIF System
PGI Fortran
Java
EDG C
Interprocedural Analysis Parallelization Locality
Opt
Inst. Scheduling Register Allocation
SUIF2
Alpha
x86
C
4Overview of SUIF Components
Basic Infrastructure Extensible IR and
utilities Modular compiler system Pass
submodule
PGI Fortran, EDG C/C, Java FE Standard IR,
OSUIF (for OO lang) Hoof Suif object
specification language SUIF1 / SUIF2
translators Statement dismantlers Suifbrowser
Backend Infrastructure Optimization
framework
Register allocation Scheduling Alpha and x86
backends
HL Analysis Infrastructure Graphs, sccs
Presburger arithmetic (omega) Farkas
lemmaGaussian Elimination Interprocedural
framework Garbage collection (Boehms)
Call graph Affine partitioning for parallelism
locality Steensgaards alias analysis Interprocedu
ral parallelization array/scalar
dependence/privatization
5Motivation for Extensible IR
- Suif1 design
- A fixed set of flat C classes
- All codes must change if we add new IR nodes
- e.g. printing objects, reading and writing to
file - Higher level semantic objects
- OSUIF (for object-oriented programming)
- Verilog event-driven control flow semantics
- Saturated arithmetic used in multimedia
instruction sets - Program analysis concepts
- phi nodes in SSA analysis
- synchronization operations introduced by
parallelization - Results of analysis
6Concept I Reflective IR
- Metaclass captures representation of IR nodes in
a data structure - Enables common generic routines to implement
- Persistence reading/writing to disk
- Cloning routine that copies the data structure
- Printing a generic routine to print out the
information - Walkers, iterators, visitors
7Concept IIObject hierarchy virtual aggregate
fields
- Abstract names to refer to fundamental concepts
in subclasses - e.g. get_child_statements
- IfStatement get_then_part and get_else_part, or
- WhileStatement get_body
8Object hierarchy virtual aggregate fields
- Maximize reuse and modular code development
- Write code that operates at the highest level of
abstraction - A pass works, without recompilation, for code
with new subclasses if new refinements are
immaterial to a pass. - The unknown information is maintained across a
pass - Example
- Reuse an intraprocedural dead code elimination
written for SUIF on OSUIF (object-oriented SUIF)
code
9Concept III Multiple Representations for
High-Level Analyses
- Multiple representations for different semantic
levels - e.g. FOR loops versus basic blocks in a control
flow graph - gt Alternative representations
- Mixture of high-level and low-level constructs
- Dismantlers lower the representation
10Concept IV High-level object specification
Insulates user from details
Object Definition (.hoof)
SUIF Macro Generator a general grammar-based tool
Meta-Class System reading writing to file in
machine-independent format
Interface for user (.h) Implementation in
Meta-Class System (.cpp)
- Easy for the programmer
- Easy for the implementor to develop the system
11Example of a Hoof Definition
C
class New public SuifObject public int
get_x() void set_x(int the_value)
New() void print() static const Lstring
get_class_name()
hoof
concrete New int x
- Uniform data access functions (get_ set_)
- Automatic generation of meta class information
etc.
12Examples of Suif Nodes
- abstract Statement ExecutionObject
-
- virtual listltStatement ownergt
child_statements - ...
-
- concrete IfStatement Statement
-
- Expression condition in source_ops
- Statement owner then_part in
child_statements - Statement owner else_part in
child_statements -
13Motivation for a Modular Compiler System
- SUIF1
- All passes read and write suif files more
modular and supportive of experimentation - but it is slow
- Data between passes are written out as
annotations - Annotations must be expressed as strings when
written out - Requires manual pickling of annotations
- Nontrivial effort to support any interactivity
14SUIF2Concept I A Modular Compiler Architecture
MODULES
15Components
- Kernel provides all basic functionality
- iokernel implements I/O
- suifkernel hides iokernel and provides modules
support, cloning, command line parsing, list of
factories, etc. - Modules
- passes provides a pass framework
- IR basic program representations
- Suifdriver
- provides execution control over modules and passes
16Memory/Memory vs File/File Passes
COMPILER
A driver that imports applies modules to
program in memory
A series of stand-alone programs
Suif-file1
Suif-file1
drivermodule1
Suif-file2
Suifdriver imports/executes module1 module2
module3
drivermodule2
Suif-file3
drivermodule3
Suif-file4
Suif-file4
17Concept II Dynamic Registration of Modules
- Compilation State SuifEnv
- Keeps the loaded SUIF program
- All the registered modules
- A module is a C class
- that implements either a pass or a set of nodes
in IR - must have a unique module_name
- one or more modules make up a dll (dynamically
linked library) - each library includes a function (init_ltdllnamegt)
to register the module dynamically
18Dynamic Assembly of a Compiler
- gt suifdriver
- suifgt import basicnodes suifnodes
- suifgt import mylibrary
- suifgt load test.suif
- suifgt mylibrary_pass1
- suifgt print test.out
- suifgt save test.tsuif
- The Suifdriver
- accepts a simple scripting language. (A version
that accepts tcl/tk also exists). - pre-registered modules (import, load, print,
save) - imports libraries dynamically which can register
new modules (new commands) - System can easily be used for demand-driven
program analysis e.g. SUIF explorer or a debugger
19Concept III Easy to write a new analysis
subclass of a pass module
Executable
suifdriver
IR
Passes
suifnodes
analyses optimizations
basicnodes
Kernel
suifkernel
iokernel
20Example Pass Count Statements in Procedures
- class mypass public Pass
- public
- mypass(SuifEnv env, const Lstring name)
Pass(env, name) - virtual mypass()
- Module clone() const return(Module) this
- void do_procedure_definition (ProcedureDefinition
proc_def) -
- cout ltlt proc_def-gtget_procedure_symbol()
-gtget_name() - cout ltlt object_iteratorltExecutionObjectgt(proc_
def).length() -
-
- extern C void init_mypass (SuifEnv suif_env)
- suif_env-gtget_module_subsystem()-gtregister_module
- (new mypass (suif_env, mypass))
-
21Research Infrastructure Support at 3 Levels
- I. Compose compiler with existing passes
- Dynamic composition of different passes
- II. Develop new passes
- User concentrates on algorithmic issues
- Infrastructure provides common functionalities
- Write code once, can run on SUIF program in
memory or a file - III. Develop new IR
- High-level specification of the IR nodes
- Old code works with new IR without recompilation
22Deliverables
- Infrastructure basesuif system
- Components Front ends and passes
- Testing
- Documentation
23Basic Infrastructure (Beta release)
- SUIF object system
- I/O, printing, cloning
- Visitors dispatch method according to type
- Iterators simple iteration of certain objects
- Walkers user-controllable traversal of data
structures - Module subsystem
- Hoof language implementation
- Standard IR representation
- General data structures
- Infinite precision integers, strings
- lists, sets, hash maps
- assertion, error handling, command line parsing
- SuifBrowser
- Presents the source and SUIF code
24Compiler components C
- EDG C front end -gt SUIF
- Created cfenodes to represent C constructs, which
are then lowered - SUIF -gt C
- SUIF1 -gt SUIF -gt SUIF1
- Enables SUIF1 users to use old SUIF1 passes in
the compiler - Testing
- PGI unit tests
- 16 errors out of gt 3000 tests
- Spec95int all but gcc work. (gcc not Ansi C, we
are working on it).
EDG C
lcc C
SUIF cfenodes
SUIF1
SUIF
C
SUIF1
25Object-oriented Languages C and Java
j2s
EDG C
- OSUIF object-extension of SUIF (for Java and
C) - Types classes, methods and fields
- Symbols fields methods
- SymbolTable class-specific behavior for member
lookup - Statements exception handling object-oriented
instructions - EDG C -gt SUIF (on track)
OSUIF
SUIF
C
26Java
- no threads, exception handling, dynamic loading
- Java byte code-gt OSUIF (Solaris)
- Class loading, resolution of the constant pool
- Control flow analysis (normal and exception
handling) - Data flow analysis (construct type information)
- OSUIF code generation
- OSUIF -gt SUIF
- build-vtables virtual tables
- lower-instance-variables layout of class-types
- lower-methods method dispatch
- lower-static-fields, lower-static-methods put
static in global scope - Testing compiled JDK 1.2beta2 javac compiler
538 Java classes
27Fortran front end
- Based on PGIs proprietary front end
- PGI Fortran includes F90 and HPF only the F77
subset is translated to SUIF - To be released only in binary form
- Alpha version delivered to Stanford, not yet
released
28Documentation
- The SUIF2 Infrastructure Guide (an index to all
documentation) - Overview of the SUIF Infrastructure
- The SUIF Representation Guide
- The Basic SUIF Programmers Guide
- The SUIF System Programmers Reference Manual
- All the high-level interfaces documented
(example) - Generated from the .h files by Doxygen
- All the cross references, e.g. class hierarchy
information - Web page http//suif.stanford.edu/
29The End
30Overview of SUIF Components
Basic Infrastructure Extensible IR and
utilities Modular compiler system Pass
submodule
PGI Fortran, EDG C/C, Java FE Standard IR,
OSUIF (for OO lang) Hoof Suif object
specification language SUIF1 / SUIF2
translators Statement dismantlers Suifbrowser
Backend Infrastructure Optimization
framework
Register allocation Scheduling Alpha code
generator, x86 code generator
HL Analysis Infrastructure Graphs, sccs
Presburger arithmetic (omega) Farkas
lemmaGaussian Elimination Interprocedural
framework Garbage collection (Boehms)
Call graph Affine partitioning for parallelism
locality Steensgaards alias analysis Interprocedu
ral parallelization array/scalar
dependence/privatization
Pre-release
In progress
31Comments
- Will never implement such a system if not for
the infrastructure project - Enables safe type casting of objects
- All objects created via factories
- Owner edges embed a tree into program
representation