Git Product home page Git Product logo

tigerc's Introduction

tiger-rs

Following along with Andrew Appel's Modern Compiler Implementation in ML.

Progress

  • Lexing

Handwritten lexer.

  • Parsing

Using LALRPOP as an LR(1) parser generator.

  • Type checking

  • IR translation

  • Abstract assembly generation

  • Register allocation

  • Optimization

TODO

  • Lexing

    • Add pretty-printing for tokens
    • Decouple lexer from parser
    • Integrate lexing phase into CLI
    • Implement string unescaping
    • Handle MIN_INT - might have to store literal ints as strings?
    • Write test cases for lexing
  • Parsing

    • Implement or find global symbol table library (EDIT: see sym)
    • Convert all allocated String fields into cached symbols
    • Implement to_span functions for AST nodes for better errors
    • Add more span fields to AST where necessary (e.g. saving function name in Call node)
  • Type checking

    • Write test cases
    • Check for variable mutability
    • Check for uniqueness of type and function names within a mutually recursive group
    • Check for invalid type cycles
    • Upgrade TypeError variants with more information
    • Use codespan::Label to display better errors
    • Possibly use macros to clean up repeated code, or reduce the number of clone calls
  • IR translation

    • Implement Appel's Tree enum
    • Implement AST translation functions
    • Attach AST translation to type checking phase
    • Implement canonization
    • Implement interpreter for testing purposes
    • Write test cases for interpreted IR
    • Make sure commuting logic is sound (i.e. pure vs. impure expressions)
    • Implement constant folding
    • Implement finding escaping variables
    • Implement static link traversal
    • Construct control flow graph from canonized IR
    • Reorder IR using control flow graph to remove unnecessary jumps
  • Abstract assembly generation

    • Design instruction types for assembly
    • Implement AT&T and Intel syntax in separate traits for easy swapping
    • Implement tiling using maximal munch
    • Implement trivial register allocation
    • Figure out how to write a C runtime for Tiger
    • Clean up command-line interface
    • Organize compiler passes into distinct phases (maybe use a Phase trait?)
    • Write assembly test suite
  • Register allocation

    • Research different allocation algorithms
    • Implement one
  • Optimization

    • Implement dataflow analysis framework(s) (IR level? Assembly level? Basic blocks or individual statements?)
    • Research different optimizations (e.g. constant propagation, dead code elimination, common subexpression elimination)
    • Write benchmark Tiger programs

Deviations

  • Allow comparison operators to associate (e.g. (a = b = c) evaluates as ((a = b) = c))
  • Allow assignment to for loop index variable (e.g. for i := 0 to 10 do i := i + 1)
  • Implement modulo operator (%)
  • Rename print runtime function to prints; implement printi function to print integers

tigerc's People

Contributors

nwtnni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.