aboutsummaryrefslogtreecommitdiffstats
path: root/backend
diff options
context:
space:
mode:
authorLéo Gourdin <leo.gourdin@univ-grenoble-alpes.fr>2021-05-24 10:07:52 +0200
committerLéo Gourdin <leo.gourdin@univ-grenoble-alpes.fr>2021-05-24 10:07:52 +0200
commit0efe7783c50d72858352fda93d30e0f52792d658 (patch)
treecba55c0122b0260000d85278c6b1a46b6d30b202 /backend
parent30e41117b57ab20beb1876e38c26dbddc5a58dfb (diff)
downloadcompcert-kvx-0efe7783c50d72858352fda93d30e0f52792d658.tar.gz
compcert-kvx-0efe7783c50d72858352fda93d30e0f52792d658.zip
Moving common tools, adding liveness input/output information to BTL generation oracle
Diffstat (limited to 'backend')
-rw-r--r--backend/Duplicateaux.ml2
-rw-r--r--backend/LICMaux.ml2
-rw-r--r--backend/RTLcommonaux.ml (renamed from backend/AuxTools.ml)37
3 files changed, 39 insertions, 2 deletions
diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml
index e8e60a4f..8ca6c6ab 100644
--- a/backend/Duplicateaux.ml
+++ b/backend/Duplicateaux.ml
@@ -23,7 +23,7 @@ open RTL
open Maps
open Camlcoq
open DebugPrint
-open AuxTools
+open RTLcommonaux
let stats_oc = ref None
diff --git a/backend/LICMaux.ml b/backend/LICMaux.ml
index df609505..82e4629f 100644
--- a/backend/LICMaux.ml
+++ b/backend/LICMaux.ml
@@ -17,7 +17,7 @@ open Kildall;;
open HashedSet;;
open Inject;;
open DebugPrint;;
-open AuxTools;;
+open RTLcommonaux;;
type reg = P.t;;
diff --git a/backend/AuxTools.ml b/backend/RTLcommonaux.ml
index 1e334524..2334dfee 100644
--- a/backend/AuxTools.ml
+++ b/backend/RTLcommonaux.ml
@@ -1,6 +1,9 @@
open RTL
open Maps
open Camlcoq
+open Registers
+open Kildall
+open Lattice
let p2i r = P.to_int r
@@ -50,3 +53,37 @@ let get_join_points code entry =
| [pc] -> traverse pc
| pc :: l -> traverse pc; traverse_succs l
in traverse entry; !reached_twice
+
+let transfer f pc after = let open Liveness in
+ match PTree.get pc f.fn_code with
+ | Some i ->
+ (match i with
+ | Inop _ -> after
+ | Iop (_, args, res, _) ->
+ reg_list_live args (Regset.remove res after)
+ | Iload (_, _, _, args, dst, _) ->
+ reg_list_live args (Regset.remove dst after)
+ | Istore (_, _, args, src, _) ->
+ reg_list_live args (Regset.add src after)
+ | Icall (_, ros, args, res, _) ->
+ reg_list_live args (reg_sum_live ros (Regset.remove res after))
+ | Itailcall (_, ros, args) ->
+ reg_list_live args (reg_sum_live ros Regset.empty)
+ | Ibuiltin (_, args, res, _) ->
+ reg_list_live (AST.params_of_builtin_args args)
+ (reg_list_dead (AST.params_of_builtin_res res) after)
+ | Icond (_, args, _, _, _) ->
+ reg_list_live args after
+ | Ijumptable (arg, _) ->
+ Regset.add arg after
+ | Ireturn optarg ->
+ reg_option_live optarg Regset.empty)
+ | None -> Regset.empty
+
+module RegsetLat = LFSet(Regset)
+
+module DS = Backward_Dataflow_Solver(RegsetLat)(NodeSetBackward)
+
+let analyze f =
+ let liveouts = get_some @@ DS.fixpoint f.fn_code successors_instr (transfer f) in
+ PTree.map (fun n _ -> let lo = PMap.get n liveouts in transfer f n lo) f.fn_code