Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
293e856
parser: introduce basic AST and parser
georgiy-belyanin Sep 27, 2025
7534f16
me: add a-normal-form
georgiy-belyanin Nov 23, 2025
7b29df1
me: improve AST pretty-printing
georgiy-belyanin Jan 3, 2026
d3cc923
me: fix ANF of if-then-else
georgiy-belyanin Jan 3, 2026
be95b2f
parser: not parse keywords as identifiers
georgiy-belyanin Jan 16, 2026
63fc9ec
parser: support plugs, tuples, units
georgiy-belyanin Jan 16, 2026
259f23a
parser: fix if-then-else internal handling
georgiy-belyanin Jan 16, 2026
9be0316
anf: accept whole program & anf tuples
georgiy-belyanin Jan 16, 2026
4b03091
cc/ll: introduce basic CC/LL
georgiy-belyanin Jan 16, 2026
7ade878
riscv: add basic runtime & compilation into rv64gc
georgiy-belyanin Jan 16, 2026
f2393ff
codegen
Dec 6, 2025
8097cfc
fix builtin
Jan 18, 2026
21539ad
fix function type lookup
Jan 18, 2026
4255794
fix void call
Jan 18, 2026
17c267b
formatted
Jan 18, 2026
293ca3a
add basic test
Jan 18, 2026
8c86231
rm unused comment
Jan 18, 2026
7f88207
fix function variables
Jan 18, 2026
ccaacd2
fix closure_apply
Jan 18, 2026
3fc57d2
emit binary
Jan 19, 2026
b6fc30b
disable llvm verbosity
Jan 19, 2026
7fdd7e1
non rec support
Jan 19, 2026
c398da6
rm unused open
Jan 19, 2026
784240c
report error on multiple params with same name
Jan 20, 2026
01d55fe
add features to binary emition
Jan 20, 2026
8f6a9a1
fix codegen test
Jan 20, 2026
2c88ac1
extra ffi non arch specific runtime
Jan 20, 2026
a879fa7
specify riscv features
Jan 20, 2026
ef9cbec
merge runtime files
Jan 20, 2026
6534ece
rm flake
Jan 23, 2026
faa4555
basic tuple expr support
Jan 19, 2026
2083d82
tuples cc,ll,anf
Jan 19, 2026
d8ef5ea
fix order
Jan 19, 2026
2afd24e
tuples llvm
Jan 19, 2026
cf216c4
fix builtin tuple_nth name
Jan 20, 2026
b105279
fix tuple_nth visibility
Jan 20, 2026
bf4026d
fix anf test
Jan 20, 2026
0e80e36
fix codegen test
Jan 20, 2026
e35f838
implement gc allocation
Jan 20, 2026
98d42ad
fix alloc sizes, add boxing runtime
Jan 20, 2026
db035a5
boxing
Jan 20, 2026
6062681
collect runtime
Jan 21, 2026
b49c17a
collect codegen
Jan 21, 2026
bcb0e79
implement unit exprs
Jan 22, 2026
49aecf7
finalize gc runtime
Jan 23, 2026
ad9c277
add gc status builtins
Jan 23, 2026
54bb99a
unbox int when printing debug info
Jan 23, 2026
bb052d6
add gc status builtins to middleend
Jan 23, 2026
ddad515
mark fwd before copying args or fields (because we can)
Jan 23, 2026
b138e2c
General fixes for DOOML
georgiy-belyanin Jan 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DOOML/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/_build
/_coverage

3 changes: 3 additions & 0 deletions DOOML/.ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version=0.28.1
profile=janestreet

