Skip to content

overminder/comp180-mips-cc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

In memory of passed days working on the COMP180 project! ----------------------------------------------------

Just found this dust-covered project at somewhere. Welp, this compiler was really a huge hack (and it even worked in some ways!).

There were several "innovations":

  • No register allocation. Each function can only use a limited number of virtual register as virtual registers were almost directly mapped to machine registers. Although Mips has about 32 machine registers, obviously it's still not enough.
  • Just plain wrong optimizations. I tried to optimize away some instructions so that the pressure on register allocation could be less but at first I didn't even know what a basic block is... Then I read from some articles and found that I need to build some sort of "graph". Then I started writing several "optimizations" that might or might not work in different cases. As as result, I learned to carefully avoid those bugs in my compiler by rewriting the source code that is going to be compiled.
  • Type systems! I decided and managed to build a cee-language-like type system where there are ints, bytes, voids and pointers. They were doing more bads than goods at the beginning but soon I got used to them. From a retrospective point of view, I think actually this decision is essential as it helped me to solved several bugs in the source language.

About

A piece of dust-covered ancient hackish compiler...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published