This is my brainfuck compiler, written in ruby. It has been written to create blisteringly fast code, at the expense of compile times.
As a result, it produces inlined brainfuck in pure ASM, and uses a few limited static analysis techniques to speed things up, including detection of deterministic elements and pre-execution of certain algorithms. Currently, I'm working on advancing the static analysis it does in order to produce cleaner and faster output.
At the moment, deterministic code can be pre-executed and optimised to be O(1). This makes compiling benchmarks incredibly fun :-)
Download BFCompiler.tar.gz.
The code is currently fairly fragmented and full of FIXMEs and TODOs. If you want a copy that's more up-to-date, please contact me.
The code is still somewhat in development, so you'll have to make do with a very vague guide. Essentially, running bfcompile.rb runs the compiler, and setting the i and o flags determines input and output.
A series of flags may be turned on and off which affect how the compiler performs optimisation and code generation. Check the Makefile for these, since they are liable to change a lot.
Once the compiler has run, it will output a GNU assembler file, which may be assembled into a working executable. The Makefile includes code to assemble and link an executable into a working state.