Live Variables
This commit is contained in:
33
bin/main.ml
33
bin/main.ml
@ -5,12 +5,15 @@ let colorred s =
|
||||
|
||||
let () =
|
||||
let program = "
|
||||
def main with input n output out as
|
||||
for (x := 2, x < 0, x := 2) do (
|
||||
y := x + 3;
|
||||
x := y;
|
||||
);
|
||||
out := 1 - y;
|
||||
def main with input c output m as
|
||||
a := 0;
|
||||
b := a + 1;
|
||||
c := c + b;
|
||||
a := b * 2;
|
||||
if a < 3 then
|
||||
c := 4
|
||||
else
|
||||
c := 6
|
||||
"
|
||||
in
|
||||
|
||||
@ -34,16 +37,22 @@ def main with input n output out as
|
||||
|
||||
let analysiscfg = DefinedVariables.compute_defined_variables convertedrisccfg in
|
||||
|
||||
Printf.printf "%s\n%a" (colorred "Analysis CFG is") DefinedVariables.DVCfg.pp analysiscfg;
|
||||
(* Printf.printf "%s\n%a" (colorred "Analysis CFG is") DefinedVariables.DVCfg.pp analysiscfg; *)
|
||||
|
||||
Printf.printf "%s%b\n" (colorred "Analysis CFG defined variables: ") (DefinedVariables.check_defined_variables analysiscfg);
|
||||
Printf.printf "%s\n" (colorred "Undefined Variables are:");
|
||||
List.iter (fun v -> Printf.printf "%a, " DefinedVariables.Variable.pp v) (DefinedVariables.undefined_variables analysiscfg);
|
||||
Printf.printf "\n";
|
||||
(* Printf.printf "%s\n" (colorred "Undefined Variables are:"); *)
|
||||
(* List.iter (fun v -> Printf.printf "%a, " DefinedVariables.Variable.pp v) (DefinedVariables.check_undefined_variables analysiscfg); *)
|
||||
(* Printf.printf "\n"; *)
|
||||
|
||||
let convertedrisccfg = DefinedVariables.compute_cfg analysiscfg in
|
||||
|
||||
Printf.printf "%s\n%a" (colorred "Converted RISC after analysis CFG is") CfgRISC.RISCCfg.pp convertedrisccfg;
|
||||
(* Printf.printf "%s\n%a" (colorred "Converted RISC after analysis CFG is") CfgRISC.RISCCfg.pp convertedrisccfg; *)
|
||||
|
||||
|
||||
let analysiscfg = LiveVariables.compute_live_variables convertedrisccfg in
|
||||
|
||||
Printf.printf "%s\n%a" (colorred "Analysis CFG is") LiveVariables.DVCfg.pp analysiscfg;
|
||||
|
||||
let convertedrisccfg = LiveVariables.optimize_cfg analysiscfg |> LiveVariables.compute_cfg in
|
||||
|
||||
(* ---------------------------------- *)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user