Skip to content

Latest commit

 

History

History
77 lines (51 loc) · 1.9 KB

INSTRUCTIONS.md

File metadata and controls

77 lines (51 loc) · 1.9 KB

Using the Compiler (With Tree IR)

Once the installation is complete, the tc executable will be generated which is the final tiger compiler executable in the root directory of the project.
You may run the compiler on an input tiger source file as follows to get the MIPS assembly code.

./tc [OPTIONS] program.tig

The compiler will by default generate and store the MIPS assembly code in the file program.s, which can then be executed using SPIM.

Available Options

-?
--help
    Display the help message.

-A
--ast
    Display the AST generated from the source file.

-C
--canon
    Display the canonicalized IR generated from the source file.

-D
--debug
   Display all the required information for debugging.

-F
--file
    Execute the source tiger file. This is the default.

-I
--ir
    Display the IR generated from the source file.

-S
--asm
    Display the final assembler code.

Examples

./tc -A program.tig  # Display the AST
./tc -I program.tig  # Display the Tree IR
./tc -C program.tig  # Display the Canonicalized Tree IR
./tc -S program.tig  # Display the MIPS assembly code generated

Using the Makefile

$ make all

Makes the tiger compiler executable named tc in the root directory of the project.

$ make log

List all the files on which the compiler depends.

$ make run [TF=tests/custom.tig]

Executes the Tiger binary for the file with default tests/custom.tig in debug mode and also execute the SPIM simulator for the generated assembly code.

$ make tc{n}

Executes the test case test{n}.tig in the tests directory.

$ make tests

Execute all the test cases listed in tests dir. Make sure to have both file.tig and file.out files present containing input and output respectively.

$ make clean

Cleans the new files generated by the compiler. This also includes the tiger compiler executable.