-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean Up Code and Fix Random Things (#45)
* Separate namespace and parameter tests * Semi-working * The easy solution to the register allocation issue * More parameter spilling tests * Remove basic test suite * Moved some CLI code to bin * Made -g work * Put asm cleaning under optimizations * An improvement on dead code elimination * Remove dead code elimination because fixing will take too long * Rename files to camel case in lib * Rename opt_tests * Update install instructions
- Loading branch information
Showing
46 changed files
with
241 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,5 @@ gitlog.txt | |
docs/html/* | ||
!docs/html/.gitkeep | ||
build_dir/ | ||
bin/* | ||
!bin/.gitkeep | ||
demo/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
# Installation Instructions | ||
|
||
> [!NOTE] | ||
> This document is not a user manual. | ||
> It simply explains how to get the project onto your computer. | ||
> To see how to get it up and running, read the [user manual](docs/user_manual.md). | ||
> This document is not a user manual. | ||
> It simply explains how to get the project onto your computer and running. | ||
> To see how to use the compiler, check out the [user manual](docs/user_manual.md). | ||
These instructions assume you already have OCaml installed. | ||
## Install System Dependencies | ||
These instructions assume you already have OCaml and `make` installed. | ||
|
||
You'll need `nasm` for compiling assembly and `clang` for compiling and linking the runtime. The recommended way to install these on Linux and Max is through [Homebrew](https://brew.sh/). | ||
|
||
Once you have Homebrew, run `brew install llvm nasm`. If you don't want to use Homebrew, | ||
you're welcome to install the dependencies on your own, but they must be in `PATH`. | ||
|
||
## Build and Run | ||
1. Create a new `opam` switch by running `opam switch create cs3110-compiler ocaml-base-compiler.5.1.1` | ||
2. Install the required libraries: `opam install menhir batteries ounit2` | ||
3. Build the project by running `dune build` | ||
4. Use `dune exec bin/main.exe -- -h` to see usage instructions. Replace `-h` in the previous command with the flags you want to use. | ||
2. Install the required libraries: `make deps` | ||
3. Build the project by running `make`. A main executable will be copied into your directory. | ||
4. Use `./main -h` to see usage instructions. Replace `-h` in the previous command with the flags you want to use. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,40 @@ | ||
open X86ISTMB | ||
|
||
let () = Driver.main Sys.argv | ||
let print_error = Printf.eprintf "error: %s" | ||
|
||
let print_help prog = | ||
let open Printf in | ||
printf "%s\n" Meta.get.description; | ||
printf "\n"; | ||
printf "Usage: %s [-h|-v]\n" prog; | ||
printf " or: %s FILE [-g][-O]\n" prog; | ||
printf "\n"; | ||
printf "-h,--help prints this info\n"; | ||
printf "-v,--version prints version info\n"; | ||
printf "-g,--gen only produces IR\n"; | ||
printf "-O,--optimize runs optimizations\n"; | ||
ignore () | ||
|
||
let print_version () = | ||
let open Printf in | ||
printf "%s %s\n" Meta.get.name (Meta.Version.to_string Meta.get.version); | ||
printf "\n"; | ||
printf "Written by: %s\n" (String.concat ", " Meta.get.authors) | ||
|
||
let rec dispatch action prog = | ||
match action with | ||
| Cli.Help -> print_help prog | ||
| Version -> print_version () | ||
| Compile { paths; flags } -> ( | ||
if List.is_empty paths then | ||
dispatch (Error { msg = "expected at least one file name" }) prog | ||
else | ||
try Driver.compile paths flags None | ||
with exn -> print_error (Printexc.to_string exn)) | ||
| Error { msg } -> Printf.sprintf "%s\nuse %s -h\n" msg prog |> print_error | ||
|
||
let main args = | ||
let parse = Cli.parse args in | ||
dispatch parse.action parse.prog | ||
|
||
let () = main Sys.argv |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
(** TODO: needs tests *) | ||
|
||
let bb_gen = Id.Gen.make () | ||
|
||
type t = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.