Commit 59bb37f5 authored by Wilke Pierre's avatar Wilke Pierre
Browse files

Update skeleton

parent a5be27ae
tests/**/*.ast
tests/**/*.cfg
tests/**/*.cfg0
tests/**/*.cfg1
tests/**/*.cfg2
tests/**/*.cfg3
tests/**/*.e.dump
tests/**/*.e.html
tests/**/*.exe
tests/**/*.json
tests/**/*.lex
tests/**/*.linear
tests/**/*.linear1
tests/**/*.ltl
tests/**/*.rig
tests/**/*.rtl
tests/**/*.s
tests/**/*.svg
tests/results.html
tests/__pycache__
src/_build
alpaga/_build
grammar.html
src/generated_parser.ml
src/config.ml
**/*.native
alpaga/ml_parser_generator
alpaga/alpaga
alpaga/ml_parser_generator.native
tykernel/*.ast
tykernel/*.cfg
tykernel/*.cfg0
tykernel/*.cfg1
tykernel/*.cfg2
tykernel/*.e.dump
tykernel/*.e.html
tykernel/*.exe
tykernel/*.lex
tykernel/*.linear
tykernel/*.linear1
tykernel/*.ltl
tykernel/*.rtl
tykernel/*.s
tykernel/*.svg
skeleton
sujet/_minted-tp
sujet/*.aux
sujet/*.fdb_latexmk
sujet/*.fls
sujet/*.log
sujet/*.out
sujet/*.pdf
sujet/*.synctex.gz
src/.vscode/
.vscode/
Makefile.config
\ No newline at end of file
all: main.native
.PHONY: main.native
main.native:
src/config.ml: configure
./configure
main.native: src/config.ml
make -C alpaga
./alpaga/alpaga \
-g expr_grammar_action.g \
-pml src/generated_parser.ml \
-t grammar.html
./configure
make -C src
ln -sf src/main.native main.native
clean:
make -C alpaga clean
rm -f src/generated_parser.ml
......
No preview for this file type
......@@ -68,7 +68,8 @@ let make_nt (table: string*string -> lltype list) (toks,nts,rules) oc n () =
) (a::r);
Printf.fprintf oc "Printf.sprintf \"}\" ^ \n"
end;
Printf.fprintf oc " Printf.sprintf \" but got '%%s' instead.\\n\" got\n";
Printf.fprintf oc " Printf.sprintf \" but got '%%s' instead.\\n\" got\n ^ ";
Printf.fprintf oc " Printf.sprintf \" '%%s' \\n\" (String.concat \",\" (List.map (fun (x, _) -> string_of_symbol x) (List.take 10 tokens)))\n";
Printf.fprintf oc " )";
Printf.fprintf oc "\n end\n\n"
......
......@@ -2,5 +2,16 @@
RUNTIME=$(pwd)/runtime
RVAS=$(which -a riscv64-unknown-linux-gnu-as riscv64-unknown-elf-as riscv64-linux-gnu-as 2>/dev/null | grep -v "not found" | head -n1)
RVLD=$(which -a riscv64-unknown-linux-gnu-ld riscv64-unknown-elf-ld riscv64-linux-gnu-ld 2>/dev/null | grep -v "not found" | head -n1)
QEMU32=$(which -a qemu-riscv32-static 2>/dev/null | grep -v "not found" | head -n1)
QEMU64=$(which -a qemu-riscv64-static 2>/dev/null | grep -v "not found" | head -n1)
echo "let runtime_dir = \"${RUNTIME}\"" > src/config.ml
echo "let qemu_path = \"/usr/local/bin/qemu-riscv\"" >> src/config.ml
echo "let qemu32 = \"${QEMU32}\"" >> src/config.ml
echo "let qemu64 = \"${QEMU64}\"" >> src/config.ml
echo "let rv_as = \"${RVAS}\"" >> src/config.ml
echo "let rv_ld = \"${RVLD}\"" >> src/config.ml
echo "let os_target = \"linux\"" >> src/config.ml
......@@ -44,7 +44,7 @@
<div id="memstate"></div>
</div>
<div id="expr">
<input type="text" id="expr_input" size="30" /><br>
<input type="text" id="expr_input" size="20" /><br>
Result: <span id="expr_res"></span><hr>
<div id="subexprs"></div>
</div>
......
......@@ -678,10 +678,10 @@ function handle_command(d){
for(let [evar,loc] of Object.entries(fb['vars'])){
if(Object.keys(loc).includes("reg")){
p.insert("span").html("Var "+evar+": "+loc["reg"])
p.insert("span").html("Var "+evar+": Reg "+loc["reg"])
.insert("br");
} else {
p.insert("span").html("Var "+evar+": "+loc["stk"])
p.insert("span").html("Var "+evar+": Stk "+loc["stk"])
.insert("br");
}
}
......
......@@ -54,7 +54,7 @@ html {
}
#body{
display: grid;
grid-template-columns: [ctrl] 300px [code] 250px [outcfg] 600px [state] 700px;
grid-template-columns: [ctrl] 250px [code] 400px [outcfg] 500px [state] 700px;
grid-template-rows: [row1] 200px [row2] 200px [row3] 400px [row4];
}
#code {
......
.include "syscall_numbers.s"
.global atoi
.global print_int
.global println
......@@ -66,7 +67,7 @@ li a3, 0
li a4, 0
li a5, 0
li a6, 0
li a7, 64
li a7, SYSCALL_WRITE
ecall
jr ra
print_char:
......
.include "syscall_numbers.s"
.global atoi
.global print_int
.global println
......@@ -55,6 +56,7 @@ jal ra, print_a1
ld ra, 0(sp)
addi sp, sp, 8
jr ra
print_a1:
addi sp, sp, -8
sd ra,0(sp)
......@@ -68,9 +70,10 @@ li a3, 0
li a4, 0
li a5, 0
li a6, 0
li a7, 64
li a7, SYSCALL_WRITE
ecall
jr ra
print_char:
addi sp, sp, -8
sd ra, 0(sp)
......
SRC=archi.ml ast.ml builtins.ml config.ml cfg_constprop.ml cfg_dead_assign.ml \
cfg.ml cfg_print.ml cfg_gen.ml cfg_liveness.ml cfg_loops.ml cfg_nop_elim.ml \
cfg_run.ml elang.ml elang_print.ml elang_gen.ml elang_run.ml e_regexp.ml \
cfg.ml cfg_print.ml cfg_gen.ml cfg_liveness.ml cfg_nop_elim.ml cfg_run.ml \
elang.ml elang_print.ml elang_gen.ml elang_run.ml e_regexp.ml \
generated_parser.ml lexer_generator.ml linear_dse.ml linear_liveness.ml \
linear.ml linear_print.ml linear_gen.ml linear_run.ml ltl.ml ltl_print.ml \
ltl_gen.ml ltl_run.ml ltl_debug.ml main.ml options.ml parser.ml prog.ml \
regalloc.ml report.ml riscv.ml rtl.ml rtl_print.ml rtl_gen.ml rtl_run.ml \
symbols.ml utils.ml
symbols.ml tokenize.ml utils.ml
TG = main.native
......
open Config
type archi = A64 | A32
let wordsize = ref 8
let assembler = ref "riscv64-unknown-elf-gcc"
let instrsuffix = ref 'd'
let archi = ref A64
let nbits = ref 64
let nbits () =
match !archi with
| A64 -> 64
| A32 -> 32
let wordsize () = nbits () / 8
let assembler () =
let opts =
match !archi with
| A64 -> "-march=rv64imafdc -mabi=lp64d"
| A32 -> "-march=rv32imafdc -mabi=ilp32"
in
Format.sprintf "%s %s" Config.rv_as opts
let linker () =
let opts =
match !archi with
A64 -> "-melf64lriscv"
| A32 -> "-melf32lriscv"
in
Format.sprintf "%s %s" Config.rv_ld opts
let instrsuffix () =
match !archi with
| A64 -> 'd'
| A32 -> 'w'
let qemu () =
match !archi with
| A64 -> Config.qemu64
| A32 -> Config.qemu32
let heapstart = ref 8
let init_archi a () =
begin match a with
| A64 ->
begin
wordsize := 8;
assembler := "riscv64-unknown-elf-gcc";
instrsuffix := 'd';
archi := A64;
end
| A32 ->
begin
wordsize := 4;
assembler := "riscv32-unknown-elf-gcc";
instrsuffix := 'w';
archi := A32;
end
end
;
nbits := !wordsize *8;
type target_system =
| Linux
| Xv6
let target = ref Linux
let lib_syscall () =
match !target with
| Linux -> "linux"
| Xv6 -> "xv6"
let target_data_segment t =
match t with
| Linux -> "8000000"
| Xv6 -> "2000"
let runtime_lib_include_path () =
Format.sprintf "%s/%s" Config.runtime_dir (lib_syscall ())
let runtime_lib_path () =
Format.sprintf "%s/lib%d.s" Config.runtime_dir (nbits ())
......@@ -3,6 +3,9 @@ open Cfg
open Elang_run
open Prog
open Utils
open Report
open Cfg_print
open Options
(* [simple_eval_eexpr e] evaluates an expression [e] with no variables. Raises
an exception if the expression contains variables. *)
......@@ -46,3 +49,10 @@ let constant_propagation_gdef = function
let constant_propagation p =
assoc_map constant_propagation_gdef p
let pass_constant_propagation p =
let cfg = constant_propagation p in
record_compile_result "Constprop";
dump (!cfg_dump >*> fun s -> s ^ "1") dump_cfg_prog cfg
(call_dot "cfg-after-cstprop" "CFG after Constant Propagation");
OK cfg
......@@ -3,6 +3,9 @@ open Cfg
open Prog
open Utils
open Cfg_liveness
open Report
open Cfg_print
open Options
(* Dead Assign Elimination -- Élimination des affectations mortes *)
......@@ -32,3 +35,10 @@ let dead_assign_elimination_gdef = function
let dead_assign_elimination p =
assoc_map dead_assign_elimination_gdef p
let pass_dead_assign_elimination cfg =
let cfg = dead_assign_elimination cfg in
record_compile_result "DeadAssign";
dump (!cfg_dump >*> fun s -> s ^ "2") dump_cfg_prog cfg
(call_dot "cfg-after-dae" "CFG after DAE");
OK cfg
......@@ -3,6 +3,9 @@ open Elang
open Cfg
open Utils
open Prog
open Report
open Cfg_print
open Options
(* [cfg_expr_of_eexpr e] converts an [Elang.expr] into a [expr res]. This should
always succeed and be straightforward.
......@@ -104,3 +107,12 @@ let cfg_gdef_of_edef gd =
let cfg_prog_of_eprog (ep: eprog) : cfg_fun prog res =
assoc_map_res (fun fname -> cfg_gdef_of_edef) ep
let pass_cfg_gen ep =
match cfg_prog_of_eprog ep with
| Error msg ->
record_compile_result ~error:(Some msg) "CFG"; Error msg
| OK cfg ->
record_compile_result "CFG";
dump !cfg_dump dump_cfg_prog cfg (call_dot "cfg" "CFG");
OK cfg
......@@ -3,6 +3,9 @@ open Batteries
open Prog
open Utils
open Cfg
open Report
open Cfg_print
open Options
(* Élimination des NOPs. *)
......@@ -77,3 +80,11 @@ let nop_elim_gdef gd =
let nop_elimination cp =
assoc_map nop_elim_gdef cp
let pass_nop_elimination cfg =
let cfg = nop_elimination cfg in
record_compile_result "NopElim";
dump (!cfg_dump >*> fun s -> s ^ "3") dump_cfg_prog cfg
(call_dot "cfg-after-nop" "CFG after NOP elim");
OK cfg
......@@ -2,6 +2,9 @@ open Ast
open Elang
open Prog
open Utils
open Report
open Elang_print
open Options
let tag_is_binop =
function
......@@ -86,3 +89,13 @@ let make_eprog_of_ast (a: tree) : eprog res =
| _ ->
Error (Printf.sprintf "make_fundef_of_ast: Expected a Tlistglobdef, got %s."
(string_of_ast a))
let pass_elang ast =
match make_eprog_of_ast ast with
| Error msg ->
record_compile_result ~error:(Some msg) "Elang";
Error msg
| OK ep ->
dump !e_dump dump_e ep (fun file () ->
add_to_report "e" "E" (Code (file_contents file))); OK ep
......@@ -63,7 +63,7 @@ let star_nfa n t =
(* [nfa_of_regexp r freshstate t] construit un NFA qui reconnaît le même langage
que l'expression régulière [r].
[freshstate] correspond à un entier pour lequel il n'y a pas encore d'état dans
le nfa. Il suffit d'incrémenter [freshstate] pour obtenir de nouveaux état non utilisés.
le nfa. Il suffit d'incrémenter [freshstate] pour obtenir de nouveaux états non utilisés.
[t] est une fonction du type [string -> token option] utile pour les état finaux.
*)
let rec nfa_of_regexp r freshstate t =
......@@ -447,11 +447,6 @@ let dfa_to_dot oc (n : dfa) (cl: char list): unit =
) n.dfa_states;
Printf.fprintf oc "}\n"
let alts l =
match l with
[] -> Eps
| a::r -> List.fold_left (fun acc r -> Alt(acc,r)) a l
let nfa_of_list_regexp l =
let (n, fs) = List.fold_left (fun (nfa, fs) (r,t) ->
let n,fs = nfa_of_regexp r fs t in
......
......@@ -5,6 +5,9 @@ open Batteries
open BatList
open Prog
open Utils
open Report
open Linear_print
open Options
let dse_instr (ins: rtl_instr) live =
[ins]
......@@ -26,3 +29,12 @@ let dse_prog p live =
let f = dse_fun live f in
(fname, Gfun f)
) p
let pass_linear_dse linear lives =
let linear = dse_prog linear lives in
record_compile_result "DSE";
dump (!linear_dump >*> fun s -> s ^ "1")
(fun oc -> dump_linear_prog oc (Some lives)) linear
(fun file () -> add_to_report "linear-after-dse" "Linear after DSE"
(Code (file_contents file)));
OK linear
......@@ -3,7 +3,10 @@ open Rtl
open Linear
open Prog
open Utils
open Report
open Linear_print
open Options
open Linear_liveness
let succs_of_rtl_instr (i: rtl_instr) =
match i with
......@@ -55,3 +58,10 @@ let linear_of_rtl_gdef = function
let linear_of_rtl r =
assoc_map linear_of_rtl_gdef r
let pass_linearize rtl =
let linear = linear_of_rtl rtl in
let lives = liveness_linear_prog linear in
dump !linear_dump (fun oc -> dump_linear_prog oc (Some lives)) linear
(fun file () -> add_to_report "linear" "Linear" (Code (file_contents file)));
OK (linear, lives)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment