All Projects → AsuMagic → AshBF

AsuMagic / AshBF

Licence: Zlib license
Over-engineered Brainfuck optimizing compiler and interpreter

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to AshBF

brainfuck
Brainfuck interpreter companion to the brain programming language
Stars: ✭ 32 (+128.57%)
Mutual labels:  brainfuck
brainfuck2wasm
A brainfuck-to-WebAssembly compiler
Stars: ✭ 36 (+157.14%)
Mutual labels:  brainfuck
ojisan f-ck
おじさん風文章を解釈して動く Brainfuck interpreter
Stars: ✭ 20 (+42.86%)
Mutual labels:  brainfuck
bfpy
Python to Brainfuck transpiler
Stars: ✭ 39 (+178.57%)
Mutual labels:  brainfuck
brainhug
A simple brainfuck translator crate in Rust
Stars: ✭ 14 (+0%)
Mutual labels:  brainfuck
rot13
This is a collection of ROT13 encoding programms written in different languages. Just for fun.
Stars: ✭ 24 (+71.43%)
Mutual labels:  brainfuck
bfloader
🧠 Brainfuck IDE and interpreter in 512 bytes. (boot sector)
Stars: ✭ 41 (+192.86%)
Mutual labels:  brainfuck
bf256
Brainfuck compiler under 256 bytes in size.
Stars: ✭ 21 (+50%)
Mutual labels:  brainfuck
esoo
Like the Programming Languages Zoo but with esoteric languages.
Stars: ✭ 18 (+28.57%)
Mutual labels:  brainfuck
vbf
A brainfuck interpreter/compiler written in V.
Stars: ✭ 17 (+21.43%)
Mutual labels:  brainfuck
BrainfuckIDE
A Brainfuck IDE/debugger designed to be intuitive, featureful and visually appealing
Stars: ✭ 77 (+450%)
Mutual labels:  brainfuck
Brainfuck
A flexible Brainfuck / Brainloller / Braincopter interpreter in Swift 3.1.
Stars: ✭ 13 (-7.14%)
Mutual labels:  brainfuck
llvm-brainfuck
Brainfuck compiler based on LLVM API
Stars: ✭ 27 (+92.86%)
Mutual labels:  brainfuck
rathilang
A small gift for someone who did big things (Python Package)
Stars: ✭ 14 (+0%)
Mutual labels:  brainfuck
Klipse
Klipse is a JavaScript plugin for embedding interactive code snippets in tech blogs.
Stars: ✭ 2,841 (+20192.86%)
Mutual labels:  brainfuck
emuStudio
Universal emulation platform and framework.
Stars: ✭ 28 (+100%)
Mutual labels:  brainfuck
brainfuck
A simple brainfuck interpreter in Rust.
Stars: ✭ 18 (+28.57%)
Mutual labels:  brainfuck
neth-proxy
Stratum <-> Stratum Proxy and optimizer for ethminer
Stars: ✭ 35 (+150%)
Mutual labels:  optimizer
BrainF.Net
A .NET brainfuck code parsing and execution library
Stars: ✭ 23 (+64.29%)
Mutual labels:  brainfuck
BfBf
A Brainfuck interpreter written by Brainfuck.
Stars: ✭ 37 (+164.29%)
Mutual labels:  brainfuck

AshBF

Introduction

Brainfuck is a minimalist turing-complete esoteric language using only 8 instructions: +-><[].,.

AshBF is C++20 optimizing brainfuck interpreter tailored for speed, written entirely from scratch.
It compiles brainfuck into an optimized IR to be interpreted by a VM or compiled down to native code.

Features

  • Fast execution through an optimized bytecode VM
  • Speedy compilation and optimization
  • AOT compilation to x86-64 assembly, C
  • IR optimization
  • Internal debugging tools for optimizations

Rationale

lol

Compiling

clang is strongly recommended. gcc works, but may poorly optimize the main interpreter loop.

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -GNinja ..
ninja

Usage

./ashbf <filename> (flags)

Specify flags with -flag=value, -flag (defaults to 1), -flagvalue (when value is a numeric value).
Short names are available for a few flags, e.g. -x instead of -execute.

-optimize-passes

Prevents the optimizer from running each optimizer more than N times for each stage.
Typically, one optimization pass will be sufficient. However, due to the way the optimizer is built, one optimization may enable another one next pass.
Do note that not all optimizations are pass-based. 5 is the default.

-optimize (-O)

Enables IL optimizations.
When disabled, the IL will be very similar to the brainfuck source. Pattern optimization will not be performed and stackable instructions (e.g. +, -, >, <) will not be merged.
1 is the default.

-optimize-debug

Detect optimization regression. The optimizer will test every optimization to detect optimization bugs.
It will then compare the ILs and print the difference between them. Note that this is extremely slow and should only be used to detect bugs in the compiler.
Programs using , are not yet supported. Regressions involving VM crashes or sanitization errors are not yet supported.
-msize is ignored during debug.
Program output will not show to stdout.

-optimize-verbose (-v)

Verbose optimization feedback.
When enabled, the optimizer will give various information on optimization tasks and passes and even more in -optimize-debug mode.

-legalize-overflow

By default, cell overflow is assumed illegal, as this is okay with most programs.
This enables better optimizations in general, but certain programs may encounter issues, in which case you may want to set this flag.

-memory-size (-m)

Defines the brainfuck tape allocated memory.
Do note that without the -sanitize flag passed, out of bounds memory accesses will cause problems.
30000 is the default.

-sanitize (unimplemented)

Sanitize brainfuck memory accesses to prevent from out of memory reads or writes.
When an invalid read or write is detected, the interpreter will exit and print an error.
0 is the default.

-print-il

Enable IL assembly listings.
Example for program +[+.]:

Compiler: Info: Compiled program size is 6 instructions (96 bytes)
0 add 1
1 jz 5
2 add 1
3 cout
4 jnz 2
5 end

-print-il-line-numbers

Determines whether the IL assembly listings should display line numbers.
0 is the default.

-execute (-x)

Enables brainfuck program execution.
Disabling this may be useful when you are only interested by the IL assembly listings or when you want to profile IL generation.
1 is the default.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].