GithubHelp home page GithubHelp logo

tigpiler's Introduction

Tigpiler

An SML based Tiger to MIPS compiler

Requirements

Setup

  • Clone repo git clone [email protected]:ParkerK/Tigpiler.git
  • Change to the program directory cd Tigpiler/RegisterAllocation

Testing

  • Run the test program to compile and run the binary sml test.sml

Status / Updates

We believe that this compiler is fully functional (though a tad dumb at times). In regards to changes on past parts, we have changed quite a bit. On the Lexer, we went through and fixed all of the issues pointed out. In addition, we found one where it could not handle 'then'. It still won't handle illegal integers (e.g. var:=5a) but being that this was optional we simply encourage any users to try to make illegal integers.

For the Parser, the only thing wrong was the excluded documentation. You are reading the documentation at this very moment, which proves that we now have documentation.

For Frame Analysis and IR we had full credit, but we still went though and fixed a few issues with things like declarations.

We also fixed Instruction Selection to handle MOVES correctly, added a missing procEntryExit1 funtion, and changed the psuedo assembly to valid MIPS.

In regards to register allocation our compiler will correctly create a control flow graph, liveness analysis, and interference graphs. It will even color registers and will spill. It's not very bright (we still love it though) though and will give up as soon as it detects something wrong.

Upon running sml test.sml the script will spit out the assembly representation of all of the test programs that we have collected. You can run sml test.sml in any directory to see the output of that stage (e.g., running sml test.sml in the IRTranslation directory will save the IR represnetation in the output directory).

Parts

1.Lexer (9/19)

To Fix:

  • A little too aggressive illegal escape char checker. e.g. \ is a regular backslash. Currently your lexer reporting error
  • Currently you seem to be checking unclosed comments by the use of escape characters. There's a better implementation.
  • Need to handle illegal integers, e.g. var a:=5a
  • There is a bug in your lexer, such that strings ending with f are not being processed

2.Parser (10/17)

To Fix:

  • Missing documentation

3.Semantic Analysis (10/31)

To Fix:

  • If, while, ... expressions are returning errors when not supposed to, e.g. "if(5>3)..." returns integer required error.
  • Certain expressions should not return any value at all (see page 516). For example a:=(if (5>4) then 3) should return an error
  • For "if then else" expressions the types of "then" and "else" values must be the same
  • Need to handle recursive declarations: At the moment not throwing errors. (See page 120)
  • How are you handling cases where types have the same name as variables? Should it return an error?

4.Frame Analysis and Intermediate Representation (11/14)

To Fix:

  • None

5.Instruction Selection (11/21)

To Fix:

  • Incorrect instructions used, ie 'LOAD' instead of 'lw'

6.Register Allocation (12/5)

To Fix:

  • Color nodes, everything is showing as $t0

7.Working compiler, produces assembly (12/9)

To Fix:

  • Fix previous issues from past modules

tigpiler's People

Contributors

cyyuen avatar parkerk avatar yangsu avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tigpiler's Issues

TypeChecker - Returning Values

  • Certain expressions should not return any value at all (see page
    516). For example a:=(if (5>4) then 3) should return an error

TypeChecker - type not defined errors

It is throwing errors on situations that arrise due to uncorrected
errors from previous projects. For example, the case on the
typechecker project, where your typechecker is throwing incorrects
"type not defined errors" in cases like "if(10>5)"

recursive and mutually recursive functions

Afterwards, check also recursive and mutually recursive functions. It
seems there is also a labeling error. At the moment they are throwing
uncaught exception errors

For Loop Bug in Translate

"I have also found a bug in the for loop in your translate module
(part of IR/Frame project) that I didn't report to you earlier. The
for loop is jumping to an incorrect label such that the conditions are
not being tested."

TypeChecker - If/Then

  • For "if then else" expressions the types of "then" and "else" values
    must be the same

TypeChecker - If/While

If, while, ... expressions are returning errors when not supposed to,
e.g. "if(5>3)..." returns integer required error.

Lexer - Start pos of String is wrong

The ending position of the string is used as the starting position.

The following is a simple tiger program

"string"

The output should be

STRING(string)     2
EOF   10

instead of

STRING(string)     9
EOF   10

Lexer Bug

Need to handle illegal integers, e.g. var a:=5a

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.