summaryrefslogtreecommitdiff
path: root/middle_end
diff options
context:
space:
mode:
authorAlain Frisch <alain.frisch@lexifi.com>2019-09-17 10:22:08 +0200
committerVincent Laviron <vincent.laviron@gmail.com>2019-09-17 10:22:08 +0200
commit5c031d2d3d8efefd862b63c5a0178d2cd04eafff (patch)
treed2ad2d02a7b4bb9c0b8b107ce5594dfb31e05d52 /middle_end
parent5c7c619d4d335eddc58a0c5e889bb71174b0f829 (diff)
downloadocaml-5c031d2d3d8efefd862b63c5a0178d2cd04eafff.tar.gz
Decide unboxing of let-bound expressions based on their Cmm translation (#2165)
Diffstat (limited to 'middle_end')
-rw-r--r--middle_end/compilenv.ml17
-rw-r--r--middle_end/compilenv.mli4
2 files changed, 15 insertions, 6 deletions
diff --git a/middle_end/compilenv.ml b/middle_end/compilenv.ml
index add4e90e57..247b069403 100644
--- a/middle_end/compilenv.ml
+++ b/middle_end/compilenv.ml
@@ -49,16 +49,18 @@ module CstMap =
because it compares "0.0" and "-0.0" equal. *)
end)
+module SymMap = Misc.Stdlib.String.Map
+
type structured_constants =
{
strcst_shared: string CstMap.t;
- strcst_all: (string * Clambda.ustructured_constant) list;
+ strcst_all: Clambda.ustructured_constant SymMap.t;
}
let structured_constants_empty =
{
strcst_shared = CstMap.empty;
- strcst_all = [];
+ strcst_all = SymMap.empty;
}
let structured_constants = ref structured_constants_empty
@@ -371,7 +373,7 @@ let new_structured_constant cst ~shared =
structured_constants :=
{
strcst_shared = CstMap.add cst lbl strcst_shared;
- strcst_all = (lbl, cst) :: strcst_all;
+ strcst_all = SymMap.add lbl cst strcst_all;
};
lbl
else
@@ -379,7 +381,7 @@ let new_structured_constant cst ~shared =
structured_constants :=
{
strcst_shared;
- strcst_all = (lbl, cst) :: strcst_all;
+ strcst_all = SymMap.add lbl cst strcst_all;
};
lbl
@@ -389,6 +391,9 @@ let add_exported_constant s =
let clear_structured_constants () =
structured_constants := structured_constants_empty
+let structured_constant_of_symbol s =
+ SymMap.find_opt s (!structured_constants).strcst_all
+
let structured_constants () =
let provenance : Clambda.usymbol_provenance =
{ original_idents = [];
@@ -396,7 +401,8 @@ let structured_constants () =
Path.Pident (Ident.create_persistent (current_unit_name ()));
}
in
- List.map
+ SymMap.bindings (!structured_constants).strcst_all
+ |> List.map
(fun (symbol, definition) ->
{
Clambda.symbol;
@@ -404,7 +410,6 @@ let structured_constants () =
definition;
provenance = Some provenance;
})
- (!structured_constants).strcst_all
let closure_symbol fv =
let compilation_unit = Closure_id.get_compilation_unit fv in
diff --git a/middle_end/compilenv.mli b/middle_end/compilenv.mli
index 569d51ea08..8f1ef284f0 100644
--- a/middle_end/compilenv.mli
+++ b/middle_end/compilenv.mli
@@ -117,6 +117,10 @@ val new_structured_constant:
val structured_constants:
unit -> Clambda.preallocated_constant list
val clear_structured_constants: unit -> unit
+
+val structured_constant_of_symbol:
+ string -> Clambda.ustructured_constant option
+
val add_exported_constant: string -> unit
(* clambda-only *)
type structured_constants