https://github.com/mrminemeet/minimizer
Compiler Optimizer on an IR for the toy language 'Mini'
https://github.com/mrminemeet/minimizer
compiler intermediate-representation optimization
Last synced: about 1 year ago
JSON representation
Compiler Optimizer on an IR for the toy language 'Mini'
- Host: GitHub
- URL: https://github.com/mrminemeet/minimizer
- Owner: MrMinemeet
- Created: 2023-05-21T06:17:00.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-01T07:43:01.000Z (over 1 year ago)
- Last Synced: 2025-02-07T16:43:09.190Z (over 1 year ago)
- Topics: compiler, intermediate-representation, optimization
- Language: Java
- Homepage:
- Size: 175 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MiniMizer
My optimizer for Project 2 of the LVA [Advanced Compiler Construction](https://ssw.jku.at/Teaching/Lectures/ACC/) @JKU Linz by Prof. Hanspeter Mössenböck.
This project was originally intended to be perfored for the lecture. As I had no time during that period, I'm performing it as a hobby project. Therefore, some requirements have changed a bit. E.g. the use of Kotlin for custom classes that are not generated by COCO/R.
## Task description:
The goal of this project is to write a compiler that translates a program of the toy language Mini
to an intermediate representation (a CFG with IR instructions), performs some optimizations
on it and finally does register allocation by graph coloring. Code generation is not part of this
project. The project can either be implemented in Java or in C#. As I do this as a hobby project, I used Kotlin for parts that have not been generated via COCO/R.
## Mini language description:
Mini is a simple Pascal-like language with integer variables and (multi-dimensional) arrays. It
has the usual kinds of statements and expressions. There are no procedures. The syntax of Mini
is as follows:
```
Mini = "PROGRAM" {VarDecl} "BEGIN" StatSeq "END" "." .
VarDecl = "VAR" {IdListDecl ";"} .
IdListDecl = ident {"," ident} ":" Type .
Type = ident | "ARRAY" number "OF" Type .
StatSeq = Statement {";" Statement} .
Statement =
[ Designator ":=" Expression
| "IF" Condition "THEN" StatSeq {"ELSIF" Condition "THEN" StatSeq} ["ELSE" StatSeq] "END"
| "WHILE" Condition "DO" StatSeq "END"
| "READ" Designator
| "WRITE" Expression
] .
Condition = Expression Relop Expression .
Expression = [Addop] Term {Addop Term} .
Term = Factor {Mulop Factor} .
Factor = Designator | number | "(" Expression ")" .
Designator = ident {"[" Expression "]"}.
Relop = "=" | "#" | "<" | ">" | ">=" | "<=".
Addop = "+" | "-".
Mulop = "*" | "/" | "%".
```
The lexical structure of SL is:
```
ident = letter {letter | digit}.
number = digit {digit}
```
Integer types are written as `INTEGER`. Comments start with `//` and go to the end of the line.
---
* Full Task Description: [Project_2.pdf](https://ssw.jku.at/Teaching/Lectures/ACC/Project_2.pdf)
* COCO/R: [Homepage](https://ssw.jku.at/Research/Projects/Coco/)