The compiler has a front-end for the brainfuck language. You can use bf_to_ir() to transform brainfuck code into IR-code:

>>> from import bf_to_ir
>>> import io
>>> ir_module = bf_to_ir(io.StringIO('>>ignore.'), 'arm')
>>> ir_module.display()
module main;

external procedure bsp_putc(u8);

global variable data (30000 bytes aligned at 4)

global procedure main() {
  main_block0: {
    blob<4:4> ptr_alloc = alloc 4 bytes aligned at 4;
    ptr ptr_addr = &ptr_alloc;
    i32 num = 1;
    i8 val_inc = cast num;
    ptr ptr_incr = cast num;
    i32 num_0 = 0;
    ptr zero_ptr = cast num_0;
    i8 zero_ptr_1 = cast num_0;
    ptr num_2 = 30000;
    store zero_ptr, ptr_addr;
    jmp main_block2;

  main_block1: {

  main_block2: {
    ptr tmp_load = load ptr_addr;
    ptr tmp = data + tmp_load;
    store num_0, tmp;
    ptr tmp_3 = tmp_load + ptr_incr;
    store tmp_3, ptr_addr;
    cjmp tmp_3 == num_2 ? main_block1 : main_block2;



This is the brain-fuck language front-end., target)

Compile brainfuck source into ir code


Brainfuck is a language that is so simple, the entire front-end can be implemented in one pass.

generate(src, module_name='main', function_name='main')

Takes a brainfuck program and returns the IR-code module