Skip to content

wlu03/tiger_compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS 4240 Compilers and Interpreters (Fall 2025) Project 1

IR Optimizer Setup and Usage Guide

This project implements an Intermediate Representation (IR) optimizer in Java. Follow this guide to set up, compile, and run the optimizer.

Project Structure

cs4240-project-1/
├── build.sh           # Compilation script
├── run.sh             # Execution script
├── optimizer/         # Main optimizer code
│   ├── src/           # Java source files
│   │   ├── Optimizer.java
│   │   ├── opt/       # Optimization algorithms
│   │   ├── ds/        # Data structures
│   │   └── ir/        # IR representation classes
│   ├── example/       # Example input/output files
│   └── public_test_cases/ # Test cases for validation
└── materials/         # Additional materials and examples

Steps

Make Scripts Executable

chmod +x build.sh run.sh

Compile the Optimizer

Run the build script to compile all Java source files:

./build.sh

What this does:

  • Creates a build directory in the optimizer folder
  • Finds all .java files in the optimizer/src directory
  • Compiles them using javac and places .class files in optimizer/build

Running the Optimizer

Basic Usage

./run.sh <input_ir_file>

This writes the optimized IR to a file named out.ir at the project root.

Examples

Example 1: Using the provided example

./run.sh optimizer/example/example.ir
# Output: out.ir

Example 2: Using test cases

# Optimize the quicksort IR
./run.sh optimizer/public_test_cases/quicksort/quicksort.ir
# Output: out.ir

# Optimize the sqrt IR
./run.sh optimizer/public_test_cases/sqrt/sqrt.ir
# Output: out.ir

Example 3: Custom IR file

./run.sh path/to/your/program.ir 
# Output: out.ir

// or set it to your desired output
./run.sh path/to/your/program.ir path/to/your/output.ir

About

Static analysis & optimization of Tiger-IR

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published