diff options
author | Cyril SIX <cyril.six@kalray.eu> | 2019-12-11 12:53:49 +0100 |
---|---|---|
committer | Cyril SIX <cyril.six@kalray.eu> | 2019-12-11 12:53:49 +0100 |
commit | f90e89cc5375383ad905ef08c782d3f7a9f639da (patch) | |
tree | 9749b991460b88a3db97b41538d4f9903ac2f190 | |
parent | bf0161e61415b981cef50d589e9c94273c580070 (diff) | |
download | compcert-kvx-f90e89cc5375383ad905ef08c782d3f7a9f639da.tar.gz compcert-kvx-f90e89cc5375383ad905ef08c782d3f7a9f639da.zip |
Loop headers detection works!
-rw-r--r-- | backend/Duplicateaux.ml | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml index 803e1c14..524122cd 100644 --- a/backend/Duplicateaux.ml +++ b/backend/Duplicateaux.ml @@ -165,18 +165,33 @@ let get_loop_headers code entrypoint = | Icond (_, _, n1, n2) -> [n1; n2] | Itailcall _ | Ireturn _ -> [] | Ijumptable (_, ln) -> ln - ) in dfs_visit code (next_visits @ ln) + ) in dfs_visit code next_visits; + visited := PTree.set node Visited !visited; + dfs_visit code ln end in begin dfs_visit code [entrypoint]; !is_loop_header end +let ptree_printbool pt = + let elements = PTree.elements pt + in begin + Printf.printf "["; + List.iter (fun (n, b) -> + if b then Printf.printf "%d, " (P.to_int n) else () + ) elements; + Printf.printf "]" + end + let get_directions code entrypoint = let bfs_order = bfs code entrypoint - (* and is_loop_header = get_loop_headers code entrypoint *) + and is_loop_header = get_loop_headers code entrypoint and directions = ref (PTree.map (fun n i -> false) code) (* false <=> fallthru *) in begin + Printf.printf "Loop headers: "; + ptree_printbool is_loop_header; + Printf.printf "\n"; List.iter (fun n -> match (get_some @@ PTree.get n code) with | Icond (cond, lr, n, n') -> directions := PTree.set n (Random.bool ()) !directions @@ -185,7 +200,6 @@ let get_directions code entrypoint = !directions end - let to_ttl_inst direction = function | Ireturn o -> Tleaf (Ireturn o) | Inop n -> Tnext (n, Inop n) |