1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(** Copyright 2025-2026, Georgiy Belyanin, Ignat Sergeev *)
(** SPDX-License-Identifier: LGPL-3.0-or-later *)
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
;;