an overview of the suif2 system l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
An Overview of the SUIF2 System PowerPoint Presentation
Download Presentation
An Overview of the SUIF2 System

Loading in 2 Seconds...

play fullscreen
1 / 20

An Overview of the SUIF2 System - PowerPoint PPT Presentation


  • 124 Views
  • Uploaded on

An Overview of the SUIF2 System. Monica Lam Stanford University http://suif.stanford.edu/. The SUIF System . PGI Fortran. EDG C++. Java. Interprocedural Analysis Parallelization Locality Opt. Inst. Scheduling Register Allocation. SUIF2. C. Alpha. x86.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'An Overview of the SUIF2 System' - trilby


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
an overview of the suif2 system

An Overview of the SUIF2 System

Monica Lam

Stanford University

http://suif.stanford.edu/

the suif system
The SUIF System

PGI Fortran

EDG C++

Java

Interprocedural Analysis

Parallelization

Locality Opt

Inst. Scheduling

Register Allocation

SUIF2

C

Alpha

x86

research infrastructure support at 3 levels
Research Infrastructure: Support at 3 Levels
  • I. Compose compiler with existing passes
    • Front ends + passes
    • Easy expression of compiler compositions (dynamically)
  • II. Develop new passes
    • User concentrates on algorithmic issues
    • Infrastructure takes care of common functionalities
    • Standard intermediate representation and associate tools
    • Common utilities and data structures
  • III. Develop new IR (new language constructs or analyses)
    • Easy definition of IR nodes
    • Old code works with new IR without recompilation
i compose compiler with existing passes
I: Compose Compiler with Existing Passes
  • Previous system
    • Each pass is an independent program that reads/writes SUIF in a file
    • Advantages: modular, visibility of intermediate results
    • Disadvantages: expensive disk access
  • New system
    • write code once, can run on program on disk or in memory
    • simple development, efficient deployment
    • How?
      • A pass = a common driver + module
      • A compound pass
        • a common driver + series of modules loaded dynamically
modular compiler system
Modular Compiler System

COMPILER

A driver that imports & applies

modules to program in memory

A series of stand-alone programs

Suif-file1

Suif-file1

driver+module1

Suif-file2

Suifdriver

imports/executes

module1

module2

module3

driver+module2

Suif-file3

driver+module3

Suif-file4

Suif-file4

suif driver
> suifdriver

suif> import basicnodes suifnodes

suif> import mylibrary

suif> load test.suif

suif> mylibrary_pass1

suif> print test.out

suif> 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)

SUIF Driver
the suif architecture

Executable

suifdriver

Passes

IR

suifnodes

analyses

optimizations

basicnodes

Kernel

suifkernel

iokernel

The SUIF Architecture

MODULES:

components
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
ii develop a new pass
II. 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 <-- Derive from this framework
    • IR: basic program representations
  • Suifdriver
    • provides execution control over modules and passes using a scripting language
compilation system suifenv modules
Compilation System = SuifEnv + Modules
  • SuifEnv:
    • Keeps the states of the compilation
    • Holds onto the representation (FileSetBlock) and the loaded 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
    • no global variables
    • one or more modules make up a dll
    • each library includes a function (init_<dllname>) to register all modules dynamically
    • Registration is based on a prototype object
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 << proc_def->get_procedure_symbol() ->get_name()

cout << object_iterator<ExecutionObject>(proc_def).length();

}

}

extern “C” void init_mypass (SuifEnv *suif_env) {

suif_env->get_module_subsystem()->register_module

(new mypass (suif_env, “mypass”));

}

Example Pass: Count Statements in Procedures
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

Tools for writing passes
program representation
Multiple representations for semantics at different abstraction levels

e.g. FOR loops or statement list with branches and jumps

High-level representation useful for high-level transformations

=> Superset representation:

mixture of high-level and low-level constructs

Dismantlers lower representation

Allow analysis to operate at different levels of abstraction

e.g. analysis may/may not care about specific arithmetic operators

=> Uses object-oriented class hierarchy

Program Representation
suif ir design

Object

SUIFObject

AnnotableObject

SymbolTable

ScopedObject

ExecutionObject

Statement

Expression

SUIF IR Design
  • Root: Object
  • Uniform functionality
    • Fields accessed with get_<field>, and set_<field>
    • printing
    • I/O to disk
    • cloning
    • iterators
    • walkers
  • Memory management aid:
    • object creation via factories
    • owner edges embed a tree into program representation
supports code with abstraction
Maximize reuse by abstract fields

allow uniform access to different child components

Supports Code with Abstraction

ExecutionObject

Statement

get_child_statements

IfStatement

WhileStatement

get_then_part

get_else_part

get_body

iii extending the ir
III. Extending the IR
  • Goals
    • Support extension by different research groups
      • Code written for a high-level IR should work on refined IR (without recompilation!)
    • Easy specification of new extensions
      • Grammar-based specification
  • How?
    • 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
insulating the user from the implementation
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
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.

Example of a Hoof Definition
examples of suif nodes
abstract Statement : ExecutionObject

{

virtual list<Statement* owner> child_statements;

...

}

concrete IfStatement : Statement

{

Expression * condition in source_ops;

Statement * owner then_part in child_statements;

Statement * owner else_part in child_statements;

}

Examples of Suif Nodes
documentation
Documentation
  • The SUIF2 Infrastructure Guide (an index to all documentation)
  • Overview of the SUIF Infrastructure
  • The SUIF Representation Guide
  • The Basic SUIF Programmer’s Guide
  • Web page: http://suif.stanford.edu/suif2