+ All Categories
Home > Documents > Project: ACM Compiler 2014 Shanghai Jiao Tong University Class ACM 2011 Dong Xie.

Project: ACM Compiler 2014 Shanghai Jiao Tong University Class ACM 2011 Dong Xie.

Date post: 01-Jan-2016
Category:
Upload: leslie-mcgee
View: 217 times
Download: 0 times
Share this document with a friend
Popular Tags:
27
Project: ACM Compiler 2014 Shanghai Jiao Tong University Class ACM 2011 Dong Xie
Transcript

Project: ACM Compiler 2014

Shanghai Jiao Tong University

Class ACM 2011

Dong Xie

Introduction

Introduction Task: Write a compiler of simplified C in full-featured Java to

MIPS.

Main Reference Book: Compilers Principles Techniques and Tools

You may also need more materials: Modern Compiler Implementation in Java/C/ML

MIPS-SPIM document

All kinds of papers

Introduction You are allowed to use a language other than Java

Whoever bootstrapping C will get a full score

NO bonus needed for other language

BUT you may not have a good support from your TAs.

Apply it explicitly to TAs if you want to do this.

TA List 贺天行 cloudygooseg [at] gmail.com

解东 xiedong1993 [at] gmail.com

吴航 wuzhongminghang [at] gmail.com

金天行 121665841 [at] qq.com

Google Groups: tiger-acm-sjtu [at] googlegroups.com

IMPORTANT Be sure you have join this group.

Schedule & Principles Lecture: every Friday 7 PM at SEIEE Building 3-404

Project Checkpoint Due: on some Friday 6 PM

There will be TWO code reviews during the project

NO CHEATING

NO LATE SUBMISSION

All test cases will be publicly available.

Versioning & Submission Version your compiler codes using BitBucket.

You are NOT allowed to publish your code on the Internet

Create a private repo named compiler2014

Add username acmcompiler to your repository with read permission

Submit your code for each phase by creating a tag.

Grading Data Correctness (60 points)

Performance (20 points)

Code review (5 points)

Attendance (5 points)

Bonus Report

Mail list Summary

Helper

Book Reader

Performance Winners

Possible Bonus List Use C language to implement the compiler.

Implement typedef

Implement higher order functions. (lambda expression, etc.)

Static analyzer (abstract interpreter)

Garbage collection (If you pass our testcases, you can get this bonus.)

Optimization (loop-unrolling, constants propagation, inline functions, dead code elimination, etc.)

Concurrency and scheduling

Reconstruct the AST

...

Q & A

Compiler Overview

Compilers vs. Interpreters Compilers:

Interpreters:

Compiler Phases Syntactic Analysis (Lexing, Parsing) Semantic Analysis (Types, Scopes, …) Intermediate Representation (IR) Optimization (CPU, Registers, Memory, …) Code Generation

Difference between compilers and interpreters?

Example int a = 1; print(a); int b = “hello” print(b)

When will a compiler and a interpreter raise the error.

Compiler Phases

Example a = b + 42

ID(a) OP(=) ID(b) OP(+) NUM(42)

Example t3 := t1 + 42 t2 := t3

lw $t1, -8($fp) addi $t2, $t1, 42 sw $t2, -4($fp)

An Appetizer A toy compiler as a tutorial written by Xiao Jia

Notice: you may not find IR phase in it.

You will find it VERY IMPORTANT if you have no idea to start.

Description: http://acm.sjtu.edu.cn/wiki/Compiler_2014:_An_appetizer

Source Code: https://github.com/stfairy/appetizer

Q & A

Phase 1: Syntactic Analysis

Example: Input

#include <stdio.h>

int main(int argc) {

printf(“Hello World!\n”);

return 0

}

Task 1: Tokenlize

int

<id, main>

(

int <id, argc>

)

{

<id, printf>

(

<string, “Hello World!\n”>

)

;

return

<number, 0>

;

}

Task 2: Parsering

(func int main[(arg int argc)])

(stmtlist

(expr (call printf[“Hello World!\n”]))

(stmtlist

(return (number 0))))

Note: you need to print out a AST NOT a Parser Tree.

Tools & Grading Following tools are allowed:

lex / yacc / Quex / flex / bison

re2c / lemon

Jflex / CUP

ANTLR (v3 or v4)

Ragel

This phase will be manually judged in code review.

Feel free to design your own output formats!

Q & A

Thanks for listening…Contact: [email protected]


Recommended