aboutsummaryrefslogtreecommitdiffstats
path: root/scheduling/BTLScheduleraux.ml
diff options
context:
space:
mode:
authorLéo Gourdin <leo.gourdin@lilo.org>2021-07-28 10:32:09 +0200
committerLéo Gourdin <leo.gourdin@lilo.org>2021-07-28 10:32:09 +0200
commit056658bd2986d9e12ac07a54d25c08eb8a62ff60 (patch)
tree93e3f9a49f656bc8cf1ea3aa460ea2be1c083915 /scheduling/BTLScheduleraux.ml
parent77ee161826e24e87f801cbbeb797fb3a4a4a0fe9 (diff)
downloadcompcert-kvx-056658bd2986d9e12ac07a54d25c08eb8a62ff60.tar.gz
compcert-kvx-056658bd2986d9e12ac07a54d25c08eb8a62ff60.zip
remove todos, clean
Diffstat (limited to 'scheduling/BTLScheduleraux.ml')
-rw-r--r--scheduling/BTLScheduleraux.ml70
1 files changed, 22 insertions, 48 deletions
diff --git a/scheduling/BTLScheduleraux.ml b/scheduling/BTLScheduleraux.ml
index 5ebc4144..c8c4e0d3 100644
--- a/scheduling/BTLScheduleraux.ml
+++ b/scheduling/BTLScheduleraux.ml
@@ -47,61 +47,45 @@ let find_array arr n =
get_some @@ !index
let count_cbs bseq olast indexes =
- debug "count_cbs\n";
let current_cbs = ref SI.empty in
let cbs_above = Hashtbl.create 100 in
let update_cbs n ib =
print_btl_inst stderr ib;
- if is_a_cb ib then (
- debug "n is %d, add cb at: %d\n" n indexes.(n);
- current_cbs := SI.add indexes.(n) !current_cbs)
- else if is_a_load ib then (
- debug "n is %d, add load at: %d\n" n indexes.(n);
- Hashtbl.add cbs_above indexes.(n) !current_cbs)
+ if is_a_cb ib then current_cbs := SI.add indexes.(n) !current_cbs
+ else if is_a_load ib then Hashtbl.add cbs_above indexes.(n) !current_cbs
in
Array.iteri (fun n ib -> update_cbs n ib) bseq;
(match olast with
- | Some last ->
- debug "last\n";
- update_cbs (Array.length bseq) last
+ | Some last -> update_cbs (Array.length bseq) last
| None -> ());
cbs_above
let apply_schedule bseq olast positions =
- let fmap n = find_array positions n in
- let seq = (Array.init (Array.length positions) (fun i -> i)) in
- let fseq = Array.map fmap seq in
- (*debug_flag := true;*)
- Array.iter (fun i -> debug "%d " i) positions;
- debug "\n";
- Array.iter (fun i -> debug "%d " i) fseq;
- debug "\n";
- Array.iter
- (fun i -> debug "%d " i)
- (Array.init (Array.length positions) (fun i -> i));
- debug "\n";
- let cbs_above_old = count_cbs bseq olast fseq in
let bseq_new = Array.map (fun i -> bseq.(i)) positions in
- let cbs_above_new = count_cbs bseq_new olast seq in
- Array.iteri
- (fun n ib ->
- let n' = fseq.(n) in
- match ib with
- | Bload (t, a, b, c, d, e) ->
- let set_old = Hashtbl.find cbs_above_old n' in
- let set_new = Hashtbl.find cbs_above_new n' in
- if SI.subset set_old set_new then
- bseq_new.(n') <- Bload (AST.TRAP, a, b, c, d, e)
- else (Printf.eprintf "\nTEST_GOURDINL_OK\n"; assert !config.has_non_trapping_loads)
- | _ -> ())
- bseq;
+ (if !config.has_non_trapping_loads then
+ let fmap n = find_array positions n in
+ let seq = Array.init (Array.length positions) (fun i -> i) in
+ let fseq = Array.map fmap seq in
+ let cbs_above_old = count_cbs bseq olast fseq in
+ let cbs_above_new = count_cbs bseq_new olast seq in
+ Array.iteri
+ (fun n ib ->
+ let n' = fseq.(n) in
+ match ib with
+ | Bload (t, a, b, c, d, e) ->
+ let set_old = Hashtbl.find cbs_above_old n' in
+ let set_new = Hashtbl.find cbs_above_new n' in
+ if SI.subset set_old set_new then
+ bseq_new.(n') <- Bload (AST.TRAP, a, b, c, d, e)
+ else assert !config.has_non_trapping_loads
+ | _ -> ())
+ bseq);
let ibl = Array.to_list bseq_new in
let rec build_iblock = function
| [] -> failwith "build_iblock: empty list"
| [ ib ] -> ( match olast with Some last -> Bseq (ib, last) | None -> ib)
| ib1 :: ib2 :: k -> Bseq (ib1, build_iblock (ib2 :: k))
in
- (*debug_flag := false;*)
build_iblock ibl
let schedule_blk n ibf btl =
@@ -110,9 +94,6 @@ let schedule_blk n ibf btl =
let bseq, olast = flatten_blk_basics ibf in
match schedule_sequence bseq btl with
| Some positions ->
- debug "%d," (p2i n);
- Array.iter (fun p -> debug "%d " p) positions;
- debug "\n";
let new_ib = apply_schedule bseq olast positions in
let new_ibf =
{ entry = new_ib; binfo = ibf.binfo; input_regs = ibf.input_regs }
@@ -139,15 +120,8 @@ let rec do_schedule btl = function
| [] -> btl
| (n, ibf) :: blks ->
let code_exp = expanse n ibf btl in
- let code_nt = turn_all_loads_nontrap n ibf btl in
+ let code_nt = turn_all_loads_nontrap n ibf code_exp in
let btl' = schedule_blk n ibf code_nt in
- (*debug_flag := true;*)
- if btl != code_exp then (
- debug "#######################################################\n";
- print_btl_code stderr btl;
- debug "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
- print_btl_code stderr code_exp);
- (*debug_flag := false;*)
do_schedule btl' blks
let btl_scheduler f =