Added dataflow module

This commit is contained in:
elvis
2024-12-12 16:37:36 +01:00
parent 08a8d07422
commit 590123d988
17 changed files with 275 additions and 57 deletions

View File

@ -4,9 +4,9 @@
(libraries exercises
miniImp
miniFun
cfg
analysis
utility)
(package miniFun)
(package miniImp)
(modes byte exe)
)

View File

@ -12,26 +12,40 @@ def main with input a output b as
"
in
Printf.printf "%s\n%s\n" (colorred "Program is") program;
(* Printf.printf "%s\n%s\n" (colorred "Program is") program; *)
let get_result x = Lexing.from_string x |> Parser.prg Lexer.lex in
let p = get_result program in
Format.printf "%s\n%a\n@?" (colorred "AST is") Types.pp_p_exp p;
(* Format.printf "%s\n%a\n@?" (colorred "AST is") Types.pp_p_exp p; *)
let convertedcfg = CfgImp.convert_io 10 p in
Printf.printf "%s\n%a" (colorred "Converted CFG is") CfgImp.SSCfg.pp convertedcfg;
(* Printf.printf "%s\n%a" (colorred "Converted CFG is") CfgImp.SSCfg.pp convertedcfg; *)
let convertedrisccfg = CfgRISC.convert convertedcfg in
Printf.printf "%s\n%a" (colorred "Converted RISC CFG is") CfgRISC.RISCCfg.pp convertedrisccfg;
(* ---------------------------------- *)
let analysiscfg = DefinedVariables.compute_defined_variables convertedrisccfg in
Printf.printf "%s\n%a" (colorred "Analysis CFG is") DefinedVariables.DVCfg.pp analysiscfg;
let convertedrisccfg = DefinedVariables.compute_cfg analysiscfg in
Printf.printf "%s\n%a" (colorred "Converted RISC after analysis CFG is") CfgRISC.RISCCfg.pp convertedrisccfg;
(* ---------------------------------- *)
let risc = RISC.convert convertedrisccfg in
Printf.printf "%s\n%a" (colorred "RISC code is") RISC.RISCAssembly.pp risc;
(* Printf.printf "%s\n%a" (colorred "RISC code is") RISC.RISCAssembly.pp risc; *)
let computerisc = RISCSemantics.reduce risc in
let _computerisc = RISCSemantics.reduce risc in
Printf.printf "%s\n%d\n" (colorred "Output of RISC code is") computerisc;
(* Printf.printf "%s\n%d\n" (colorred "Output of RISC code is") computerisc; *)
()