Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shivansh/gogo

Go to MIPS compiler, written in Go. Course project for Compiler Design (CS335).
https://github.com/shivansh/gogo

compiler garbage-collection go gocc mips peephole reaching-definitions

Last synced: 5 days ago
JSON representation

Go to MIPS compiler, written in Go. Course project for Compiler Design (CS335).

Awesome Lists containing this project

README

        

# gogo
[![Build Status](https://travis-ci.org/shivansh/gogo.svg?branch=master)](https://travis-ci.org/shivansh/gogo)

Go to MIPS compiler, written in Go.


Logo

*Gopher vector imported from [egonelbre/gophers
](https://github.com/egonelbre/gophers).*

- - -

## Components

| Component | Demo |
|:------------------------:|:----------------------------------------------------------------------------------------------------------------------------------:|
| Token generation / Lexer | [`test1.out`](test/lexer/test1.out) |
| Parser | [`struct.go`](test/parser/struct.go) :arrow_right: [`struct.html`](https://shivanshrai84.gitlab.io/staticPages/assets/struct.html) |
| IR generation | [`scope.go`](test/codegen/scope.go) :arrow_right: [`scope.ir`](test/codegen/scope.ir) |
| Code generation | [`pascalTriangle.ir`](test/ir/pascalTriangle.ir) :arrow_right: [`pascalTriangle.asm`](test/ir/pascalTriangle.asm) |

## Setting up
Run `./scripts/setup.sh` from the root directory of the project to set up the pre-commit git hooks.

## Dependencies
* [gocc](https://github.com/goccmack/gocc)

## Build
The following should generate relevant binaries inside the directory `bin` -
```
make
```

The generated binary `bin/gogo` can be used as follows -
```
Usage: gogo (-r | -r2s | -s)
-p Generates rightmost derivations used in bottom-up parsing
-r Generates IR instructions from go program
-r2s Generates the MIPS assembly from IR
-s Generates MIPS assembly from go program
```

**NOTE:** The generated MIPS assembly has been tested to work on [SPIM](http://spimsimulator.sourceforge.net/) MIPS32 simulator.

## Testing
The [tests](test) can be built via -
```
make test
```