Fixes for RISC evaluation

This commit is contained in:
elvis
2025-01-11 20:32:11 +01:00
parent 3be05222ab
commit 9bcc88e016
11 changed files with 261 additions and 115 deletions

View File

@ -116,9 +116,13 @@ module RISCAssembly = struct
let pp (ppf: out_channel) (t: t) : unit =
Printf.fprintf ppf "Input Val: ";
match t.inputval with
None -> Printf.fprintf ppf "None\n"
| Some i -> Printf.fprintf ppf "Some %d\n" i;
( match t.inputval with
None -> Printf.fprintf ppf "None\n"
| Some i -> Printf.fprintf ppf "Some %d\n" i );
Printf.fprintf ppf "Input/Output Registers: ";
( match t.inputoutputreg with
None -> Printf.fprintf ppf "None\n"
| Some (i, o) -> Printf.fprintf ppf "[i: Some r%s, o: Some r%s]\n" i.index o.index);
Printf.fprintf ppf "Code:\n";
List.iter (pp_risci ppf) t.code
end
@ -225,7 +229,7 @@ let rec helper
in
match nextnodes with
| Some (nextnode1, None) ->
let res, vis = (helper prg nextnode1) (currentnode :: alreadyVisited) in
let res, vis = (helper prg nextnode1 (currentnode :: alreadyVisited)) in
(currentcode @ res, vis)
| Some (nextnode1, Some nextnode2) -> (
let ncs = nextCommonSuccessor prg nextnode1 nextnode2 in
@ -248,6 +252,7 @@ let rec helper
| BImmOp (_, _, _, r)
| URegOp (_, _, r)
| Load (_, r)
| Store (r, _)
| LoadI (_, r) -> (([Label label1] : RISCAssembly.risci list) @
currentcode @
([CJump (r, label2, label3); Label label2] : RISCAssembly.risci list) @
@ -269,6 +274,7 @@ let rec helper
| BImmOp (_, _, _, r)
| URegOp (_, _, r)
| Load (_, r)
| Store (r, _)
| LoadI (_, r) -> (currentcode @
([CJump (r, label1, label2); Label label1] : RISCAssembly.risci list) @
res1 @