aboutsummaryrefslogtreecommitdiffstats
path: root/aarch64/PrepassSchedulingOracle.ml
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-10-22 13:26:35 +0200
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-10-22 13:26:35 +0200
commit1740571e67f4c9384aea706132b534411d24b36c (patch)
treeb302aa3a47591031c5a9efa4a129eb9165e6a6f4 /aarch64/PrepassSchedulingOracle.ml
parenta8f9909dda3a6f1f997721b753057030575c3c4e (diff)
downloadcompcert-kvx-1740571e67f4c9384aea706132b534411d24b36c.tar.gz
compcert-kvx-1740571e67f4c9384aea706132b534411d24b36c.zip
allow changing target cpu
Diffstat (limited to 'aarch64/PrepassSchedulingOracle.ml')
-rw-r--r--aarch64/PrepassSchedulingOracle.ml44
1 files changed, 23 insertions, 21 deletions
diff --git a/aarch64/PrepassSchedulingOracle.ml b/aarch64/PrepassSchedulingOracle.ml
index 63fdec17..358ee97b 100644
--- a/aarch64/PrepassSchedulingOracle.ml
+++ b/aarch64/PrepassSchedulingOracle.ml
@@ -3,7 +3,8 @@ open RTL
open Maps
open InstructionScheduler
open Registers
-
+open PrepassSchedulingOracleDeps
+
let use_alias_analysis () = false
let length_of_chunk = function
@@ -18,14 +19,14 @@ let length_of_chunk = function
| Mfloat64
| Many64 -> 8;;
-let get_simple_dependencies (seqa : (instruction*Regset.t) array) =
+let get_simple_dependencies (opweights : opweights) (seqa : (instruction*Regset.t) array) =
let last_reg_reads : int list PTree.t ref = ref PTree.empty
and last_reg_write : (int*int) PTree.t ref = ref PTree.empty
and last_mem_reads : int list ref = ref []
and last_mem_write : int option ref = ref None
and last_branch : int option ref = ref None
and last_non_pipelined_op : int array = Array.make
- OpWeights.nr_non_pipelined_units ( -1 )
+ opweights.nr_non_pipelined_units ( -1 )
and latency_constraints : latency_constraint list ref = ref [] in
let add_constraint instr_from instr_to latency =
assert (instr_from <= instr_to);
@@ -141,15 +142,15 @@ let get_simple_dependencies (seqa : (instruction*Regset.t) array) =
| Inop _ -> ()
| Iop(op, inputs, output, _) ->
add_non_pipelined_resources i
- (OpWeights.non_pipelined_resources_of_op op (List.length inputs));
+ (opweights.non_pipelined_resources_of_op op (List.length inputs));
(if Op.is_trapping_op op then irreversible_action i);
add_input_regs i inputs;
- add_output_reg i (OpWeights.latency_of_op op (List.length inputs)) output
+ add_output_reg i (opweights.latency_of_op op (List.length inputs)) output
| Iload(trap, chunk, addressing, addr_regs, output, _) ->
(if trap=TRAP then irreversible_action i);
add_input_mem i;
add_input_regs i addr_regs;
- add_output_reg i (OpWeights.latency_of_load trap chunk addressing (List.length addr_regs)) output
+ add_output_reg i (opweights.latency_of_load trap chunk addressing (List.length addr_regs)) output
| Istore(chunk, addressing, addr_regs, input, _) ->
irreversible_action i;
add_input_regs i addr_regs;
@@ -163,7 +164,7 @@ let get_simple_dependencies (seqa : (instruction*Regset.t) array) =
);
add_input_mem i;
add_input_regs i inputs;
- add_output_reg i (OpWeights.latency_of_call signature ef) output;
+ add_output_reg i (opweights.latency_of_call signature ef) output;
add_output_mem i;
failwith "Icall"
| Itailcall(signature, ef, inputs) ->
@@ -200,21 +201,21 @@ let get_simple_dependencies (seqa : (instruction*Regset.t) array) =
end seqa;
!latency_constraints;;
-let resources_of_instruction = function
- | Inop _ -> Array.map (fun _ -> 0) OpWeights.resource_bounds
+let resources_of_instruction (opweights : opweights) = function
+ | Inop _ -> Array.map (fun _ -> 0) opweights.pipelined_resource_bounds
| Iop(op, inputs, output, _) ->
- OpWeights.resources_of_op op (List.length inputs)
+ opweights.resources_of_op op (List.length inputs)
| Iload(trap, chunk, addressing, addr_regs, output, _) ->
- OpWeights.resources_of_load trap chunk addressing (List.length addr_regs)
+ opweights.resources_of_load trap chunk addressing (List.length addr_regs)
| Istore(chunk, addressing, addr_regs, input, _) ->
- OpWeights.resources_of_store chunk addressing (List.length addr_regs)
+ opweights.resources_of_store chunk addressing (List.length addr_regs)
| Icall(signature, ef, inputs, output, _) ->
- OpWeights.resources_of_call signature ef
+ opweights.resources_of_call signature ef
| Ibuiltin(ef, builtin_inputs, builtin_output, _) ->
- OpWeights.resources_of_builtin ef
+ opweights.resources_of_builtin ef
| Icond(cond, args, _, _ , _) ->
- OpWeights.resources_of_cond cond (List.length args)
- | Itailcall _ | Ijumptable _ | Ireturn _ -> OpWeights.resource_bounds
+ opweights.resources_of_cond cond (List.length args)
+ | Itailcall _ | Ijumptable _ | Ireturn _ -> opweights.pipelined_resource_bounds
let print_sequence pp (seqa : instruction array) =
Array.iteri (
@@ -405,11 +406,11 @@ let get_alias_dependencies seqa =
!deps;;
*)
-let define_problem seqa =
- let simple_deps = get_simple_dependencies seqa in
+let define_problem (opweights : opweights) seqa =
+ let simple_deps = get_simple_dependencies opweights seqa in
{ max_latency = -1;
- resource_bounds = OpWeights.resource_bounds;
- instruction_usages = Array.map resources_of_instruction (Array.map fst seqa);
+ resource_bounds = opweights.pipelined_resource_bounds;
+ instruction_usages = Array.map (resources_of_instruction opweights) (Array.map fst seqa);
latency_constraints =
(* if (use_alias_analysis ())
then (get_alias_dependencies seqa) @ simple_deps
@@ -439,6 +440,7 @@ let prepass_scheduler_by_name name problem early_ones =
| _ -> scheduler_by_name name problem
let schedule_sequence (seqa : (instruction*Regset.t) array) =
+ let opweights = OpWeights.get_opweights () in
try
if (Array.length seqa) <= 1
then None
@@ -446,7 +448,7 @@ let schedule_sequence (seqa : (instruction*Regset.t) array) =
begin
let nr_instructions = Array.length seqa in
Printf.printf "prepass scheduling length = %d\n" (Array.length seqa);
- let problem = define_problem seqa in
+ let problem = define_problem opweights seqa in
print_sequence stdout (Array.map fst seqa);
print_problem stdout problem;
match prepass_scheduler_by_name