Title: SUIF1 Versus SUIF2
1 SUIF1 Versus SUIF2
- February 18, 2002
- presented by
- Amit Jain
2The SUIF1 System
C
Fortran
SUIF1
MIPS(R3000)
C
3The SUIF2 System
C
Java
C
Fortran
SUIF2
Alpha
x86
C
4SUIF1 Pass execution
- Each pass is an independent program that
reads/writes SUIF in a file - Advantages visibility of intermediate results
- Disadvantages expensive disk access
Suif-file 1
Suif-file N
Pass 1
Pass N
Suif-file 2
Suif-file N1
5SUIF2 Pass execution
- simple development, efficient deployment
- can run on program on disk or in memory
- How? A pass a common driver moduleA
compound passa common driver series of modules
loaded dynamically - pipelining passes
6Continued.
COMPILER
A driver that imports applies modules to
program in memory
A series of stand-alone programs
Suif-file1
Suif-file1
drivermodule1
Suifdriver imports/executes module1 module2
module3
Suif-file2
drivermodule2
Suif-file3
drivermodule3
Suif-file4
Suif-file4
7SUIF1 Support Level
- New passes development
- Developer concentrates on algorithmic issues
- Infrastructure takes care of common
functionalities - Intermediate representation and the associated
tools - Generic data structures
8SUIF2 Support at 3 Levels
- 1. Compose compiler with existing passes
- Front ends passes
- Easy expression of compiler compositions
- 2. Develop new passes
- Developer concentrates on algorithmic issues
- Infrastructure takes care of common
functionalities - Standard intermediate representation and
associate tools - Common utilities and data structures
- 3. Develop new IR (new language constructs or
analysis) - Easy definition of IR nodes
- Old code works with new IR without recompilation
9SUIF1 Architecture
Set of Passes
Kernel
10SUIF2 Architecture
MODULES
11SUIF2 Architecture Components
- 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 using a scripting language
12SUIF2 Architecture Driver
- gt suifdriver
- suifgt import basicnodes suifnodes
- suifgt import mylibrary
- suifgt load test.suif
- suifgt mypass
- suifgt print test.out
- suifgt save test.tsuif
- Suifdriver
- accepts a simple scripting language
- pre-registered modules (import, load, print,
save) - loads libraries dynamically which can register
new modules (new commands)
13SUIF2 Develop a New Pass
- 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 lt-- Derive from
this framework - IR basic program representations
- Suifdriver
- provides execution control over modules and
passes using a scripting language
14SUIF2 Develop a New Pass...
- SuifEnv
- Program representation
- Object factories
- Subsystems
- A module is a C class
- that implements either a pass or a set of nodes
in IR - must have a unique module_name
- no global variables
- one or more modules make up a dll
- each library includes a function (init_ltdllnamegt)
to register all modules dynamically
15SUIF2 Example 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_m
odule - (new mypass (suif_env, mypass))
-
16SUIF2 Tools for writing passes
- Traversing and manipulating data structures
- Visitors dispatch method according to type
- Iterators simple iteration of certain objects
- Walkers user-controllable traversal of data
structures - Data structures
- Infinite precision integers
- strings
- lists, sets, hash maps
- assertion/error handling
17SUIF1 IR Design
fileset
fileset entry
fileset entry
tree proc
tree proc
tree node list
tree block
tree for
tree if
tree instr
tree loop
18SUIF2 IR Design
- Root Object
- Uniform functionality
- Fields accessed with get_ltfieldgt, and set_ltfieldgt
- printing
- I/O to disk
- cloning
- iterators
- walkers
- Memory management aid
- object creation via factories
- owner edges embed a tree into program
representation
19SUIF2 Code with Abstraction
ExecutionObject
Statement
get_child_statements
IfStatement
WhileStatement
get_then_part get_else_part
get_body
- Maximize reuse by abstract fields
- allow uniform access to different child
components
20SUIF2 Extending the IR
- Code written for a high-level IR works on refined
IR (without recompilation!) - Easy specification of new extensions
- Grammar-based specification
- Meta-class system
- Objects contain information describing
representation - If environment does not include definitions of
refinements - information retained even if methods are not
available - written out when representation saved
21Insulating the User from the Implementation
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
22Example of a Hoof Definition
- concrete New
- int x
- class New public SuifObject
-
- public
- int get_x()
- void set_x(int the_value)
- example()
- void print()
- static const Lstring get_class_name()
-
-
- Uniform data access functions (get_ set_)
- Automatic generation of meta class information
etc.
23Examples of IR Node in Hoof
- 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 -
24Documentation