Date post: | 01-Jan-2016 |
Category: |
Documents |
Author: | leslie-mcgee |
View: | 214 times |
Download: | 0 times |
Project: ACM Compiler 2014
Project: ACM Compiler 2014Shanghai Jiao Tong UniversityClass ACM 2011Dong XieIntroductionIntroductionTask: Write a compiler of simplified C in full-featured Java to MIPS.
Main Reference Book: Compilers Principles Techniques and ToolsYou may also need more materials:Modern Compiler Implementation in Java/C/MLMIPS-SPIM documentAll kinds of papers
IntroductionYou are allowed to use a language other than Java
Whoever bootstrapping C will get a full scoreNO bonus needed for other languageBUT you may not have a good support from your TAs.
Apply it explicitly to TAs if you want to do this.
TA Listcloudygooseg [at] gmail.comxiedong1993 [at] gmail.comwuzhongminghang [at] gmail.com121665841 [at] qq.com
Google Groups: tiger-acm-sjtu [at] googlegroups.comIMPORTANT Be sure you have join this group.Schedule & PrinciplesLecture: every Friday 7 PM at SEIEE Building 3-404Project Checkpoint Due: on some Friday 6 PMThere will be TWO code reviews during the project
NO CHEATINGNO LATE SUBMISSION
All test cases will be publicly available.Versioning & SubmissionVersion your compiler codes using BitBucket.You are NOT allowed to publish your code on the Internet
Create a private repo named compiler2014Add username acmcompiler to your repository with read permission
Submit your code for each phase by creating a tag.GradingData Correctness (60 points)Performance (20 points)Code review (5 points)Attendance (5 points)BonusReportMail list SummaryHelperBook ReaderPerformance WinnersPossible Bonus ListUse C language to implement the compiler. Implement typedefImplement 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 schedulingReconstruct the AST...Q & ACompiler OverviewCompilers vs. InterpretersCompilers:
Interpreters:
Compiler PhasesSyntactic Analysis (Lexing, Parsing)Semantic Analysis (Types, Scopes, )Intermediate Representation (IR)Optimization (CPU, Registers, Memory, )Code Generation
Difference between compilers and interpreters?Exampleint a = 1;print(a);int b = helloprint(b)
When will a compiler and a interpreter raise the error.Compiler Phases
Examplea = b + 42
ID(a) OP(=) ID(b) OP(+) NUM(42)
Examplet3 := t1 + 42t2 := t3
lw $t1, -8($fp)addi $t2, $t1, 42sw $t2, -4($fp)
An AppetizerA toy compiler as a tutorial written by Xiao JiaNotice: 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_appetizerSource Code: https://github.com/stfairy/appetizer
Q & APhase 1: Syntactic AnalysisExample: Input#include
int main(int argc) {printf(Hello World!\n);return 0}Task 1: Tokenlizeint
(int ){
(
);return
;}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.Syntactic SpecificationTokens:http://acm.sjtu.edu.cn/wiki/Compiler_2014:_Tokens
Grammar:http://acm.sjtu.edu.cn/wiki/Compiler_2014:_GrammarTools & GradingFollowing tools are allowed:lex / yacc / Quex / flex / bisonre2c / lemonJflex / CUPANTLR (v3 or v4)Ragel
This phase will be manually judged in code review.Feel free to design your own output formats!Q & AThanks for listeningContact: [email protected]