TWISTER. a language designed for image manipulation

Similar documents
Twister: Language Reference Manual

Sequence 5.1 Building stack frames in LLVM

GaE Graphs Ain t Easy. Andrew Jones (adj2129) Kevin Zeng (ksz2109) Samara Nebel (srn2134)

Oscar. Ethan Adams Howon Byun Jibben Hillen Vladislav Scherbich Anthony Holley. Project Manager Language Guru System Architect System Architect Tester

blur Melissa Kaufman-Gomez Team Leader Timothy Goodwin System Architect Dexter Callender Language Guru Daniel Hong Test Wizard

Amit Shravan Patel UNI: ap3567 COMS W4115 (CVN) Prof. Stephen Edwards Final Project Report AP++

Homework #3: CMPT-379

Tree++ PLT FALL 2018

Recap: Functions as first-class values

SIPL: Simple Image Processing Language

Accelerating Stateflow With LLVM

Compiler Construction

LECTURE 3. Compiler Phases

The Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer.

NumNum Language Proposal 1. COMS 4115: NumNum Language Proposal. Programming Languages and Translators. COMS 4115 W Section 1. Prof.

Shalva Kohen Arunavha Chanda Kai-Zhan Lee Emma Etherington

The Warhol Language Reference Manual

tiler. A 2D turn-based gaming language Tester: Jacky Cheung Manager: Jason Lei System Architects: Jiayin Tang, Evan Ziebart Language Guru: Monica Ting

An Overview of Compilation

PIXL. Maxwell Hu (mh3289) Justin Borczuk (jnb2135) Marco Starger (mes2312) Shiv Sakhuja (ss4757)

A Framework for Automatic OpenMP Code Generation

The MatriCs. Reloaded. A linear algebra-specific language for the budding C enthusiast. Short name: MaC Extension:.neo

Introduction to Programming Using Java (98-388)

Language Reference Manual

CMAT Language - Language Reference Manual COMS 4115

Language Proposal: tail

Lecture 15 CIS 341: COMPILERS

yeezygraph Project Report

Lecture Compiler Middle-End

Using image manipulation to create post-postmodern art. Jessica Cheng, Kenny Yuan, Anna Lu, Hana Mizuta, Spencer Yen

EZ-ASCII A Language for ASCII-Art Manipulation

CIS 341 Midterm March 2, 2017 SOLUTIONS

Compiler Construction

A JSON Data Processing Language. Audrey Copeland, Walter Meyer, Taimur Samee, Rizwan Syed

Programming Languages

Parameter passing. Programming in C. Important. Parameter passing... C implements call-by-value parameter passing. UVic SEng 265

Programming Language Concepts, cs2104 Lecture 04 ( )

Compiler Construction

Type Checking. Chapter 6, Section 6.3, 6.5

Dara Hazeghi 12/22/11 COMS 4115 Fall 2011

LLVM and IR Construction

Lab Session # 5 Arrays. ALQUDS University Department of Computer Engineering

Begin at the beginning

ebpf-based tracing tools under 32 bit architectures

CIS 341 Midterm March 2, Name (printed): Pennkey (login id): Do not begin the exam until you are told to do so.

Formal Semantics. Prof. Clarkson Fall Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack

LDC: The LLVM-based D Compiler

Values (a.k.a. data) representation. Advanced Compiler Construction Michel Schinz

Values (a.k.a. data) representation. The problem. Values representation. The problem. Advanced Compiler Construction Michel Schinz

CSE 401 Midterm Exam Sample Solution 11/4/11

Compiler Construction

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

Compiler Construction

Compiler Construction: LLVMlite

SMURF Language Reference Manual Serial MUsic Represented as Functions

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

COLLEGE OF ENGINEERING, NASHIK. LANGUAGE TRANSLATOR

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #16 Loops: Matrix Using Nested for Loop

Yo : A Video Analytical Editing Programming Language

News. CSE 130: Programming Languages. Environments & Closures. Functions are first-class values. Recap: Functions as first-class values

The Design and Implementation of Gnu Compiler Collection

Outline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context

Renaud Durlin. May 16, 2007

CIS 130 Exam #2 Review Suggestions

Course introduction. Advanced Compiler Construction Michel Schinz

Semantic Analysis. Compiler Architecture

Slide 1 CS 170 Java Programming 1 Multidimensional Arrays Duration: 00:00:39 Advance mode: Auto

Mutation Testing. How good your tests are

Baggy bounds with LLVM

GraphQuil Language Reference Manual COMS W4115

Chapter 9 Introduction to Arrays. Fundamentals of Java

JSTEM: A Matrix Manipulation Language. Final Report

