程序代写 GA-2130:

CSCI-GA-2130:
Compiler Construction

Copyright By PowCoder代写 加微信 powcoder

Instructor

Joseph Tassarotti

Office: 60 FA 401

What is this about?
● Compilers translate from programming languages to

machine code.

● How do we structure a compiler to be:
– Maintainable
– Extensible

Compiler Architecture

Parsing Elaboration Lowering

Generation

Optimization

● Convert a string into a data structure:

– Lexing: Convert raw characters into list of tokens
– Parsing: List of tokens into abstract syntax tree

Strings/Files Tokens

Syntax Trees

Elaboration
● Type-checking
● Resolve variables/modules/names
● Check other “well-formedness” properties

Syntax Trees

Syntax Trees

● Translate high-level features into lower-level

constructs:

E.g. while/for replaced by “goto”

Intermediate

Typed Syntax

Optimization
● Make code more efficient:

– Remove “dead” code
– Simplify computations (replace 3+6 with 9)
– Reuse repeated computations

Code Generation
● Convert Intermediate code to target:

– Register Allocation
– Instruction Selection

Machine Code
Intermediate

Required Background
● Officially:

– CSCI-GA 1170, CSCI-GA 2110, and CSCI-GA 2250.

● Unofficially:
– Passing familiarity with basic computer

systems/architecture
– Willingness to work hard to fill gaps

Administrative Details
● Website: BrightSpace*
● Assignment submission: GradeScope

● ~9 assignments determine the entirety grade.
– 3 late days total throughout semester
– See collaboration policy on website

Programming Environment

– Functional programming language, very good for writing

– Intensive introduction in first week

– Simulator for MIPS assembly language

● No official book, but there are many references about

OCaml and compilers

● Closest to what we’re doing:

Modern Compiler
Implementation in ML

Assignments (Tentative)

0. Ocaml warm-up
1. MIPS Simulator
2. Fortran-ish → MIPS
3. C-ish → MIPS
4. Scheme-ish → C-ish
5. ML-ish → Scheme-ish
6. Optimization

7. Control-Flow Graphs
8. Register Allocation

Learning Outcomes
● Understand how compilers work:

– What can they do?
– What can they not do?

● Lots of functional programming experience
● Thinking of languages as an extensible

programming interface

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com