diff options
author | Cyril SIX <cyril.six@kalray.eu> | 2019-12-11 14:16:51 +0100 |
---|---|---|
committer | Cyril SIX <cyril.six@kalray.eu> | 2019-12-11 14:16:51 +0100 |
commit | 05dd74d92c2589eeb6a933138a484896c4eb6969 (patch) | |
tree | 7c49531ded68cfb38602f332bdf6fa9710f4a735 /backend | |
parent | f90e89cc5375383ad905ef08c782d3f7a9f639da (diff) | |
download | compcert-kvx-05dd74d92c2589eeb6a933138a484896c4eb6969.tar.gz compcert-kvx-05dd74d92c2589eeb6a933138a484896c4eb6969.zip |
Function to look ahead unconditionally
Diffstat (limited to 'backend')
-rw-r--r-- | backend/Duplicateaux.ml | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml index 524122cd..569f4c51 100644 --- a/backend/Duplicateaux.ml +++ b/backend/Duplicateaux.ml @@ -184,6 +184,18 @@ let ptree_printbool pt = Printf.printf "]" end +(* Looks ahead (until a branch) to see if a node further down verifies + * the given predicate *) +let rec look_ahead code node is_loop_header predicate = + if (predicate node) then true + else match (get_some @@ PTree.get node code) with + | Ireturn _ | Itailcall _ | Icond _ | Ijumptable _ -> false + | Inop n | Iop (_, _, _, n) | Iload (_, _, _, _, _, n) + | Istore (_, _, _, _, n) | Icall (_, _, _, _, n) + | Ibuiltin (_, _, _, n) -> + if (get_some @@ PTree.get n is_loop_header) then false + else look_ahead code n is_loop_header predicate + let get_directions code entrypoint = let bfs_order = bfs code entrypoint and is_loop_header = get_loop_headers code entrypoint |