Chapter 8 Arrays and Strings. Objectives. Objectives (cont d.) Introduction. Arrays 12/23/2016. In this chapter, you will:

CIS 341 Final Examination 4 May 2017

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

CSE P 501 Compilers. Intermediate Representations Hal Perkins Spring UW CSE P 501 Spring 2018 G-1

Iteration: Intro. Two types of loops: 1. Pretest Condition precedes body Iterates 0+ times. 2. Posttest Condition follows body Iterates 1+ times

Lecture 9 CIS 341: COMPILERS

Pixel Power (P2) Eliane Kabkab System Integrator Nageswar Keetha Language Guru Eric Liu Project Manager Kaushik Viswanathan System Architect

Variables and Bindings

easel LANGUAGE REFERENCE MANUAL

Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan

CS /534 Compiler Construction University of Massachusetts Lowell

Alex Kalicki, Alexandra Medway, Daniel Echikson, Lilly Wang

Undergraduate Compilers in a Day

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules.

Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan

Programming Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science Indian Institute of Technology, Madras

SML: Specialized Matrix Language White Paper

COMP-520 GoLite Tutorial

Targeting LLVM IR. LLVM IR, code emission, assignment 4

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference

Type Inference Systems. Type Judgments. Deriving a Type Judgment. Deriving a Judgment. Hypothetical Type Judgments CS412/CS413

The ActionScript Markup Language

CSE 401/M501 Compilers

What is a compiler? var a var b mov 3 a mov 4 r1 cmpi a r1 jge l_e mov 2 b jmp l_d l_e: mov 3 b l_d: ;done

Yacc: A Syntactic Analysers Generator

Introduction to Compilers and Language Design

Introduction: Language Description:

sum: tree -> int sum_leaf: tree -> int sum_leaf: tree -> int Representing Trees Next: Lets get cosy with Recursion Sum up the leaf values. E.g.

Transcription:

TWISTER a language designed for image manipulation

TEAM MEMBERS Manager: Anand Sundaram (as5209) Language Guru: Arushi Gupta (ag3309) System Architect: Annalise Mariottini (aim2120) Tester: Chuan Tian (ct2698)

THE GOAL Twister is an image manipulation language designed with users in mind who may not be familiar with complex syntax. In this presentation we will demonstrate how users can use Twister to write a convolution function.

PROJECT LOG Feb 22 Scanner compiles! Seems mostly complete. Mar 1 Parser, ast, and scanner all build w/o errors! Mar 20 Added a codegen file Mar 25 Hello world works now Mar 26 Tests running on Travis Apr 24 Semant is ready for testing May 10 Final presentation

LANGUAGE FEATURES! Nested functions! Easy Matrix Manipulation! Functions do not have to be declared at the beginning of a file! Simplified for loops with for(elem in range()) syntax

COMPILER ARCHITECTURE

SEMANT: UNIQUE VARIABLE NAMES Output: int x = 0; x = 5; bool x = 2; Error: " Name x is already declared with type int " @ statement: bool x = 2;

SEMANT: TYPE CHECK INDICES Matrix<int> x = [1,2,3; 4,5,6]; String t = True ; int k = x[t][1]; Output: Error: Expression t has type List<Char> and cannot be used as a matrix index. @ statement: int k = x[t][1];

SEMANT: TYPE CHECK RETURN Output: fun fill = (r: int, c: int, x: int) -> Matrix<int> Matrix<int> M = Matrix(r,c); if (x < 2) for (i in range(0,r)) for (j in range(0,c)) else return 2; ; Error: " Error: " Error: " Statement '' return 2; '' would return invalid type int where return values should be of type Matrix<int> " @ statement: return 2; " @ statement: if (x < 2) for i in range(0,r): for j in range(0,r): M[i][j] = x; return M; else return 2; " @ statement: fun fill = (r : int,c : int,x : int) -> Matrix<int> Matrix<int> M = Matrix(r,c); if (x < 2) for i in range(0,r): for j in range(0,r): M[i][j] = x; return M; else return 2; ;

SEMANT: TYPE CHECK RETURN Output: List<int> x = 1, 3, 5, 6; int y = x[0][2]; Error: " Variable x is of type List<int>, not of type Matrix<element_type>, and cannot be indexed into. " @ statement: int y = x[0][2];

