Skip to content

Commit

Permalink
flambda-backend: Revert "Communicate frontend layouts to lambda" (#1507)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccasin authored Jun 16, 2023
1 parent 383e158 commit 0ea8b04
Show file tree
Hide file tree
Showing 52 changed files with 731 additions and 1,134 deletions.
23 changes: 3 additions & 20 deletions .depend
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ parsing/jane_syntax.cmo : \
parsing/parsetree.cmi \
parsing/longident.cmi \
parsing/location.cmi \
utils/language_extension.cmi \
parsing/jane_syntax_parsing.cmi \
parsing/asttypes.cmi \
parsing/ast_helper.cmi \
Expand All @@ -442,6 +443,7 @@ parsing/jane_syntax.cmx : \
parsing/parsetree.cmi \
parsing/longident.cmx \
parsing/location.cmx \
utils/language_extension.cmx \
parsing/jane_syntax_parsing.cmx \
parsing/asttypes.cmi \
parsing/ast_helper.cmx \
Expand Down Expand Up @@ -1234,22 +1236,19 @@ typing/primitive.cmo : \
typing/outcometree.cmi \
utils/misc.cmi \
parsing/location.cmi \
typing/layouts.cmi \
parsing/attr_helper.cmi \
typing/primitive.cmi
typing/primitive.cmx : \
parsing/parsetree.cmi \
typing/outcometree.cmi \
utils/misc.cmx \
parsing/location.cmx \
typing/layouts.cmx \
parsing/attr_helper.cmx \
typing/primitive.cmi
typing/primitive.cmi : \
parsing/parsetree.cmi \
typing/outcometree.cmi \
parsing/location.cmi \
typing/layouts.cmi
parsing/location.cmi
typing/printpat.cmo : \
typing/types.cmi \
typing/typedtree.cmi \
Expand Down Expand Up @@ -1981,7 +1980,6 @@ typing/typeopt.cmi : \
typing/typedtree.cmi \
typing/path.cmi \
parsing/location.cmi \
typing/layouts.cmi \
lambda/lambda.cmi \
typing/env.cmi
typing/types.cmo : \
Expand Down Expand Up @@ -3712,7 +3710,6 @@ lambda/lambda.cmo : \
utils/misc.cmi \
parsing/longident.cmi \
parsing/location.cmi \
typing/layouts.cmi \
typing/ident.cmi \
typing/env.cmi \
lambda/debuginfo.cmi \
Expand All @@ -3728,7 +3725,6 @@ lambda/lambda.cmx : \
utils/misc.cmx \
parsing/longident.cmx \
parsing/location.cmx \
typing/layouts.cmx \
typing/ident.cmx \
typing/env.cmx \
lambda/debuginfo.cmx \
Expand All @@ -3743,7 +3739,6 @@ lambda/lambda.cmi : \
typing/primitive.cmi \
typing/path.cmi \
parsing/location.cmi \
typing/layouts.cmi \
typing/ident.cmi \
typing/env.cmi \
lambda/debuginfo.cmi \
Expand Down Expand Up @@ -3798,7 +3793,6 @@ lambda/matching.cmx : \
lambda/matching.cmi : \
typing/typedtree.cmi \
parsing/location.cmi \
typing/layouts.cmi \
lambda/lambda.cmi \
typing/ident.cmi \
lambda/debuginfo.cmi
Expand Down Expand Up @@ -3887,7 +3881,6 @@ lambda/transl_array_comprehension.cmo : \
typing/predef.cmi \
utils/misc.cmi \
lambda/matching.cmi \
typing/layouts.cmi \
lambda/lambda.cmi \
typing/ident.cmi \
typing/env.cmi \
Expand All @@ -3901,7 +3894,6 @@ lambda/transl_array_comprehension.cmx : \
typing/predef.cmx \
utils/misc.cmx \
lambda/matching.cmx \
typing/layouts.cmx \
lambda/lambda.cmx \
typing/ident.cmx \
typing/env.cmx \
Expand All @@ -3910,7 +3902,6 @@ lambda/transl_array_comprehension.cmx : \
lambda/transl_array_comprehension.cmi
lambda/transl_array_comprehension.cmi : \
typing/typedtree.cmi \
typing/layouts.cmi \
lambda/lambda.cmi \
lambda/debuginfo.cmi
lambda/transl_comprehension_utils.cmo : \
Expand All @@ -3932,7 +3923,6 @@ lambda/transl_list_comprehension.cmo : \
typing/typedtree.cmi \
lambda/transl_comprehension_utils.cmi \
lambda/matching.cmi \
typing/layouts.cmi \
lambda/lambda.cmi \
typing/ident.cmi \
parsing/asttypes.cmi \
Expand All @@ -3942,14 +3932,12 @@ lambda/transl_list_comprehension.cmx : \
typing/typedtree.cmx \
lambda/transl_comprehension_utils.cmx \
lambda/matching.cmx \
typing/layouts.cmx \
lambda/lambda.cmx \
typing/ident.cmx \
parsing/asttypes.cmi \
lambda/transl_list_comprehension.cmi
lambda/transl_list_comprehension.cmi : \
typing/typedtree.cmi \
typing/layouts.cmi \
lambda/lambda.cmi \
lambda/debuginfo.cmi
lambda/translattribute.cmo : \
Expand Down Expand Up @@ -3992,7 +3980,6 @@ lambda/translclass.cmo : \
typing/path.cmi \
lambda/matching.cmi \
parsing/location.cmi \
typing/layouts.cmi \
lambda/lambda.cmi \
typing/ident.cmi \
typing/env.cmi \
Expand All @@ -4010,7 +3997,6 @@ lambda/translclass.cmx : \
typing/path.cmx \
lambda/matching.cmx \
parsing/location.cmx \
typing/layouts.cmx \
lambda/lambda.cmx \
typing/ident.cmx \
typing/env.cmx \
Expand Down Expand Up @@ -4097,7 +4083,6 @@ lambda/translcore.cmx : \
parsing/asttypes.cmi \
lambda/translcore.cmi
lambda/translcore.cmi : \
typing/types.cmi \
typing/typedtree.cmi \
parsing/longident.cmi \
parsing/location.cmi \
Expand Down Expand Up @@ -4219,7 +4204,6 @@ lambda/translprim.cmo : \
utils/misc.cmi \
lambda/matching.cmi \
parsing/location.cmi \
typing/layouts.cmi \
lambda/lambda.cmi \
typing/ident.cmi \
typing/env.cmi \
Expand All @@ -4240,7 +4224,6 @@ lambda/translprim.cmx : \
utils/misc.cmx \
lambda/matching.cmx \
parsing/location.cmx \
typing/layouts.cmx \
lambda/lambda.cmx \
typing/ident.cmx \
typing/env.cmx \
Expand Down
2 changes: 1 addition & 1 deletion asmcomp/cmm_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ let box_sized size mode dbg exp =
(* Simplification of some primitives into C calls *)

let default_prim name =
Primitive.simple_on_values ~name ~arity:0(*ignored*) ~alloc:true
Primitive.simple ~name ~arity:0(*ignored*) ~alloc:true


let int64_native_prim name arity ~alloc =
Expand Down
14 changes: 3 additions & 11 deletions asmcomp/cmmgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ let rec transl env e =
transl_make_array dbg env kind alloc_heap args
| (Pduparray _, [arg]) ->
let prim_obj_dup =
Primitive.simple_on_values ~name:"caml_obj_dup" ~arity:1 ~alloc:true
Primitive.simple ~name:"caml_obj_dup" ~arity:1 ~alloc:true
in
transl_ccall env prim_obj_dup [arg] dbg
| (Pmakearray _, []) ->
Expand Down Expand Up @@ -826,13 +826,9 @@ and transl_make_array dbg env kind mode args =

and transl_ccall env prim args dbg =
let transl_arg native_repr arg =
(* CR layouts v2: This match to be extended with
| Same_as_ocaml_repr Float64 -> (XFloat, transl env arg)
in the PR that adds Float64 *)
match native_repr with
| Same_as_ocaml_repr Value ->
| Same_as_ocaml_repr ->
(XInt, transl env arg)
| Same_as_ocaml_repr Void -> assert false
| Unboxed_float ->
(XFloat, transl_unbox_float dbg env arg)
| Unboxed_integer bi ->
Expand Down Expand Up @@ -860,11 +856,7 @@ and transl_ccall env prim args dbg =
in
let typ_res, wrap_result =
match prim.prim_native_repr_res with
(* CR layouts v2: This match to be extended with
| Same_as_ocaml_repr Float64 -> (typ_float, fun x -> x)
in the PR that adds Float64 *)
| _, Same_as_ocaml_repr Value -> (typ_val, fun x -> x)
| _, Same_as_ocaml_repr Void -> assert false
| _, Same_as_ocaml_repr -> (typ_val, fun x -> x)
(* TODO: Allow Alloc_local on suitably typed C stubs *)
| _, Unboxed_float -> (typ_float, box_float dbg alloc_heap)
| _, Unboxed_integer Pint64 when size_int = 4 ->
Expand Down
Binary file modified boot/ocamlc
Binary file not shown.
Binary file modified boot/ocamllex
Binary file not shown.
2 changes: 1 addition & 1 deletion bytecomp/bytegen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ let rec comp_expr env exp sz cont =
comp_expr env (Lprim (Pmakearray (kind, mutability, m), args, loc)) sz cont
| Lprim (Pduparray _, [arg], loc) ->
let prim_obj_dup =
Primitive.simple_on_values ~name:"caml_obj_dup" ~arity:1 ~alloc:true
Primitive.simple ~name:"caml_obj_dup" ~arity:1 ~alloc:true
in
comp_expr env (Lprim (Pccall prim_obj_dup, [arg], loc)) sz cont
| Lprim (Pduparray _, _, _) ->
Expand Down
2 changes: 1 addition & 1 deletion compilerlibs/Makefile.compilerlibs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ PARSING_CMI = \

TYPING = \
typing/path.cmo \
typing/layouts.cmo \
typing/primitive.cmo \
typing/shape.cmo \
typing/layouts.cmo \
typing/types.cmo \
typing/btype.cmo \
typing/oprint.cmo \
Expand Down
4 changes: 2 additions & 2 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
asttypes parsetree

;; TYPING
ident path layouts primitive shape types btype oprint subst predef datarepr
ident path primitive shape layouts types btype oprint subst predef datarepr
cmi_format persistent_env env errortrace
typedtree printtyped ctype printtyp includeclass mtype envaux includecore
tast_iterator tast_mapper signature_group cmt_format cms_format untypeast
Expand Down Expand Up @@ -263,8 +263,8 @@
(parsetree.mli as compiler-libs/parsetree.mli)
(ident.mli as compiler-libs/ident.mli)
(path.mli as compiler-libs/path.mli)
(layouts.mli as compiler-libs/layouts.mli)
(primitive.mli as compiler-libs/primitive.mli)
(layouts.mli as compiler-libs/layouts.mli)
(types.mli as compiler-libs/types.mli)
(btype.mli as compiler-libs/btype.mli)
(binutils.mli as compiler-libs/binutils.mli)
Expand Down
18 changes: 7 additions & 11 deletions lambda/lambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -637,14 +637,13 @@ let layout_class = Pvalue Pgenval
let layout_module = Pvalue Pgenval
let layout_module_field = Pvalue Pgenval
let layout_functor = Pvalue Pgenval
let layout_boxed_float = Pvalue Pfloatval
let layout_float = Pvalue Pfloatval
let layout_string = Pvalue Pgenval
let layout_boxedint bi = Pvalue (Pboxedintval bi)
let layout_lazy = Pvalue Pgenval
let layout_lazy_contents = Pvalue Pgenval
let layout_any_value = Pvalue Pgenval
let layout_letrec = layout_any_value
let layout_probe_arg = Pvalue Pgenval

(* CR ncourant: use [Ptop] or remove this as soon as possible. *)
let layout_top = layout_any_value
Expand Down Expand Up @@ -1439,15 +1438,12 @@ let primitive_result_layout (p : primitive) =
| Pfield _ | Pfield_computed _ -> layout_field
| Pfloatfield _ | Pfloatofint _ | Pnegfloat _ | Pabsfloat _
| Paddfloat _ | Psubfloat _ | Pmulfloat _ | Pdivfloat _
| Pbox_float _ -> layout_boxed_float
| Pbox_float _ -> layout_float
| Punbox_float -> Punboxed_float
| Pccall { prim_native_repr_res = _, Untagged_int; _} -> layout_int
| Pccall { prim_native_repr_res = _, Unboxed_float; _} -> layout_boxed_float
| Pccall { prim_native_repr_res = _, Same_as_ocaml_repr s; _} ->
begin match s with
| Value -> layout_any_value
| Void -> assert false
end
| Pccall { prim_native_repr_res = _, Unboxed_float; _} -> layout_float
| Pccall { prim_native_repr_res = _, Same_as_ocaml_repr; _} ->
layout_any_value
| Pccall { prim_native_repr_res = _, Unboxed_integer bi; _} ->
layout_boxedint bi
| Praise _ -> layout_bottom
Expand All @@ -1469,7 +1465,7 @@ let primitive_result_layout (p : primitive) =
| Parrayrefu array_ref_kind | Parrayrefs array_ref_kind ->
(match array_ref_kind with
| Pintarray_ref -> layout_int
| Pfloatarray_ref _ -> layout_boxed_float
| Pfloatarray_ref _ -> layout_float
| Pgenarray_ref _ | Paddrarray_ref -> layout_field)
| Pbintofint (bi, _) | Pcvtbint (_,bi,_)
| Pnegbint (bi, _) | Paddbint (bi, _) | Psubbint (bi, _)
Expand All @@ -1486,7 +1482,7 @@ let primitive_result_layout (p : primitive) =
| Pbigarrayref (_, _, kind, _) ->
begin match kind with
| Pbigarray_unknown -> layout_any_value
| Pbigarray_float32 | Pbigarray_float64 -> layout_boxed_float
| Pbigarray_float32 | Pbigarray_float64 -> layout_float
| Pbigarray_sint8 | Pbigarray_uint8
| Pbigarray_sint16 | Pbigarray_uint16
| Pbigarray_caml_int -> layout_int
Expand Down
4 changes: 1 addition & 3 deletions lambda/lambda.mli
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ val layout_module : layout
val layout_functor : layout
val layout_module_field : layout
val layout_string : layout
val layout_boxed_float : layout
val layout_float : layout
val layout_boxedint : boxed_integer -> layout
(* A layout that is Pgenval because it is the field of a block *)
val layout_field : layout
Expand All @@ -537,8 +537,6 @@ val layout_lazy_contents : layout
val layout_any_value : layout
(* A layout that is Pgenval because it is bound by a letrec *)
val layout_letrec : layout
(* The probe hack: Free vars in probes must have layout value. *)
val layout_probe_arg : layout

val layout_top : layout
val layout_bottom : layout
Expand Down
Loading

0 comments on commit 0ea8b04

Please sign in to comment.