aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-10-22 13:26:00 +0200
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-10-22 13:26:00 +0200
commita8f9909dda3a6f1f997721b753057030575c3c4e (patch)
treeb6bc19298c57a56bd9303cfdb3b00087d5646fa0
parentbc80528de5dfbc864c611e23691ddd96f15dfdc7 (diff)
downloadcompcert-kvx-a8f9909dda3a6f1f997721b753057030575c3c4e.tar.gz
compcert-kvx-a8f9909dda3a6f1f997721b753057030575c3c4e.zip
allow changing the target core
-rw-r--r--riscV/OpWeights.ml279
l---------riscV/PrepassSchedulingOracleDeps.ml1
2 files changed, 160 insertions, 120 deletions
diff --git a/riscV/OpWeights.ml b/riscV/OpWeights.ml
index 637f2904..75a913c6 100644
--- a/riscV/OpWeights.ml
+++ b/riscV/OpWeights.ml
@@ -1,122 +1,161 @@
open Op;;
-
-(* Attempt at modeling the Rocket core *)
-
-let resource_bounds = [| 1 |];;
-let nr_non_pipelined_units = 1;; (* divider *)
-
-let latency_of_op (op : operation) (nargs : int) =
- match op with
- | Omul | Omulhs | Omulhu
- | Omull | Omullhs | Omullhu -> 4
-
- | Onegf -> 1 (*r [rd = - r1] *)
- | Oabsf (*r [rd = abs(r1)] *)
- | Oaddf (*r [rd = r1 + r2] *)
- | Osubf (*r [rd = r1 - r2] *)
- | Omulf -> 6 (*r [rd = r1 * r2] *)
- | Onegfs -> 1 (*r [rd = - r1] *)
- | Oabsfs (*r [rd = abs(r1)] *)
- | Oaddfs (*r [rd = r1 + r2] *)
- | Osubfs (*r [rd = r1 - r2] *)
- | Omulfs -> 4 (*r [rd = r1 * r2] *)
- | Osingleoffloat (*r [rd] is [r1] truncated to single-precision float *)
- | Ofloatofsingle -> 4 (*r [rd] is [r1] extended to double-precision float *)
-(*c Conversions between int and float: *)
- | Ointoffloat (*r [rd = signed_int_of_float64(r1)] *)
- | Ointuoffloat (*r [rd = unsigned_int_of_float64(r1)] *)
- | Ofloatofint (*r [rd = float64_of_signed_int(r1)] *)
- | Ofloatofintu -> 6 (*r [rd = float64_of_unsigned_int(r1)] *)
- | Ointofsingle (*r [rd = signed_int_of_float32(r1)] *)
- | Ointuofsingle (*r [rd = unsigned_int_of_float32(r1)] *)
- | Osingleofint (*r [rd = float32_of_signed_int(r1)] *)
- | Osingleofintu -> 4 (*r [rd = float32_of_unsigned_int(r1)] *)
- | Olongoffloat (*r [rd = signed_long_of_float64(r1)] *)
- | Olonguoffloat (*r [rd = unsigned_long_of_float64(r1)] *)
- | Ofloatoflong (*r [rd = float64_of_signed_long(r1)] *)
- | Ofloatoflongu -> 6 (*r [rd = float64_of_unsigned_long(r1)] *)
- | Olongofsingle (*r [rd = signed_long_of_float32(r1)] *)
- | Olonguofsingle (*r [rd = unsigned_long_of_float32(r1)] *)
- | Osingleoflong (*r [rd = float32_of_signed_long(r1)] *)
- | Osingleoflongu -> 4 (*r [rd = float32_of_unsigned_int(r1)] *)
-
- | Odiv | Odivu | Odivl | Odivlu -> 16
- | Odivfs -> 35
- | Odivf -> 50
-
- | Ocmp cond ->
- (match cond with
- | Ccomp _
- | Ccompu _
- | Ccompimm _
- | Ccompuimm _
- | Ccompl _
- | Ccomplu _
- | Ccomplimm _
- | Ccompluimm _ -> 1
- | Ccompf _
- | Cnotcompf _ -> 6
- | Ccompfs _
- | Cnotcompfs _ -> 4)
- | _ -> 1;;
-
-let resources_of_op (op : operation) (nargs : int) = resource_bounds;;
-
-let non_pipelined_resources_of_op (op : operation) (nargs : int) =
- match op with
- | Odiv | Odivu -> [| 29 |]
- | Odivfs -> [| 20 |]
- | Odivl | Odivlu | Odivf -> [| 50 |]
- | _ -> [| -1 |];;
-
-let resources_of_cond (cond : condition) (nargs : int) = resource_bounds;;
-
-let latency_of_load trap chunk (addr : addressing) (nargs : int) = 3;;
-let latency_of_call _ _ = 6;;
-
-let resources_of_load trap chunk addressing nargs = resource_bounds;;
-
-let resources_of_store chunk addressing nargs = resource_bounds;;
-
-let resources_of_call _ _ = resource_bounds;;
-let resources_of_builtin _ = resource_bounds;;
-
-(*
-(* Attempt at modeling SweRV EH1
-[| issues ; LSU ; multiplier |] *)
-let resource_bounds = [| 2 ; 1; 1 |];;
-let nr_non_pipelined_units = 1;; (* divider *)
-
-let latency_of_op (op : operation) (nargs : int) =
- match op with
- | Omul | Omulhs | Omulhu
- | Omull | Omullhs | Omullhu -> 3
- | Odiv | Odivu | Odivl | Odivlu -> 16
- | _ -> 1;;
-
-let resources_of_op (op : operation) (nargs : int) =
- match op with
- | Omul | Omulhs | Omulhu
- | Omull | Omullhs | Omullhu -> [| 1 ; 0 ; 1 |]
- | Odiv | Odivu | Odivl | Odivlu -> [| 0 ; 0; 0 |]
- | _ -> [| 1; 0; 0; 0 |];;
+open PrepassSchedulingOracleDeps;;
+
+module Rocket =
+ struct
+ (* Attempt at modeling the Rocket core *)
+
+ let resource_bounds = [| 1 |];;
+ let nr_non_pipelined_units = 1;; (* divider *)
+
+ let latency_of_op (op : operation) (nargs : int) =
+ match op with
+ | Omul | Omulhs | Omulhu
+ | Omull | Omullhs | Omullhu -> 4
+
+ | Onegf -> 1 (*r [rd = - r1] *)
+ | Oabsf (*r [rd = abs(r1)] *)
+ | Oaddf (*r [rd = r1 + r2] *)
+ | Osubf (*r [rd = r1 - r2] *)
+ | Omulf -> 6 (*r [rd = r1 * r2] *)
+ | Onegfs -> 1 (*r [rd = - r1] *)
+ | Oabsfs (*r [rd = abs(r1)] *)
+ | Oaddfs (*r [rd = r1 + r2] *)
+ | Osubfs (*r [rd = r1 - r2] *)
+ | Omulfs -> 4 (*r [rd = r1 * r2] *)
+ | Osingleoffloat (*r [rd] is [r1] truncated to single-precision float *)
+ | Ofloatofsingle -> 4 (*r [rd] is [r1] extended to double-precision float *)
+ (*c Conversions between int and float: *)
+ | Ointoffloat (*r [rd = signed_int_of_float64(r1)] *)
+ | Ointuoffloat (*r [rd = unsigned_int_of_float64(r1)] *)
+ | Ofloatofint (*r [rd = float64_of_signed_int(r1)] *)
+ | Ofloatofintu -> 6 (*r [rd = float64_of_unsigned_int(r1)] *)
+ | Ointofsingle (*r [rd = signed_int_of_float32(r1)] *)
+ | Ointuofsingle (*r [rd = unsigned_int_of_float32(r1)] *)
+ | Osingleofint (*r [rd = float32_of_signed_int(r1)] *)
+ | Osingleofintu -> 4 (*r [rd = float32_of_unsigned_int(r1)] *)
+ | Olongoffloat (*r [rd = signed_long_of_float64(r1)] *)
+ | Olonguoffloat (*r [rd = unsigned_long_of_float64(r1)] *)
+ | Ofloatoflong (*r [rd = float64_of_signed_long(r1)] *)
+ | Ofloatoflongu -> 6 (*r [rd = float64_of_unsigned_long(r1)] *)
+ | Olongofsingle (*r [rd = signed_long_of_float32(r1)] *)
+ | Olonguofsingle (*r [rd = unsigned_long_of_float32(r1)] *)
+ | Osingleoflong (*r [rd = float32_of_signed_long(r1)] *)
+ | Osingleoflongu -> 4 (*r [rd = float32_of_unsigned_int(r1)] *)
+
+ | Odiv | Odivu | Odivl | Odivlu -> 16
+ | Odivfs -> 35
+ | Odivf -> 50
+
+ | Ocmp cond ->
+ (match cond with
+ | Ccomp _
+ | Ccompu _
+ | Ccompimm _
+ | Ccompuimm _
+ | Ccompl _
+ | Ccomplu _
+ | Ccomplimm _
+ | Ccompluimm _ -> 1
+ | Ccompf _
+ | Cnotcompf _ -> 6
+ | Ccompfs _
+ | Cnotcompfs _ -> 4)
+ | _ -> 1;;
+
+ let resources_of_op (op : operation) (nargs : int) = resource_bounds;;
-let non_pipelined_resources_of_op (op : operation) (nargs : int) =
- match op with
- | Odiv | Odivu -> [| 29 |]
- | Odivfs -> [| 20 |]
- | Odivl | Odivlu | Odivf -> [| 50 |]
- | _ -> [| -1 |];;
-
-let resources_of_cond (cond : condition) (nargs : int) = [| 1; 0; 0 |];;
-
-let latency_of_load trap chunk (addr : addressing) (nargs : int) = 3;;
-let latency_of_call _ _ = 6;;
-
-let resources_of_load trap chunk addressing nargs = [| 1; 1; 0 |];;
-
-let resources_of_store chunk addressing nargs = [| 1; 1; 0 |];;
-
-let resources_of_call _ _ = resource_bounds;;
-let resources_of_builtin _ = resource_bounds;;
- *)
+ let non_pipelined_resources_of_op (op : operation) (nargs : int) =
+ match op with
+ | Odiv | Odivu -> [| 29 |]
+ | Odivfs -> [| 20 |]
+ | Odivl | Odivlu | Odivf -> [| 50 |]
+ | _ -> [| -1 |];;
+
+ let resources_of_cond (cond : condition) (nargs : int) = resource_bounds;;
+
+ let latency_of_load trap chunk (addr : addressing) (nargs : int) = 3;;
+ let latency_of_call _ _ = 6;;
+
+ let resources_of_load trap chunk addressing nargs = resource_bounds;;
+
+ let resources_of_store chunk addressing nargs = resource_bounds;;
+
+ let resources_of_call _ _ = resource_bounds;;
+ let resources_of_builtin _ = resource_bounds;;
+ end;;
+
+module SweRV_EH1 =
+ struct
+ (* Attempt at modeling SweRV EH1
+ [| issues ; LSU ; multiplier |] *)
+ let resource_bounds = [| 2 ; 1; 1 |];;
+ let nr_non_pipelined_units = 1;; (* divider *)
+
+ let latency_of_op (op : operation) (nargs : int) =
+ match op with
+ | Omul | Omulhs | Omulhu
+ | Omull | Omullhs | Omullhu -> 3
+ | Odiv | Odivu | Odivl | Odivlu -> 16
+ | _ -> 1;;
+
+ let resources_of_op (op : operation) (nargs : int) =
+ match op with
+ | Omul | Omulhs | Omulhu
+ | Omull | Omullhs | Omullhu -> [| 1 ; 0 ; 1 |]
+ | Odiv | Odivu | Odivl | Odivlu -> [| 0 ; 0; 0 |]
+ | _ -> [| 1; 0; 0; 0 |];;
+
+ let non_pipelined_resources_of_op (op : operation) (nargs : int) =
+ match op with
+ | Odiv | Odivu -> [| 29 |]
+ | Odivfs -> [| 20 |]
+ | Odivl | Odivlu | Odivf -> [| 50 |]
+ | _ -> [| -1 |];;
+
+ let resources_of_cond (cond : condition) (nargs : int) = [| 1; 0; 0 |];;
+
+ let latency_of_load trap chunk (addr : addressing) (nargs : int) = 3;;
+ let latency_of_call _ _ = 6;;
+
+ let resources_of_load trap chunk addressing nargs = [| 1; 1; 0 |];;
+
+ let resources_of_store chunk addressing nargs = [| 1; 1; 0 |];;
+
+ let resources_of_call _ _ = resource_bounds;;
+ let resources_of_builtin _ = resource_bounds;;
+ end;;
+
+let get_opweights () : opweights =
+ match !Clflags.option_mtune with
+ | "rocket" | "" ->
+ {
+ pipelined_resource_bounds = Rocket.resource_bounds;
+ nr_non_pipelined_units = Rocket.nr_non_pipelined_units;
+ latency_of_op = Rocket.latency_of_op;
+ resources_of_op = Rocket.resources_of_op;
+ non_pipelined_resources_of_op = Rocket.non_pipelined_resources_of_op;
+ latency_of_load = Rocket.latency_of_load;
+ resources_of_load = Rocket.resources_of_load;
+ resources_of_store = Rocket.resources_of_store;
+ resources_of_cond = Rocket.resources_of_cond;
+ latency_of_call = Rocket.latency_of_call;
+ resources_of_call = Rocket.resources_of_call;
+ resources_of_builtin = Rocket.resources_of_builtin
+ }
+ | "SweRV_EH1" | "EH1" ->
+ {
+ pipelined_resource_bounds = SweRV_EH1.resource_bounds;
+ nr_non_pipelined_units = SweRV_EH1.nr_non_pipelined_units;
+ latency_of_op = SweRV_EH1.latency_of_op;
+ resources_of_op = SweRV_EH1.resources_of_op;
+ non_pipelined_resources_of_op = SweRV_EH1.non_pipelined_resources_of_op;
+ latency_of_load = SweRV_EH1.latency_of_load;
+ resources_of_load = SweRV_EH1.resources_of_load;
+ resources_of_store = SweRV_EH1.resources_of_store;
+ resources_of_cond = SweRV_EH1.resources_of_cond;
+ latency_of_call = SweRV_EH1.latency_of_call;
+ resources_of_call = SweRV_EH1.resources_of_call;
+ resources_of_builtin = SweRV_EH1.resources_of_builtin
+ }
+ | xxx -> failwith (Printf.sprintf "unknown -mtune: %s" xxx);;
diff --git a/riscV/PrepassSchedulingOracleDeps.ml b/riscV/PrepassSchedulingOracleDeps.ml
new file mode 120000
index 00000000..1e955b85
--- /dev/null
+++ b/riscV/PrepassSchedulingOracleDeps.ml
@@ -0,0 +1 @@
+../aarch64/PrepassSchedulingOracleDeps.ml \ No newline at end of file