NESTED FUNCTIONS LLVM IR (trimmed) define i32 @sf(i32 %x, i32 %a) entry: %x1 = alloca i32 store i32 %x, i32* %x1 %a2 = alloca i32 store i32 %a, i32* %a2 %"%tmp" = load i32, i32* %x1 %"%tmp3" = load i32, i32* %a2 %"%tmp4" = add i32 %"%tmp", %"%tmp3" ret i32 %"%tmp4" define i32 @mf() entry: %a = alloca i32 store i32 3, i32* %a %a1 = load i32, i32* %a %sf_result = call i32 @sf(i32 9, i32 %a1) ret i32 %sf_result fun mf = () -> int int a = 3; fun sf = (x: int) -> int return x + a; ; return sf(9); ; int l = mf(); bool g = print_int(l); define i32 @main() entry: %l = call i32 @mf() %l1 = alloca i32 store i32 %l, i32* %l1 %"%tmp" = load i32, i32* %l1 %print = call i32 (i8*,...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @fmt, i32 0, i32 0), i32 %"%tmp") %g = alloca i1 store i1 true, i1* %g ret i32 0

SCOPE Twister is statically scoped The result of printing this function is 3, not 5 int a = 5; fun mf = () -> int int a = 3; fun sf = () -> int return a; ; return sf(); ; int b = mf(); int h = print_int(b);

SCOPE On the other hand, this will print 5 int a = 5; fun mf = () -> int int a = 3; fun sf = () -> int return a; ; return sf(); ; int b = mf(); int h = print_int(a);

FOR LIST SCOPE List<int> l = 0,9,3,2; for (el in l) int h = print_int(el); //this will print 0, 9, 3, 2 //this will not run because el in not defined anymore int a = print_int(el);

CONVOLUTION

THE PGM FILE FORMAT

EXAMPLE PROGRAM: CONVOLUTION fun small_c = ( i: int, j: int, img: Matrix<int>, kernel : Matrix<int>) -> int int nr = kernel.num_rows; int nc = kernel.num_cols; int endrow = i + nc; int endcol = j + nr; int sum = 0; for ( mr in range(i, endrow)) for (mc in range(j, endcol)) int imen = img[mr][mc]; int keren = kernel[mr-i][mc-j]; sum = sum + keren*imen; return sum; ; Matrix<int> res = [0, 0, 0; 0, 0, 0; 0, 0, 0];

EXAMPLE PROGRAM: CONVOLUTION fun small_c = ( i: int, j: int, img: Matrix<int>, kernel : Matrix<int>) -> int int nr = kernel.num_rows; int nc = kernel.num_cols; int endrow = i + nc; int endcol = j + nr; int sum = 0; for ( mr in range(i, endrow)) for (mc in range(j, endcol)) int imen = img[mr][mc]; int keren = kernel[mr-i][mc-j]; sum = sum + keren*imen; computes a single pixel of our output image range(i, j) syntax variables may be defined before or after functions easily interchange between being inside functions & outside of them return sum; ; Matrix<int> res = [0, 0, 0; 0, 0, 0; 0, 0, 0];

EXAMPLE PROGRAM: MATRIX ROW SUM OUTPUT Matrix<int> res = [0, 0, 0; 0, 0, 0; 0, 0, 0]; fun convol = (img: Matrix<int>, kernel : Matrix<int>) -> Matrix<int> int imw = img.num_cols; int imh = img.num_rows; int knw = kernel.num_rows; int redw = imw - knw + 1; int redh = imh - knw + 1; for (i in range(0, redh)) for (j in range(0, redw)) res[i][j] = small_c(i, j, img, kernel); return img; ;

CONVOLUTION CTD Matrix<int> res = [0, 0, 0; 0, 0, 0; 0, 0, 0]; fun convol = (img: Matrix<int>, kernel : Matrix<int>) -> Matrix<int> int imw = img.num_cols; int imh = img.num_rows; int knw = kernel.num_rows; functions see variables above their scope functions do not see variables below their scope Can return original image as matrix from function int redw = imw - knw + 1; int redh = imh - knw + 1; for (i in range(0, redh)) for (j in range(0, redw)) res[i][j] = small_c(i, j, img, kernel); return img; ;

EXAMPLE Original Image Kernel After Convolution 18 2 0 1 5 3 1 2 1 4 7 9 3 1 2 9 5 6 7 1 0 8 6 2 3 1 2 1 2 3 1 4 5 6 124 69 47 148 126 84 143 125 93

RGB IMAGES AND EXTRACTING COLORS Matrices store tuples for RGB images (type represents type of contents of tuple) Small example: Matrix<int> a= [(1,2,4);(2,4,1)]; Tup<int> ftup = a[0][0]; int h = println_int(ftup[1]); will print 2.

TEST AND DEBUG Test Procedures for scanner/ parser/ semant/ codegen: clean.sh build.sh test.sh Automating Tests for every build:.travis.yml.travis-ci.sh

THANK YOU!