Parasol.tamu.edu/courses/minipolaris. What is Polaris? Polaris is a source to source transforming compiler, originally developed at UIUC, intended to.

Slides:



Advertisements
Similar presentations
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Advertisements

ITEC113 Algorithms and Programming Techniques
CPSC Compiler Tutorial 9 Review of Compiler.
Chih-Hung Wang Chapter 2: Assembler (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
Chapter 10.
1 Semantic Processing. 2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice.
CS1061 C Programming Lecture 2: A Few Simple Programs A. O’Riordan, 2004.
Program Design and Development
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
Statement-Level Control Structures Sections 1-4
Guide To UNIX Using Linux Third Edition
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
Computer Science 101 Introduction to Programming.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Computer Science 101 Introduction to Programming.
LANGUAGE TRANSLATORS: WEEK 24 TRANSLATION TO ‘INTERMEDIATE’ CODE (overview) Labs this week: Tutorial Exercises on Code Generation.
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Dr. Andy Seddon Staffordshire UNIVERSITY School of Computing Code Design (The use of pseudo code for Elementary Process Descriptions)
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Compiler Chapter# 5 Intermediate code generation.
Assemblers.
Introduction to PHP A user navigates in her browser to a page that ends with a.php extension The request is sent to a web server, which directs the request.
Interpretation Environments and Evaluation. CS 354 Spring Translation Stages Lexical analysis (scanning) Parsing –Recognizing –Building parse tree.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
CS 152: Programming Language Paradigms April 2 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
Query Execution Section 15.1 Shweta Athalye CS257: Database Systems ID: 118 Section 1.
Some Fortran programming tips ATM 562 Fall 2015 Fovell (see also PDF file on class page) 1.
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
CPS 506 Comparative Programming Languages Syntax Specification.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Introduction to Code Generation and Intermediate Representations
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
Control Structures (B) Topics to cover here: Sequencing in C++ language.
CSCE 121: Introduction to Program Design and Concepts Dr. J. Michael Moore Spring 2015 Set 4: Computation 1 Based on slides created by Bjarne Stroustrup.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Compiler Construction By: Muhammad Nadeem Edited By: M. Bilal Qureshi.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 6: User-Defined Functions I.
Costas Busch - LSU1 Parsing. Costas Busch - LSU2 Compiler Program File v = 5; if (v>5) x = 12 + v; while (x !=3) { x = x - 3; v = 10; } Add v,v,5.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
C++ Array 1. C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used.
Introduction to Computer Programming using Fortran 77.
Fundamentals of Algorithms MCS - 2 Lecture # 3. Representation of Algorithms.
Chapter 1: Introduction to Computers and Programming.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Chapter 6: User-Defined Functions I
Ch. 7 Programming Languages
Compiler Lecture 1 CS510.
Scripts & Functions Scripts and functions are contained in .m-files
PL/SQL Scripting in Oracle:
Chapter 15 QUERY EXECUTION.
Chapter 10 Programming Fundamentals with JavaScript
Parsing Costas Busch - LSU.
Web DB Programming: PHP
CMPE 152: Compiler Design August 21/23 Lab
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
The structure of programming
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Presentation transcript:

parasol.tamu.edu/courses/minipolaris

What is Polaris? Polaris is a source to source transforming compiler, originally developed at UIUC, intended to parallelize programs written as conventional, sequential algorithms. Polaris is essentially a driver routine which scans a FORTRAN 77 program and converts it into an Abstract Syntax Tree (AST). Then, various passes are called by the driver on the AST. Each pass attempts to optimize the program via specific methods, such as constant propagation, reduction recognition, etc.. The driver program completes its task by printing the program

What is Minipolaris? MiniPolaris is a version of Polaris with only the most fundamental passes.The source program is read, parsed, and converted to an AST. The user will then provide custom passes to extract information or make transformations on the statements. After the custom passes are executed, the driver program outputs the resulting code.

Polaris Passes Printed CodeProgram IR passes Order of the passes is determined by the driver (~/minipolaris/cvdl/driver/driver.cc). A pass is nothing more that a function call in the driver. User can specify in a switches file (e.g. ~/minipolaris/switches) what passes to do and what options to use. The driver will read this switches file

Classes in MiniPolaris Minipolaris provides classes for every Fortran77 construct at various levels. The most important classes for the first projects are: the Program Class the ProgramUnit Class the StmtList Class the Statement Class the Expression Class the Symbol Class

Program The Program class is nothing more than a collection of ProgramUnit's. You can iterate over the collection to get to the actual ProgramUnit's. There are some methods to read in complete Fortran programs and display them. But you will not need them for the projects

ProgramUnit The ProgramUnit class is mostly a holder for the various data structure elements that make up a Fortran program unit (e.g. main program, subroutines). Examples of data structure elements are the statement list and the symbol table. Some useful methods are: stmts()‏ symtab()‏ routine_name_ref()‏

StmtList The StmtList class holds all the executable statements in a ProgramUnit. It's more than just a list. It provides functions to find statements by its tag, inserting and deleting single statements or whole blocks of statements. Some useful methods are: stmts_of_type(STMT_TYPE)‏ ins_before(Statement,Statement)‏ del(Statement)‏

Statement The Statement class represents the actual Fortran statements. Almost every Fortran Statement has a representation (examples are AssignmentStmt, DoStmt, IfStmt, WhileStmt,....) All these classes are derived from the base class Statement. The Statement classes provide the methods to get all the information of a given StatementNode: next_ref()‏ prev_ref()‏ lhs(), rhs() for assignments init(), index() for do statements

Expression The Expression class holds every type of Fortran Expression the same way as the Statement class represents any type of Fortran statement. Examples are IntConstExpr, IDExpr, BinaryExpr,... Some methods in the Expression classes are: symbol()‏ op() left_guarded()‏ right_guarded()‏ subscript()

Symbol The Symbol class represents all of the different Fortran Symbols. Same as for Expression and Statement there are Symbols for every Fortran symbol type. Examples are ProgramSymbol, SubroutineSymbol, VariableSymbol. Some methods are: type()‏ name_ref()‏

Example Suppose we are given a ProgramUnit (pu) and want to print all the variables that are defined in the assignment statements. // get all the assignment statements Iterator it = pu.stmts().stmts_of_type(ASSIGN_STMT)‏ //Iterate over the list and for every statement do Expression& lhs = it.current().lhs()‏ //print out the name cout << lhs.symbol().name_ref()‏

Collections Polaris provides it's own set of collection classes. For example List<>, DataBase<>. These Collection classes can only holds objects that are derived from the Listable class. Once an object is put into a Collection the Collection owns that object (when the collection gets destroyed, all the elements in the Collection also get destroyed. There are also containers such as RefList. They can only hold references and do not own the elements.

Setup MiniPolaris Everything is done on linux.cs.tamu.edu to setup just type /pub/courses/cpsc605/minipolaris/config/setup This will create a new directory minipolaris in your home directory and installs the necessary files The skeleton files for all the projects are stored in the ~/minipolaris directory For compiling you can just use the make command and for running use “mini_polaris -f switchfile my_prog.f”. To test your results you can compile it with the gnu Fortran compiler g77 For detailed information look at the sections page of the minipolaris website.

Projects There will be a total of 5 projects: 1A: Transforming Gotos 1B: Find Basic Block 2: SSA/DESSA 3: Constant Propagation/GCSE/??? 4: DDtest 5: Code generation

Transforming Gotos Arithmetic if Statement: Computed Goto if (expr) label1, label2, label3 if (expr.LT. 0) then goto label1 elseif ( expr.EQ. 0) then goto label2 else goto label3 endif goto (label1,label2,label3) expr if ( expr.EQ. 1) then goto label1 elsif ( expr.EQ. 2) then goto label2 elsif (expr.EQ. 3) then goto label3 endif

Fortran Fortran has very specific rules about its format Column 1 can only be a c or a * to indicate the line is a comment Columns 2 to 6 are reserved for labels Columns 7 to 79 are used for actual statements a * in Column 5 or 6 means it's a continuation of the previous line In Fortran every parameter is passed by reference

GOOD LUCK!!! Read all the documentation before you start Start on time check the class newsgroup regularly