-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathtranslmode.ml
56 lines (47 loc) · 2.48 KB
/
translmode.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Zesen Qian, Jane Street, London *)
(* *)
(* Copyright 2024 Jane Street Group LLC *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
open Lambda
open Mode
let transl_locality_mode = function
| Locality.Const.Global -> alloc_heap
| Locality.Const.Local -> alloc_local
let transl_locality_mode_l locality =
Locality.zap_to_floor locality |> transl_locality_mode
let transl_locality_mode_r locality =
(* r mode are for allocations; [optimise_allocations] should have pushed it
to ceil and determined; here we push it again just to get the constant. *)
Locality.zap_to_ceil locality |> transl_locality_mode
let transl_alloc_mode_l mode =
(* we only take the locality axis *)
Alloc.proj (Comonadic Areality) mode |> transl_locality_mode_l
let transl_alloc_mode_r mode =
(* we only take the locality axis *)
Alloc.proj (Comonadic Areality) mode |> transl_locality_mode_r
let transl_alloc_mode (mode : Typedtree.alloc_mode) =
transl_alloc_mode_r mode.mode
let transl_modify_mode locality =
match Locality.zap_to_floor locality with
| Global -> modify_heap
| Local -> modify_maybe_stack
let transl_unique_barrier barrier =
match Typedtree.Unique_barrier.resolve barrier with
| Uniqueness.Const.Aliased -> May_be_pushed_down
| Uniqueness.Const.Unique ->
(* CR uniqueness: this is a temporary measure to ensure that we can roll
the compiler without breaking existing code. Once uniqueness is stable,
we can simplify this to always return [Must_stay_here]. *)
if Language_extension.is_at_least Unique
Language_extension.maturity_of_unique_for_destruction
then Must_stay_here
else assert false