Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 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
b001c51
codegen
Dec 6, 2025
5dc27ba
fix builtin
Jan 18, 2026
3b80f8a
fix function type lookup
Jan 18, 2026
d231656
fix void call
Jan 18, 2026
5b36f18
formatted
Jan 18, 2026
d6345eb
add basic test
Jan 18, 2026
944e369
rm unused comment
Jan 18, 2026
fc5df6d
fix function variables
Jan 18, 2026
f6c8bbe
fix closure_apply
Jan 18, 2026
acf8943
emit binary
Jan 19, 2026
0d79086
disable llvm verbosity
Jan 19, 2026
f080c83
non rec support
Jan 19, 2026
a63f35e
rm unused open
Jan 19, 2026
0f1d2c1
report error on multiple params with same name
Jan 20, 2026
5a49d40
add features to binary emition
Jan 20, 2026
06fd7c2
fix codegen test
Jan 20, 2026
09da99f
extra ffi non arch specific runtime
Jan 20, 2026
55bf9a7
specify riscv features
Jan 20, 2026
2b6b220
merge runtime files
Jan 20, 2026
28318dd
rm flake
Jan 23, 2026
15f8331
basic tuple expr support
Jan 19, 2026
589906a
tuples cc,ll,anf
Jan 19, 2026
6c33b73
fix order
Jan 19, 2026
3c8e7ee
tuples llvm
Jan 19, 2026
2561d1d
fix builtin tuple_nth name
Jan 20, 2026
0b0c0a4
fix tuple_nth visibility
Jan 20, 2026
2f228cf
fix anf test
Jan 20, 2026
88232d1
fix codegen test
Jan 20, 2026
fe4e4de
implement gc allocation
Jan 20, 2026
7344b75
fix alloc sizes, add boxing runtime
Jan 20, 2026
388fd24
boxing
Jan 20, 2026
67a58bb
collect runtime
Jan 21, 2026
88cd1ff
collect codegen
Jan 21, 2026
4039ee5
implement unit exprs
Jan 22, 2026
485bcba
finalize gc runtime
Jan 23, 2026
dd88609
add gc status builtins
Jan 23, 2026
9667502
unbox int when printing debug info
Jan 23, 2026
d9072c9
add gc status builtins to middleend
Jan 23, 2026
34b60dc
mark fwd before copying args or fields (because we can)
Jan 23, 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.27.0
profile=janestreet

41 changes: 41 additions & 0 deletions DOOML/DOOML.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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_deriving_qcheck" {= "0.6"}
"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"
10 changes: 10 additions & 0 deletions DOOML/bin/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(executable
(public_name DOOML)
(name main)
(modules main)
(libraries DOOML)
(instrumentation
(backend bisect_ppx)))

(cram
(deps ./main.exe runtime.c))
34 changes: 34 additions & 0 deletions DOOML/bin/main.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
;;
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);
}
33 changes: 33 additions & 0 deletions DOOML/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(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_deriving_qcheck
(= "0.6"))))

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