Taddeus Kroes 11 vuotta sitten
vanhempi
sitoutus
25bcd246c9
1 muutettua tiedostoa jossa 37 lisäystä ja 0 poistoa
  1. 37 0
      README.md

+ 37 - 0
README.md

@@ -0,0 +1,37 @@
+About
+=====
+
+This is a minimal compiler for the
+[Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) language, written for the
+purpose of practicing Ocaml LLVM bindings and seeing how well LLVM optimizes
+arrays. Brainfuck commands are transformed to LLVM IR, which is generated in
+such a way that it is easy to optimize for LLVM's `opt` utility.
+
+Building and usage
+==================
+
+Building the `bf` compiler (Debian dependencies):
+
+    $ sudo apt-get install ocaml llvm-3.4 libllvm-3.4-ocaml-dev
+    $ make
+
+Building a brainfuck program (plain and optimized):
+
+    $ make hello hello-opt  # compile file "hello.b" to binaries
+    $ ./hello
+    Hello World!
+    $ ./hello-opt
+    Hello World!
+
+Quick compilation and running (deletes temporary binary after running):
+
+    $ echo ++++++++++++. | ./run.sh
+    $ ./run.sh < hello.b
+    Hello World!
+
+Examining generated LLVM:
+
+    $ echo ++++++++++++. | ./bf
+    ...
+    $ echo ++++++++++++. | ./bf | opt -O3 -S
+    ...