43 changes: 43 additions & 0 deletions DOOML/DOOML.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "A short LLVM demo"
maintainer: ["Georgiy Belyanin" "Ignatiy Sergeev"]
authors: ["Georgiy Belyanin" "Ignatiy Sergeev"]
license: "LGPL-3.0-or-later WITH OCaml-LGPL-linking-exception"
homepage: "https://github.com/Kakadu/comp24"
bug-reports: "https://github.com/Kakadu/comp24/issues"
depends: [
"ocaml"
"dune" {>= "3.8" & = "3.19.1"}
"angstrom" {= "0.16.0"}
"qcheck"
"bisect_ppx"
"llvm" {= "18-shared"}
"qcheck" {with-tests}
"ppx_expect"
"ppx_inline_test"
"ppx_variants_conv"
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/Kakadu/comp24.git"
depexts: [
[ "llvm-18-dev" "clang-18" "gcc-riscv64-linux-gnu" "g++-riscv64-linux-gnu" "qemu-user"] {os-distribution = "ubuntu"}
]
pin-depends: [
["ppx_deriving_qcheck.0.6" "git+https://github.com/c-cube/qcheck.git#42429bf06ba12373cad02b1404f50d0ad6238af5"]
]
# Don't edit '*.opam' file manually. Use 'dune b @install'
7 changes: 7 additions & 0 deletions DOOML/DOOML.opam.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
depexts: [
[ "llvm-18-dev" "clang-18" "gcc-riscv64-linux-gnu" "g++-riscv64-linux-gnu" "qemu-user"] {os-distribution = "ubuntu"}
]
pin-depends: [
["ppx_deriving_qcheck.0.6" "git+https://github.com/c-cube/qcheck.git#42429bf06ba12373cad02b1404f50d0ad6238af5"]
]
# Don't edit '*.opam' file manually. Use 'dune b @install'
20 changes: 20 additions & 0 deletions DOOML/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: all test
all:
dune build

test:
dune test

TEST_COV_D = /tmp/cov
COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect bin/

.PHONY: test_coverage coverage
test_coverage: coverage
coverage:
$(RM) -r $(TEST_COV_D)
mkdir -p $(TEST_COV_D)
BISECT_FILE=$(TEST_COV_D)/language dune runtest --no-print-directory \
--instrument-with bisect_ppx --force
bisect-ppx-report html $(COVERAGE_OPTS)
bisect-ppx-report summary $(COVERAGE_OPTS)
@echo "Use 'xdg-open _coverage/index.html' to see coverage report"
18 changes: 18 additions & 0 deletions DOOML/bin/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(executable
(public_name Dooml-Llvm)
(name llvm)
(modules llvm)
(libraries DOOML)
(instrumentation
(backend bisect_ppx)))

(executable
(public_name Dooml-Riscv)
(name riscv)
(modules riscv)
(libraries DOOML)
(instrumentation
(backend bisect_ppx)))

(cram
(deps ./main.exe runtime.c))
34 changes: 34 additions & 0 deletions DOOML/bin/llvm.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[@@@ocaml.text "/*"]

(** Copyright 2023-2025, Kakadu and contributors *)

(** SPDX-License-Identifier: LGPL-3.0-or-later *)

[@@@ocaml.text "/*"]

open DOOML
module Map = Base.Map.Poly

let failf fmt = Format.kasprintf failwith fmt

let parse input =
let code = In_channel.with_open_text input In_channel.input_all in
match Fe.parse code with
| Error msg -> Error msg
| Ok ast_list -> Ok (ast_list |> Cc.cc |> Ll.ll |> Anf.anf)
;;

let () =
match Array.to_list Sys.argv with
| [ _exe; input; output ] ->
let riscv_triple = "riscv64-unknown-linux-gnu" in
let riscv_features = "+d" in
let module_ =
match parse input with
| Error msg -> failf "%s" msg
| Ok anf_list -> Codegen.emit_ir ~triple:riscv_triple anf_list
in
Codegen.optimize_ir ~triple:riscv_triple module_;
Codegen.emit_binary ~triple:riscv_triple ~features:riscv_features module_ output
| _ -> exit 1
;;
51 changes: 51 additions & 0 deletions DOOML/bin/riscv.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[@@@ocaml.text "/*"]

(** Copyright 2023-2025, Kakadu and contributors *)

(** SPDX-License-Identifier: LGPL-3.0-or-later *)

[@@@ocaml.text "/*"]

open DOOML
module Map = Base.Map.Poly

let failf fmt = Format.kasprintf failwith fmt

let parse input =
let code = In_channel.with_open_text input In_channel.input_all in
match Fe.parse code with
| Error msg -> Error msg
| Ok ast_list ->
Ok
(ast_list
|> Cc.cc
(*|> fun asts ->
Format.printf
"CC: %a\n\n"
(Format.pp_print_list ~pp_sep:Format.pp_print_newline Ast.pp_top_level)
asts;
asts*)
|> Ll.ll
(*|> fun asts ->
Format.printf
"LL: %a\n\n"
(Format.pp_print_list ~pp_sep:Format.pp_print_newline Ast.pp_top_level)
asts;
asts*)
(*Cc.cc |> Ll.ll *)
|> Anf.anf
(*|> fun asts ->
Format.printf
"ANF %a\n\n"
(Format.pp_print_list ~pp_sep:Format.pp_print_newline Anf.pp_decl)
asts;
asts
*)
)
;;

let () =
match parse Sys.argv.(1) with
| Error msg -> failf "%s" msg
| Ok anf_list -> Format.printf "%a\n" Riscv.pp_code (Riscv.riscv anf_list)
;;
20 changes: 20 additions & 0 deletions DOOML/bin/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$ clang-18 -c runtime.c -o runtime.o
$ ./main.exe
$ ls
main.exe
out.ll
runtime.c
runtime.o
$ cat out.ll | grep -E 'source_filename|target datalayout|ModuleID' --invert-match
target triple = "x86_64-pc-linux-gnu"

declare void @print_int(i64)

define i64 @main() {
entry:
call void @print_int(i64 70)
ret i64 0
}
$ clang-18 out.ll runtime.o -o demo1.exe
$ echo "Press $(./demo1.exe) to pay respect"
Press F to pay respect
10 changes: 10 additions & 0 deletions DOOML/bin/runtime.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* Copyright 2023-2024, Kakadu and contributors */
/* SPDX-License-Identifier: LGPL-3.0-or-later */

#include <stdint.h>
#include <stdio.h>

void print_int(int64_t n) {
putchar(n);
fflush(stdout);
}
34 changes: 34 additions & 0 deletions DOOML/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(lang dune 3.8)

(name DOOML)

(generate_opam_files true)

(source
(github Kakadu/comp24))

(authors "Georgiy Belyanin" "Ignatiy Sergeev")

(maintainers "Georgiy Belyanin" "Ignatiy Sergeev")

(license "LGPL-3.0-or-later WITH OCaml-LGPL-linking-exception")

(package
(name DOOML)
(synopsis "A short LLVM demo")
(depends
ocaml
(dune
(= "3.19.1"))
(angstrom
(= "0.16.0"))
qcheck
bisect_ppx
(llvm
(= "18-shared"))
(qcheck :with-tests)
ppx_expect
ppx_inline_test
ppx_variants_conv))

; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project
Loading
Loading