SUIF1 Versus SUIF2 - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

SUIF1 Versus SUIF2

Description:

Each pass is an independent program that reads/writes SUIF in a file ... Traversing and manipulating data structures. Visitors: dispatch method according to type ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 25
Provided by: monic6
Category:

less

Transcript and Presenter's Notes

Title: SUIF1 Versus SUIF2


1
SUIF1 Versus SUIF2
  • February 18, 2002
  • presented by
  • Amit Jain

2
The SUIF1 System
C
Fortran
SUIF1
MIPS(R3000)
C
3
The SUIF2 System
C
Java
C
Fortran
SUIF2
Alpha
x86
C
4
SUIF1 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
5
SUIF2 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


6
Continued.
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
7
SUIF1 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

8
SUIF2 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

9
SUIF1 Architecture
Set of Passes
Kernel
10
SUIF2 Architecture
MODULES
11
SUIF2 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

12
SUIF2 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)

13
SUIF2 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

14
SUIF2 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

15
SUIF2 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))

16
SUIF2 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

17
SUIF1 IR Design
fileset
fileset entry
fileset entry
tree proc
tree proc
tree node list
tree block
tree for
tree if
tree instr
tree loop
18
SUIF2 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

19
SUIF2 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

20
SUIF2 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

21
Insulating 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

22
Example 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.

23
Examples 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

24
Documentation
  • http//suif.stanford.edu
Write a Comment
User Comments (0)
About PowerShow.com