├── test ├── check │ ├── mem.err │ ├── tiny.err │ ├── main-args.err │ ├── undef.err │ ├── extra.err │ ├── missarg.err │ ├── undef.bril │ ├── mainret.bril │ ├── missdest.err │ ├── printres.err │ ├── mainret.err │ ├── missdest.bril │ ├── printres.bril │ ├── argtype.bril │ ├── extra.bril │ ├── missarg.bril │ ├── argtype.err │ ├── noret.err │ ├── typeconflict.err │ ├── ptr.err │ ├── tiny.bril │ ├── typeconflict.bril │ ├── badid.bril │ ├── ptr.bril │ ├── noret.bril │ ├── main-args.bril │ ├── badconst.bril │ ├── badid.err │ ├── labels.bril │ ├── labels.err │ ├── badconst.err │ ├── mem.bril │ ├── ssa.err │ ├── char.bril │ ├── speculate.bril │ ├── badmem.bril │ ├── speculate.err │ ├── turnt.toml │ └── ssa.bril ├── rs │ ├── cond.out │ ├── boolvar.out │ ├── ackermann.out │ ├── call-explicit.out │ ├── factorial.out │ ├── loopfact.out │ ├── nested_call.out │ ├── float-add.out │ ├── riemann.out │ ├── float-add.rs │ ├── call-explicit.rs │ ├── nested_call.rs │ ├── boolvar.rs │ ├── loopfact.rs │ ├── cond.rs │ ├── factorial.rs │ ├── turnt.toml │ └── cholesky.out ├── interp │ ├── mem │ │ ├── ptr_call.out │ │ ├── ptr_ret.out │ │ ├── fib.out │ │ ├── access.out │ │ ├── alloc.out │ │ ├── mem_id.out │ │ ├── access_many.out │ │ ├── access_ptr.out │ │ ├── alloc_large.out │ │ ├── alloc_many.out │ │ ├── ptr_call.bril │ │ ├── ptr_ret.bril │ │ ├── mem_id.bril │ │ ├── alloc.bril │ │ ├── alloc_many.bril │ │ ├── alloc_large.bril │ │ └── access.bril │ ├── core │ │ ├── br.out │ │ ├── div.out │ │ ├── jmp.out │ │ ├── nop.out │ │ ├── ret.out │ │ ├── tiny.out │ │ ├── call.out │ │ ├── dead_block.out │ │ ├── main-args.out │ │ ├── main-bool-args.out │ │ ├── call-with-args.out │ │ ├── non_linear_control_flow.out │ │ ├── tiny.bril │ │ ├── add-overflow.out │ │ ├── ret.bril │ │ ├── nop.bril │ │ ├── main-args.bril │ │ ├── div.bril │ │ ├── jmp.bril │ │ ├── br.bril │ │ ├── call.bril │ │ ├── dead_block.bril │ │ ├── main-bool-args.bril │ │ └── call-with-args.bril │ ├── ssa │ │ ├── undef.out │ │ ├── ssa-simple.out │ │ ├── ssa-two-phi.out │ │ ├── ssu-regression.out │ │ ├── swap-problem.out │ │ ├── undef.bril │ │ ├── ssa-simple.bril │ │ ├── ssa-two-phi.bril │ │ └── ssu-regression.bril │ ├── char │ │ ├── char.out │ │ ├── char_args.out │ │ ├── conversions.out │ │ ├── control_char.out │ │ ├── char_ops.out │ │ ├── char_args.bril │ │ ├── char.bril │ │ ├── char_ops.bril │ │ ├── conversions.bril │ │ └── control_char.bril │ ├── spec │ │ ├── spec-abort.out │ │ ├── spec-commit.out │ │ ├── spec-noabort.out │ │ ├── spec-nested.out │ │ ├── spec-commit.bril │ │ ├── spec-abort.bril │ │ ├── spec-noabort.bril │ │ └── spec-nested.bril │ ├── dynamic │ │ ├── mem_dynamic_struct.out │ │ ├── float_dynamic.out │ │ ├── mem_dynamic_enum.out │ │ ├── mem_dynamic_dispatch.out │ │ ├── float_dynamic.bril │ │ └── mem_dynamic_struct.bril │ ├── mixed │ │ ├── store-char.out │ │ ├── store-float.out │ │ └── store-float.bril │ ├── float │ │ ├── float_divide_by_zero.out │ │ ├── float_args.out │ │ ├── float.out │ │ ├── float_args.bril │ │ ├── float_special.out │ │ ├── float_divide_by_zero.bril │ │ └── float.bril │ └── bitcast │ │ ├── float_and_int.out │ │ └── float_and_int.bril ├── linking │ ├── recursive.out │ ├── link_ops.out │ ├── nested.out │ ├── diamond.out │ ├── nested.bril │ ├── turnt.toml │ └── diamond.bril ├── ts-error │ ├── call-return-nothing.out │ ├── call-wrong-arity.out │ ├── call-void-return.out │ ├── call-wrong-declared-type.out │ ├── call-nonvoid-return-nothing.out │ ├── call-wrong-arity.err │ ├── call-void-return.err │ ├── call-return-nothing.err │ ├── turnt.toml │ ├── call-nonvoid-return-nothing.err │ ├── call-wrong-declared-type.err │ ├── call-return-nothing.ts │ ├── call-void-return.ts │ ├── call-nonvoid-return-nothing.ts │ ├── call-wrong-declared-type.ts │ └── call-wrong-arity.ts ├── ts │ ├── float-add.ts │ ├── printvar.ts │ ├── turnt.toml │ ├── boolvar.ts │ ├── main.ts │ ├── call.ts │ ├── cond.ts │ ├── nested-call.ts │ ├── call-explicit-void.ts │ ├── printvar.out │ ├── loopfact.ts │ ├── float-add.out │ ├── return.ts │ ├── main.out │ ├── simplified.ts │ ├── call.out │ ├── factorial.ts │ ├── call-explicit-void.out │ ├── nested-call.out │ ├── simplified.out │ ├── memory-call.ts │ └── boolvar.out ├── interp-error │ ├── core-error │ │ ├── divide_by_zero.err │ │ ├── undefined-func.bril │ │ ├── undefined-func.err │ │ ├── call-wrong-arity.err │ │ ├── duplicate_function.err │ │ ├── duplicate_main.err │ │ ├── call-wrong-argument-types.err │ │ ├── call-void-return-error.err │ │ ├── call-return-nothing-error.err │ │ ├── call-nonvoid-return-nothing-error.err │ │ ├── call-return-wrong-type.err │ │ ├── call-wrong-declared-type.err │ │ ├── call-return-nothing-error.bril │ │ ├── call-void-return-error.bril │ │ ├── divide_by_zero.bril │ │ ├── duplicate_main.bril │ │ ├── call-return-wrong-type.bril │ │ ├── duplicate_function.bril │ │ ├── call-wrong-argument-types.bril │ │ ├── call-wrong-arity.bril │ │ ├── call-wrong-declared-type.bril │ │ └── call-nonvoid-return-nothing-error.bril │ ├── ssa-error │ │ ├── missing-set.bril │ │ ├── undef-add.err │ │ ├── undef-print.err │ │ ├── double-phi.err │ │ ├── missing-set.err │ │ ├── undef-print.bril │ │ └── undef-add.bril │ ├── mem-error │ │ ├── wrong_write.err │ │ ├── uninit_read.err │ │ ├── leak.bril │ │ ├── leak.err │ │ ├── out_of_bounds.err │ │ ├── out_of_bounds_2.err │ │ ├── double_free.err │ │ ├── free_offset.err │ │ ├── double_free.bril │ │ ├── uninit_read.bril │ │ ├── wrong_write.bril │ │ ├── out_of_bounds.bril │ │ ├── free_offset.bril │ │ └── out_of_bounds_2.bril │ ├── spec-error │ │ ├── spec-call.err │ │ ├── spec-nonspec-abort.err │ │ ├── spec-return-implicit.bril │ │ ├── spec-return.bril │ │ ├── spec-return.err │ │ ├── spec-double-commit.err │ │ ├── spec-return-implicit.err │ │ ├── spec-double-commit.bril │ │ ├── spec-call.bril │ │ └── spec-nonspec-abort.bril │ ├── char-error │ │ ├── badconversion.err │ │ └── badconversion.bril │ ├── dynamic-error │ │ ├── dynamic_error_simple.err │ │ └── dynamic_error_simple.bril │ └── turnt.toml ├── parse │ ├── print.bril │ ├── add.bril │ ├── comment.bril │ ├── positions.bril │ ├── char.bril │ ├── turnt.toml │ ├── comment.json │ ├── float.bril │ └── print.json └── print │ ├── char.bril │ ├── add.bril │ ├── ptr.bril │ ├── call.bril │ ├── spec-abort.bril │ ├── turnt.toml │ └── char.json ├── benchmarks ├── mem │ ├── lis.out │ ├── vsmul.out │ ├── fib.out │ ├── kadane.out │ ├── binary-search.out │ ├── eight-queens.out │ ├── major-elm.out │ ├── quickselect.out │ ├── two-sum.out │ ├── adler32.out │ ├── dot-product.out │ ├── fnv1-hash.out │ ├── max-subarray.out │ ├── primitive-root.out │ ├── fib.prof │ ├── lis.prof │ ├── 1dconv.prof │ ├── adj2csr.prof │ ├── adler32.prof │ ├── char-poly.prof │ ├── cordic.out │ ├── cordic.prof │ ├── csrmv.prof │ ├── filter.out │ ├── filter.prof │ ├── kadane.prof │ ├── major-elm.prof │ ├── quicksort.prof │ ├── sieve.prof │ ├── systolic.prof │ ├── two-sum.prof │ ├── vsmul.prof │ ├── 2dconvol.prof │ ├── binary-search.prof │ ├── bubblesort.prof │ ├── char-poly.out │ ├── dot-product.prof │ ├── fnv1-hash.prof │ ├── insertion-sort.prof │ ├── mat-mul.prof │ ├── max-subarray.prof │ ├── quickselect.prof │ ├── shufflesort.prof │ ├── bubblesort.out │ ├── eight-queens.prof │ ├── primitive-root.prof │ ├── quicksort-hoare.prof │ ├── connected-components.prof │ ├── insertion-sort.out │ ├── quicksort.out │ ├── sorting-network-five.prof │ ├── shufflesort.out │ ├── sorting-network-five.out │ ├── quicksort-hoare.out │ ├── connected-components.out │ ├── systolic.out │ ├── 1dconv.out │ └── sieve.out ├── core │ ├── euclid.out │ ├── gcd.out │ ├── gebmm.out │ ├── gpf.out │ ├── hamming.out │ ├── lcm.out │ ├── perfect.out │ ├── rot13.out │ ├── tail-call.out │ ├── ackermann.out │ ├── armstrong.out │ ├── bin-search.out │ ├── binpow.out │ ├── bitwise-ops.out │ ├── catalan.out │ ├── dayofweek.out │ ├── legendre.out │ ├── loopfact.out │ ├── mccarthy91.out │ ├── mod_inv.out │ ├── mod_pow.out │ ├── montgomery.out │ ├── mountain.out │ ├── recfact.out │ ├── reverse.out │ ├── sum-bits.out │ ├── sum-digits.out │ ├── triangle.out │ ├── up-arrow.out │ ├── bitshift.out │ ├── combination.out │ ├── delannoy.out │ ├── fib_recursive.out │ ├── fitsinside.out │ ├── geometric-sum.out │ ├── is-decreasing.out │ ├── palindrome.out │ ├── permutation.out │ ├── quadratic.out │ ├── sum-of-cubes.out │ ├── arithmetic-series.out │ ├── bbs.prof │ ├── fact.out │ ├── gcd.prof │ ├── gpf.prof │ ├── grad_desc.out │ ├── karatsuba.out │ ├── rot13.prof │ ├── sqrt_bin_search.out │ ├── sum-divisible-by-m.out │ ├── sum-sq-diff.out │ ├── totient.out │ ├── binpow.prof │ ├── bitshift.prof │ ├── braille.prof │ ├── collatz.prof │ ├── euclid.prof │ ├── fact.prof │ ├── factors.out │ ├── factors.prof │ ├── gebmm.prof │ ├── hamming.prof │ ├── hanoi.prof │ ├── lcm.prof │ ├── legendre.prof │ ├── loopfact.prof │ ├── mod_inv.prof │ ├── mod_pow.prof │ ├── mountain.prof │ ├── orders.prof │ ├── perfect.prof │ ├── recfact.prof │ ├── reverse.prof │ ├── squares.prof │ ├── sum-bits.prof │ ├── totient.prof │ ├── triangle.prof │ ├── up-arrow.prof │ ├── ackermann.prof │ ├── armstrong.prof │ ├── bin-search.prof │ ├── binary-fmt.prof │ ├── bitwise-ops.prof │ ├── catalan.prof │ ├── check-primes.prof │ ├── combination.prof │ ├── dayofweek.prof │ ├── delannoy.prof │ ├── digital-root.prof │ ├── fitsinside.prof │ ├── fizz-buzz.prof │ ├── geometric-sum.prof │ ├── grad_desc.prof │ ├── graycode.prof │ ├── is-decreasing.prof │ ├── karatsuba.prof │ ├── mccarthy91.prof │ ├── montgomery.prof │ ├── palindrome.prof │ ├── pascals-row.prof │ ├── permutation.prof │ ├── quadratic.prof │ ├── sum-check.prof │ ├── sum-digits.prof │ ├── sum-divisors.prof │ ├── sum-of-cubes.prof │ ├── sum-sq-diff.prof │ ├── tail-call.prof │ ├── arithmetic-series.prof │ ├── bbs.out │ ├── fib_recursive.prof │ ├── primes-between.prof │ ├── relative-primes.prof │ ├── sqrt_bin_search.prof │ ├── sum-check.out │ ├── sum-divisible-by-m.prof │ ├── pythagorean_triple.prof │ ├── rectangles-area-difference.out │ ├── braille.out │ ├── pythagorean_triple.out │ ├── rectangles-area-difference.prof │ ├── binary-fmt.out │ ├── pascals-row.out │ ├── hanoi.out │ ├── relative-primes.out │ ├── sum-divisors.out │ ├── digital-root.out │ ├── graycode.out │ ├── collatz.out │ ├── arithmetic-series.bril │ ├── squares.out │ ├── tail-call.bril │ ├── sum-of-cubes.bril │ ├── check-primes.out │ └── squares.bril ├── long │ ├── dead-branch.out │ └── dead-branch.prof ├── float │ ├── pow.prof │ ├── sin.out │ ├── sin.prof │ ├── birthday.out │ ├── cordic.out │ ├── cordic.prof │ ├── euler.out │ ├── euler.prof │ ├── leibniz.out │ ├── n_root.out │ ├── n_root.prof │ ├── newton.out │ ├── newton.prof │ ├── norm.out │ ├── norm.prof │ ├── pow.out │ ├── ray-bbox-intersection.out │ ├── ray-sphere-intersection.out │ ├── rgb2gray.prof │ ├── riemann.prof │ ├── sqrt.out │ ├── sqrt.prof │ ├── birthday.prof │ ├── harmonic-sum.out │ ├── leibniz.prof │ ├── logistic.prof │ ├── rgb2gray.out │ ├── sum-to-ten.out │ ├── sum-to-ten.prof │ ├── harmonic-sum.prof │ ├── mandelbrot.prof │ ├── conjugate-gradient.prof │ ├── ray-bbox-intersection.prof │ ├── exponentiation-by-squaring.prof │ ├── ray-sphere-intersection.prof │ ├── exponentiation-by-squaring.out │ ├── riemann.out │ └── conjugate-gradient.out ├── pi.prof ├── mixed │ ├── gol.prof │ ├── cholesky.prof │ ├── mat-inv.prof │ ├── random_walk.prof │ ├── brilirs-only │ │ ├── montecarlo.out │ │ ├── fast-inverse-sqrt.out │ │ ├── fast-inverse-sqrt.prof │ │ └── montecarlo.prof │ ├── gol.out │ └── mat-inv.out └── .gitignore ├── brench └── .gitignore ├── brilift └── .gitignore ├── bril2json-rs ├── .gitignore ├── parse-error.bril └── Cargo.toml ├── examples ├── test │ ├── ssa │ │ ├── if-orig.out │ │ ├── if-ssa.out │ │ ├── loop-orig.out │ │ ├── loop-ssa.out │ │ ├── turnt.toml │ │ ├── if-orig.bril │ │ └── loop-orig.bril │ ├── from_ssa │ │ ├── basic.out │ │ ├── dead-set.out │ │ ├── ssa-simple.out │ │ ├── swap-problem.out │ │ ├── basic.bril │ │ ├── dead-set.bril │ │ ├── turnt.toml │ │ └── ssa-simple.bril │ ├── ssa_roundtrip │ │ ├── if.out │ │ ├── loop-branch.out │ │ ├── loop.out │ │ ├── while.out │ │ ├── argwrite.out │ │ ├── if-const.out │ │ ├── if-ssa.out │ │ ├── selfloop.out │ │ ├── argwrite.bril │ │ ├── turnt.toml │ │ ├── selfloop.bril │ │ ├── if.bril │ │ ├── loop.bril │ │ ├── while.bril │ │ └── if-const.bril │ ├── tdce │ │ ├── reassign-dkp.out │ │ ├── turnt.toml │ │ ├── reassign.bril │ │ ├── reassign.out │ │ ├── combo.out │ │ ├── double.out │ │ ├── reassign-dkp.bril │ │ ├── simple.out │ │ ├── skipped.bril │ │ ├── skipped.out │ │ ├── double-pass.out │ │ ├── simple.bril │ │ ├── double.bril │ │ ├── combo.bril │ │ ├── double-pass.bril │ │ ├── diamond.bril │ │ └── diamond.out │ ├── lvn │ │ ├── clobber-fold.out │ │ ├── turnt.toml │ │ ├── reassign.bril │ │ ├── reassign.out │ │ ├── clobber-arg.out │ │ ├── clobber-arg.bril │ │ ├── rename-fold.out │ │ ├── nonlocal-clobber.out │ │ ├── nonlocal-clobber.bril │ │ ├── divide-by-zero.out │ │ ├── idchain.out │ │ ├── clobber.out │ │ ├── divide-by-zero.bril │ │ ├── idchain-prop.out │ │ ├── idchain.bril │ │ ├── redundant-dce.out │ │ ├── idchain-prop.bril │ │ ├── commute.out │ │ ├── redundant.out │ │ ├── idchain-nonlocal.out │ │ ├── redundant.bril │ │ ├── idchain-nonlocal.bril │ │ ├── nonlocal.bril │ │ ├── nonlocal.out │ │ ├── commute.bril │ │ ├── redundant-dce.bril │ │ └── rename-fold.bril │ ├── dom │ │ ├── loopcond.ts │ │ ├── while.front.json │ │ ├── while.tree.json │ │ ├── loopcond.front.json │ │ ├── loopcond.tree.json │ │ ├── while.bril │ │ ├── while.dom.json │ │ └── turnt.toml │ ├── to_ssa │ │ ├── argwrite.bril │ │ ├── turnt.toml │ │ ├── if.bril │ │ ├── selfloop.bril │ │ ├── argwrite.full │ │ ├── loop.bril │ │ ├── while.bril │ │ ├── if.full │ │ └── if-const.bril │ └── df │ │ ├── cond.live.out │ │ ├── cond-args.live.out │ │ ├── cond-args.defined.out │ │ ├── fact.live.out │ │ ├── cond.defined.out │ │ ├── cond-args.cprop.out │ │ ├── fact.defined.out │ │ ├── cond-args.bril │ │ ├── cond.bril │ │ ├── cond.cprop.out │ │ ├── turnt.toml │ │ └── fact.bril ├── .gitignore ├── Makefile └── README.md ├── fastbril ├── config │ ├── ssa.cf │ ├── types.cf │ ├── mem.cf │ ├── float.cf │ └── base.cf ├── src │ ├── bril-insns │ │ ├── ssa.h │ │ ├── types.h │ │ ├── mem.h │ │ └── float.h │ ├── .gitignore │ ├── asm │ │ ├── trivial-regalloc.h │ │ ├── linear-scan.h │ │ └── to_abstract_asm.h │ ├── parser.h │ └── byte-io.h ├── .gitignore ├── srcgen.awk ├── doc │ └── .gitignore ├── docgen.awk └── docgen.sh ├── flat-bril ├── rustfmt.toml ├── .gitignore └── Cargo.toml ├── bril-ocaml ├── dune-workspace ├── .gitignore ├── test │ └── count │ │ ├── empty.bril │ │ ├── ptr.out │ │ ├── bools.out │ │ ├── empty.out │ │ ├── floats.out │ │ ├── funcs.out │ │ ├── ints.out │ │ ├── ints.bril │ │ ├── turnt.toml │ │ ├── bools.bril │ │ ├── floats.bril │ │ └── funcs.bril ├── dune-project ├── count │ └── dune └── lib │ ├── dest.ml │ ├── dest.mli │ ├── dune │ ├── common.mli │ ├── const.mli │ ├── common.ml │ ├── const.ml │ ├── bril_type.mli │ └── bril.mli ├── bril-rs ├── brillvm │ ├── .gitignore │ └── runtime │ │ └── build.rs ├── bril2json │ ├── .gitignore │ ├── build.rs │ ├── README.md │ └── src │ │ └── main.rs ├── .gitignore └── examples │ └── bril2txt.rs ├── brilirs └── .rustfmt.toml ├── brilir ├── lib │ └── CMakeLists.txt ├── include │ ├── CMakeLists.txt │ └── bril │ │ └── CMakeLists.txt ├── bril2mlir │ └── CMakeLists.txt ├── bril-opt │ └── CMakeLists.txt └── mlir2bril │ └── CMakeLists.txt ├── type-infer ├── tests │ ├── infer │ │ ├── tiny.bril │ │ ├── tiny.tbril │ │ ├── ret.bril │ │ ├── ret.tbril │ │ ├── nop.bril │ │ ├── nop.tbril │ │ ├── turnt.toml │ │ ├── div.bril │ │ ├── div.tbril │ │ ├── jmp.bril │ │ ├── jmp.tbril │ │ ├── tricky-jump.bril │ │ ├── tricky-jump.tbril │ │ ├── br.bril │ │ ├── br.tbril │ │ ├── many_functions.bril │ │ ├── addarg.bril │ │ ├── addarg.tbril │ │ ├── many_functions.tbril │ │ ├── idchain.bril │ │ ├── logic_ops.bril │ │ ├── idchain.tbril │ │ ├── control_ops.bril │ │ ├── arith_ops.bril │ │ ├── logic_ops.tbril │ │ ├── control_ops.tbril │ │ ├── arith_ops.tbril │ │ └── comp_ops.bril │ ├── print │ │ ├── turnt.toml │ │ ├── add.bril │ │ ├── partial.bril │ │ └── div.bril │ ├── typecheck │ │ ├── tiny.bril │ │ ├── tiny.tbril │ │ ├── ret.bril │ │ ├── ret.tbril │ │ ├── nop.bril │ │ ├── nop.tbril │ │ ├── turnt.toml │ │ ├── div.bril │ │ ├── div.tbril │ │ ├── jmp.bril │ │ ├── jmp.tbril │ │ ├── tricky-jump.bril │ │ ├── tricky-jump.tbril │ │ ├── br.bril │ │ ├── br.tbril │ │ ├── many_functions.bril │ │ ├── many_functions.tbril │ │ ├── idchain.bril │ │ ├── logic_ops.bril │ │ ├── idchain.tbril │ │ ├── control_ops.bril │ │ ├── arith_ops.bril │ │ ├── logic_ops.tbril │ │ ├── control_ops.tbril │ │ ├── arith_ops.tbril │ │ └── comp_ops.bril │ ├── parse │ │ ├── turnt.toml │ │ ├── add.bril │ │ ├── partial.bril │ │ └── div.bril │ ├── fail-infer │ │ ├── turnt.toml │ │ ├── assign_label.bril │ │ ├── div.bril │ │ ├── jmp.bril │ │ ├── tricky-jump.bril │ │ ├── br.bril │ │ ├── many_functions.bril │ │ ├── idchain.bril │ │ ├── logic_ops.bril │ │ ├── control_ops.bril │ │ ├── arith_ops.bril │ │ └── comp_ops.bril │ └── fail-typecheck │ │ ├── turnt.toml │ │ ├── tiny.bril │ │ ├── ret.bril │ │ ├── nop.bril │ │ ├── add.bril │ │ ├── div.bril │ │ ├── jmp.bril │ │ ├── tricky-jump.bril │ │ ├── br.bril │ │ ├── many_functions.bril │ │ ├── idchain.bril │ │ ├── logic_ops.bril │ │ ├── control_ops.bril │ │ ├── arith_ops.bril │ │ └── comp_ops.bril └── Makefile ├── bril-vim ├── ftdetect │ └── bril.vim └── ftplugin │ └── bril.vim ├── bril-swift ├── Sources │ └── Bril │ │ ├── BrilParseError.swift │ │ ├── Argument.swift │ │ └── Program.swift └── .gitignore ├── docs └── tools │ └── README.md ├── .gitignore ├── bracket └── tests │ ├── recfact.rkt │ ├── triangle.rkt │ ├── loopfact.rkt │ ├── mccarthy91.rkt │ ├── fib_recursive.rkt │ ├── ackermann.rkt │ ├── gcd.rkt │ └── delannoy.rkt ├── bril-llvm └── README.md ├── .github └── brilck-matcher.json └── bril-ts └── util.ts /test/check/mem.err: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/check/tiny.err: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/rs/cond.out: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /benchmarks/mem/lis.out: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /benchmarks/mem/vsmul.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /brench/.gitignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | -------------------------------------------------------------------------------- /test/check/main-args.err: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/interp/mem/ptr_call.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/interp/mem/ptr_ret.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/rs/boolvar.out: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /benchmarks/core/euclid.out: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /benchmarks/core/gcd.out: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /benchmarks/core/gebmm.out: -------------------------------------------------------------------------------- 1 | 188 2 | -------------------------------------------------------------------------------- /benchmarks/core/gpf.out: -------------------------------------------------------------------------------- 1 | 29 2 | -------------------------------------------------------------------------------- /benchmarks/core/hamming.out: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /benchmarks/core/lcm.out: -------------------------------------------------------------------------------- 1 | 192 2 | -------------------------------------------------------------------------------- /benchmarks/core/perfect.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /benchmarks/core/rot13.out: -------------------------------------------------------------------------------- 1 | 23 2 | -------------------------------------------------------------------------------- /benchmarks/core/tail-call.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/mem/fib.out: -------------------------------------------------------------------------------- 1 | 34 2 | -------------------------------------------------------------------------------- /benchmarks/mem/kadane.out: -------------------------------------------------------------------------------- 1 | 6 2 | -------------------------------------------------------------------------------- /brilift/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /test/interp/core/br.out: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/interp/core/div.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/interp/core/jmp.out: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /test/interp/core/nop.out: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /test/interp/core/ret.out: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /test/interp/core/tiny.out: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /test/interp/mem/fib.out: -------------------------------------------------------------------------------- 1 | 34 2 | -------------------------------------------------------------------------------- /test/interp/ssa/undef.out: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/linking/recursive.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/rs/ackermann.out: -------------------------------------------------------------------------------- 1 | 509 2 | -------------------------------------------------------------------------------- /test/rs/call-explicit.out: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /test/rs/factorial.out: -------------------------------------------------------------------------------- 1 | 120 2 | -------------------------------------------------------------------------------- /test/rs/loopfact.out: -------------------------------------------------------------------------------- 1 | 40320 2 | -------------------------------------------------------------------------------- /test/rs/nested_call.out: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /benchmarks/core/ackermann.out: -------------------------------------------------------------------------------- 1 | 509 2 | -------------------------------------------------------------------------------- /benchmarks/core/armstrong.out: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /benchmarks/core/bin-search.out: -------------------------------------------------------------------------------- 1 | 738 2 | -------------------------------------------------------------------------------- /benchmarks/core/binpow.out: -------------------------------------------------------------------------------- 1 | 2048 2 | -------------------------------------------------------------------------------- /benchmarks/core/bitwise-ops.out: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /benchmarks/core/catalan.out: -------------------------------------------------------------------------------- 1 | 16796 2 | -------------------------------------------------------------------------------- /benchmarks/core/dayofweek.out: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /benchmarks/core/legendre.out: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /benchmarks/core/loopfact.out: -------------------------------------------------------------------------------- 1 | 40320 2 | -------------------------------------------------------------------------------- /benchmarks/core/mccarthy91.out: -------------------------------------------------------------------------------- 1 | 91 2 | -------------------------------------------------------------------------------- /benchmarks/core/mod_inv.out: -------------------------------------------------------------------------------- 1 | 2393 2 | -------------------------------------------------------------------------------- /benchmarks/core/mod_pow.out: -------------------------------------------------------------------------------- 1 | 445 2 | -------------------------------------------------------------------------------- /benchmarks/core/montgomery.out: -------------------------------------------------------------------------------- 1 | 11 2 | -------------------------------------------------------------------------------- /benchmarks/core/mountain.out: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /benchmarks/core/recfact.out: -------------------------------------------------------------------------------- 1 | 40320 2 | -------------------------------------------------------------------------------- /benchmarks/core/reverse.out: -------------------------------------------------------------------------------- 1 | 321 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-bits.out: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-digits.out: -------------------------------------------------------------------------------- 1 | 45 2 | -------------------------------------------------------------------------------- /benchmarks/core/triangle.out: -------------------------------------------------------------------------------- 1 | 666 2 | -------------------------------------------------------------------------------- /benchmarks/core/up-arrow.out: -------------------------------------------------------------------------------- 1 | 65536 2 | -------------------------------------------------------------------------------- /benchmarks/long/dead-branch.out: -------------------------------------------------------------------------------- 1 | 50 2 | -------------------------------------------------------------------------------- /benchmarks/mem/binary-search.out: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /benchmarks/mem/eight-queens.out: -------------------------------------------------------------------------------- 1 | 92 2 | -------------------------------------------------------------------------------- /benchmarks/mem/major-elm.out: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /benchmarks/mem/quickselect.out: -------------------------------------------------------------------------------- 1 | 108 2 | -------------------------------------------------------------------------------- /benchmarks/mem/two-sum.out: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | -------------------------------------------------------------------------------- /bril2json-rs/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /examples/test/ssa/if-orig.out: -------------------------------------------------------------------------------- 1 | no 2 | -------------------------------------------------------------------------------- /examples/test/ssa/if-ssa.out: -------------------------------------------------------------------------------- 1 | yes 2 | -------------------------------------------------------------------------------- /examples/test/ssa/loop-orig.out: -------------------------------------------------------------------------------- 1 | no 2 | -------------------------------------------------------------------------------- /examples/test/ssa/loop-ssa.out: -------------------------------------------------------------------------------- 1 | yes 2 | -------------------------------------------------------------------------------- /fastbril/config/ssa.cf: -------------------------------------------------------------------------------- 1 | PHI 22 2 | 3 | -------------------------------------------------------------------------------- /flat-bril/rustfmt.toml: -------------------------------------------------------------------------------- 1 | max_width = 80 -------------------------------------------------------------------------------- /test/interp/char/char.out: -------------------------------------------------------------------------------- 1 | h e y 🐶 2 | -------------------------------------------------------------------------------- /test/interp/core/call.out: -------------------------------------------------------------------------------- 1 | 4 2 | 2 3 | -------------------------------------------------------------------------------- /test/interp/core/dead_block.out: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/interp/core/main-args.out: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /test/interp/mem/access.out: -------------------------------------------------------------------------------- 1 | 1000000 2 | -------------------------------------------------------------------------------- /test/interp/mem/alloc.out: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/interp/mem/mem_id.out: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/interp/spec/spec-abort.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/interp/spec/spec-commit.out: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/interp/ssa/ssa-simple.out: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /test/ts-error/call-return-nothing.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/ts-error/call-wrong-arity.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/core/bitshift.out: -------------------------------------------------------------------------------- 1 | 96 2 | 625 3 | -------------------------------------------------------------------------------- /benchmarks/core/combination.out: -------------------------------------------------------------------------------- 1 | 220 2 | -------------------------------------------------------------------------------- /benchmarks/core/delannoy.out: -------------------------------------------------------------------------------- 1 | 265729 2 | -------------------------------------------------------------------------------- /benchmarks/core/fib_recursive.out: -------------------------------------------------------------------------------- 1 | 55 2 | -------------------------------------------------------------------------------- /benchmarks/core/fitsinside.out: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /benchmarks/core/geometric-sum.out: -------------------------------------------------------------------------------- 1 | 242 2 | -------------------------------------------------------------------------------- /benchmarks/core/is-decreasing.out: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /benchmarks/core/palindrome.out: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /benchmarks/core/permutation.out: -------------------------------------------------------------------------------- 1 | 120 2 | -------------------------------------------------------------------------------- /benchmarks/core/quadratic.out: -------------------------------------------------------------------------------- 1 | -1 2 | 3 3 | -------------------------------------------------------------------------------- /benchmarks/core/sum-of-cubes.out: -------------------------------------------------------------------------------- 1 | 441 2 | -------------------------------------------------------------------------------- /benchmarks/mem/adler32.out: -------------------------------------------------------------------------------- 1 | 1794899728 2 | -------------------------------------------------------------------------------- /benchmarks/mem/dot-product.out: -------------------------------------------------------------------------------- 1 | 17050 2 | -------------------------------------------------------------------------------- /benchmarks/mem/fnv1-hash.out: -------------------------------------------------------------------------------- 1 | 8573363309 2 | -------------------------------------------------------------------------------- /benchmarks/mem/max-subarray.out: -------------------------------------------------------------------------------- 1 | 100 2 | -------------------------------------------------------------------------------- /benchmarks/mem/primitive-root.out: -------------------------------------------------------------------------------- 1 | 17 2 | -------------------------------------------------------------------------------- /bril-ocaml/dune-workspace: -------------------------------------------------------------------------------- 1 | (lang dune 2.7) -------------------------------------------------------------------------------- /bril-rs/brillvm/.gitignore: -------------------------------------------------------------------------------- 1 | *.bc 2 | *.ll -------------------------------------------------------------------------------- /brilirs/.rustfmt.toml: -------------------------------------------------------------------------------- 1 | tab_spaces = 2 2 | -------------------------------------------------------------------------------- /examples/test/from_ssa/basic.out: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /examples/test/from_ssa/dead-set.out: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /examples/test/from_ssa/ssa-simple.out: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/if.out: -------------------------------------------------------------------------------- 1 | 2209 2 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/loop-branch.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/loop.out: -------------------------------------------------------------------------------- 1 | 16 2 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/while.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/interp/char/char_args.out: -------------------------------------------------------------------------------- 1 | h e y 🐱 2 | -------------------------------------------------------------------------------- /test/interp/core/main-bool-args.out: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/interp/mem/access_many.out: -------------------------------------------------------------------------------- 1 | 1000000 2 | -------------------------------------------------------------------------------- /test/interp/mem/access_ptr.out: -------------------------------------------------------------------------------- 1 | 1000000 2 | -------------------------------------------------------------------------------- /test/interp/mem/alloc_large.out: -------------------------------------------------------------------------------- 1 | 1000000 2 | -------------------------------------------------------------------------------- /test/interp/mem/alloc_many.out: -------------------------------------------------------------------------------- 1 | 1000000 2 | -------------------------------------------------------------------------------- /test/interp/spec/spec-noabort.out: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/interp/ssa/ssa-two-phi.out: -------------------------------------------------------------------------------- 1 | 7 2 | 7 3 | -------------------------------------------------------------------------------- /test/interp/ssa/ssu-regression.out: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/linking/link_ops.out: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 0 4 | -------------------------------------------------------------------------------- /test/linking/nested.out: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 0 4 | -------------------------------------------------------------------------------- /test/ts-error/call-void-return.out: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /test/ts-error/call-wrong-declared-type.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/core/arithmetic-series.out: -------------------------------------------------------------------------------- 1 | 28 2 | -------------------------------------------------------------------------------- /benchmarks/core/bbs.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 137 2 | -------------------------------------------------------------------------------- /benchmarks/core/fact.out: -------------------------------------------------------------------------------- 1 | 2432902008176640000 2 | -------------------------------------------------------------------------------- /benchmarks/core/gcd.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 46 2 | -------------------------------------------------------------------------------- /benchmarks/core/gpf.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 759 2 | -------------------------------------------------------------------------------- /benchmarks/core/grad_desc.out: -------------------------------------------------------------------------------- 1 | 2048 2 | 2304 3 | -------------------------------------------------------------------------------- /benchmarks/core/karatsuba.out: -------------------------------------------------------------------------------- 1 | 4267635650 2 | -------------------------------------------------------------------------------- /benchmarks/core/rot13.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 8 2 | -------------------------------------------------------------------------------- /benchmarks/core/sqrt_bin_search.out: -------------------------------------------------------------------------------- 1 | 6120 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-divisible-by-m.out: -------------------------------------------------------------------------------- 1 | 15150 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-sq-diff.out: -------------------------------------------------------------------------------- 1 | 25164150 2 | -------------------------------------------------------------------------------- /benchmarks/core/totient.out: -------------------------------------------------------------------------------- 1 | 2023 2 | 1632 3 | -------------------------------------------------------------------------------- /benchmarks/float/pow.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 36 2 | -------------------------------------------------------------------------------- /benchmarks/float/sin.out: -------------------------------------------------------------------------------- 1 | 0.97533831838863938 2 | -------------------------------------------------------------------------------- /benchmarks/float/sin.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 58 2 | -------------------------------------------------------------------------------- /benchmarks/mem/fib.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 121 2 | -------------------------------------------------------------------------------- /benchmarks/mem/lis.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 583 2 | -------------------------------------------------------------------------------- /benchmarks/pi.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 5929426 2 | -------------------------------------------------------------------------------- /bril-ocaml/.gitignore: -------------------------------------------------------------------------------- 1 | .merlin 2 | _build/ 3 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/empty.bril: -------------------------------------------------------------------------------- 1 | @main {} 2 | -------------------------------------------------------------------------------- /bril-rs/bril2json/.gitignore: -------------------------------------------------------------------------------- 1 | src/bril_grammar.rs -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/argwrite.out: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/if-const.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/if-ssa.out: -------------------------------------------------------------------------------- 1 | 94 2 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/selfloop.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /fastbril/src/bril-insns/ssa.h: -------------------------------------------------------------------------------- 1 | #define PHI 22 2 | -------------------------------------------------------------------------------- /test/interp/spec/spec-nested.out: -------------------------------------------------------------------------------- 1 | 2 2 | 0 3 | -------------------------------------------------------------------------------- /test/rs/float-add.out: -------------------------------------------------------------------------------- 1 | 42.00000000000000000 2 | -------------------------------------------------------------------------------- /test/ts-error/call-nonvoid-return-nothing.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/core/binpow.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 105 2 | -------------------------------------------------------------------------------- /benchmarks/core/bitshift.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 167 2 | -------------------------------------------------------------------------------- /benchmarks/core/braille.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 325 2 | -------------------------------------------------------------------------------- /benchmarks/core/collatz.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 169 2 | -------------------------------------------------------------------------------- /benchmarks/core/euclid.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 563 2 | -------------------------------------------------------------------------------- /benchmarks/core/fact.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 229 2 | -------------------------------------------------------------------------------- /benchmarks/core/factors.out: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | 3 4 | 5 5 | -------------------------------------------------------------------------------- /benchmarks/core/factors.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 72 2 | -------------------------------------------------------------------------------- /benchmarks/core/gebmm.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 3011 2 | -------------------------------------------------------------------------------- /benchmarks/core/hamming.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 117 2 | -------------------------------------------------------------------------------- /benchmarks/core/hanoi.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 99 2 | -------------------------------------------------------------------------------- /benchmarks/core/lcm.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 2326 2 | -------------------------------------------------------------------------------- /benchmarks/core/legendre.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 153 2 | -------------------------------------------------------------------------------- /benchmarks/core/loopfact.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 116 2 | -------------------------------------------------------------------------------- /benchmarks/core/mod_inv.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 558 2 | -------------------------------------------------------------------------------- /benchmarks/core/mod_pow.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 243 2 | -------------------------------------------------------------------------------- /benchmarks/core/mountain.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 100 2 | -------------------------------------------------------------------------------- /benchmarks/core/orders.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 5352 2 | -------------------------------------------------------------------------------- /benchmarks/core/perfect.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 232 2 | -------------------------------------------------------------------------------- /benchmarks/core/recfact.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 104 2 | -------------------------------------------------------------------------------- /benchmarks/core/reverse.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 46 2 | -------------------------------------------------------------------------------- /benchmarks/core/squares.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 153 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-bits.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 73 2 | -------------------------------------------------------------------------------- /benchmarks/core/totient.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 253 2 | -------------------------------------------------------------------------------- /benchmarks/core/triangle.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 188 2 | -------------------------------------------------------------------------------- /benchmarks/core/up-arrow.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 252 2 | -------------------------------------------------------------------------------- /benchmarks/float/birthday.out: -------------------------------------------------------------------------------- 1 | 0.50729723432398566 2 | -------------------------------------------------------------------------------- /benchmarks/float/cordic.out: -------------------------------------------------------------------------------- 1 | 0.86369602123419631 2 | -------------------------------------------------------------------------------- /benchmarks/float/cordic.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 517 2 | -------------------------------------------------------------------------------- /benchmarks/float/euler.out: -------------------------------------------------------------------------------- 1 | 2.71828182845904553 2 | -------------------------------------------------------------------------------- /benchmarks/float/euler.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1908 2 | -------------------------------------------------------------------------------- /benchmarks/float/leibniz.out: -------------------------------------------------------------------------------- 1 | 3.14159365359077425 2 | -------------------------------------------------------------------------------- /benchmarks/float/n_root.out: -------------------------------------------------------------------------------- 1 | 1.51571786995120950 2 | -------------------------------------------------------------------------------- /benchmarks/float/n_root.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 733 2 | -------------------------------------------------------------------------------- /benchmarks/float/newton.out: -------------------------------------------------------------------------------- 1 | 316.22618487405497945 2 | -------------------------------------------------------------------------------- /benchmarks/float/newton.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 217 2 | -------------------------------------------------------------------------------- /benchmarks/float/norm.out: -------------------------------------------------------------------------------- 1 | 110.55285076250027032 2 | -------------------------------------------------------------------------------- /benchmarks/float/norm.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 505 2 | -------------------------------------------------------------------------------- /benchmarks/float/pow.out: -------------------------------------------------------------------------------- 1 | 10.24000000000000199 2 | -------------------------------------------------------------------------------- /benchmarks/float/ray-bbox-intersection.out: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /benchmarks/float/ray-sphere-intersection.out: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /benchmarks/float/rgb2gray.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 14 2 | -------------------------------------------------------------------------------- /benchmarks/float/riemann.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 298 2 | -------------------------------------------------------------------------------- /benchmarks/float/sqrt.out: -------------------------------------------------------------------------------- 1 | 18.08314132002512409 2 | -------------------------------------------------------------------------------- /benchmarks/float/sqrt.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 322 2 | -------------------------------------------------------------------------------- /benchmarks/mem/1dconv.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 391 2 | -------------------------------------------------------------------------------- /benchmarks/mem/adj2csr.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 56629 2 | -------------------------------------------------------------------------------- /benchmarks/mem/adler32.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 6851 2 | -------------------------------------------------------------------------------- /benchmarks/mem/char-poly.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 383 2 | -------------------------------------------------------------------------------- /benchmarks/mem/cordic.out: -------------------------------------------------------------------------------- 1 | 0.76616737005754065 2 | -------------------------------------------------------------------------------- /benchmarks/mem/cordic.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1062 2 | -------------------------------------------------------------------------------- /benchmarks/mem/csrmv.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 121202 2 | -------------------------------------------------------------------------------- /benchmarks/mem/filter.out: -------------------------------------------------------------------------------- 1 | 102 2 | 103 3 | 105 4 | -------------------------------------------------------------------------------- /benchmarks/mem/filter.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 94 2 | -------------------------------------------------------------------------------- /benchmarks/mem/kadane.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 157 2 | -------------------------------------------------------------------------------- /benchmarks/mem/major-elm.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 47 2 | -------------------------------------------------------------------------------- /benchmarks/mem/quicksort.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 264 2 | -------------------------------------------------------------------------------- /benchmarks/mem/sieve.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 3482 2 | -------------------------------------------------------------------------------- /benchmarks/mem/systolic.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 527 2 | -------------------------------------------------------------------------------- /benchmarks/mem/two-sum.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 98 2 | -------------------------------------------------------------------------------- /benchmarks/mem/vsmul.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 86036 2 | -------------------------------------------------------------------------------- /benchmarks/mixed/gol.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1425 2 | -------------------------------------------------------------------------------- /brilir/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(bril) 2 | -------------------------------------------------------------------------------- /fastbril/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *~ 3 | \#*\# 4 | *.o -------------------------------------------------------------------------------- /test/check/undef.err: -------------------------------------------------------------------------------- 1 | 2:3: a (arg 0) undefined 2 | -------------------------------------------------------------------------------- /test/interp/char/conversions.out: -------------------------------------------------------------------------------- 1 | A 65 𝛀 120512 2 | -------------------------------------------------------------------------------- /test/interp/core/call-with-args.out: -------------------------------------------------------------------------------- 1 | 4 2 | 2 3 | 4 4 | -------------------------------------------------------------------------------- /test/interp/dynamic/mem_dynamic_struct.out: -------------------------------------------------------------------------------- 1 | true 0 2 | -------------------------------------------------------------------------------- /test/interp/mixed/store-char.out: -------------------------------------------------------------------------------- 1 | o 2 | i 3 | . 4 | -------------------------------------------------------------------------------- /test/ts/float-add.ts: -------------------------------------------------------------------------------- 1 | console.log(40.2 + 1.8); 2 | -------------------------------------------------------------------------------- /benchmarks/core/ackermann.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1464231 2 | -------------------------------------------------------------------------------- /benchmarks/core/armstrong.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 133 2 | -------------------------------------------------------------------------------- /benchmarks/core/bin-search.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 358 2 | -------------------------------------------------------------------------------- /benchmarks/core/binary-fmt.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 100 2 | -------------------------------------------------------------------------------- /benchmarks/core/bitwise-ops.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1690 2 | -------------------------------------------------------------------------------- /benchmarks/core/catalan.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 659378 2 | -------------------------------------------------------------------------------- /benchmarks/core/check-primes.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 8468 2 | -------------------------------------------------------------------------------- /benchmarks/core/combination.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 178 2 | -------------------------------------------------------------------------------- /benchmarks/core/dayofweek.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 269 2 | -------------------------------------------------------------------------------- /benchmarks/core/delannoy.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 5748752 2 | -------------------------------------------------------------------------------- /benchmarks/core/digital-root.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 247 2 | -------------------------------------------------------------------------------- /benchmarks/core/fitsinside.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 10 2 | -------------------------------------------------------------------------------- /benchmarks/core/fizz-buzz.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 3652 2 | -------------------------------------------------------------------------------- /benchmarks/core/geometric-sum.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 35 2 | -------------------------------------------------------------------------------- /benchmarks/core/grad_desc.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 229 2 | -------------------------------------------------------------------------------- /benchmarks/core/graycode.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1259 2 | -------------------------------------------------------------------------------- /benchmarks/core/is-decreasing.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 127 2 | -------------------------------------------------------------------------------- /benchmarks/core/karatsuba.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1548 2 | -------------------------------------------------------------------------------- /benchmarks/core/mccarthy91.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1385 2 | -------------------------------------------------------------------------------- /benchmarks/core/montgomery.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 17 2 | -------------------------------------------------------------------------------- /benchmarks/core/palindrome.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 298 2 | -------------------------------------------------------------------------------- /benchmarks/core/pascals-row.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 146 2 | -------------------------------------------------------------------------------- /benchmarks/core/permutation.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 130 2 | -------------------------------------------------------------------------------- /benchmarks/core/quadratic.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 785 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-check.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 5018 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-digits.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 219 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-divisors.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 159 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-of-cubes.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 8 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-sq-diff.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 3038 2 | -------------------------------------------------------------------------------- /benchmarks/core/tail-call.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 10504 2 | -------------------------------------------------------------------------------- /benchmarks/float/birthday.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 484 2 | -------------------------------------------------------------------------------- /benchmarks/float/harmonic-sum.out: -------------------------------------------------------------------------------- 1 | 14.07801616295706282 2 | -------------------------------------------------------------------------------- /benchmarks/float/leibniz.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 12499997 2 | -------------------------------------------------------------------------------- /benchmarks/float/logistic.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1110 2 | -------------------------------------------------------------------------------- /benchmarks/float/rgb2gray.out: -------------------------------------------------------------------------------- 1 | 170.37999999999996703 2 | -------------------------------------------------------------------------------- /benchmarks/float/sum-to-ten.out: -------------------------------------------------------------------------------- 1 | 55.00000000000000000 2 | -------------------------------------------------------------------------------- /benchmarks/float/sum-to-ten.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 143 2 | -------------------------------------------------------------------------------- /benchmarks/long/dead-branch.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1196 2 | -------------------------------------------------------------------------------- /benchmarks/mem/2dconvol.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 21709 2 | -------------------------------------------------------------------------------- /benchmarks/mem/binary-search.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 78 2 | -------------------------------------------------------------------------------- /benchmarks/mem/bubblesort.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 253 2 | -------------------------------------------------------------------------------- /benchmarks/mem/char-poly.out: -------------------------------------------------------------------------------- 1 | -1 2 | 8 3 | -11 4 | -156 5 | -------------------------------------------------------------------------------- /benchmarks/mem/dot-product.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 88 2 | -------------------------------------------------------------------------------- /benchmarks/mem/fnv1-hash.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1768440 2 | -------------------------------------------------------------------------------- /benchmarks/mem/insertion-sort.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 170 2 | -------------------------------------------------------------------------------- /benchmarks/mem/mat-mul.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1990407 2 | -------------------------------------------------------------------------------- /benchmarks/mem/max-subarray.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 193 2 | -------------------------------------------------------------------------------- /benchmarks/mem/quickselect.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 279 2 | -------------------------------------------------------------------------------- /benchmarks/mem/shufflesort.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 36564 2 | -------------------------------------------------------------------------------- /benchmarks/mixed/cholesky.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 3761 2 | -------------------------------------------------------------------------------- /benchmarks/mixed/mat-inv.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1044 2 | -------------------------------------------------------------------------------- /bril-ocaml/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 2.7) 2 | (name bril) -------------------------------------------------------------------------------- /brilir/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(bril) 2 | -------------------------------------------------------------------------------- /test/check/extra.err: -------------------------------------------------------------------------------- 1 | 2:3: add expects 2 args, not 3 2 | -------------------------------------------------------------------------------- /test/check/missarg.err: -------------------------------------------------------------------------------- 1 | 2:3: add expects 2 args, not 1 2 | -------------------------------------------------------------------------------- /test/interp/char/control_char.out: -------------------------------------------------------------------------------- 1 |   2 | 3 | -------------------------------------------------------------------------------- /test/interp/core/non_linear_control_flow.out: -------------------------------------------------------------------------------- 1 | 2 2 | 0 3 | -------------------------------------------------------------------------------- /test/ts/printvar.ts: -------------------------------------------------------------------------------- 1 | var x = 5n; 2 | console.log(x); 3 | -------------------------------------------------------------------------------- /benchmarks/.gitignore: -------------------------------------------------------------------------------- 1 | *.json 2 | bench.csv 3 | plot.svg 4 | -------------------------------------------------------------------------------- /benchmarks/core/arithmetic-series.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 7 2 | -------------------------------------------------------------------------------- /benchmarks/core/bbs.out: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 0 4 | 0 5 | 1 6 | 0 7 | -------------------------------------------------------------------------------- /benchmarks/core/fib_recursive.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 2693 2 | -------------------------------------------------------------------------------- /benchmarks/core/primes-between.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 574100 2 | -------------------------------------------------------------------------------- /benchmarks/core/relative-primes.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1923 2 | -------------------------------------------------------------------------------- /benchmarks/core/sqrt_bin_search.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 744 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-check.out: -------------------------------------------------------------------------------- 1 | 500500 2 | 500500 3 | true 4 | -------------------------------------------------------------------------------- /benchmarks/core/sum-divisible-by-m.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 16 2 | -------------------------------------------------------------------------------- /benchmarks/float/harmonic-sum.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 10950013 2 | -------------------------------------------------------------------------------- /benchmarks/float/mandelbrot.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 2720947 2 | -------------------------------------------------------------------------------- /benchmarks/mem/bubblesort.out: -------------------------------------------------------------------------------- 1 | 1 2 | 3 3 | 7 4 | 9 5 | 10 6 | -------------------------------------------------------------------------------- /benchmarks/mem/eight-queens.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1006454 2 | -------------------------------------------------------------------------------- /benchmarks/mem/primitive-root.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 11029 2 | -------------------------------------------------------------------------------- /benchmarks/mem/quicksort-hoare.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 27333 2 | -------------------------------------------------------------------------------- /benchmarks/mixed/random_walk.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 516754 2 | -------------------------------------------------------------------------------- /bril-rs/.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | Cargo.lock 3 | .idea/** 4 | -------------------------------------------------------------------------------- /flat-bril/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /target 3 | *.fbril 4 | 5 | -------------------------------------------------------------------------------- /test/check/undef.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | b: int = add a b; 3 | } 4 | -------------------------------------------------------------------------------- /test/interp/char/char_ops.out: -------------------------------------------------------------------------------- 1 | false true true false false 2 | -------------------------------------------------------------------------------- /test/interp/mixed/store-float.out: -------------------------------------------------------------------------------- 1 | 109658.00000000000000000 2 | -------------------------------------------------------------------------------- /test/linking/diamond.out: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 0 4 | 0 5 | 1 6 | 0 7 | -------------------------------------------------------------------------------- /benchmarks/core/pythagorean_triple.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 61518 2 | -------------------------------------------------------------------------------- /benchmarks/core/rectangles-area-difference.out: -------------------------------------------------------------------------------- 1 | 50 2 | 78 3 | 28 4 | -------------------------------------------------------------------------------- /benchmarks/float/conjugate-gradient.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1999 2 | -------------------------------------------------------------------------------- /benchmarks/float/ray-bbox-intersection.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 33 2 | -------------------------------------------------------------------------------- /benchmarks/mem/connected-components.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 1978 2 | -------------------------------------------------------------------------------- /benchmarks/mem/insertion-sort.out: -------------------------------------------------------------------------------- 1 | 7 2 | 22 3 | 35 4 | 60 5 | 81 6 | -------------------------------------------------------------------------------- /benchmarks/mem/quicksort.out: -------------------------------------------------------------------------------- 1 | 5 2 | 6 3 | 21 4 | 46 5 | 82 6 | 94 7 | -------------------------------------------------------------------------------- /benchmarks/mem/sorting-network-five.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 284 2 | -------------------------------------------------------------------------------- /benchmarks/mixed/brilirs-only/montecarlo.out: -------------------------------------------------------------------------------- 1 | 3.15280000000000005 2 | -------------------------------------------------------------------------------- /test/check/mainret.bril: -------------------------------------------------------------------------------- 1 | @main(x: int): int { 2 | ret x; 3 | } 4 | -------------------------------------------------------------------------------- /test/check/missdest.err: -------------------------------------------------------------------------------- 1 | 2:3: missing result type int for add 2 | -------------------------------------------------------------------------------- /test/check/printres.err: -------------------------------------------------------------------------------- 1 | 2:3: print should have no result type 2 | -------------------------------------------------------------------------------- /test/interp/dynamic/float_dynamic.out: -------------------------------------------------------------------------------- 1 | 4 4 4.00000000000000000 2 | -------------------------------------------------------------------------------- /test/interp/dynamic/mem_dynamic_enum.out: -------------------------------------------------------------------------------- 1 | 42 42.00000000000000000 2 | -------------------------------------------------------------------------------- /test/ts/turnt.toml: -------------------------------------------------------------------------------- 1 | command = "ts2bril {filename} | bril2txt" 2 | -------------------------------------------------------------------------------- /benchmarks/core/braille.out: -------------------------------------------------------------------------------- 1 | 701110110 2 | 701011111 3 | 711000000 4 | -------------------------------------------------------------------------------- /benchmarks/core/pythagorean_triple.out: -------------------------------------------------------------------------------- 1 | 75 100 2 | 44 117 3 | 35 120 4 | -------------------------------------------------------------------------------- /benchmarks/core/rectangles-area-difference.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 14 2 | -------------------------------------------------------------------------------- /benchmarks/float/exponentiation-by-squaring.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 187 2 | -------------------------------------------------------------------------------- /benchmarks/float/ray-sphere-intersection.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 142 2 | -------------------------------------------------------------------------------- /benchmarks/mem/shufflesort.out: -------------------------------------------------------------------------------- 1 | 12 2 | 123 3 | 234 4 | 525 5 | 873 6 | -------------------------------------------------------------------------------- /benchmarks/mem/sorting-network-five.out: -------------------------------------------------------------------------------- 1 | 1 2 | 3 3 | 7 4 | 9 5 | 10 6 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/ptr.out: -------------------------------------------------------------------------------- 1 | Ints: 6 Bools: 0 Floats: 0 Pointers: 9 2 | -------------------------------------------------------------------------------- /test/check/mainret.err: -------------------------------------------------------------------------------- 1 | 1:1: @main must have no return type; found int 2 | -------------------------------------------------------------------------------- /test/check/missdest.bril: -------------------------------------------------------------------------------- 1 | @main(a: int, b: int) { 2 | add a b; 3 | } 4 | -------------------------------------------------------------------------------- /benchmarks/core/binary-fmt.out: -------------------------------------------------------------------------------- 1 | 1 2 | 0 3 | 0 4 | 0 5 | 0 6 | 0 7 | 0 8 | 0 9 | -------------------------------------------------------------------------------- /benchmarks/core/pascals-row.out: -------------------------------------------------------------------------------- 1 | 1 2 | 6 3 | 30 4 | 120 5 | 360 6 | 720 7 | -------------------------------------------------------------------------------- /benchmarks/mixed/brilirs-only/fast-inverse-sqrt.out: -------------------------------------------------------------------------------- 1 | 0.70692965079546399 2 | -------------------------------------------------------------------------------- /benchmarks/mixed/brilirs-only/fast-inverse-sqrt.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 28 2 | -------------------------------------------------------------------------------- /benchmarks/mixed/brilirs-only/montecarlo.prof: -------------------------------------------------------------------------------- 1 | total_dyn_inst: 110333392 2 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/bools.out: -------------------------------------------------------------------------------- 1 | Ints: 1 Bools: 2 Floats: 0 Pointers: 0 2 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/empty.out: -------------------------------------------------------------------------------- 1 | Ints: 0 Bools: 0 Floats: 0 Pointers: 0 2 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/floats.out: -------------------------------------------------------------------------------- 1 | Ints: 1 Bools: 1 Floats: 2 Pointers: 0 2 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/funcs.out: -------------------------------------------------------------------------------- 1 | Ints: 3 Bools: 3 Floats: 0 Pointers: 0 2 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/ints.out: -------------------------------------------------------------------------------- 1 | Ints: 2 Bools: 0 Floats: 0 Pointers: 0 2 | -------------------------------------------------------------------------------- /fastbril/src/.gitignore: -------------------------------------------------------------------------------- 1 | base.h 2 | float.h 3 | mem.h 4 | ssa.h 5 | types.h 6 | -------------------------------------------------------------------------------- /test/check/printres.bril: -------------------------------------------------------------------------------- 1 | @main(a: int) { 2 | b: int = print a; 3 | } 4 | -------------------------------------------------------------------------------- /test/interp-error/core-error/divide_by_zero.err: -------------------------------------------------------------------------------- 1 | error: division by zero 2 | -------------------------------------------------------------------------------- /test/interp/float/float_divide_by_zero.out: -------------------------------------------------------------------------------- 1 | -Infinity 2 | Infinity 3 | NaN 4 | -------------------------------------------------------------------------------- /benchmarks/core/hanoi.out: -------------------------------------------------------------------------------- 1 | 0 2 2 | 0 1 3 | 2 1 4 | 0 2 5 | 1 0 6 | 1 2 7 | 0 2 8 | -------------------------------------------------------------------------------- /benchmarks/mem/quicksort-hoare.out: -------------------------------------------------------------------------------- 1 | true 2 | true 3 | true 4 | true 5 | true 6 | -------------------------------------------------------------------------------- /test/check/argtype.bril: -------------------------------------------------------------------------------- 1 | @main(a: int, b: bool) { 2 | c: int = add a b; 3 | } 4 | -------------------------------------------------------------------------------- /test/check/extra.bril: -------------------------------------------------------------------------------- 1 | @main(a: int, b: int) { 2 | c: int = add a b a; 3 | } 4 | -------------------------------------------------------------------------------- /test/check/missarg.bril: -------------------------------------------------------------------------------- 1 | @main(a: int, b: int) { 2 | c: int = add a; 3 | } 4 | -------------------------------------------------------------------------------- /test/interp-error/ssa-error/missing-set.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = get; 3 | } 4 | -------------------------------------------------------------------------------- /test/interp-error/ssa-error/undef-add.err: -------------------------------------------------------------------------------- 1 | error: add argument 0 must be a int 2 | -------------------------------------------------------------------------------- /test/interp-error/ssa-error/undef-print.err: -------------------------------------------------------------------------------- 1 | error: print of undefined value 2 | -------------------------------------------------------------------------------- /test/interp/core/tiny.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 5; 3 | print v; 4 | } 5 | -------------------------------------------------------------------------------- /test/interp/ssa/swap-problem.out: -------------------------------------------------------------------------------- 1 | 0 1 2 | 1 0 3 | 0 1 4 | 1 0 5 | 0 1 6 | 1 0 7 | -------------------------------------------------------------------------------- /test/parse/print.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 42; 3 | print v; 4 | } 5 | -------------------------------------------------------------------------------- /test/ts-error/call-wrong-arity.err: -------------------------------------------------------------------------------- 1 | error: function expected 2 arguments, got 3 2 | -------------------------------------------------------------------------------- /benchmarks/core/relative-primes.out: -------------------------------------------------------------------------------- 1 | 19 2 | 17 3 | 13 4 | 11 5 | 9 6 | 7 7 | 3 8 | 1 9 | -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | *.norm.csv 2 | ssa_results.csv 3 | ssa_plot.png 4 | ssa_plot.pdf 5 | -------------------------------------------------------------------------------- /examples/test/from_ssa/swap-problem.out: -------------------------------------------------------------------------------- 1 | 0 1 2 | 1 0 3 | 0 1 4 | 1 0 5 | 0 1 6 | 1 0 7 | -------------------------------------------------------------------------------- /fastbril/config/types.cf: -------------------------------------------------------------------------------- 1 | BRILINT 0 2 | BRILBOOL 1 3 | BRILFLOAT 2 4 | BRILVOID 3 5 | -------------------------------------------------------------------------------- /test/check/argtype.err: -------------------------------------------------------------------------------- 1 | 2:3: b has type bool, but arg 1 for add should have type int 2 | -------------------------------------------------------------------------------- /test/check/noret.err: -------------------------------------------------------------------------------- 1 | 1:1: function with return type must have at least one `ret` 2 | -------------------------------------------------------------------------------- /test/check/typeconflict.err: -------------------------------------------------------------------------------- 1 | 3:3: new type int for a conflicts with old type bool 2 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/wrong_write.err: -------------------------------------------------------------------------------- 1 | error: store argument 1 must be a int 2 | -------------------------------------------------------------------------------- /examples/test/tdce/reassign-dkp.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 42; 3 | print a; 4 | } 5 | -------------------------------------------------------------------------------- /fastbril/config/mem.cf: -------------------------------------------------------------------------------- 1 | ALLOC 23 2 | FREE 24 3 | STORE 25 4 | LOAD 26 5 | PTRADD 27 6 | -------------------------------------------------------------------------------- /test/check/ptr.err: -------------------------------------------------------------------------------- 1 | 3:3: a has type ptr, but arg 0 for id should have type ptr 2 | -------------------------------------------------------------------------------- /test/check/tiny.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 0 2 | @main { 3 | v: int = const 5; 4 | print v; 5 | } 6 | -------------------------------------------------------------------------------- /test/interp-error/core-error/undefined-func.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | call @notafun; 3 | } 4 | -------------------------------------------------------------------------------- /test/interp-error/core-error/undefined-func.err: -------------------------------------------------------------------------------- 1 | error: no function of name notafun found 2 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/uninit_read.err: -------------------------------------------------------------------------------- 1 | error: Pointer p points to uninitialized data 2 | -------------------------------------------------------------------------------- /test/interp-error/spec-error/spec-call.err: -------------------------------------------------------------------------------- 1 | error: call not allowed during speculation 2 | -------------------------------------------------------------------------------- /test/interp-error/spec-error/spec-nonspec-abort.err: -------------------------------------------------------------------------------- 1 | error: abort in non-speculative state 2 | -------------------------------------------------------------------------------- /test/interp-error/spec-error/spec-return-implicit.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | speculate; 3 | } 4 | -------------------------------------------------------------------------------- /test/interp-error/spec-error/spec-return.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | speculate; 3 | ret; 4 | } 5 | -------------------------------------------------------------------------------- /test/interp-error/spec-error/spec-return.err: -------------------------------------------------------------------------------- 1 | error: ret not allowed during speculation 2 | -------------------------------------------------------------------------------- /test/interp-error/ssa-error/double-phi.err: -------------------------------------------------------------------------------- 1 | error: get without corresponding set for x 2 | -------------------------------------------------------------------------------- /test/interp-error/ssa-error/missing-set.err: -------------------------------------------------------------------------------- 1 | error: get without corresponding set for x 2 | -------------------------------------------------------------------------------- /type-infer/tests/infer/tiny.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 5; 3 | print v; 4 | } 5 | -------------------------------------------------------------------------------- /type-infer/tests/infer/tiny.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 5; 3 | print v; 4 | } 5 | -------------------------------------------------------------------------------- /type-infer/tests/print/turnt.toml: -------------------------------------------------------------------------------- 1 | command = "bril2txt < {filename}" 2 | output.bril = "-" 3 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/tiny.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 5; 3 | print v; 4 | } 5 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/ints.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 2; 3 | b: int = const 3; 4 | } 5 | -------------------------------------------------------------------------------- /test/check/typeconflict.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: bool = const true; 3 | a: int = const 4; 4 | } 5 | -------------------------------------------------------------------------------- /test/interp-error/char-error/badconversion.err: -------------------------------------------------------------------------------- 1 | error: value 56193 cannot be converted to char 2 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-wrong-arity.err: -------------------------------------------------------------------------------- 1 | error: function expected 2 arguments, got 3 2 | -------------------------------------------------------------------------------- /test/interp-error/core-error/duplicate_function.err: -------------------------------------------------------------------------------- 1 | error: multiple functions of name f found 2 | -------------------------------------------------------------------------------- /test/interp-error/core-error/duplicate_main.err: -------------------------------------------------------------------------------- 1 | error: multiple functions of name main found 2 | -------------------------------------------------------------------------------- /test/interp-error/dynamic-error/dynamic_error_simple.err: -------------------------------------------------------------------------------- 1 | error: and argument 0 must be a bool 2 | -------------------------------------------------------------------------------- /test/interp-error/spec-error/spec-double-commit.err: -------------------------------------------------------------------------------- 1 | error: commit in non-speculative state 2 | -------------------------------------------------------------------------------- /test/interp/float/float_args.out: -------------------------------------------------------------------------------- 1 | 3.00000000000000000 3.00000000000000000 -0.29999999999999999 2 | -------------------------------------------------------------------------------- /test/rs/riemann.out: -------------------------------------------------------------------------------- 1 | 284.00000000000000000 2 | 330.00000000000000000 3 | 380.00000000000000000 4 | -------------------------------------------------------------------------------- /test/ts-error/call-void-return.err: -------------------------------------------------------------------------------- 1 | error: function with void return type used in value call 2 | -------------------------------------------------------------------------------- /type-infer/tests/parse/turnt.toml: -------------------------------------------------------------------------------- 1 | command = "bril2json < {filename}" 2 | output.json = "-" 3 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/tiny.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 5; 3 | print v; 4 | } 5 | -------------------------------------------------------------------------------- /examples/test/lvn/clobber-fold.out: -------------------------------------------------------------------------------- 1 | @main { 2 | prod2: int = const 36; 3 | print prod2; 4 | } 5 | -------------------------------------------------------------------------------- /test/check/badid.bril: -------------------------------------------------------------------------------- 1 | @main(a: int) { 2 | b: bool = id a; 3 | id a; 4 | c: int = id; 5 | } 6 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-wrong-argument-types.err: -------------------------------------------------------------------------------- 1 | error: function argument type mismatch 2 | -------------------------------------------------------------------------------- /test/interp-error/spec-error/spec-return-implicit.err: -------------------------------------------------------------------------------- 1 | error: implicit return in speculative state 2 | -------------------------------------------------------------------------------- /test/interp-error/ssa-error/undef-print.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = undef; 3 | print x; 4 | } 5 | -------------------------------------------------------------------------------- /test/interp/bitcast/float_and_int.out: -------------------------------------------------------------------------------- 1 | 4591870180066957722 0.10000000000000001 4591870180066957722 2 | -------------------------------------------------------------------------------- /test/interp/dynamic/mem_dynamic_dispatch.out: -------------------------------------------------------------------------------- 1 | 1 1 2 | 2.00000000000000000 3 | 2.00000000000000000 4 | -------------------------------------------------------------------------------- /test/interp/float/float.out: -------------------------------------------------------------------------------- 1 | -0.45000000000000001 2 | 0.30000000000000004 3 | 0.30000000000000004 4 | -------------------------------------------------------------------------------- /test/ts-error/call-return-nothing.err: -------------------------------------------------------------------------------- 1 | error: non-void function (type: int) doesn't return anything 2 | -------------------------------------------------------------------------------- /benchmarks/float/exponentiation-by-squaring.out: -------------------------------------------------------------------------------- 1 | 3.08394593452957709e+53 2 | 1.42202344098973190e+137 3 | -------------------------------------------------------------------------------- /benchmarks/float/riemann.out: -------------------------------------------------------------------------------- 1 | 284.00000000000000000 2 | 330.00000000000000000 3 | 380.00000000000000000 4 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/turnt.toml: -------------------------------------------------------------------------------- 1 | command = "bril2json < {filename} | dune exec ../../count/count.exe" 2 | -------------------------------------------------------------------------------- /examples/test/lvn/turnt.toml: -------------------------------------------------------------------------------- 1 | command = "bril2json < {filename} | python3 ../../lvn.py {args} | bril2txt" 2 | -------------------------------------------------------------------------------- /test/check/ptr.bril: -------------------------------------------------------------------------------- 1 | @main(a: ptr) { 2 | b: ptr = id a; 3 | c: ptr = id a; 4 | } 5 | -------------------------------------------------------------------------------- /test/interp/core/add-overflow.out: -------------------------------------------------------------------------------- 1 | 4611686018427387904 2 | 9223372036854775807 3 | -9223372036854775808 4 | -------------------------------------------------------------------------------- /test/interp/core/ret.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | print v; 4 | ret; 5 | print v; 6 | } 7 | -------------------------------------------------------------------------------- /test/rs/float-add.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x: f64 = 40.2 + 1.8; 3 | println!("{:.17}", x); 4 | } 5 | -------------------------------------------------------------------------------- /test/ts-error/turnt.toml: -------------------------------------------------------------------------------- 1 | command = "ts2bril {filename} | brili" 2 | return_code = 2 3 | output.err = "2" 4 | -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/turnt.toml: -------------------------------------------------------------------------------- 1 | command = "cat {filename} | bril2json | python ../../infer.py" 2 | -------------------------------------------------------------------------------- /benchmarks/core/sum-divisors.out: -------------------------------------------------------------------------------- 1 | 1 2 | 100 3 | 2 4 | 50 5 | 4 6 | 25 7 | 5 8 | 20 9 | 10 10 | 217 11 | -------------------------------------------------------------------------------- /benchmarks/float/conjugate-gradient.out: -------------------------------------------------------------------------------- 1 | 5.00000000000000000 2 | 3.00000000000000000 3 | 2.33333333333333348 4 | -------------------------------------------------------------------------------- /bril-vim/ftdetect/bril.vim: -------------------------------------------------------------------------------- 1 | " ftdetect/bril.vim 2 | autocmd BufNewFile,BufRead *.bril set filetype=bril 3 | -------------------------------------------------------------------------------- /examples/test/tdce/turnt.toml: -------------------------------------------------------------------------------- 1 | command = "bril2json < {filename} | python3 ../../tdce.py {args} | bril2txt" 2 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-void-return-error.err: -------------------------------------------------------------------------------- 1 | error: unexpected value returned without destination 2 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/leak.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | two: int = const 2; 3 | p: ptr = alloc two; 4 | } 5 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/leak.err: -------------------------------------------------------------------------------- 1 | error: Some memory locations have not been freed by end of execution. 2 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/out_of_bounds.err: -------------------------------------------------------------------------------- 1 | error: Uninitialized heap location 0 and/or illegal offset 2 2 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/out_of_bounds_2.err: -------------------------------------------------------------------------------- 1 | error: Uninitialized heap location 0 and/or illegal offset -1 2 | -------------------------------------------------------------------------------- /test/ts-error/call-nonvoid-return-nothing.err: -------------------------------------------------------------------------------- 1 | error: non-void function (type: int) doesn't return anything 2 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/turnt.toml: -------------------------------------------------------------------------------- 1 | command = "cat {filename} | bril2json | python ../../infer.py -t" 2 | -------------------------------------------------------------------------------- /examples/test/lvn/reassign.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 100; 3 | a: int = const 42; 4 | print a; 5 | } 6 | -------------------------------------------------------------------------------- /examples/test/lvn/reassign.out: -------------------------------------------------------------------------------- 1 | @main { 2 | lvn.0: int = const 100; 3 | a: int = const 42; 4 | print a; 5 | } 6 | -------------------------------------------------------------------------------- /examples/test/tdce/reassign.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 100; 3 | a: int = const 42; 4 | print a; 5 | } 6 | -------------------------------------------------------------------------------- /examples/test/tdce/reassign.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 100; 3 | a: int = const 42; 4 | print a; 5 | } 6 | -------------------------------------------------------------------------------- /test/interp-error/dynamic-error/dynamic_error_simple.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | v: any = const 4; 3 | b: bool = and v v; 4 | } -------------------------------------------------------------------------------- /test/interp-error/spec-error/spec-double-commit.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | speculate; 3 | commit; 4 | commit; 5 | } 6 | -------------------------------------------------------------------------------- /test/interp/core/nop.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | nop; 3 | v: int = const 5; 4 | nop; 5 | print v; 6 | nop; 7 | } 8 | -------------------------------------------------------------------------------- /test/ts-error/call-wrong-declared-type.err: -------------------------------------------------------------------------------- 1 | error: type of value returned by function does not match declaration 2 | -------------------------------------------------------------------------------- /type-infer/tests/infer/ret.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | print v; 4 | ret; 5 | print v; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/infer/ret.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | print v; 4 | ret; 5 | print v; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/ret.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | print v; 4 | ret; 5 | print v; 6 | } 7 | -------------------------------------------------------------------------------- /benchmarks/mem/connected-components.out: -------------------------------------------------------------------------------- 1 | 5 2 | 0 3 | 4 | 3 5 | 4 6 | 2 7 | 1 8 | 9 | 7 10 | 6 11 | 12 | 3 13 | -------------------------------------------------------------------------------- /benchmarks/mem/systolic.out: -------------------------------------------------------------------------------- 1 | 0 2 | -1 3 | -8 4 | -5 5 | 4 6 | -5 7 | 6 8 | 3 9 | -6 10 | -3 11 | -62 12 | 25 13 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/bools.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 0; 3 | b: bool = eq a a; 4 | c: bool = le a a; 5 | } 6 | -------------------------------------------------------------------------------- /bril-swift/Sources/Bril/BrilParseError.swift: -------------------------------------------------------------------------------- 1 | public struct BrilParseError: Error { 2 | let message: String 3 | } 4 | -------------------------------------------------------------------------------- /docs/tools/README.md: -------------------------------------------------------------------------------- 1 | Bril Tools 2 | ========== 3 | 4 | These sections describe tools for dealing with Bril programs. 5 | -------------------------------------------------------------------------------- /fastbril/src/bril-insns/types.h: -------------------------------------------------------------------------------- 1 | #define BRILINT 0 2 | #define BRILBOOL 1 3 | #define BRILFLOAT 2 4 | #define BRILVOID 3 5 | -------------------------------------------------------------------------------- /fastbril/srcgen.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S awk -f 2 | 3 | { 4 | if($0 != "") 5 | print "#define " $1 " " $2; 6 | } 7 | -------------------------------------------------------------------------------- /test/check/noret.bril: -------------------------------------------------------------------------------- 1 | @noret(): int { 2 | x: int = const 5; 3 | } 4 | 5 | @main { 6 | a: int = call @noret; 7 | } 8 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-return-nothing-error.err: -------------------------------------------------------------------------------- 1 | error: non-void function (type: int) doesn't return anything 2 | -------------------------------------------------------------------------------- /test/print/char.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | c1: char = const '7'; 3 | c2: char = const 'a'; 4 | c2: char = const '\n'; 5 | } 6 | -------------------------------------------------------------------------------- /test/ts/boolvar.ts: -------------------------------------------------------------------------------- 1 | let x: boolean = true; 2 | if (x) { 3 | console.log(1n); 4 | } else { 5 | console.log(2n); 6 | } 7 | -------------------------------------------------------------------------------- /test/ts/main.ts: -------------------------------------------------------------------------------- 1 | function getThree(): bigint { 2 | return 3n; 3 | } 4 | 5 | var v = getThree(); 6 | console.log(v); 7 | -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/assign_label.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | .label: 3 | x: int = const 5; 4 | label = const 5; 5 | } 6 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/tiny.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # 3 | @main { 4 | v: bool = const 5; 5 | print v; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/infer/nop.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | nop; 3 | v: int = const 5; 4 | nop; 5 | print v; 6 | nop; 7 | } 8 | -------------------------------------------------------------------------------- /type-infer/tests/infer/nop.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | nop; 3 | v: int = const 5; 4 | nop; 5 | print v; 6 | nop; 7 | } 8 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/ret.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | print v; 4 | ret; 5 | print v; 6 | } 7 | -------------------------------------------------------------------------------- /bril-ocaml/count/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name count) 3 | (libraries bril core yojson) 4 | (preprocess (pps ppx_jane))) 5 | -------------------------------------------------------------------------------- /examples/test/from_ssa/basic.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | y: int = const 42; 3 | set x y; 4 | x: int = get; 5 | print x; 6 | } 7 | -------------------------------------------------------------------------------- /test/interp/core/main-args.bril: -------------------------------------------------------------------------------- 1 | # ARGS: 1 2 2 | @main(x: int, y: int) { 3 | v: int = add x y; 4 | print v; 5 | } 6 | -------------------------------------------------------------------------------- /test/interp/ssa/undef.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | z: int = const 42; 3 | x: int = undef; 4 | y: int = id x; 5 | print z; 6 | } 7 | -------------------------------------------------------------------------------- /test/ts/call.ts: -------------------------------------------------------------------------------- 1 | var x: bigint = 5n; 2 | callPrint(x); 3 | 4 | function callPrint(x: bigint) { 5 | console.log(x); 6 | } 7 | -------------------------------------------------------------------------------- /test/ts/cond.ts: -------------------------------------------------------------------------------- 1 | var value = 5n; 2 | if (value + 3n < 6n) { 3 | console.log(1n); 4 | } else { 5 | console.log(2n); 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/parse/add.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0 = const 1; 3 | v1 = const 2; 4 | v2 = add v0 v1; 5 | print v2; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/print/add.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0 = const 1; 3 | v1 = const 2; 4 | v2 = add v0 v1; 5 | print v2; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/nop.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | nop; 3 | v: int = const 5; 4 | nop; 5 | print v; 6 | nop; 7 | } 8 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/nop.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | nop; 3 | v: int = const 5; 4 | nop; 5 | print v; 6 | nop; 7 | } 8 | -------------------------------------------------------------------------------- /bril-ocaml/lib/dest.ml: -------------------------------------------------------------------------------- 1 | open! Core 2 | open! Common 3 | 4 | type t = string * Bril_type.t [@@deriving compare, equal, sexp_of] 5 | -------------------------------------------------------------------------------- /bril-ocaml/lib/dest.mli: -------------------------------------------------------------------------------- 1 | open! Core 2 | open! Common 3 | 4 | type t = string * Bril_type.t [@@deriving compare, equal, sexp_of] 5 | -------------------------------------------------------------------------------- /examples/test/lvn/clobber-arg.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 1; 3 | b: int = const 2; 4 | .lbl: 5 | b: int = add a b; 6 | } 7 | -------------------------------------------------------------------------------- /examples/test/tdce/combo.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 1; 3 | b: int = const 3; 4 | d: int = add a b; 5 | print d; 6 | } 7 | -------------------------------------------------------------------------------- /fastbril/src/bril-insns/mem.h: -------------------------------------------------------------------------------- 1 | #define ALLOC 23 2 | #define FREE 24 3 | #define STORE 25 4 | #define LOAD 26 5 | #define PTRADD 27 6 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-nonvoid-return-nothing-error.err: -------------------------------------------------------------------------------- 1 | error: non-void function (type: int) doesn't return anything 2 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-return-wrong-type.err: -------------------------------------------------------------------------------- 1 | error: type of value returned by function does not match destination type 2 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-wrong-declared-type.err: -------------------------------------------------------------------------------- 1 | error: type of value returned by function does not match declaration 2 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/double_free.err: -------------------------------------------------------------------------------- 1 | error: Tried to free illegal memory location base: 0, offset: 0. Offset must be 0. 2 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/free_offset.err: -------------------------------------------------------------------------------- 1 | error: Tried to free illegal memory location base: 0, offset: 1. Offset must be 0. 2 | -------------------------------------------------------------------------------- /test/interp-error/spec-error/spec-call.bril: -------------------------------------------------------------------------------- 1 | @foo { 2 | } 3 | 4 | @main { 5 | speculate; 6 | call @foo; 7 | commit; 8 | } 9 | -------------------------------------------------------------------------------- /test/interp-error/ssa-error/undef-add.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = undef; 3 | y: int = const 2; 4 | z: int = add x y; 5 | } 6 | -------------------------------------------------------------------------------- /test/interp/char/char_args.bril: -------------------------------------------------------------------------------- 1 | # ARGS: h e y 🐱 2 | @main(c1: char, c2: char, c3: char, c4: char) { 3 | print c1 c2 c3 c4; 4 | } -------------------------------------------------------------------------------- /test/parse/add.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 1; 3 | v1: int = const 2; 4 | v2: int = add v0 v1; 5 | print v2; 6 | } 7 | -------------------------------------------------------------------------------- /test/print/add.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 1; 3 | v1: int = const 2; 4 | v2: int = add v0 v1; 5 | print v2; 6 | } 7 | -------------------------------------------------------------------------------- /test/ts/nested-call.ts: -------------------------------------------------------------------------------- 1 | var y = 1n + getTwo(); 2 | console.log(y); 3 | 4 | function getTwo(): bigint { 5 | return 2n; 6 | } 7 | -------------------------------------------------------------------------------- /benchmarks/core/digital-root.out: -------------------------------------------------------------------------------- 1 | 4 2 | 9 3 | 15 4 | 6 5 | 10 6 | 1 7 | 4 8 | 10 9 | 1 10 | 6 11 | 10 12 | 1 13 | 7 14 | 7 15 | -------------------------------------------------------------------------------- /examples/test/lvn/clobber-arg.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | a: int = const 1; 3 | b: int = const 2; 4 | .lbl: 5 | b: int = add a b; 6 | } 7 | -------------------------------------------------------------------------------- /examples/test/tdce/double.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | d: int = add a b; 5 | print d; 6 | } 7 | -------------------------------------------------------------------------------- /examples/test/tdce/reassign-dkp.bril: -------------------------------------------------------------------------------- 1 | # ARGS: dkp 2 | @main { 3 | a: int = const 100; 4 | a: int = const 42; 5 | print a; 6 | } 7 | -------------------------------------------------------------------------------- /examples/test/tdce/simple.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | d: int = add a b; 5 | print d; 6 | } 7 | -------------------------------------------------------------------------------- /test/check/main-args.bril: -------------------------------------------------------------------------------- 1 | # ARGS: 1 2 2 | # RETURN: 0 3 | @main(x: int, y: int) { 4 | v: int = add x y; 5 | print v; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/infer/turnt.toml: -------------------------------------------------------------------------------- 1 | command = "cat {filename} | bril2json | python ../../infer.py | bril2txt" 2 | output.tbril = "-" 3 | -------------------------------------------------------------------------------- /type-infer/tests/parse/partial.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0 = const 1; 3 | v1: int = const 2; 4 | v2 = add v0 v1; 5 | print v2; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/print/partial.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0 = const 1; 3 | v1: int = const 2; 4 | v2 = add v0 v1; 5 | print v2; 6 | } 7 | -------------------------------------------------------------------------------- /bril-ocaml/lib/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name bril) 3 | (public_name bril) 4 | (libraries core yojson) 5 | (preprocess (pps ppx_jane))) 6 | -------------------------------------------------------------------------------- /bril-rs/examples/bril2txt.rs: -------------------------------------------------------------------------------- 1 | use bril_rs::load_abstract_program; 2 | 3 | fn main() { 4 | print!("{}", load_abstract_program()); 5 | } 6 | -------------------------------------------------------------------------------- /bril2json-rs/parse-error.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 1; 3 | v1: int = const 2; 4 | v2: int = add v0 v1; 5 | prinft v2; 6 | } 7 | -------------------------------------------------------------------------------- /examples/test/lvn/rename-fold.out: -------------------------------------------------------------------------------- 1 | @main { 2 | mul1: int = const 0; 3 | add1: int = const 4; 4 | print mul1; 5 | print add1; 6 | } 7 | -------------------------------------------------------------------------------- /fastbril/doc/.gitignore: -------------------------------------------------------------------------------- 1 | *.aux 2 | *.out 3 | *.log 4 | base.tex 5 | float.tex 6 | mem.tex 7 | ssa.tex 8 | types.tex 9 | brb.pdf 10 | -------------------------------------------------------------------------------- /test/interp/core/div.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 9; 3 | v1: int = const -20; 4 | res: int = div v0 v1; 5 | print res; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/turnt.toml: -------------------------------------------------------------------------------- 1 | command = "cat {filename} | bril2json | python ../../infer.py -t | bril2txt" 2 | output.tbril = "-" 3 | -------------------------------------------------------------------------------- /benchmarks/core/graycode.out: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 3 4 | 2 5 | 6 6 | 7 7 | 5 8 | 4 9 | 12 10 | 13 11 | 15 12 | 14 13 | 10 14 | 11 15 | 9 16 | 8 17 | -------------------------------------------------------------------------------- /test/check/badconst.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: bool = const 4; 3 | b: int = const true; 4 | c: ptr = const 2; 5 | d: blah = const 0; 6 | } 7 | -------------------------------------------------------------------------------- /test/interp-error/char-error/badconversion.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | i: int = const 56193; 3 | 4 | c: char = int2char i; 5 | 6 | print c; 7 | } 8 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-return-nothing-error.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = call @print4; 3 | } 4 | @print4: int { 5 | ret; 6 | } 7 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/double_free.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | one: int = const 1; 3 | p: ptr = alloc one; 4 | free p; 5 | free p; 6 | } 7 | -------------------------------------------------------------------------------- /test/interp/core/jmp.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | jmp .somewhere; 4 | v: int = const 2; 5 | .somewhere: 6 | print v; 7 | } 8 | -------------------------------------------------------------------------------- /test/interp/spec/spec-commit.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | speculate; 4 | v: int = const 2; 5 | commit; 6 | print v; 7 | } 8 | -------------------------------------------------------------------------------- /test/ts/call-explicit-void.ts: -------------------------------------------------------------------------------- 1 | var x: bigint = 5n; 2 | callPrint(x); 3 | 4 | function callPrint(x: bigint): void { 5 | console.log(x); 6 | } 7 | -------------------------------------------------------------------------------- /test/ts/printvar.out: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 5; 3 | x: int = id v0; 4 | v1: int = id x; 5 | print v1; 6 | v2: int = const 0; 7 | } 8 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/ret.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # 3 | @main { 4 | v: bool = const 4; 5 | print v; 6 | ret; 7 | print v; 8 | } 9 | -------------------------------------------------------------------------------- /type-infer/tests/infer/div.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 9; 3 | v1: int = const -20; 4 | res: int = div v0 v1; 5 | print res; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/infer/div.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 9; 3 | v1: int = const -20; 4 | res: int = div v0 v1; 5 | print res; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/parse/div.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 9; 3 | v1: int = const -20; 4 | res: int = div v0 v1; 5 | print res; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/print/div.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 9; 3 | v1: int = const -20; 4 | res: int = div v0 v1; 5 | print res; 6 | } 7 | -------------------------------------------------------------------------------- /benchmarks/mem/1dconv.out: -------------------------------------------------------------------------------- 1 | 54.00000000000000000 2 | 54.00000000000000000 3 | 54.00000000000000000 4 | 54.00000000000000000 5 | 54.00000000000000000 6 | -------------------------------------------------------------------------------- /examples/test/lvn/nonlocal-clobber.out: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = const 1; 3 | .lb: 4 | y: int = id x; 5 | x: int = add x x; 6 | print y; 7 | } 8 | -------------------------------------------------------------------------------- /examples/test/tdce/skipped.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | jmp .end; 5 | print b; 6 | .end: 7 | print a; 8 | } 9 | -------------------------------------------------------------------------------- /examples/test/tdce/skipped.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | jmp .end; 5 | print b; 6 | .end: 7 | print a; 8 | } 9 | -------------------------------------------------------------------------------- /test/parse/comment.bril: -------------------------------------------------------------------------------- 1 | # This is an awesome program! 2 | @main { 3 | v: int = const 42; # More comments! 4 | # v2: whatever = const 47; 5 | } 6 | -------------------------------------------------------------------------------- /type-infer/tests/infer/jmp.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | jmp .somewhere; 4 | v: int = const 2; 5 | .somewhere: 6 | print v; 7 | } 8 | -------------------------------------------------------------------------------- /type-infer/tests/infer/jmp.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | jmp .somewhere; 4 | v: int = const 2; 5 | .somewhere: 6 | print v; 7 | } 8 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/div.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 9; 3 | v1: int = const -20; 4 | res: int = div v0 v1; 5 | print res; 6 | } 7 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/div.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 9; 3 | v1: int = const -20; 4 | res: int = div v0 v1; 5 | print res; 6 | } 7 | -------------------------------------------------------------------------------- /benchmarks/core/collatz.out: -------------------------------------------------------------------------------- 1 | 7 2 | 22 3 | 11 4 | 34 5 | 17 6 | 52 7 | 26 8 | 13 9 | 40 10 | 20 11 | 10 12 | 5 13 | 16 14 | 8 15 | 4 16 | 2 17 | 1 18 | -------------------------------------------------------------------------------- /examples/test/from_ssa/dead-set.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | y: int = const 4; 3 | x: int = const 2; 4 | set x y; 5 | print x; 6 | x: int = get; 7 | } 8 | -------------------------------------------------------------------------------- /test/check/badid.err: -------------------------------------------------------------------------------- 1 | 2:3: a has type int, but arg 0 for id should have type bool 2 | 3:3: missing result type T for id 3 | 4:3: id expects 1 args, not 0 4 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-void-return-error.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | call @print4; 3 | } 4 | @print4 { 5 | v: int = const 4; 6 | ret v; 7 | } 8 | -------------------------------------------------------------------------------- /test/rs/call-explicit.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x :i64 = 5; 3 | call_print(x); 4 | } 5 | 6 | fn call_print(x:i64) { 7 | println!("{:?}", x) 8 | } -------------------------------------------------------------------------------- /type-infer/tests/typecheck/jmp.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | jmp .somewhere; 4 | v: int = const 2; 5 | .somewhere: 6 | print v; 7 | } 8 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/jmp.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | jmp .somewhere; 4 | v: int = const 2; 5 | .somewhere: 6 | print v; 7 | } 8 | -------------------------------------------------------------------------------- /bril-ocaml/lib/common.mli: -------------------------------------------------------------------------------- 1 | open! Core 2 | 3 | val has_key : Yojson.Basic.t -> string -> bool 4 | val to_list_nonnull : Yojson.Basic.t -> Yojson.Basic.t list 5 | -------------------------------------------------------------------------------- /examples/test/tdce/double-pass.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | c: int = const 1; 5 | d: int = add a b; 6 | print d; 7 | } 8 | -------------------------------------------------------------------------------- /examples/test/tdce/simple.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | c: int = const 1; 5 | d: int = add a b; 6 | print d; 7 | } 8 | -------------------------------------------------------------------------------- /fastbril/config/float.cf: -------------------------------------------------------------------------------- 1 | FADD 28 2 | FMUL 29 3 | FSUB 30 4 | FDIV 31 5 | FEQ 32 6 | FLT 33 7 | FLE 34 8 | FGT 35 9 | FGE 36 10 | -------------------------------------------------------------------------------- /test/interp-error/spec-error/spec-nonspec-abort.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | speculate; 3 | commit; 4 | f: bool = const false; 5 | guard f .lbl; 6 | .lbl: 7 | } 8 | -------------------------------------------------------------------------------- /test/rs/nested_call.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let y:i64 = 1 + get_two(); 3 | println!("{}", y); 4 | } 5 | 6 | fn get_two() -> i64 { 7 | return 2; 8 | } 9 | -------------------------------------------------------------------------------- /test/ts-error/call-return-nothing.ts: -------------------------------------------------------------------------------- 1 | var x = 1n; 2 | var y = 2n; 3 | add2(x, y); 4 | 5 | function add2(x: bigint, y: bigint): bigint { 6 | return; 7 | } 8 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/nop.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # 3 | @main { 4 | nop; 5 | v: bool = const 5; 6 | nop; 7 | print v; 8 | nop; 9 | } 10 | -------------------------------------------------------------------------------- /examples/test/lvn/nonlocal-clobber.bril: -------------------------------------------------------------------------------- 1 | # ARGS: -p 2 | @main { 3 | x: int = const 1; 4 | .lb: 5 | y: int = id x; 6 | x: int = add x x; 7 | print y; 8 | } 9 | -------------------------------------------------------------------------------- /fastbril/src/asm/trivial-regalloc.h: -------------------------------------------------------------------------------- 1 | #ifndef TRIVREG_H 2 | #define TRIVREG_H 3 | #include "asm.h" 4 | 5 | asm_prog_t triv_allocate(asm_prog_t prog); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /test/interp-error/core-error/divide_by_zero.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const -1; 3 | zero: int = const 0; 4 | res: int = div v0 zero; 5 | print res; 6 | } 7 | -------------------------------------------------------------------------------- /test/interp/dynamic/float_dynamic.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | i: int = const 4; 3 | a: any = const 4; 4 | f: float = const 4; 5 | print i a f; # `4 4 4.00000000000000000` 6 | } -------------------------------------------------------------------------------- /test/ts/loopfact.ts: -------------------------------------------------------------------------------- 1 | let value = 8n; 2 | let result = 1n; 3 | for (let i = value; i > 0n; i = i - 1n) { 4 | result = result * i; 5 | } 6 | console.log(result); 7 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/floats.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: float = const 2; 3 | b: float = const 3; 4 | x: int = const 4; 5 | y: bool = eq x x; 6 | print a; 7 | } 8 | -------------------------------------------------------------------------------- /examples/test/lvn/divide-by-zero.out: -------------------------------------------------------------------------------- 1 | @main { 2 | .entry: 3 | zero: int = const 0; 4 | one: int = const 1; 5 | baddiv: int = div one zero; 6 | print baddiv; 7 | } 8 | -------------------------------------------------------------------------------- /examples/test/lvn/idchain.out: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = const 4; 3 | copy1: int = id x; 4 | copy2: int = id copy1; 5 | copy3: int = id copy2; 6 | print copy3; 7 | } 8 | -------------------------------------------------------------------------------- /test/interp-error/core-error/duplicate_main.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 1; 3 | print v; 4 | } 5 | @main { 6 | v: int = const 2; 7 | print v; 8 | } 9 | -------------------------------------------------------------------------------- /test/interp/float/float_args.bril: -------------------------------------------------------------------------------- 1 | # ARGS: 3 3.0 -0.3 2 | @main(float_one : float, float_two : float, float_three : float) { 3 | print float_one float_two float_three; 4 | } -------------------------------------------------------------------------------- /test/linking/nested.bril: -------------------------------------------------------------------------------- 1 | # ARGS: ../linking ../../benchmarks/core 2 | from "link_ops.bril" import @main as @nested_main; 3 | 4 | @main(){ 5 | call @nested_main; 6 | } -------------------------------------------------------------------------------- /test/ts-error/call-void-return.ts: -------------------------------------------------------------------------------- 1 | var x : number = print4(); 2 | 3 | function print4() : void { 4 | var x : number = 4; 5 | console.log(4); 6 | return x; 7 | } -------------------------------------------------------------------------------- /test/ts/float-add.out: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: float = const 40.2; 3 | v1: float = const 1.8; 4 | v2: float = fadd v0 v1; 5 | print v2; 6 | v3: int = const 0; 7 | } 8 | -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/div.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | @main { 3 | v0: int = const false; 4 | v1: int = const -20; 5 | res: int = div v0 v1; 6 | print res; 7 | } 8 | -------------------------------------------------------------------------------- /bril-swift/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | DerivedData/ 7 | .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata 8 | -------------------------------------------------------------------------------- /examples/test/dom/loopcond.ts: -------------------------------------------------------------------------------- 1 | let x = 0; 2 | for (let i = 0; i < 10; i = i + 1) { 3 | if (i < 5) { 4 | x = x + 1; 5 | } 6 | x = x * 2; 7 | } 8 | console.log(x); 9 | -------------------------------------------------------------------------------- /examples/test/lvn/clobber.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | lvn.2: int = add a b; 5 | prod1: int = mul lvn.2 lvn.2; 6 | print prod1; 7 | } 8 | -------------------------------------------------------------------------------- /examples/test/lvn/divide-by-zero.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | .entry: 3 | zero : int = const 0; 4 | one : int = const 1; 5 | baddiv : int = div one zero; 6 | print baddiv; 7 | } 8 | -------------------------------------------------------------------------------- /examples/test/lvn/idchain-prop.out: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = const 4; 3 | copy1: int = const 4; 4 | copy2: int = const 4; 5 | copy3: int = const 4; 6 | print x; 7 | } 8 | -------------------------------------------------------------------------------- /examples/test/lvn/idchain.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = const 4; 3 | copy1: int = id x; 4 | copy2: int = id copy1; 5 | copy3: int = id copy2; 6 | print copy3; 7 | } 8 | -------------------------------------------------------------------------------- /fastbril/src/asm/linear-scan.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEAR_SCAN_H 2 | #define LINEAR_SCAN_H 3 | #include "asm.h" 4 | 5 | 6 | asm_prog_t linear_scan(asm_prog_t prog); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/check/labels.bril: -------------------------------------------------------------------------------- 1 | @main(b: bool) { 2 | jmp .bad; 3 | br b .foo; 4 | br b .foo .foo .foo; 5 | c: bool = not b .foo; 6 | .foo: 7 | .bar: 8 | .bar: 9 | } 10 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-return-wrong-type.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = call @print4; 3 | } 4 | @print4: int { 5 | b: bool = const false; 6 | ret b; 7 | } 8 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/uninit_read.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | two: int = const 2; 3 | p: ptr = alloc two; 4 | tmp: int = load p; 5 | print tmp; 6 | free p; 7 | } 8 | -------------------------------------------------------------------------------- /test/ts-error/call-nonvoid-return-nothing.ts: -------------------------------------------------------------------------------- 1 | var x = 1n; 2 | var y = 2n; 3 | var z = add2(x, y); 4 | 5 | function add2(x: bigint, y: bigint): bigint { 6 | return; 7 | } 8 | -------------------------------------------------------------------------------- /test/ts/return.ts: -------------------------------------------------------------------------------- 1 | var x = 1n; 2 | var y = 2n; 3 | var v = add2(x, y); 4 | console.log(v); 5 | 6 | function add2(x: bigint, y: bigint): bigint { 7 | return x + y; 8 | } 9 | -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/jmp.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | @main { 3 | v: int = const false; 4 | jmp .somewhere; 5 | v: int = const 2; 6 | .somewhere: 7 | print v; 8 | } 9 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/add.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # OUT: err 2 3 | @main { 4 | v0: bool = const 1; 5 | v1 = const 2; 6 | v2 = add v0 v1; 7 | print v2; 8 | } 9 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/div.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # 3 | @main { 4 | v0: int = const 9; 5 | v1: int = const -20; 6 | res: bool = div v0 v1; 7 | print res; 8 | } 9 | -------------------------------------------------------------------------------- /type-infer/tests/infer/tricky-jump.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | jmp .later; 3 | .earlier: 4 | x = id y; 5 | ret; 6 | .later: 7 | y = const 5; 8 | jmp .earlier; 9 | } 10 | -------------------------------------------------------------------------------- /bril-vim/ftplugin/bril.vim: -------------------------------------------------------------------------------- 1 | " ftplugin/bril.vim 2 | setlocal commentstring=\#\ %s 3 | setlocal tabstop=2 4 | setlocal softtabstop=2 5 | setlocal shiftwidth=2 6 | setlocal nospell 7 | -------------------------------------------------------------------------------- /examples/test/lvn/redundant-dce.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | sum1: int = add a b; 5 | prod: int = mul sum1 sum1; 6 | print prod; 7 | } 8 | -------------------------------------------------------------------------------- /examples/test/tdce/double.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | c: int = const 1; 5 | d: int = add a b; 6 | e: int = add c d; 7 | print d; 8 | } 9 | -------------------------------------------------------------------------------- /examples/test/to_ssa/argwrite.bril: -------------------------------------------------------------------------------- 1 | @main(a: int) { 2 | cond: bool = const true; 3 | br cond .here .there; 4 | .here: 5 | a: int = const 5; 6 | .there: 7 | print a; 8 | } 9 | -------------------------------------------------------------------------------- /test/interp/char/char.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | c1: char = const 'h'; 3 | c2: char = const 'e'; 4 | c3: char = const 'y'; 5 | c4: char = const '🐶'; 6 | print c1 c2 c3 c4; 7 | } -------------------------------------------------------------------------------- /type-infer/tests/typecheck/tricky-jump.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | jmp .later; 3 | .earlier: 4 | x = id y; 5 | ret; 6 | .later: 7 | y = const 5; 8 | jmp .earlier; 9 | } 10 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/wrong_write.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | two: int = const 2; 3 | p: ptr = alloc two; 4 | btrue: bool = const true; 5 | store p btrue; 6 | free p; 7 | } 8 | -------------------------------------------------------------------------------- /type-infer/Makefile: -------------------------------------------------------------------------------- 1 | TESTS := tests/parse/*.bril \ 2 | tests/print/*.json \ 3 | tests/infer/*.bril \ 4 | tests/typecheck/*.bril 5 | 6 | .PHONY: test 7 | test: 8 | turnt $(TESTS) 9 | -------------------------------------------------------------------------------- /type-infer/tests/infer/tricky-jump.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | jmp .later; 3 | .earlier: 4 | x: int = id y; 5 | ret; 6 | .later: 7 | y: int = const 5; 8 | jmp .earlier; 9 | } 10 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/out_of_bounds.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | two: int = const 2; 3 | p: ptr = alloc two; 4 | p1: ptr = ptradd p two; 5 | store p1 two; 6 | free p; 7 | } 8 | -------------------------------------------------------------------------------- /test/interp/core/br.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | b: bool = const false; 4 | br b .there .here; 5 | .here: 6 | v: int = const 2; 7 | .there: 8 | print v; 9 | } 10 | -------------------------------------------------------------------------------- /test/parse/positions.bril: -------------------------------------------------------------------------------- 1 | # ARGS: -p 2 | @main { 3 | v0: int = const 1; 4 | v1: int = const 2; 5 | jmp .label; 6 | .label: 7 | v2: int = add v0 v1; 8 | print v2; 9 | } 10 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/jmp.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # 3 | @main { 4 | v: int = const 4; 5 | jmp .somewhere; 6 | v: bool = const 2; 7 | .somewhere: 8 | print v; 9 | } 10 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/tricky-jump.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | jmp .later; 3 | .earlier: 4 | x: int = id y; 5 | ret; 6 | .later: 7 | y: int = const 5; 8 | jmp .earlier; 9 | } 10 | -------------------------------------------------------------------------------- /examples/test/df/cond.live.out: -------------------------------------------------------------------------------- 1 | b1: 2 | in: ∅ 3 | out: a 4 | left: 5 | in: a 6 | out: a, c 7 | right: 8 | in: ∅ 9 | out: a, c 10 | end: 11 | in: a, c 12 | out: ∅ 13 | -------------------------------------------------------------------------------- /examples/test/lvn/idchain-prop.bril: -------------------------------------------------------------------------------- 1 | # ARGS: -p 2 | @main { 3 | x: int = const 4; 4 | copy1: int = id x; 5 | copy2: int = id copy1; 6 | copy3: int = id copy2; 7 | print copy3; 8 | } 9 | -------------------------------------------------------------------------------- /test/check/labels.err: -------------------------------------------------------------------------------- 1 | 8:1: multiply defined label .bar 2 | 2:3: label .bad undefined 3 | 3:3: br needs 2 labels; found 1 4 | 4:3: br needs 2 labels; found 3 5 | 5:3: not needs 0 labels; found 1 6 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/free_offset.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | one: int = const 1; 3 | two: int = const 2; 4 | p: ptr = alloc two; 5 | p1: ptr = ptradd p one; 6 | free p1; 7 | } 8 | -------------------------------------------------------------------------------- /test/interp/core/call.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | v: int = const 2; 3 | call @print4; 4 | print v; 5 | } 6 | @print4 { 7 | v: int = const 4; 8 | print v; 9 | ret; 10 | } 11 | -------------------------------------------------------------------------------- /test/interp/core/dead_block.bril: -------------------------------------------------------------------------------- 1 | @abs(x: int): int { 2 | ret x; 3 | .label435: 4 | } 5 | 6 | @main() { 7 | x : int = const 42; 8 | y : int = call @abs x; 9 | print y; 10 | } -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/tricky-jump.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 0 2 | @main { 3 | jmp x; 4 | .earlier: 5 | x = id y; 6 | ret; 7 | .later: 8 | y = const 5; 9 | jmp .earlier; 10 | } 11 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/tricky-jump.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | @main { 3 | jmp x; 4 | .earlier: 5 | x = id y; 6 | ret; 7 | .later: 8 | y = const 5; 9 | jmp .earlier; 10 | } 11 | -------------------------------------------------------------------------------- /type-infer/tests/infer/br.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | b: bool = const false; 4 | br b .there .here; 5 | .here: 6 | v: int = const 2; 7 | .there: 8 | print v; 9 | } 10 | -------------------------------------------------------------------------------- /examples/test/df/cond-args.live.out: -------------------------------------------------------------------------------- 1 | b1: 2 | in: cond 3 | out: a 4 | left: 5 | in: a 6 | out: a, c 7 | right: 8 | in: ∅ 9 | out: a, c 10 | end: 11 | in: a, c 12 | out: ∅ 13 | -------------------------------------------------------------------------------- /examples/test/lvn/commute.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | sum1: int = add a b; 5 | sum2: int = id sum1; 6 | prod: int = mul sum1 sum1; 7 | print prod; 8 | } 9 | -------------------------------------------------------------------------------- /examples/test/lvn/redundant.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | sum1: int = add a b; 5 | sum2: int = id sum1; 6 | prod: int = mul sum1 sum1; 7 | print prod; 8 | } 9 | -------------------------------------------------------------------------------- /test/check/badconst.err: -------------------------------------------------------------------------------- 1 | 2:3: const value 4 does not match type bool 2 | 3:3: const value true does not match type int 3 | 4:3: const of non-primitive type ptr 4 | 5:3: unknown const type blah 5 | -------------------------------------------------------------------------------- /test/interp/mem/ptr_call.bril: -------------------------------------------------------------------------------- 1 | @funcA(p: ptr) { 2 | ret; 3 | } 4 | 5 | @main { 6 | five: int = const 5; 7 | x: ptr = alloc five; 8 | call @funcA x; 9 | free x; 10 | } 11 | -------------------------------------------------------------------------------- /test/linking/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.bril-rs] 2 | command = "cargo run --manifest-path ../../bril-rs/brild/Cargo.toml -- --file {filename} --libs {args} | cargo run --manifest-path ../../brilirs/Cargo.toml" 3 | -------------------------------------------------------------------------------- /type-infer/tests/infer/br.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | b: bool = const false; 4 | br b .there .here; 5 | .here: 6 | v: int = const 2; 7 | .there: 8 | print v; 9 | } 10 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/br.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | b: bool = const false; 4 | br b .there .here; 5 | .here: 6 | v: int = const 2; 7 | .there: 8 | print v; 9 | } 10 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/br.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | b: bool = const false; 4 | br b .there .here; 5 | .here: 6 | v: int = const 2; 7 | .there: 8 | print v; 9 | } 10 | -------------------------------------------------------------------------------- /examples/test/dom/while.front.json: -------------------------------------------------------------------------------- 1 | { 2 | "entry1": [], 3 | "while.body": [ 4 | "while.cond" 5 | ], 6 | "while.cond": [ 7 | "while.cond" 8 | ], 9 | "while.finish": [] 10 | } 11 | -------------------------------------------------------------------------------- /test/print/ptr.bril: -------------------------------------------------------------------------------- 1 | @ident(p: ptr): ptr { 2 | ret p; 3 | } 4 | @main { 5 | a: int = const 9; 6 | b: ptr = alloc a; 7 | c: ptr = call @ident b; 8 | free b; 9 | } 10 | -------------------------------------------------------------------------------- /examples/test/from_ssa/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.orig] 2 | command = "bril2json < {filename} | brili {args}" 3 | 4 | [envs.from_ssa] 5 | command = "bril2json < {filename} | python3 ../../from_ssa.py | brili {args}" 6 | -------------------------------------------------------------------------------- /examples/test/lvn/idchain-nonlocal.out: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = const 4; 3 | jmp .label; 4 | .label: 5 | copy1: int = id x; 6 | copy2: int = id x; 7 | copy3: int = id x; 8 | print x; 9 | } 10 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/argwrite.bril: -------------------------------------------------------------------------------- 1 | # ARGS: 3 2 | @main(a: int) { 3 | cond: bool = const true; 4 | br cond .here .there; 5 | .here: 6 | a: int = const 5; 7 | .there: 8 | print a; 9 | } 10 | -------------------------------------------------------------------------------- /examples/test/tdce/combo.bril: -------------------------------------------------------------------------------- 1 | # ARGS: tdce+ 2 | @main { 3 | a: int = const 1; 4 | b: int = const 2; 5 | c: int = add a b; 6 | b: int = const 3; 7 | d: int = add a b; 8 | print d; 9 | } 10 | -------------------------------------------------------------------------------- /test/interp/mem/ptr_ret.bril: -------------------------------------------------------------------------------- 1 | @ident(p: ptr): ptr { 2 | ret p; 3 | } 4 | @main { 5 | a: int = const 9; 6 | b: ptr = alloc a; 7 | c: ptr = call @ident b; 8 | free b; 9 | } 10 | -------------------------------------------------------------------------------- /examples/test/tdce/double-pass.bril: -------------------------------------------------------------------------------- 1 | # ARGS: tdcep 2 | @main { 3 | a: int = const 4; 4 | b: int = const 2; 5 | c: int = const 1; 6 | d: int = add a b; 7 | e: int = add c d; 8 | print d; 9 | } 10 | -------------------------------------------------------------------------------- /fastbril/src/bril-insns/float.h: -------------------------------------------------------------------------------- 1 | #define FADD 28 2 | #define FMUL 29 3 | #define FSUB 30 4 | #define FDIV 31 5 | #define FEQ 32 6 | #define FLT 33 7 | #define FLE 34 8 | #define FGT 35 9 | #define FGE 36 10 | -------------------------------------------------------------------------------- /test/check/mem.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 0 2 | @main(i: int) { 3 | p: ptr = alloc i; 4 | r: ptr = alloc i; 5 | store p i; 6 | j: int = load p; 7 | q: ptr = ptradd p i; 8 | free p; 9 | } 10 | -------------------------------------------------------------------------------- /test/interp-error/core-error/duplicate_function.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | call @f; 3 | } 4 | @f { 5 | v: int = const 1; 6 | print v; 7 | } 8 | @f { 9 | v: int = const 2; 10 | print v; 11 | } 12 | -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/br.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | @main { 3 | v: int = const 4; 4 | b: bool = const 1; 5 | br b .there .here; 6 | .here: 7 | v: int = const 2; 8 | .there: 9 | print v; 10 | } 11 | -------------------------------------------------------------------------------- /benchmarks/mem/sieve.out: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 5 4 | 7 5 | 11 6 | 13 7 | 17 8 | 19 9 | 23 10 | 29 11 | 31 12 | 37 13 | 41 14 | 43 15 | 47 16 | 53 17 | 59 18 | 61 19 | 67 20 | 71 21 | 73 22 | 79 23 | 83 24 | 89 25 | 97 26 | -------------------------------------------------------------------------------- /brilir/include/bril/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_mlir_dialect(BrilOps bril) 2 | 3 | set(LLVM_TARGET_DEFINITIONS BrilPasses.td) 4 | mlir_tablegen(BrilPasses.h.inc --gen-pass-decls) 5 | add_public_tablegen_target(MLIRBrilPassesIncGen) -------------------------------------------------------------------------------- /test/print/call.bril: -------------------------------------------------------------------------------- 1 | @add5(n: int): int { 2 | five: int = const 5; 3 | sum: int = add n five; 4 | ret sum; 5 | } 6 | @main { 7 | a: int = const 9; 8 | b: int = call @add5 a; 9 | print b; 10 | } 11 | -------------------------------------------------------------------------------- /bril-ocaml/lib/const.mli: -------------------------------------------------------------------------------- 1 | open! Core 2 | open! Common 3 | 4 | type t = 5 | | Int of int 6 | | Bool of bool 7 | | Float of float 8 | [@@deriving compare, equal, sexp_of] 9 | 10 | val to_string : t -> string 11 | -------------------------------------------------------------------------------- /test/interp-error/mem-error/out_of_bounds_2.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | two: int = const 2; 3 | negone: int = const -1; 4 | p: ptr = alloc two; 5 | p1: ptr = ptradd p negone; 6 | store p1 two; 7 | free p; 8 | } 9 | -------------------------------------------------------------------------------- /test/interp/mixed/store-float.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | one: int = const 1; 3 | seed: float = const 109658.0; 4 | rng: ptr = alloc one; 5 | store rng seed; 6 | x: float = load rng; 7 | print x; 8 | free rng; 9 | } -------------------------------------------------------------------------------- /test/ts/main.out: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = call @getThree; 3 | v: int = id v; 4 | v1: int = id v; 5 | print v1; 6 | v2: int = const 0; 7 | } 8 | @getThree: int { 9 | v0: int = const 3; 10 | ret v0; 11 | } 12 | -------------------------------------------------------------------------------- /type-infer/tests/infer/many_functions.bril: -------------------------------------------------------------------------------- 1 | @foo { 2 | a = const 1; 3 | b = const 2; 4 | c = add a b; 5 | } 6 | @main { 7 | f = const false; 8 | t = const true; 9 | b = or f t; 10 | print f t b; 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | book/ 3 | venv/ 4 | node_modules/ 5 | .hypothesis/ 6 | .pytest_cache/ 7 | hypothesis_* 8 | __pycache__ 9 | .vscode 10 | 11 | **/*.o 12 | .DS_Store 13 | 14 | # vim swap files 15 | *.swp 16 | *.swo 17 | -------------------------------------------------------------------------------- /benchmarks/core/arithmetic-series.bril: -------------------------------------------------------------------------------- 1 | # ARGS: 7 2 | @main(n: int) { 3 | a: int = const 1; 4 | b: int = add n a; 5 | c: int = mul n b; 6 | d: int = const 2; 7 | e: int = div c d; 8 | print e; 9 | ret; 10 | } -------------------------------------------------------------------------------- /examples/test/df/cond-args.defined.out: -------------------------------------------------------------------------------- 1 | b1: 2 | in: ∅ 3 | out: a, b 4 | left: 5 | in: a, b 6 | out: a, b, c 7 | right: 8 | in: a, b 9 | out: a, b, c 10 | end: 11 | in: a, b, c 12 | out: a, b, c, d 13 | -------------------------------------------------------------------------------- /examples/test/df/fact.live.out: -------------------------------------------------------------------------------- 1 | b1: 2 | in: ∅ 3 | out: i, result 4 | header: 5 | in: i, result 6 | out: i, result 7 | body: 8 | in: i, result 9 | out: i, result 10 | end: 11 | in: result 12 | out: ∅ 13 | -------------------------------------------------------------------------------- /examples/test/dom/while.tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "entry1": [ 3 | "while.cond" 4 | ], 5 | "while.body": [], 6 | "while.cond": [ 7 | "while.body", 8 | "while.finish" 9 | ], 10 | "while.finish": [] 11 | } 12 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/br.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # 3 | @main { 4 | v: int = const 4; 5 | b: int = const false; 6 | br b .there .here; 7 | .here: 8 | v: int = const 2; 9 | .there: 10 | print v; 11 | } 12 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/many_functions.bril: -------------------------------------------------------------------------------- 1 | @foo { 2 | a = const 1; 3 | b = const 2; 4 | c = add a b; 5 | } 6 | @main { 7 | f = const false; 8 | t = const true; 9 | b = or f t; 10 | print f t b; 11 | } 12 | -------------------------------------------------------------------------------- /bracket/tests/recfact.rkt: -------------------------------------------------------------------------------- 1 | (module 2 | (define fact 3 | (lambda (n) 4 | (if (call <= n 1) 5 | 1 6 | (call * (call fact (call - n 1)) n)))) 7 | (let ([arg.x 8]) 8 | (call fact arg.x))) 9 | -------------------------------------------------------------------------------- /bracket/tests/triangle.rkt: -------------------------------------------------------------------------------- 1 | (module 2 | (define tri 3 | (lambda (n) 4 | (if (call eq? n 1) 5 | 1 6 | (call + (call tri (call - n 1)) n)))) 7 | (let ([arg.x 36]) 8 | (call tri arg.x))) 9 | -------------------------------------------------------------------------------- /examples/test/lvn/redundant.bril: -------------------------------------------------------------------------------- 1 | # (a + b) * (a + b) 2 | @main { 3 | a: int = const 4; 4 | b: int = const 2; 5 | sum1: int = add a b; 6 | sum2: int = add a b; 7 | prod: int = mul sum1 sum2; 8 | print prod; 9 | } 10 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-wrong-argument-types.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = const 1; 3 | call @add2 x; 4 | } 5 | @add2(x: bool): int { 6 | z: int = const 2; 7 | w: int = add x z; 8 | print w; 9 | } 10 | -------------------------------------------------------------------------------- /test/interp/bitcast/float_and_int.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | as_int: int = const 4591870180066957722; 3 | as_float: float = bits2float as_int; 4 | back_to_int: int = float2bits as_float; 5 | print as_int as_float back_to_int; 6 | } 7 | -------------------------------------------------------------------------------- /test/ts-error/call-wrong-declared-type.ts: -------------------------------------------------------------------------------- 1 | var x : number = 1; 2 | var y : number = 2; 3 | var z : number = addboth(x, y); 4 | 5 | function addboth(x : number, y : number) : boolean { 6 | var w : number = x + y; 7 | return w; 8 | } -------------------------------------------------------------------------------- /type-infer/tests/infer/addarg.bril: -------------------------------------------------------------------------------- 1 | @main(arg: int) { 2 | five = const 5; 3 | ten = const 10; 4 | res = add arg five; 5 | cond = le res ten; 6 | br cond .then .else; 7 | .then: 8 | print res; 9 | .else: 10 | } 11 | -------------------------------------------------------------------------------- /examples/test/lvn/idchain-nonlocal.bril: -------------------------------------------------------------------------------- 1 | # ARGS: -p 2 | @main { 3 | x: int = const 4; 4 | jmp .label; 5 | .label: 6 | copy1: int = id x; 7 | copy2: int = id copy1; 8 | copy3: int = id copy2; 9 | print copy3; 10 | } 11 | -------------------------------------------------------------------------------- /examples/test/lvn/nonlocal.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | sum1: int = add a b; 5 | sum2: int = add a b; 6 | jmp .label; 7 | .label: 8 | prod: int = mul sum1 sum2; 9 | print prod; 10 | } 11 | -------------------------------------------------------------------------------- /examples/test/lvn/nonlocal.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 4; 3 | b: int = const 2; 4 | sum1: int = add a b; 5 | sum2: int = id sum1; 6 | jmp .label; 7 | .label: 8 | prod: int = mul sum1 sum2; 9 | print prod; 10 | } 11 | -------------------------------------------------------------------------------- /test/rs/boolvar.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x: bool = true; 3 | if x { 4 | let one:i64 = 1; 5 | println!("{:?}", one); 6 | } else { 7 | let two:i64 = 2; 8 | println!("{:?}", two); 9 | } 10 | } -------------------------------------------------------------------------------- /test/ts-error/call-wrong-arity.ts: -------------------------------------------------------------------------------- 1 | var x : number = 1; 2 | var y : number = 2; 3 | var z : number = 3; 4 | addboth(x, y, z); 5 | 6 | function addboth(x : number, y : number) : void { 7 | var z : number = x + y; 8 | console.log(z); 9 | } -------------------------------------------------------------------------------- /benchmarks/mixed/gol.out: -------------------------------------------------------------------------------- 1 | 13 0 1 2 | 13 1 1 3 | 13 2 1 4 | 13 3 1 5 | 13 4 0 6 | 13 5 1 7 | 13 6 1 8 | 13 7 0 9 | 13 8 0 10 | 3 11 | 13 0 1 12 | 13 1 0 13 | 13 2 1 14 | 13 3 1 15 | 13 4 0 16 | 13 5 1 17 | 13 6 0 18 | 13 7 1 19 | 13 8 0 20 | -------------------------------------------------------------------------------- /test/interp/mem/mem_id.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | bp: ptr = alloc v; 4 | bp2: ptr = id bp; 5 | b: bool = const true; 6 | store bp2 b; 7 | b: bool = load bp2; 8 | print b; 9 | free bp; 10 | } 11 | -------------------------------------------------------------------------------- /test/parse/char.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | c1: char = const '6'; 3 | c2: char = const ';'; 4 | 5 | b1: bool = ceq c1 c2; 6 | b2: bool = clt c1 c2; 7 | b3: bool = cle c1 c2; 8 | b4: bool = cgt c1 c2; 9 | b5: bool = cge c1 c2; 10 | } -------------------------------------------------------------------------------- /test/ts/simplified.ts: -------------------------------------------------------------------------------- 1 | erronious(1n); 2 | 3 | // This snippet checks that the ts compiler doesn't try to create an unreachable else branch 4 | function erronious(x: bigint): bigint { 5 | if (true) { 6 | return x; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /bracket/tests/loopfact.rkt: -------------------------------------------------------------------------------- 1 | (module 2 | (define loop 3 | (lambda (prod n) 4 | (if (call >= n 1) 5 | (call loop (call * n prod) (call - n 1)) 6 | prod))) 7 | (let ([arg.x 8]) 8 | (call loop 1 arg.x))) 9 | -------------------------------------------------------------------------------- /bracket/tests/mccarthy91.rkt: -------------------------------------------------------------------------------- 1 | (module 2 | (define mac 3 | (lambda (n) 4 | (if (call > n 100) 5 | (call - n 10) 6 | (call mac (call mac (call + n 11)))))) 7 | (let ([arg.x 15]) 8 | (call mac arg.x))) 9 | -------------------------------------------------------------------------------- /examples/test/lvn/commute.bril: -------------------------------------------------------------------------------- 1 | # ARGS: -c 2 | # (a + b) * (b + a) 3 | @main { 4 | a: int = const 4; 5 | b: int = const 2; 6 | sum1: int = add a b; 7 | sum2: int = add b a; 8 | prod: int = mul sum1 sum2; 9 | print prod; 10 | } 11 | -------------------------------------------------------------------------------- /test/rs/loopfact.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value:i64 = 8; 3 | let mut result:i64 = 1; 4 | let mut i:i64 = value; 5 | while i > 0 { 6 | result *= i; 7 | i-= 1; 8 | } 9 | println!("{:?}", result); 10 | } 11 | -------------------------------------------------------------------------------- /bril-ocaml/test/count/funcs.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 2; 3 | b: int = id a; 4 | c: bool = eq a b; 5 | d: bool = id c; 6 | } 7 | 8 | @f(i: int): bool { 9 | zero: int = const 0; 10 | b: bool = eq i zero; 11 | ret b; 12 | } 13 | -------------------------------------------------------------------------------- /test/check/ssa.err: -------------------------------------------------------------------------------- 1 | 12:3: new type float for z conflicts with old type int 2 | 13:3: get expects 0 args, not 1 3 | 21:3: set expects 2 args, not 0 4 | 22:3: set should have no result type 5 | 23:3: d has type float, but arg 1 for set should have type int 6 | -------------------------------------------------------------------------------- /test/interp/core/main-bool-args.bril: -------------------------------------------------------------------------------- 1 | # ARGS: true 2 | @main(b: bool) { 3 | br b .here .there; 4 | .here: 5 | v: int = const 1; 6 | print v; 7 | ret; 8 | .there: 9 | v: int = const 2; 10 | print v; 11 | ret; 12 | } 13 | -------------------------------------------------------------------------------- /test/linking/diamond.bril: -------------------------------------------------------------------------------- 1 | # ARGS: ../linking ../../benchmarks/core 2 | from "link_ops.bril" import @main as @inner_main; 3 | from "nested.bril" import @main as @nested_main; 4 | 5 | 6 | @main(){ 7 | call @nested_main; 8 | call @inner_main; 9 | } -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/many_functions.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | @foo { 3 | a = const 1; 4 | b = const false; 5 | c = add a b; 6 | } 7 | @main { 8 | f = const false; 9 | t = const true; 10 | b = or f t; 11 | print f t b; 12 | } 13 | -------------------------------------------------------------------------------- /type-infer/tests/infer/addarg.tbril: -------------------------------------------------------------------------------- 1 | @main(arg: int) { 2 | five: int = const 5; 3 | ten: int = const 10; 4 | res: int = add arg five; 5 | cond: bool = le res ten; 6 | br cond .then .else; 7 | .then: 8 | print res; 9 | .else: 10 | } 11 | -------------------------------------------------------------------------------- /examples/test/ssa/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.is_ssa] 2 | command = "bril2json < {filename} | python3 ../../is_ssa.py" 3 | 4 | [envs.crude] 5 | command = "bril2json < {filename} | python3 ../../to_ssa_crude.py | bril2txt" 6 | output."ssa.bril" = "-" 7 | default = false 8 | -------------------------------------------------------------------------------- /fastbril/src/parser.h: -------------------------------------------------------------------------------- 1 | #ifndef PARSER_H 2 | #define PARSER_H 3 | 4 | #include "libs/json.h" 5 | #include "bril-insns/instrs.h" 6 | 7 | /** 8 | * parses a program... 9 | */ 10 | program_t *parse_program(struct json_object_s *json); 11 | #endif 12 | -------------------------------------------------------------------------------- /test/rs/cond.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value:i64 = 5; 3 | if value + 3 < 6 { 4 | let one:i64 = 1; 5 | println!("{:?}", one); 6 | } else { 7 | let two:i64 = 2; 8 | println!("{:?}", two); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/ts/call.out: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 5; 3 | x: int = id v0; 4 | v1: int = id x; 5 | call @callPrint v1; 6 | v2: int = const 0; 7 | } 8 | @callPrint(x: int) { 9 | v0: int = id x; 10 | print v0; 11 | v1: int = const 0; 12 | } 13 | -------------------------------------------------------------------------------- /type-infer/tests/infer/many_functions.tbril: -------------------------------------------------------------------------------- 1 | @foo { 2 | a: int = const 1; 3 | b: int = const 2; 4 | c: int = add a b; 5 | } 6 | @main { 7 | f: bool = const false; 8 | t: bool = const true; 9 | b: bool = or f t; 10 | print f t b; 11 | } 12 | -------------------------------------------------------------------------------- /bracket/tests/fib_recursive.rkt: -------------------------------------------------------------------------------- 1 | (module 2 | (define fibo 3 | (lambda (n) 4 | (if (call <= n 1) 5 | n 6 | (call + (call fibo (call - n 1)) (call fibo (call - n 2)))))) 7 | (let ([arg.x 10]) 8 | (call fibo arg.x))) 9 | -------------------------------------------------------------------------------- /examples/test/df/cond.defined.out: -------------------------------------------------------------------------------- 1 | b1: 2 | in: ∅ 3 | out: a, b, cond 4 | left: 5 | in: a, b, cond 6 | out: a, b, c, cond 7 | right: 8 | in: a, b, cond 9 | out: a, b, c, cond 10 | end: 11 | in: a, b, c, cond 12 | out: a, b, c, cond, d 13 | -------------------------------------------------------------------------------- /examples/test/dom/loopcond.front.json: -------------------------------------------------------------------------------- 1 | { 2 | "body": [ 3 | "loop" 4 | ], 5 | "endif": [ 6 | "loop" 7 | ], 8 | "entry": [], 9 | "exit": [], 10 | "loop": [ 11 | "loop" 12 | ], 13 | "then": [ 14 | "endif" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /fastbril/docgen.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | printf "\\begin{tabular}{|r|l|}\\hline\n\\multicolumn{2}{|c|}{%s}\\\\ \\hline\n", header 3 | } 4 | { 5 | if($0 != "") 6 | print $1 " & " $2 " \\\\ \\hline" 7 | } 8 | END { 9 | print "\\end{tabular}" 10 | } 11 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-wrong-arity.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = const 1; 3 | y: int = const 2; 4 | z: int = const 3; 5 | call @addboth x y z; 6 | } 7 | @addboth(x: int, y: int) { 8 | w: int = add x y; 9 | print w; 10 | } 11 | -------------------------------------------------------------------------------- /test/interp/ssa/ssa-simple.bril: -------------------------------------------------------------------------------- 1 | # ARGS: true 2 | @main(cond: bool) { 3 | .top: 4 | a: int = const 5; 5 | set c a; 6 | br cond .here .there; 7 | .here: 8 | b: int = const 7; 9 | set c b; 10 | .there: 11 | c: int = get; 12 | print c; 13 | } 14 | -------------------------------------------------------------------------------- /test/print/spec-abort.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | speculate; 4 | v: int = const 2; 5 | b: bool = const false; 6 | guard b .failed; 7 | commit; 8 | print v; 9 | ret; 10 | .failed: 11 | y: int = const 0; 12 | print y; 13 | } 14 | -------------------------------------------------------------------------------- /test/print/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.bril-txt] 2 | command = "bril2txt < {filename}" 3 | output.bril = "-" 4 | 5 | [envs.bril-rs] 6 | default = false 7 | command = "cargo run --example bril2txt --manifest-path ../../bril-rs/Cargo.toml < {filename}" 8 | output.bril = "-" 9 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/many_functions.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # 3 | @foo { 4 | a: bool = const 1; 5 | b = const 2; 6 | c = add a b; 7 | } 8 | @main { 9 | f = const false; 10 | t = const true; 11 | b = or f t; 12 | print f t b; 13 | } 14 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/many_functions.tbril: -------------------------------------------------------------------------------- 1 | @foo { 2 | a: int = const 1; 3 | b: int = const 2; 4 | c: int = add a b; 5 | } 6 | @main { 7 | f: bool = const false; 8 | t: bool = const true; 9 | b: bool = or f t; 10 | print f t b; 11 | } 12 | -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | all: ssa_plot.svg 3 | 4 | ssa_results.csv: ssa_brench.toml 5 | brench $^ > $@ 6 | 7 | %.norm.csv: %.csv 8 | python normalize.py < $^ > $@ 9 | 10 | ssa_plot.svg: ssa_plot.json ssa_results.norm.csv 11 | npx vl2svg $< > $@ 12 | -------------------------------------------------------------------------------- /examples/test/dom/loopcond.tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "body": [ 3 | "endif", 4 | "then" 5 | ], 6 | "endif": [], 7 | "entry": [ 8 | "loop" 9 | ], 10 | "exit": [], 11 | "loop": [ 12 | "body", 13 | "exit" 14 | ], 15 | "then": [] 16 | } 17 | -------------------------------------------------------------------------------- /examples/test/from_ssa/ssa-simple.bril: -------------------------------------------------------------------------------- 1 | # ARGS: true 2 | @main(cond: bool) { 3 | .top: 4 | a: int = const 5; 5 | set c a; 6 | br cond .here .there; 7 | .here: 8 | b: int = const 7; 9 | set c b; 10 | .there: 11 | c: int = get; 12 | print c; 13 | } 14 | -------------------------------------------------------------------------------- /examples/test/to_ssa/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.crude] 2 | command = "bril2json < {filename} | python3 ../../to_ssa_crude.py | bril2txt" 3 | output.crude = "-" 4 | 5 | [envs.full] 6 | command = "bril2json < {filename} | python3 ../../to_ssa.py | bril2txt" 7 | output.full = "-" 8 | -------------------------------------------------------------------------------- /test/interp/spec/spec-abort.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | speculate; 4 | v: int = const 2; 5 | b: bool = const false; 6 | guard b .failed; 7 | commit; 8 | print v; 9 | ret; 10 | .failed: 11 | y: int = const 0; 12 | print y; 13 | } 14 | -------------------------------------------------------------------------------- /test/ts/factorial.ts: -------------------------------------------------------------------------------- 1 | var x: bigint = 5n; 2 | var f: bigint = fac(x); 3 | console.log(f); 4 | 5 | function fac(x: bigint): bigint { 6 | if (x <= 1n) { 7 | return 1n; 8 | } 9 | var result = x * fac(x - 1n); 10 | return result; 11 | } 12 | -------------------------------------------------------------------------------- /examples/test/tdce/diamond.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 47; 3 | cond: bool = const true; 4 | br cond .left .right; 5 | .left: 6 | a: int = const 1; 7 | jmp .end; 8 | .right: 9 | a: int = const 2; 10 | jmp .end; 11 | .end: 12 | print a; 13 | } 14 | -------------------------------------------------------------------------------- /examples/test/tdce/diamond.out: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 47; 3 | cond: bool = const true; 4 | br cond .left .right; 5 | .left: 6 | a: int = const 1; 7 | jmp .end; 8 | .right: 9 | a: int = const 2; 10 | jmp .end; 11 | .end: 12 | print a; 13 | } 14 | -------------------------------------------------------------------------------- /test/interp/spec/spec-noabort.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | speculate; 4 | v: int = const 2; 5 | b: bool = const true; 6 | guard b .failed; 7 | commit; 8 | print v; 9 | ret; 10 | .failed: 11 | y: int = const 0; 12 | print y; 13 | } 14 | -------------------------------------------------------------------------------- /test/parse/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.bril-txt] 2 | command = "bril2json {args} < {filename}" 3 | output.json = "-" 4 | 5 | [envs.bril-rs] 6 | default = false 7 | command = "cargo run --manifest-path ../../bril-rs/bril2json/Cargo.toml -- {args} < {filename}" 8 | output.json = "-" 9 | -------------------------------------------------------------------------------- /test/ts/call-explicit-void.out: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 5; 3 | x: int = id v0; 4 | v1: int = id x; 5 | call @callPrint v1; 6 | v2: int = const 0; 7 | } 8 | @callPrint(x: int) { 9 | v0: int = id x; 10 | print v0; 11 | v1: int = const 0; 12 | } 13 | -------------------------------------------------------------------------------- /examples/test/to_ssa/if.bril: -------------------------------------------------------------------------------- 1 | @main(cond: bool) { 2 | .entry: 3 | a: int = const 47; 4 | br cond .left .right; 5 | .left: 6 | a: int = add a a; 7 | jmp .exit; 8 | .right: 9 | a: int = mul a a; 10 | jmp .exit; 11 | .exit: 12 | print a; 13 | } 14 | -------------------------------------------------------------------------------- /benchmarks/core/squares.out: -------------------------------------------------------------------------------- 1 | 1 2 | 4 3 | 9 4 | 16 5 | 25 6 | 36 7 | 49 8 | 64 9 | 81 10 | 100 11 | 121 12 | 144 13 | 169 14 | 196 15 | 225 16 | 256 17 | 289 18 | 324 19 | 361 20 | 400 21 | 441 22 | 484 23 | 529 24 | 576 25 | 625 26 | 676 27 | 729 28 | 784 29 | 841 30 | 900 31 | -------------------------------------------------------------------------------- /benchmarks/mixed/mat-inv.out: -------------------------------------------------------------------------------- 1 | -20.00000000000000000 2 | 0.25000000000000000 3 | -1.14999999999999991 4 | 0.80000000000000004 5 | -0.75000000000000000 6 | 2.45000000000000018 7 | -1.39999999999999991 8 | 0.25000000000000000 9 | -0.34999999999999998 10 | 0.20000000000000001 11 | -------------------------------------------------------------------------------- /examples/test/ssa/if-orig.bril: -------------------------------------------------------------------------------- 1 | @main(cond: bool) { 2 | .entry: 3 | a: int = const 47; 4 | br cond .left .right; 5 | .left: 6 | a: int = add a a; 7 | jmp .exit; 8 | .right: 9 | a: int = mul a a; 10 | jmp .exit; 11 | .exit: 12 | print a; 13 | } 14 | -------------------------------------------------------------------------------- /test/ts/nested-call.out: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 1; 3 | v1: int = call @getTwo; 4 | v2: int = add v0 v1; 5 | y: int = id v2; 6 | v3: int = id y; 7 | print v3; 8 | v4: int = const 0; 9 | } 10 | @getTwo: int { 11 | v0: int = const 2; 12 | ret v0; 13 | } 14 | -------------------------------------------------------------------------------- /test/ts/simplified.out: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: int = const 1; 3 | call @erronious v0; 4 | v1: int = const 0; 5 | } 6 | @erronious(x: int): int { 7 | v1: bool = const true; 8 | br v1 .then.0 .else.0; 9 | .then.0: 10 | v2: int = id x; 11 | ret v2; 12 | .else.0: 13 | } 14 | -------------------------------------------------------------------------------- /type-infer/tests/infer/idchain.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | jmp .l1; 3 | .l5: 4 | d = id c; 5 | ret; 6 | .l4: 7 | c = id b; 8 | jmp .l5; 9 | .l3: 10 | b = id a; 11 | jmp .l4; 12 | .l2: 13 | a = id z; 14 | jmp .l3; 15 | .l1: 16 | z = const 0; 17 | jmp .l2; 18 | } 19 | -------------------------------------------------------------------------------- /bril-rs/bril2json/build.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error; 2 | 3 | fn main() -> Result<(), Box> { 4 | let mut config = lalrpop::Configuration::new(); 5 | config.emit_rerun_directives(true); 6 | config.generate_in_source_tree(); 7 | config.process_current_dir() 8 | } 9 | -------------------------------------------------------------------------------- /examples/test/df/cond-args.cprop.out: -------------------------------------------------------------------------------- 1 | b1: 2 | in: ∅ 3 | out: a: 47, b: 42 4 | left: 5 | in: a: 47, b: 42 6 | out: a: 47, b: 1, c: 5 7 | right: 8 | in: a: 47, b: 42 9 | out: a: 2, b: 42, c: 10 10 | end: 11 | in: a: ?, b: ?, c: ? 12 | out: a: ?, b: ?, c: ?, d: ? 13 | -------------------------------------------------------------------------------- /test/interp/char/char_ops.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | c1: char = const 'a'; 3 | c2: char = const 'b'; 4 | 5 | b1: bool = ceq c1 c2; 6 | b2: bool = clt c1 c2; 7 | b3: bool = cle c1 c2; 8 | b4: bool = cgt c1 c2; 9 | b5: bool = cge c1 c2; 10 | 11 | print b1 b2 b3 b4 b5; 12 | } -------------------------------------------------------------------------------- /test/rs/factorial.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x:i64 = 5; 3 | let f:i64 = fac(x); 4 | println!("{:?}", f); 5 | } 6 | 7 | fn fac(x:i64) -> i64 { 8 | if x <= 1 { 9 | return 1; 10 | } 11 | let result: i64 = x * fac(x -1); 12 | return result; 13 | } 14 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/idchain.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | jmp .l1; 3 | .l5: 4 | d = id c; 5 | ret; 6 | .l4: 7 | c = id b; 8 | jmp .l5; 9 | .l3: 10 | b = id a; 11 | jmp .l4; 12 | .l2: 13 | a = id z; 14 | jmp .l3; 15 | .l1: 16 | z = const 0; 17 | jmp .l2; 18 | } 19 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.crude] 2 | command = "bril2json < {filename} | python3 ../../to_ssa_crude.py | python3 ../../from_ssa.py | brili {args}" 3 | 4 | [envs.full] 5 | command = "bril2json < {filename} | python3 ../../to_ssa.py | python3 ../../from_ssa.py | brili {args}" 6 | -------------------------------------------------------------------------------- /examples/test/to_ssa/selfloop.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | .entry: 3 | one: int = const 1; 4 | zero: int = const 0; 5 | x: int = const 5; 6 | .loop: 7 | x: int = sub x one; 8 | done: bool = eq x zero; 9 | .br: 10 | br done .exit .loop; 11 | .exit: 12 | print x; 13 | ret; 14 | } 15 | -------------------------------------------------------------------------------- /test/check/char.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | c: char = const 'a'; 3 | n: int = id c; 4 | 5 | b1: bool = ceq c c; 6 | b2: bool = clt c b1; 7 | b3: bool = cle n c; 8 | b4: bool = cgt c; 9 | b5: char = cge c c; 10 | 11 | c2: char = int2char c; 12 | i2: int = char2int b1; 13 | } -------------------------------------------------------------------------------- /test/check/speculate.bril: -------------------------------------------------------------------------------- 1 | @main(x: int, b: bool) { 2 | speculate; 3 | commit; 4 | guard b .l; 5 | 6 | speculate x; 7 | y: int = speculate; 8 | 9 | commit x; 10 | y: int = commit; 11 | 12 | guard .l; 13 | guard b; 14 | y: int = guard b .l; 15 | 16 | .l: 17 | } 18 | -------------------------------------------------------------------------------- /test/interp/mem/alloc.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | o1: int = const 1; 4 | bp: ptr = alloc v; 5 | bp2: ptr = ptradd bp o1; 6 | b: bool = const true; 7 | store bp b; 8 | store bp2 b; 9 | b: bool = load bp2; 10 | print b; 11 | free bp; 12 | } 13 | -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/idchain.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | jmp .l1; 3 | .l5: 4 | d: bool = id c; 5 | ret; 6 | .l4: 7 | c = id b; 8 | jmp .l5; 9 | .l3: 10 | b = id a; 11 | jmp .l4; 12 | .l2: 13 | a = id z; 14 | jmp .l3; 15 | .l1: 16 | z = const 0; 17 | jmp .l2; 18 | } 19 | -------------------------------------------------------------------------------- /bril-llvm/README.md: -------------------------------------------------------------------------------- 1 | Bril-to-LLVM Compiler 2 | ===================== 3 | 4 | The program `brilc` implements a Bril-to-LLVM compiler that supports the [struct 5 | extension][struct]. 6 | It is originally by Mark Moeller. 7 | 8 | [struct]: https://www.cs.cornell.edu/courses/cs6120/2020fa/blog/brilc/ 9 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/selfloop.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | .entry: 3 | one: int = const 1; 4 | zero: int = const 0; 5 | x: int = const 5; 6 | .loop: 7 | x: int = sub x one; 8 | done: bool = eq x zero; 9 | .br: 10 | br done .exit .loop; 11 | .exit: 12 | print x; 13 | ret; 14 | } 15 | -------------------------------------------------------------------------------- /examples/test/to_ssa/argwrite.full: -------------------------------------------------------------------------------- 1 | @main(a: int) { 2 | .b1: 3 | cond.0: bool = const true; 4 | set a.1 a; 5 | br cond.0 .here .there; 6 | .here: 7 | a.0: int = const 5; 8 | set a.1 a.0; 9 | jmp .there; 10 | .there: 11 | a.1: int = get; 12 | print a.1; 13 | ret; 14 | } 15 | -------------------------------------------------------------------------------- /test/interp/float/float_special.out: -------------------------------------------------------------------------------- 1 | 0.00000000000000000 2 | -0.00000000000000000 3 | true 4 | 1000000.00000000000000000 5 | 0.00000100000000000 6 | -1000000.00000000000000000 7 | 1.10000000000000000e+11 8 | 1.00000000000000000e+21 9 | 9.99999999999999908e-22 10 | 100000.00000000000000000 11 | -------------------------------------------------------------------------------- /test/parse/comment.json: -------------------------------------------------------------------------------- 1 | { 2 | "functions": [ 3 | { 4 | "instrs": [ 5 | { 6 | "dest": "v", 7 | "op": "const", 8 | "type": "int", 9 | "value": 42 10 | } 11 | ], 12 | "name": "main" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /examples/test/ssa/loop-orig.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | .entry: 3 | i: int = const 1; 4 | jmp .loop; 5 | .loop: 6 | max: int = const 10; 7 | cond: bool = lt i max; 8 | br cond .body .exit; 9 | .body: 10 | i: int = add i i; 11 | jmp .loop; 12 | .exit: 13 | print i; 14 | } 15 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/if.bril: -------------------------------------------------------------------------------- 1 | # ARGS: false 2 | @main(cond: bool) { 3 | .entry: 4 | a: int = const 47; 5 | br cond .left .right; 6 | .left: 7 | a: int = add a a; 8 | jmp .exit; 9 | .right: 10 | a: int = mul a a; 11 | jmp .exit; 12 | .exit: 13 | print a; 14 | } 15 | -------------------------------------------------------------------------------- /examples/test/to_ssa/loop.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | .entry: 3 | i: int = const 1; 4 | jmp .loop; 5 | .loop: 6 | max: int = const 10; 7 | cond: bool = lt i max; 8 | br cond .body .exit; 9 | .body: 10 | i: int = add i i; 11 | jmp .loop; 12 | .exit: 13 | print i; 14 | } 15 | -------------------------------------------------------------------------------- /type-infer/tests/infer/logic_ops.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | F1 = const false; 3 | T1 = const true; 4 | a1 = not F1; 5 | b1 = and a1 T1; 6 | c1 = or a1 b1; 7 | F2: bool = const false; 8 | T2 = const true; 9 | a2: bool = not F2; 10 | b2 = and a2 T2; 11 | c2: bool = or a2 b2; 12 | } 13 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/logic_ops.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | F1 = const false; 3 | T1 = const true; 4 | a1 = not F1; 5 | b1 = and a1 T1; 6 | c1 = or a1 b1; 7 | F2: bool = const false; 8 | T2 = const true; 9 | a2: bool = not F2; 10 | b2 = and a2 T2; 11 | c2: bool = or a2 b2; 12 | } 13 | -------------------------------------------------------------------------------- /benchmarks/core/tail-call.bril: -------------------------------------------------------------------------------- 1 | #ARGS: 1500 2 | @main(depth: int) { 3 | zero: int = const 0; 4 | cond: bool = eq depth zero; 5 | br cond .end .inc_depth; 6 | .inc_depth: 7 | one: int = const 1; 8 | new_depth: int = sub depth one; 9 | call @main new_depth; 10 | .end: 11 | ret; 12 | } 13 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | Bril Examples 2 | ============= 3 | 4 | This directory contains assorted examples showing how to do interesting analyses and transformations on Bril programs. They are intentionally under-documented because you should be figuring this stuff out yourself, not reading my half-baked code! 5 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/loop.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | .entry: 3 | i: int = const 1; 4 | jmp .loop; 5 | .loop: 6 | max: int = const 10; 7 | cond: bool = lt i max; 8 | br cond .body .exit; 9 | .body: 10 | i: int = add i i; 11 | jmp .loop; 12 | .exit: 13 | print i; 14 | } 15 | -------------------------------------------------------------------------------- /test/check/badmem.bril: -------------------------------------------------------------------------------- 1 | @main(i: int, f: float) { 2 | p: ptr = alloc f; 3 | p2: int = alloc i; 4 | 5 | store p f; 6 | store i p; 7 | 8 | j: float = load p; 9 | i: int = load i; 10 | 11 | q: ptr = ptradd p i; 12 | q2: ptr = ptradd i p; 13 | 14 | free i; 15 | } 16 | -------------------------------------------------------------------------------- /type-infer/tests/infer/idchain.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | jmp .l1; 3 | .l5: 4 | d: int = id c; 5 | ret; 6 | .l4: 7 | c: int = id b; 8 | jmp .l5; 9 | .l3: 10 | b: int = id a; 11 | jmp .l4; 12 | .l2: 13 | a: int = id z; 14 | jmp .l3; 15 | .l1: 16 | z: int = const 0; 17 | jmp .l2; 18 | } 19 | -------------------------------------------------------------------------------- /examples/test/dom/while.bril: -------------------------------------------------------------------------------- 1 | @main(a: int) { 2 | .while.cond: 3 | zero: int = const 0; 4 | is_term: bool = eq a zero; 5 | br is_term .while.finish .while.body; 6 | .while.body: 7 | one: int = const 1; 8 | a: int = sub a one; 9 | jmp .while.cond; 10 | .while.finish: 11 | print a; 12 | } 13 | -------------------------------------------------------------------------------- /examples/test/to_ssa/while.bril: -------------------------------------------------------------------------------- 1 | @main(a: int) { 2 | .while.cond: 3 | zero: int = const 0; 4 | is_term: bool = eq a zero; 5 | br is_term .while.finish .while.body; 6 | .while.body: 7 | one: int = const 1; 8 | a: int = sub a one; 9 | jmp .while.cond; 10 | .while.finish: 11 | print a; 12 | } 13 | -------------------------------------------------------------------------------- /test/check/speculate.err: -------------------------------------------------------------------------------- 1 | 6:3: speculate expects 0 args, not 1 2 | 7:3: speculate should have no result type 3 | 9:3: commit expects 0 args, not 1 4 | 10:3: commit should have no result type 5 | 12:3: guard expects 1 args, not 0 6 | 13:3: guard needs 1 labels; found 0 7 | 14:3: guard should have no result type 8 | -------------------------------------------------------------------------------- /test/interp/core/call-with-args.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = const 2; 3 | y: int = const 2; 4 | z: int = call @add2 x y; 5 | print y; 6 | print z; 7 | } 8 | 9 | @add2(x: int, y: int): int { 10 | w: int = add x y; 11 | y: int = const 5; 12 | print w; 13 | ret w; 14 | } 15 | -------------------------------------------------------------------------------- /test/interp/float/float_divide_by_zero.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: float = const -1.0; 3 | v1: float = const 1.0; 4 | zero: float = const 0.0; 5 | res: float = fdiv v0 zero; 6 | print res; 7 | res: float = fdiv v1 zero; 8 | print res; 9 | res: float = fdiv zero zero; 10 | print res; 11 | } 12 | -------------------------------------------------------------------------------- /test/ts/memory-call.ts: -------------------------------------------------------------------------------- 1 | import * as mem from "../../bril-ts/mem"; 2 | 3 | function update(p: mem.Pointer): mem.Pointer { 4 | mem.store(p, 42n); 5 | return p; 6 | } 7 | 8 | let p1 = mem.alloc(1n); 9 | let p2 = update(p1); 10 | console.log(mem.load(p2)); 11 | 12 | mem.free(p1); -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/idchain.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | @main { 3 | jmp .l1; 4 | .l5: 5 | d: bool = id c; 6 | ret; 7 | .l4: 8 | c = id b; 9 | jmp .l5; 10 | .l3: 11 | b = id a; 12 | jmp .l4; 13 | .l2: 14 | a = id z; 15 | jmp .l3; 16 | .l1: 17 | z = const 0; 18 | jmp .l2; 19 | } 20 | -------------------------------------------------------------------------------- /type-infer/tests/infer/control_ops.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | one = const 1; 3 | n = const 5; 4 | res = const 1; 5 | i = id n; 6 | .cond: 7 | b = gt i one; 8 | br b .body .end; 9 | .body: 10 | res = mul res i; 11 | i = sub i one; 12 | jmp .cond; 13 | .end: 14 | print res; 15 | ret; 16 | } 17 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/idchain.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | jmp .l1; 3 | .l5: 4 | d: int = id c; 5 | ret; 6 | .l4: 7 | c: int = id b; 8 | jmp .l5; 9 | .l3: 10 | b: int = id a; 11 | jmp .l4; 12 | .l2: 13 | a: int = id z; 14 | jmp .l3; 15 | .l1: 16 | z: int = const 0; 17 | jmp .l2; 18 | } 19 | -------------------------------------------------------------------------------- /examples/test/lvn/redundant-dce.bril: -------------------------------------------------------------------------------- 1 | # CMD: bril2json < {filename} | python3 ../../lvn.py | python3 ../../tdce.py tdce | bril2txt 2 | 3 | @main { 4 | a: int = const 4; 5 | b: int = const 2; 6 | sum1: int = add a b; 7 | sum2: int = add a b; 8 | prod: int = mul sum1 sum2; 9 | print prod; 10 | } 11 | -------------------------------------------------------------------------------- /fastbril/docgen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | CORE=$(echo $1 | awk -F'[/.]' '{print $2}') 5 | IF=$(echo $1 | awk -F'[/.]' '{printf "config/%s.cf", $2}') 6 | if [[ $CORE == "types" ]]; then 7 | CORE="Types" 8 | else 9 | CORE="$CORE Instructions" 10 | fi 11 | awk -v header="$CORE" -f docgen.awk $IF > $1 12 | -------------------------------------------------------------------------------- /test/interp/mem/alloc_many.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 1; 3 | max: int = const 1000000; 4 | count: int = const 0; 5 | .lbl: 6 | count: int = add count v; 7 | p: ptr = alloc v; 8 | free p; 9 | loop: bool = ge count max; 10 | br loop .end .lbl; 11 | .end: 12 | print count; 13 | } 14 | -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/logic_ops.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | @main { 3 | F1 = const false; 4 | T1 = const 1; 5 | a1 = not F1; 6 | b1 = and a1 T1; 7 | c1 = or a1 b1; 8 | F2: bool = const 999; 9 | T2 = const true; 10 | a2: bool = not F2; 11 | b2 = and a2 T2; 12 | c2: bool = or a2 b2; 13 | } 14 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/control_ops.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | one = const 1; 3 | n = const 5; 4 | res = const 1; 5 | i = id n; 6 | .cond: 7 | b = gt i one; 8 | br b .body .end; 9 | .body: 10 | res = mul res i; 11 | i = sub i one; 12 | jmp .cond; 13 | .end: 14 | print res; 15 | ret; 16 | } 17 | -------------------------------------------------------------------------------- /fastbril/src/asm/to_abstract_asm.h: -------------------------------------------------------------------------------- 1 | #ifndef TO_ABS_H 2 | #define TO_ABS_H 3 | 4 | #include "../bril-insns/instrs.h" 5 | #include "asm.h" 6 | 7 | 8 | //#define __ARM_ARCH 9 | #ifdef __ARM_ARCH 10 | #include "armv8.h" 11 | #endif 12 | 13 | asm_prog_t bytecode_to_abs_asm(program_t *prog); 14 | 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /test/interp/char/conversions.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | c1: char = const 'A'; 3 | c2: char = const '𝛀'; 4 | i1: int = const 65; 5 | i2: int = const 120512; 6 | 7 | c3: char = int2char i1; 8 | i3: int = char2int c1; 9 | c4: char = int2char i2; 10 | i4: int = char2int c2; 11 | 12 | print c3 i3 c4 i4; 13 | } -------------------------------------------------------------------------------- /bril-ocaml/lib/common.ml: -------------------------------------------------------------------------------- 1 | open! Core 2 | 3 | let has_key json key = 4 | let open Yojson.Basic.Util in 5 | match json |> member key with 6 | | `Null -> false 7 | | _ -> true 8 | 9 | let to_list_nonnull = 10 | let open Yojson.Basic.Util in 11 | function 12 | | `Null -> [] 13 | | json -> to_list json 14 | -------------------------------------------------------------------------------- /bril-ocaml/lib/const.ml: -------------------------------------------------------------------------------- 1 | open! Core 2 | open! Common 3 | 4 | type t = 5 | | Int of int 6 | | Bool of bool 7 | | Float of float 8 | [@@deriving compare, equal, sexp_of] 9 | 10 | let to_string = function 11 | | Int i -> Int.to_string i 12 | | Bool b -> Bool.to_string b 13 | | Float f -> Float.to_string f 14 | -------------------------------------------------------------------------------- /bril-rs/bril2json/README.md: -------------------------------------------------------------------------------- 1 | # Bril2json 2 | 3 | This project is a Rust implementation of the Bril2json tool. 4 | 5 | View the interface with `cargo doc --open` or install with `make install` using the Makefile in `bril/bril_rs`. Then use `bril2json --help` to get the help page for `bril2json` with all of the supported flags. 6 | -------------------------------------------------------------------------------- /examples/test/lvn/rename-fold.bril: -------------------------------------------------------------------------------- 1 | # CMD: bril2json < {filename} | python3 ../../lvn.py -f | python3 ../../tdce.py tdce | bril2txt 2 | @main { 3 | v1: int = const 4; 4 | v2: int = const 0; 5 | mul1: int = mul v1 v2; 6 | add1: int = add v1 v2; 7 | v2: int = const 3; 8 | print mul1; 9 | print add1; 10 | } 11 | -------------------------------------------------------------------------------- /test/check/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.brilck] 2 | command = "bril2json -p < {filename} | brilck" 3 | return_code = 1 4 | output.err = "2" 5 | 6 | [envs.brilirs] 7 | default = false 8 | command = "cargo run --manifest-path ../../brilirs/Cargo.toml -- --check --file {filename} --text {args}" 9 | return_code = 2 10 | output = {} 11 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-wrong-declared-type.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = const 2; 3 | y: int = const 2; 4 | z: int = call @add2 x y; 5 | print y; 6 | print z; 7 | } 8 | @add2(x: int, y: int): bool { 9 | w: int = add x y; 10 | y: int = const 5; 11 | print w; 12 | ret w; 13 | } 14 | -------------------------------------------------------------------------------- /test/interp-error/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.brili] 2 | command = "bril2json < {filename} | brili {args}" 3 | return_code = 2 4 | output.err = "2" 5 | 6 | [envs.brilirs] 7 | default = false 8 | command = "cargo run --manifest-path ../../brilirs/Cargo.toml -- --file {filename} --text {args}" 9 | return_code = 2 10 | output = {} 11 | -------------------------------------------------------------------------------- /fastbril/config/base.cf: -------------------------------------------------------------------------------- 1 | CONST 1 2 | ADD 2 3 | MUL 3 4 | SUB 4 5 | DIV 5 6 | EQ 6 7 | LT 7 8 | GT 8 9 | LE 9 10 | GE 10 11 | NOT 11 12 | AND 12 13 | OR 13 14 | JMP 14 15 | BR 15 16 | CALL 16 17 | RET 17 18 | PRINT 18 19 | LCONST 19 20 | NOP 20 21 | ID 21 22 | 23 | -------------------------------------------------------------------------------- /test/interp/ssa/ssa-two-phi.bril: -------------------------------------------------------------------------------- 1 | # ARGS: true 2 | @main(cond: bool) { 3 | .top: 4 | a: int = const 5; 5 | set c a; 6 | set d a; 7 | br cond .here .there; 8 | .here: 9 | b: int = const 7; 10 | set c b; 11 | set d b; 12 | .there: 13 | c: int = get; 14 | d: int = get; 15 | print c; 16 | print d; 17 | } 18 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/logic_ops.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # 3 | @main { 4 | F1 = const false; 5 | T1 = const true; 6 | a1 = not F1; 7 | b1 = and a1 T1; 8 | c1 = or a1 b1; 9 | F2: int = const false; 10 | T2 = const true; 11 | a2: int = not F2; 12 | b2 = and a2 T2; 13 | c2: bool = or a2 b2; 14 | } 15 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/while.bril: -------------------------------------------------------------------------------- 1 | # ARGS: 5 2 | @main(a: int) { 3 | .while.cond: 4 | zero: int = const 0; 5 | is_term: bool = eq a zero; 6 | br is_term .while.finish .while.body; 7 | .while.body: 8 | one: int = const 1; 9 | a: int = sub a one; 10 | jmp .while.cond; 11 | .while.finish: 12 | print a; 13 | } 14 | -------------------------------------------------------------------------------- /test/interp-error/core-error/call-nonvoid-return-nothing-error.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | x: int = const 2; 3 | y: int = const 2; 4 | z: int = call @add2 x y; 5 | print y; 6 | print z; 7 | } 8 | @add2(x: int, y: int): int { 9 | w: int = add x y; 10 | y: int = const 5; 11 | print w; 12 | ret; 13 | } 14 | -------------------------------------------------------------------------------- /test/interp/char/control_char.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | 3 | c1: char = const '\a'; 4 | c2: char = const '\b'; 5 | c3: char = const '\f'; 6 | c4: char = const '\n'; 7 | c5: char = const '\r'; 8 | c6: char = const '\t'; 9 | c7: char = const '\v'; 10 | c8: char = const '\0'; 11 | 12 | print c1 c2 c3 c4 c5 c6 c7 c8; 13 | } -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/control_ops.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | @main { 3 | one = const true; 4 | n = const 5; 5 | res = const 1; 6 | i = id n; 7 | .cond: 8 | b = gt i one; 9 | br b .body .end; 10 | .body: 11 | res = mul res i; 12 | i = sub i one; 13 | jmp .cond; 14 | .end: 15 | print res; 16 | ret; 17 | } 18 | -------------------------------------------------------------------------------- /type-infer/tests/infer/arith_ops.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a1 = const 1; 3 | b1 = const 2; 4 | c1 = add a1 b1; 5 | d1 = mul c1 b1; 6 | e1 = sub d1 c1; 7 | f1 = div e1 d1; 8 | a2 = const 1; 9 | b2: int = const 2; 10 | c2 = add a2 b2; 11 | d2: int = mul c2 b2; 12 | e2: int = sub d2 c2; 13 | f2 = div e2 d2; 14 | } 15 | -------------------------------------------------------------------------------- /examples/test/df/fact.defined.out: -------------------------------------------------------------------------------- 1 | b1: 2 | in: ∅ 3 | out: i, result 4 | header: 5 | in: cond, i, one, result, zero 6 | out: cond, i, one, result, zero 7 | body: 8 | in: cond, i, one, result, zero 9 | out: cond, i, one, result, zero 10 | end: 11 | in: cond, i, one, result, zero 12 | out: cond, i, one, result, zero 13 | -------------------------------------------------------------------------------- /type-infer/tests/infer/logic_ops.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | F1: bool = const false; 3 | T1: bool = const true; 4 | a1: bool = not F1; 5 | b1: bool = and a1 T1; 6 | c1: bool = or a1 b1; 7 | F2: bool = const false; 8 | T2: bool = const true; 9 | a2: bool = not F2; 10 | b2: bool = and a2 T2; 11 | c2: bool = or a2 b2; 12 | } 13 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/arith_ops.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a1 = const 1; 3 | b1 = const 2; 4 | c1 = add a1 b1; 5 | d1 = mul c1 b1; 6 | e1 = sub d1 c1; 7 | f1 = div e1 d1; 8 | a2 = const 1; 9 | b2: int = const 2; 10 | c2 = add a2 b2; 11 | d2: int = mul c2 b2; 12 | e2: int = sub d2 c2; 13 | f2 = div e2 d2; 14 | } 15 | -------------------------------------------------------------------------------- /bril-ocaml/lib/bril_type.mli: -------------------------------------------------------------------------------- 1 | open! Core 2 | 3 | type t = 4 | | IntType 5 | | BoolType 6 | | FloatType 7 | | PtrType of t 8 | [@@deriving compare, equal, sexp_of] 9 | 10 | val of_json : Yojson.Basic.t -> t 11 | val of_json_opt : Yojson.Basic.t -> t option 12 | val to_json : t -> Yojson.Basic.t 13 | val to_string : t -> string 14 | -------------------------------------------------------------------------------- /test/interp/mem/alloc_large.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | inc: int = const 1; 3 | v: int = const 1000; 4 | max: int = const 1000000; 5 | count: int = const 0; 6 | .lbl: 7 | count: int = add count inc; 8 | p: ptr = alloc v; 9 | free p; 10 | loop: bool = ge count max; 11 | br loop .end .lbl; 12 | .end: 13 | print count; 14 | } 15 | -------------------------------------------------------------------------------- /test/parse/float.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: float = const 1.1; 3 | v1: float = const .02; 4 | v2: float = const 0.3; 5 | v3: float = fadd v0 v1; 6 | v4: float = fmul v2 v2; 7 | v5: float = const 1.; 8 | v6: float = const 1e6; 9 | # v7: float = const 1E-6; 10 | v8: float = const -1E+6; 11 | v9: float = const +.11e12; 12 | } 13 | -------------------------------------------------------------------------------- /test/ts/boolvar.out: -------------------------------------------------------------------------------- 1 | @main { 2 | v0: bool = const true; 3 | x: bool = id v0; 4 | v2: bool = id x; 5 | br v2 .then.1 .else.1; 6 | .then.1: 7 | v3: int = const 1; 8 | print v3; 9 | v4: int = const 0; 10 | jmp .endif.1; 11 | .else.1: 12 | v5: int = const 2; 13 | print v5; 14 | v6: int = const 0; 15 | .endif.1: 16 | } 17 | -------------------------------------------------------------------------------- /type-infer/tests/infer/control_ops.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | one: int = const 1; 3 | n: int = const 5; 4 | res: int = const 1; 5 | i: int = id n; 6 | .cond: 7 | b: bool = gt i one; 8 | br b .body .end; 9 | .body: 10 | res: int = mul res i; 11 | i: int = sub i one; 12 | jmp .cond; 13 | .end: 14 | print res; 15 | ret; 16 | } 17 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/logic_ops.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | F1: bool = const false; 3 | T1: bool = const true; 4 | a1: bool = not F1; 5 | b1: bool = and a1 T1; 6 | c1: bool = or a1 b1; 7 | F2: bool = const false; 8 | T2: bool = const true; 9 | a2: bool = not F2; 10 | b2: bool = and a2 T2; 11 | c2: bool = or a2 b2; 12 | } 13 | -------------------------------------------------------------------------------- /examples/test/df/cond-args.bril: -------------------------------------------------------------------------------- 1 | @main(cond: bool) { 2 | a: int = const 47; 3 | b: int = const 42; 4 | br cond .left .right; 5 | .left: 6 | b: int = const 1; 7 | c: int = const 5; 8 | jmp .end; 9 | .right: 10 | a: int = const 2; 11 | c: int = const 10; 12 | jmp .end; 13 | .end: 14 | d: int = sub a c; 15 | print d; 16 | } 17 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/control_ops.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # 3 | @main { 4 | one = const 1; 5 | n = const 5; 6 | res = const 1; 7 | i = id n; 8 | .cond: 9 | b = gt i one; 10 | br b .body .end; 11 | .body: 12 | res: bool = mul res i; 13 | i = sub i one; 14 | jmp .cond; 15 | .end: 16 | print res; 17 | ret; 18 | } 19 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/control_ops.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | one: int = const 1; 3 | n: int = const 5; 4 | res: int = const 1; 5 | i: int = id n; 6 | .cond: 7 | b: bool = gt i one; 8 | br b .body .end; 9 | .body: 10 | res: int = mul res i; 11 | i: int = sub i one; 12 | jmp .cond; 13 | .end: 14 | print res; 15 | ret; 16 | } 17 | -------------------------------------------------------------------------------- /benchmarks/core/sum-of-cubes.bril: -------------------------------------------------------------------------------- 1 | # ARGS: 6 2 | 3 | @main(n: int) { 4 | v0: int = const 1; 5 | v1: int = const 2; 6 | v2: int = id n; 7 | 8 | v3: int = add v0 v2; # n + 1 9 | v4: int = mul v2 v3; # n(n+1) 10 | v5: int = div v4 v1; # n(n+1)/2 11 | v6: int = mul v5 v5; # (n(n+1)/2)^2 12 | print v6; 13 | 14 | } -------------------------------------------------------------------------------- /examples/test/to_ssa/if.full: -------------------------------------------------------------------------------- 1 | @main(cond: bool) { 2 | .entry: 3 | a.0: int = const 47; 4 | br cond .left .right; 5 | .left: 6 | a.2: int = add a.0 a.0; 7 | set a.1 a.2; 8 | jmp .exit; 9 | .right: 10 | a.3: int = mul a.0 a.0; 11 | set a.1 a.3; 12 | jmp .exit; 13 | .exit: 14 | a.1: int = get; 15 | print a.1; 16 | ret; 17 | } 18 | -------------------------------------------------------------------------------- /test/interp/dynamic/mem_dynamic_struct.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 2; 3 | o1: int = const 1; 4 | bp: ptr = alloc v; 5 | bp2: ptr = ptradd bp o1; 6 | b: bool = const true; 7 | i: int = const 0; 8 | store bp b; 9 | store bp2 i; 10 | b: bool = load bp; 11 | i: int = load bp2; 12 | print b i; 13 | free bp; 14 | } 15 | -------------------------------------------------------------------------------- /brilir/bril2mlir/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(nlohmann_json 3.12.0 REQUIRED) 2 | 3 | set(LIBS 4 | MLIRBril 5 | nlohmann_json::nlohmann_json 6 | ) 7 | add_llvm_executable(bril2mlir bril2mlir.cpp) 8 | 9 | llvm_update_compile_flags(bril2mlir) 10 | target_link_libraries(bril2mlir PRIVATE ${LIBS}) 11 | 12 | mlir_check_all_link_libraries(bril2mlir) -------------------------------------------------------------------------------- /examples/test/dom/while.dom.json: -------------------------------------------------------------------------------- 1 | { 2 | "entry1": [ 3 | "entry1" 4 | ], 5 | "while.body": [ 6 | "entry1", 7 | "while.body", 8 | "while.cond" 9 | ], 10 | "while.cond": [ 11 | "entry1", 12 | "while.cond" 13 | ], 14 | "while.finish": [ 15 | "entry1", 16 | "while.cond", 17 | "while.finish" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/arith_ops.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | @main { 3 | a1 = const false; 4 | b1 = const 2; 5 | c1 = add a1 b1; 6 | d1 = mul c1 b1; 7 | e1 = sub d1 c1; 8 | f1 = div e1 d1; 9 | a2 = const 1; 10 | b2: int = const 2; 11 | c2 = add a2 b2; 12 | d2: int = mul c2 b2; 13 | e2: int = sub d2 c2; 14 | f2 = div e2 d2; 15 | } 16 | -------------------------------------------------------------------------------- /bracket/tests/ackermann.rkt: -------------------------------------------------------------------------------- 1 | (module 2 | (define ack 3 | (lambda (m n) 4 | (if (call eq? m 0) 5 | (call + n 1) 6 | (if (call eq? n 0) 7 | (call ack (call - m 1) 1) 8 | (call ack (call - m 1) (call ack m (call - n 1))))))) 9 | (let ([arg.x 3] [arg.y 6]) 10 | (call ack arg.x arg.y))) 11 | -------------------------------------------------------------------------------- /examples/test/df/cond.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a: int = const 47; 3 | b: int = const 42; 4 | cond: bool = const true; 5 | br cond .left .right; 6 | .left: 7 | b: int = const 1; 8 | c: int = const 5; 9 | jmp .end; 10 | .right: 11 | a: int = const 2; 12 | c: int = const 10; 13 | jmp .end; 14 | .end: 15 | d: int = sub a c; 16 | print d; 17 | } 18 | -------------------------------------------------------------------------------- /examples/test/df/cond.cprop.out: -------------------------------------------------------------------------------- 1 | b1: 2 | in: ∅ 3 | out: a: 47, b: 42, cond: True 4 | left: 5 | in: a: 47, b: 42, cond: True 6 | out: a: 47, b: 1, c: 5, cond: True 7 | right: 8 | in: a: 47, b: 42, cond: True 9 | out: a: 2, b: 42, c: 10, cond: True 10 | end: 11 | in: a: ?, b: ?, c: ?, cond: True 12 | out: a: ?, b: ?, c: ?, cond: True, d: ? 13 | -------------------------------------------------------------------------------- /benchmarks/core/check-primes.out: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 1 4 | 0 5 | 1 6 | 0 7 | 1 8 | 0 9 | 0 10 | 0 11 | 1 12 | 0 13 | 1 14 | 0 15 | 0 16 | 0 17 | 1 18 | 0 19 | 1 20 | 0 21 | 0 22 | 0 23 | 1 24 | 0 25 | 0 26 | 0 27 | 0 28 | 0 29 | 1 30 | 0 31 | 1 32 | 0 33 | 0 34 | 0 35 | 0 36 | 0 37 | 1 38 | 0 39 | 0 40 | 0 41 | 1 42 | 0 43 | 1 44 | 0 45 | 0 46 | 0 47 | 1 48 | 0 49 | 0 50 | -------------------------------------------------------------------------------- /examples/test/to_ssa/if-const.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | cond: bool = const true; 3 | br cond .true .false; 4 | .true: 5 | a: int = const 0; 6 | jmp .zexit; 7 | .false: 8 | b: int = const 1; 9 | jmp .zexit; 10 | # zexit to trigger a bug in to_ssa.py that depends on 11 | # the order that basic blocks get renamed. 12 | .zexit: 13 | print a; 14 | } -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/arith_ops.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # 3 | @main { 4 | a1 = const 1; 5 | b1 = const 2; 6 | c1 = add a1 b1; 7 | d1 = mul c1 b1; 8 | e1 = sub d1 c1; 9 | f1 = div e1 d1; 10 | a2 = const 1; 11 | b2: int = const 2; 12 | c2 = add a2 b2; 13 | d2: bool = mul c2 b2; 14 | e2: int = sub d2 c2; 15 | f2 = div e2 d2; 16 | } 17 | -------------------------------------------------------------------------------- /brilir/bril-opt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBS 2 | MLIRArithDialect 3 | MLIROptLib 4 | MLIRRegisterAllDialects 5 | MLIRRegisterAllPasses 6 | MLIRBril 7 | ) 8 | add_llvm_executable(bril-opt bril-opt.cpp) 9 | 10 | llvm_update_compile_flags(bril-opt) 11 | target_link_libraries(bril-opt PRIVATE ${LIBS}) 12 | 13 | mlir_check_all_link_libraries(bril-opt) 14 | -------------------------------------------------------------------------------- /benchmarks/core/squares.bril: -------------------------------------------------------------------------------- 1 | # ARGS: 30 2 | # prints squares of all integers from 1 up to input. 3 | @main(input: int) { 4 | one: int = const 1; 5 | zero: int = const 0; 6 | cur: int = const 1; 7 | .print: 8 | square: int = mul cur cur; 9 | print square; 10 | isdone: bool = eq cur input; 11 | cur: int = add cur one; 12 | br isdone .done .print; 13 | .done: 14 | } 15 | -------------------------------------------------------------------------------- /brilir/mlir2bril/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(nlohmann_json 3.12.0 REQUIRED) 2 | 3 | set(LIBS 4 | MLIRBril 5 | MLIRParser 6 | nlohmann_json::nlohmann_json 7 | ) 8 | add_llvm_executable(mlir2bril mlir2bril.cpp) 9 | 10 | llvm_update_compile_flags(mlir2bril) 11 | target_link_libraries(mlir2bril PRIVATE ${LIBS}) 12 | 13 | mlir_check_all_link_libraries(mlir2bril) -------------------------------------------------------------------------------- /examples/test/dom/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.dom] 2 | command = "bril2json < {filename} | python3 ../../dom.py dom" 3 | output."dom.json" = "-" 4 | 5 | [envs.front] 6 | command = "bril2json < {filename} | python3 ../../dom.py front" 7 | output."front.json" = "-" 8 | 9 | [envs.tree] 10 | command = "bril2json < {filename} | python3 ../../dom.py tree" 11 | output."tree.json" = "-" 12 | -------------------------------------------------------------------------------- /examples/test/ssa_roundtrip/if-const.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | cond: bool = const true; 3 | br cond .true .false; 4 | .true: 5 | a: int = const 0; 6 | jmp .zexit; 7 | .false: 8 | b: int = const 1; 9 | jmp .zexit; 10 | # zexit to trigger a bug in to_ssa.py that depends on 11 | # the order that basic blocks get renamed. 12 | .zexit: 13 | print a; 14 | } 15 | -------------------------------------------------------------------------------- /test/rs/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.bril-rs] 2 | command = "cargo run --manifest-path ../../bril-rs/rs2bril/Cargo.toml < {filename} | cargo run --manifest-path ../../brilirs/Cargo.toml -- {args}" 3 | output.out = "-" 4 | 5 | [envs.rustc] 6 | default = false 7 | command = "rustc {filename} --crate-type bin -o ../../bril-rs/target/a.out && ../../bril-rs/target/a.out {args}" 8 | output.out = "-" -------------------------------------------------------------------------------- /type-infer/tests/infer/arith_ops.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | a1: int = const 1; 3 | b1: int = const 2; 4 | c1: int = add a1 b1; 5 | d1: int = mul c1 b1; 6 | e1: int = sub d1 c1; 7 | f1: int = div e1 d1; 8 | a2: int = const 1; 9 | b2: int = const 2; 10 | c2: int = add a2 b2; 11 | d2: int = mul c2 b2; 12 | e2: int = sub d2 c2; 13 | f2: int = div e2 d2; 14 | } 15 | -------------------------------------------------------------------------------- /examples/test/df/turnt.toml: -------------------------------------------------------------------------------- 1 | [envs.defined] 2 | command = "bril2json < {filename} | python3 ../../df.py defined" 3 | output."defined.out" = "-" 4 | 5 | [envs.live] 6 | command = "bril2json < {filename} | python3 ../../df.py live" 7 | output."live.out" = "-" 8 | 9 | [envs.cprop] 10 | command = "bril2json < {filename} | python3 ../../df.py cprop" 11 | output."cprop.out" = "-" 12 | -------------------------------------------------------------------------------- /fastbril/src/byte-io.h: -------------------------------------------------------------------------------- 1 | #ifndef BYTE_OUTPUT_H 2 | #define BYTE_OUTPUT_H 3 | #include "bril-insns/instrs.h" 4 | #include 5 | 6 | /** 7 | * emit prog as bytecode to dest 8 | */ 9 | void output_program(program_t *prog, FILE *dest); 10 | 11 | /** 12 | * read source as bytecode and return a program 13 | */ 14 | program_t *read_program(FILE *source); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /test/interp/ssa/ssu-regression.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | one: int = const 1; 3 | set shadow one; 4 | main.cond: bool = const true; 5 | set cond main.cond; 6 | .test: 7 | cond: bool = get; 8 | shadow: int = get; 9 | br cond .false .end; 10 | .false: 11 | false.cond: bool = const false; 12 | set cond false.cond; 13 | jmp .test; 14 | .end: 15 | print shadow; 16 | } 17 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/arith_ops.tbril: -------------------------------------------------------------------------------- 1 | @main { 2 | a1: int = const 1; 3 | b1: int = const 2; 4 | c1: int = add a1 b1; 5 | d1: int = mul c1 b1; 6 | e1: int = sub d1 c1; 7 | f1: int = div e1 d1; 8 | a2: int = const 1; 9 | b2: int = const 2; 10 | c2: int = add a2 b2; 11 | d2: int = mul c2 b2; 12 | e2: int = sub d2 c2; 13 | f2: int = div e2 d2; 14 | } 15 | -------------------------------------------------------------------------------- /.github/brilck-matcher.json: -------------------------------------------------------------------------------- 1 | { 2 | "problemMatcher": [ 3 | { 4 | "owner": "brilck", 5 | "pattern": [{ 6 | "regexp": "^([^:]+):(\\d+):(\\d+): (.*)$", 7 | "file": 1, 8 | "line": 2, 9 | "column": 3, 10 | "message": "4" 11 | }] 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /bracket/tests/gcd.rkt: -------------------------------------------------------------------------------- 1 | (module 2 | (define loop 3 | (lambda (a b) 4 | (if (call eq? a b) 5 | a 6 | (if (call < a b) 7 | (let ([c (call - b a)]) 8 | (call loop a c)) 9 | (let ([c (call - a b)]) 10 | (call loop b c)))))) 11 | (let ([arg.x 4] [arg.y 20]) 12 | (call loop arg.x arg.y))) 13 | -------------------------------------------------------------------------------- /bril-rs/bril2json/src/main.rs: -------------------------------------------------------------------------------- 1 | use bril_rs::output_abstract_program; 2 | use bril2json::cli::Cli; 3 | use bril2json::parse_abstract_program; 4 | use clap::Parser; 5 | 6 | fn main() { 7 | let args = Cli::parse(); 8 | output_abstract_program(&parse_abstract_program( 9 | args.position >= 1, 10 | args.position >= 2, 11 | args.file, 12 | )) 13 | } 14 | -------------------------------------------------------------------------------- /bril2json-rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bril2json" 3 | description = "Convert textual Bril to JSON" 4 | authors = ["Ethan Uppal"] 5 | version = "0.1.0" 6 | edition = "2021" 7 | readme = "README.md" 8 | license = "MIT" 9 | 10 | [dependencies] 11 | bril-frontend = "0.2.2" 12 | annotate-snippets = "0.11.5" 13 | snafu = "0.8.5" 14 | argh = "0.1.13" 15 | serde_json = "1.0.138" 16 | -------------------------------------------------------------------------------- /test/interp/mem/access.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | inc: int = const 1; 3 | v: int = const 1000000; 4 | max: int = const 1000000; 5 | p: ptr = alloc v; 6 | count: int = const 0; 7 | .lbl: 8 | count: int = add count inc; 9 | store p v; 10 | val: int = load p; 11 | loop: bool = ge count max; 12 | br loop .end .lbl; 13 | .end: 14 | free p; 15 | print count; 16 | } 17 | -------------------------------------------------------------------------------- /test/print/char.json: -------------------------------------------------------------------------------- 1 | { 2 | "functions": [ 3 | { 4 | "name": "main", 5 | "instrs": [ 6 | { "op": "const", "type": "char", "dest": "c1", "value": "7" }, 7 | { "op": "const", "type": "char", "dest": "c2", "value": "a" }, 8 | { "op": "const", "type": "char", "dest": "c2", "value": "\n" } 9 | ], 10 | "args": [] 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /type-infer/tests/infer/comp_ops.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a1 = const 1; 3 | b1 = const 2; 4 | c1 = eq a1 b1; 5 | d1 = lt a1 b1; 6 | e1 = gt a1 b1; 7 | f1 = le a1 b1; 8 | g1 = ge a1 b1; 9 | 10 | a2 = const 1; 11 | b2 = const 2; 12 | c2: bool = eq a2 b2; 13 | d2 = lt a2 b2; 14 | e2: bool = gt a2 b2; 15 | f2: bool = le a2 b2; 16 | g2 = ge a2 b2; 17 | } 18 | -------------------------------------------------------------------------------- /bril-ocaml/lib/bril.mli: -------------------------------------------------------------------------------- 1 | open! Core 2 | open! Common 3 | module Bril_type = Bril_type 4 | module Const = Const 5 | module Dest = Dest 6 | module Func = Func 7 | module Instr = Instr 8 | module Op = Op 9 | 10 | type t = Func.t list [@@deriving compare, equal, sexp_of] 11 | 12 | val from_json : Yojson.Basic.t -> t 13 | val to_json : t -> Yojson.Basic.t 14 | val to_string : t -> string 15 | -------------------------------------------------------------------------------- /type-infer/tests/typecheck/comp_ops.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | a1 = const 1; 3 | b1 = const 2; 4 | c1 = eq a1 b1; 5 | d1 = lt a1 b1; 6 | e1 = gt a1 b1; 7 | f1 = le a1 b1; 8 | g1 = ge a1 b1; 9 | 10 | a2 = const 1; 11 | b2 = const 2; 12 | c2: bool = eq a2 b2; 13 | d2 = lt a2 b2; 14 | e2: bool = gt a2 b2; 15 | f2: bool = le a2 b2; 16 | g2 = ge a2 b2; 17 | } 18 | -------------------------------------------------------------------------------- /test/check/ssa.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | .a: 3 | x: int = const 4; 4 | set z x; 5 | jmp .c; 6 | .b: 7 | y: int = const 2; 8 | set z y; 9 | jmp .c; 10 | .c: 11 | z: int = get; 12 | z: float = get; 13 | z: int = get x; 14 | } 15 | 16 | @more { 17 | b: int = const 1; 18 | c: int = const 2; 19 | d: float = const 3.14; 20 | 21 | set; 22 | a: int = set b c; 23 | set b d; 24 | } 25 | -------------------------------------------------------------------------------- /bracket/tests/delannoy.rkt: -------------------------------------------------------------------------------- 1 | (module 2 | (define delan 3 | (lambda (m n) 4 | (if (call eq? m 0) 5 | 1 6 | (if (call eq? n 0) 7 | 1 8 | (call + (call + (call delan (call - m 1) n) (call delan m (call - n 1))) 9 | (call delan (call - m 1) (call - n 1))))))) 10 | (let ([arg.x 8]) 11 | (call delan arg.x arg.x))) 12 | -------------------------------------------------------------------------------- /bril-swift/Sources/Bril/Argument.swift: -------------------------------------------------------------------------------- 1 | public struct Argument: Equatable, Decodable { 2 | public var name: String 3 | public var type: Type 4 | 5 | public init(name: String, type: Type) { 6 | self.name = name 7 | self.type = type 8 | } 9 | } 10 | 11 | extension Argument: CustomStringConvertible { 12 | public var description: String { "\(name): \(type)" } 13 | } 14 | -------------------------------------------------------------------------------- /test/interp/spec/spec-nested.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | v: int = const 4; 3 | speculate; 4 | v: int = const 2; 5 | speculate; 6 | v: int = const 7; 7 | b1: bool = const false; 8 | guard b1 .failed1; 9 | ret; 10 | .failed1: 11 | y: int = const 0; 12 | b2: bool = const true; 13 | guard b2 .failed2; 14 | commit; 15 | print v; 16 | print y; 17 | ret; 18 | .failed2: 19 | ret; 20 | } 21 | -------------------------------------------------------------------------------- /bril-swift/Sources/Bril/Program.swift: -------------------------------------------------------------------------------- 1 | public struct Program: Equatable, Decodable { 2 | public var functions: [Function] 3 | 4 | public init(functions: [Function]) { 5 | self.functions = functions 6 | } 7 | } 8 | 9 | extension Program: CustomStringConvertible { 10 | public var description: String { 11 | functions.map(String.init).joined(separator: "\n\n") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/parse/print.json: -------------------------------------------------------------------------------- 1 | { 2 | "functions": [ 3 | { 4 | "instrs": [ 5 | { 6 | "dest": "v", 7 | "op": "const", 8 | "type": "int", 9 | "value": 42 10 | }, 11 | { 12 | "args": [ 13 | "v" 14 | ], 15 | "op": "print" 16 | } 17 | ], 18 | "name": "main" 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /type-infer/tests/fail-infer/comp_ops.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | @main { 3 | a1 = const 1; 4 | b1 = const 2; 5 | c1 = eq a1 b1; 6 | d1 = lt a1 b1; 7 | e1 = gt a1 b1; 8 | f1 = le a1 b1; 9 | g1 = ge a1 b1; 10 | 11 | a2 = const 1; 12 | b2 = const 2; 13 | c2: bool = and a2 b2; 14 | d2 = lt a2 b2; 15 | e2: bool = gt a2 b2; 16 | f2: bool = le a2 b2; 17 | g2 = ge a2 b2; 18 | } 19 | -------------------------------------------------------------------------------- /flat-bril/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "flat-bril" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | clap = "4.5.37" 8 | memmap2 = "0.9.5" 9 | num-derive = "0.4.2" 10 | num-traits = "0.2.19" 11 | serde = {version = "1.0.219", features = ["derive"]} 12 | serde_json = "1.0.140" 13 | strum = "0.27.1" 14 | strum_macros = "0.27.1" 15 | zerocopy = {version = "0.8.25", features = ["derive"]} 16 | -------------------------------------------------------------------------------- /bril-rs/brillvm/runtime/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | #[cfg(target_os = "linux")] 3 | println!("cargo:rustc-link-arg=-nostdlib"); 4 | #[cfg(target_os = "macos")] 5 | println!("cargo:rustc-link-arg=-undefined"); 6 | #[cfg(target_os = "macos")] 7 | println!("cargo:rustc-link-arg=dynamic_lookup"); 8 | 9 | #[cfg(not(any(target_os = "linux", target_os = "macos")))] 10 | assert!(false) 11 | } 12 | -------------------------------------------------------------------------------- /bril-ts/util.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Read all the data from stdin as a string. 3 | */ 4 | export async function readStdin(): Promise { 5 | let buf = ""; 6 | const dec = new TextDecoder(); 7 | for await (const chunk of Deno.stdin.readable) { 8 | buf += dec.decode(chunk); 9 | } 10 | return buf; 11 | } 12 | 13 | export function unreachable(_: never): never { 14 | throw "impossible case reached"; 15 | } 16 | -------------------------------------------------------------------------------- /examples/test/df/fact.bril: -------------------------------------------------------------------------------- 1 | @main { 2 | result: int = const 1; 3 | i: int = const 8; 4 | 5 | .header: 6 | # Enter body if i >= 0. 7 | zero: int = const 0; 8 | cond: bool = gt i zero; 9 | br cond .body .end; 10 | 11 | .body: 12 | result: int = mul result i; 13 | 14 | # i-- 15 | one: int = const 1; 16 | i: int = sub i one; 17 | 18 | jmp .header; 19 | 20 | .end: 21 | print result; 22 | } 23 | -------------------------------------------------------------------------------- /type-infer/tests/fail-typecheck/comp_ops.bril: -------------------------------------------------------------------------------- 1 | # RETURN: 1 2 | # 3 | @main { 4 | a1 = const 1; 5 | b1 = const 2; 6 | c1 = eq a1 b1; 7 | d1 = lt a1 b1; 8 | e1 = gt a1 b1; 9 | f1 = le a1 b1; 10 | g1 = ge a1 b1; 11 | 12 | a2 = const 1; 13 | b2 = const 2; 14 | c2: int = eq a2 b2; 15 | d2 = lt a2 b2; 16 | e2: bool = gt a2 b2; 17 | f2: bool = le a2 b2; 18 | g2 = ge a2 b2; 19 | } 20 | -------------------------------------------------------------------------------- /test/interp/float/float.bril: -------------------------------------------------------------------------------- 1 | @main() { 2 | v0: float = const 9.0; 3 | v1: float = const -20.0; 4 | res: float = fdiv v0 v1; 5 | print res; 6 | 7 | v2: float = const .1; 8 | v3: float = const 0.1; 9 | add1: float = fadd v2 v3; 10 | dres: float = fadd add1 v2; 11 | print dres; 12 | 13 | v4: float = const .1; 14 | add2: float = fadd v4 v4; 15 | fres: float = fadd add2 v4; 16 | print fres; 17 | } 18 | -------------------------------------------------------------------------------- /test/rs/cholesky.out: -------------------------------------------------------------------------------- 1 | 65.00000000000000000 2 | 0.00000000000000000 3 | 0.00000000000000000 4 | 0.00000000000000000 5 | 137.43076923076924345 6 | 55.16143280081702471 7 | 0.00000000000000000 8 | 0.00000000000000000 9 | 148.46153846153845279 10 | 22.60304899166557746 11 | 44.73559850849774477 12 | 0.00000000000000000 13 | 432.26153846153846416 14 | 250.01098702698598686 15 | 374.19363889460623795 16 | 548.34440759751453243 17 | --------------------------------------------------------------------------------