1 / 20

An Overview of the SUIF2 System

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.

dbleich
Download Presentation

An Overview of the SUIF2 System

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Overview of the SUIF2 System Monica Lam Stanford University http://suif.stanford.edu/

  2. The SUIF System PGI Fortran EDG C++ Java Interprocedural Analysis Parallelization Locality Opt Inst. Scheduling Register Allocation SUIF2 C Alpha x86

  3. 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

  4. 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

  5. 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

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

  7. Executable suifdriver Passes IR suifnodes analyses optimizations basicnodes Kernel suifkernel iokernel The SUIF Architecture MODULES:

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

  9. 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

  10. 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

  11. 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

  12. 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

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

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

  15. 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

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

  17. 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

  18. 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

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

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

More Related