Skip to content

Commit 23c793d

Browse files
authored
Add layout type in Lambda (#1032)
1 parent eae2049 commit 23c793d

File tree

93 files changed

+921
-809
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+921
-809
lines changed

backend/cmm_helpers.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,7 @@ module SArgBlocks = struct
19011901

19021902
type loc = Debuginfo.t
19031903

1904-
type nonrec value_kind = value_kind
1904+
type layout = value_kind
19051905

19061906
(* CR mshinwell: GPR#2294 will fix the Debuginfo here *)
19071907

@@ -3889,3 +3889,5 @@ let transl_attrib : Lambda.check_attribute -> Cmm.codegen_option list = function
38893889
| Default_check -> []
38903890
| Assert p -> [Assert (transl_property p)]
38913891
| Assume p -> [Assume (transl_property p)]
3892+
3893+
let kind_of_layout (Lambda.Pvalue kind) = Vval kind

backend/cmm_helpers.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,3 +1195,5 @@ val transl_attrib : Lambda.check_attribute -> Cmm.codegen_option list
11951195

11961196
(* CR lmaurer: Return [Linkage_name.t] instead *)
11971197
val make_symbol : ?compilation_unit:Compilation_unit.t -> string -> string
1198+
1199+
val kind_of_layout : Lambda.layout -> value_kind

backend/cmmgen.ml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -654,27 +654,27 @@ let rec transl env e =
654654
(untag_int (transl env arg) dbg)
655655
s.us_index_consts
656656
(Array.map (fun expr -> transl env expr, dbg) s.us_actions_consts)
657-
dbg (Vval kind)
657+
dbg (kind_of_layout kind)
658658
else if Array.length s.us_index_consts = 0 then
659659
bind "switch" (transl env arg) (fun arg ->
660-
transl_switch dbg (Vval kind) env (get_tag arg dbg)
660+
transl_switch dbg (kind_of_layout kind) env (get_tag arg dbg)
661661
s.us_index_blocks s.us_actions_blocks)
662662
else
663663
bind "switch" (transl env arg) (fun arg ->
664664
Cifthenelse(
665665
Cop(Cand, [arg; Cconst_int (1, dbg)], dbg),
666666
dbg,
667-
transl_switch dbg (Vval kind) env
667+
transl_switch dbg (kind_of_layout kind) env
668668
(untag_int arg dbg) s.us_index_consts s.us_actions_consts,
669669
dbg,
670-
transl_switch dbg (Vval kind) env
670+
transl_switch dbg (kind_of_layout kind) env
671671
(get_tag arg dbg) s.us_index_blocks s.us_actions_blocks,
672-
dbg, Vval kind))
672+
dbg, kind_of_layout kind))
673673
| Ustringswitch(arg,sw,d, kind) ->
674674
let dbg = Debuginfo.none in
675675
bind "switch" (transl env arg)
676676
(fun arg ->
677-
strmatch_compile dbg (Vval kind) arg (Option.map (transl env) d)
677+
strmatch_compile dbg (kind_of_layout kind) arg (Option.map (transl env) d)
678678
(List.map (fun (s,act) -> s,transl env act) sw))
679679
| Ustaticfail (nfail, args) ->
680680
let cargs = List.map (transl env) args in
@@ -684,21 +684,21 @@ let rec transl env e =
684684
| Ucatch(nfail, [], body, handler, kind) ->
685685
let dbg = Debuginfo.none in
686686
let env_body = enter_catch_body env nfail in
687-
make_catch (Vval kind) nfail
687+
make_catch (kind_of_layout kind) nfail
688688
(transl env_body body)
689689
(transl env handler) dbg
690690
| Ucatch(nfail, ids, body, handler, kind) ->
691691
let dbg = Debuginfo.none in
692-
transl_catch (Vval kind) env nfail ids body handler dbg
692+
transl_catch (kind_of_layout kind) env nfail ids body handler dbg
693693
| Utrywith(body, exn, handler, kind) ->
694694
let dbg = Debuginfo.none in
695695
let new_body = transl (incr_depth env) body in
696-
Ctrywith(new_body, Regular, exn, transl env handler, dbg, Vval kind)
696+
Ctrywith(new_body, Regular, exn, transl env handler, dbg, kind_of_layout kind)
697697
| Uifthenelse(cond, ifso, ifnot, kind) ->
698698
let ifso_dbg = Debuginfo.none in
699699
let ifnot_dbg = Debuginfo.none in
700700
let dbg = Debuginfo.none in
701-
transl_if env (Vval kind) Unknown dbg cond
701+
transl_if env (kind_of_layout kind) Unknown dbg cond
702702
ifso_dbg (transl env ifso) ifnot_dbg (transl env ifnot)
703703
| Usequence(exp1, exp2) ->
704704
Csequence(remove_unit(transl env exp1), transl env exp2)
@@ -773,7 +773,7 @@ and transl_catch (kind : Cmm.value_kind) env nfail ids body handler dbg =
773773
each argument. *)
774774
let report args =
775775
List.iter2
776-
(fun (_id, kind, u) c ->
776+
(fun (_id, Pvalue kind, u) c ->
777777
let strict = is_strict kind in
778778
u := join_unboxed_number_kind ~strict !u
779779
(is_unboxed_number_cmm c)
@@ -1221,7 +1221,7 @@ and transl_unbox_sized size dbg env exp =
12211221
| Thirty_two -> transl_unbox_int dbg env Pint32 exp
12221222
| Sixty_four -> transl_unbox_int dbg env Pint64 exp
12231223

1224-
and transl_let env str (kind : Lambda.value_kind) id exp transl_body =
1224+
and transl_let env str (Pvalue kind : Lambda.layout) id exp transl_body =
12251225
let dbg = Debuginfo.none in
12261226
let cexp = transl env exp in
12271227
let unboxing =

middle_end/clambda.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,31 @@ and ulambda =
5858
scanned_slots : ulambda list ;
5959
}
6060
| Uoffset of ulambda * int
61-
| Ulet of mutable_flag * value_kind * Backend_var.With_provenance.t
61+
| Ulet of mutable_flag * layout * Backend_var.With_provenance.t
6262
* ulambda * ulambda
6363
| Uphantom_let of Backend_var.With_provenance.t
6464
* uphantom_defining_expr option * ulambda
6565
| Uletrec of (Backend_var.With_provenance.t * ulambda) list * ulambda
6666
| Uprim of Clambda_primitives.primitive * ulambda list * Debuginfo.t
67-
| Uswitch of ulambda * ulambda_switch * Debuginfo.t * Lambda.value_kind
67+
| Uswitch of ulambda * ulambda_switch * Debuginfo.t * layout
6868
| Ustringswitch of
6969
ulambda *
7070
(string * ulambda) list *
7171
ulambda option *
72-
Lambda.value_kind
72+
layout
7373
| Ustaticfail of int * ulambda list
7474
| Ucatch of
7575
int *
76-
(Backend_var.With_provenance.t * value_kind) list *
76+
(Backend_var.With_provenance.t * layout) list *
7777
ulambda *
7878
ulambda *
79-
Lambda.value_kind
79+
layout
8080
| Utrywith of
8181
ulambda *
8282
Backend_var.With_provenance.t *
8383
ulambda *
84-
Lambda.value_kind
85-
| Uifthenelse of ulambda * ulambda * ulambda * Lambda.value_kind
84+
layout
85+
| Uifthenelse of ulambda * ulambda * ulambda * layout
8686
| Usequence of ulambda * ulambda
8787
| Uwhile of ulambda * ulambda
8888
| Ufor of Backend_var.With_provenance.t * ulambda * ulambda
@@ -98,8 +98,8 @@ and ulambda =
9898
and ufunction = {
9999
label : function_label;
100100
arity : arity;
101-
params : (Backend_var.With_provenance.t * value_kind) list;
102-
return : value_kind;
101+
params : (Backend_var.With_provenance.t * layout) list;
102+
return : layout;
103103
body : ulambda;
104104
dbg : Debuginfo.t;
105105
env : Backend_var.t option;

middle_end/clambda.mli

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,31 @@ and ulambda =
6969
scanned_slots : ulambda list
7070
}
7171
| Uoffset of ulambda * int
72-
| Ulet of mutable_flag * value_kind * Backend_var.With_provenance.t
72+
| Ulet of mutable_flag * layout * Backend_var.With_provenance.t
7373
* ulambda * ulambda
7474
| Uphantom_let of Backend_var.With_provenance.t
7575
* uphantom_defining_expr option * ulambda
7676
| Uletrec of (Backend_var.With_provenance.t * ulambda) list * ulambda
7777
| Uprim of Clambda_primitives.primitive * ulambda list * Debuginfo.t
78-
| Uswitch of ulambda * ulambda_switch * Debuginfo.t * Lambda.value_kind
78+
| Uswitch of ulambda * ulambda_switch * Debuginfo.t * Lambda.layout
7979
| Ustringswitch of
8080
ulambda *
8181
(string * ulambda) list *
8282
ulambda option *
83-
Lambda.value_kind
83+
Lambda.layout
8484
| Ustaticfail of int * ulambda list
8585
| Ucatch of
8686
int *
87-
(Backend_var.With_provenance.t * value_kind) list *
87+
(Backend_var.With_provenance.t * layout) list *
8888
ulambda *
8989
ulambda *
90-
Lambda.value_kind
90+
Lambda.layout
9191
| Utrywith of
9292
ulambda *
9393
Backend_var.With_provenance.t *
9494
ulambda *
95-
Lambda.value_kind
96-
| Uifthenelse of ulambda * ulambda * ulambda * Lambda.value_kind
95+
Lambda.layout
96+
| Uifthenelse of ulambda * ulambda * ulambda * Lambda.layout
9797
| Usequence of ulambda * ulambda
9898
| Uwhile of ulambda * ulambda
9999
| Ufor of Backend_var.With_provenance.t * ulambda * ulambda
@@ -109,8 +109,8 @@ and ulambda =
109109
and ufunction = {
110110
label : function_label;
111111
arity : arity;
112-
params : (Backend_var.With_provenance.t * value_kind) list;
113-
return : value_kind;
112+
params : (Backend_var.With_provenance.t * layout) list;
113+
return : layout;
114114
body : ulambda;
115115
dbg : Debuginfo.t;
116116
env : Backend_var.t option;

middle_end/clambda_primitives.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ and value_kind = Lambda.value_kind =
141141
}
142142
| Parrayval of array_kind
143143

144+
and layout = Lambda.layout =
145+
| Pvalue of value_kind
146+
144147
and block_shape = Lambda.block_shape
145148
and boxed_integer = Primitive.boxed_integer =
146149
Pnativeint | Pint32 | Pint64

middle_end/clambda_primitives.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ and value_kind = Lambda.value_kind =
144144
}
145145
| Parrayval of array_kind
146146

147+
and layout = Lambda.layout =
148+
| Pvalue of value_kind
149+
147150
and block_shape = Lambda.block_shape
148151
and boxed_integer = Primitive.boxed_integer =
149152
Pnativeint | Pint32 | Pint64

0 commit comments

Comments
 (0)