diff options
author | Pierre Chambart <chambart@users.noreply.github.com> | 2019-02-14 15:30:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-14 15:30:37 +0100 |
commit | 1e6c739811ac93d126d6cb92f678d0c15754c82c (patch) | |
tree | d3a15fedd29fbad8acccca668e6cd1aa07077df1 /bytecomp | |
parent | 5a29ea7c2b31051de814ed7e45bb45098b512b9b (diff) | |
parent | 80ad15d45fce7f2f33225793a19fddd139dbc8f7 (diff) | |
download | ocaml-1e6c739811ac93d126d6cb92f678d0c15754c82c.tar.gz |
Merge pull request #1579 from chambart/split_backend_primitives
Use a different type for primitives in clambda and lambda
Diffstat (limited to 'bytecomp')
-rw-r--r-- | bytecomp/printlambda.mli | 8 | ||||
-rw-r--r-- | bytecomp/semantics_of_primitives.ml | 180 | ||||
-rw-r--r-- | bytecomp/semantics_of_primitives.mli | 69 |
3 files changed, 7 insertions, 250 deletions
diff --git a/bytecomp/printlambda.mli b/bytecomp/printlambda.mli index 137190efd6..7dab5229ac 100644 --- a/bytecomp/printlambda.mli +++ b/bytecomp/printlambda.mli @@ -17,10 +17,16 @@ open Lambda open Format +val integer_comparison: formatter -> integer_comparison -> unit +val float_comparison: formatter -> float_comparison -> unit val structured_constant: formatter -> structured_constant -> unit val lambda: formatter -> lambda -> unit val program: formatter -> program -> unit val primitive: formatter -> primitive -> unit val name_of_primitive : primitive -> string val value_kind : formatter -> value_kind -> unit -val array_kind : array_kind -> string +val block_shape : formatter -> value_kind list option -> unit +val record_rep : formatter -> Types.record_representation -> unit +val print_bigarray : + string -> bool -> Lambda.bigarray_kind -> formatter -> + Lambda.bigarray_layout -> unit diff --git a/bytecomp/semantics_of_primitives.ml b/bytecomp/semantics_of_primitives.ml deleted file mode 100644 index b6b09e1936..0000000000 --- a/bytecomp/semantics_of_primitives.ml +++ /dev/null @@ -1,180 +0,0 @@ -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Pierre Chambart, OCamlPro *) -(* Mark Shinwell and Leo White, Jane Street Europe *) -(* *) -(* Copyright 2013--2016 OCamlPro SAS *) -(* Copyright 2014--2016 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. *) -(* *) -(**************************************************************************) - -[@@@ocaml.warning "+a-4-9-30-40-41-42"] - -type effects = No_effects | Only_generative_effects | Arbitrary_effects -type coeffects = No_coeffects | Has_coeffects - -let for_primitive (prim : Lambda.primitive) = - match prim with - | Pignore | Pidentity -> - No_effects, No_coeffects - | Pbytes_to_string | Pbytes_of_string -> - No_effects, No_coeffects - | Pmakeblock _ - | Pmakearray (_, Mutable) -> Only_generative_effects, No_coeffects - | Pmakearray (_, Immutable) -> No_effects, No_coeffects - | Pduparray (_, Immutable) -> - No_effects, No_coeffects (* Pduparray (_, Immutable) is allowed only on - immutable arrays. *) - | Pduparray (_, Mutable) | Pduprecord _ -> - Only_generative_effects, Has_coeffects - | Pccall { prim_name = - ( "caml_format_float" | "caml_format_int" | "caml_int32_format" - | "caml_nativeint_format" | "caml_int64_format" ) } -> - No_effects, No_coeffects - | Pccall _ -> Arbitrary_effects, Has_coeffects - | Praise _ -> Arbitrary_effects, No_coeffects - | Pnot - | Pnegint - | Paddint - | Psubint - | Pmulint - | Pandint - | Porint - | Pxorint - | Plslint - | Plsrint - | Pasrint - | Pintcomp _ -> No_effects, No_coeffects - | Pdivbint { is_safe = Unsafe } - | Pmodbint { is_safe = Unsafe } - | Pdivint Unsafe - | Pmodint Unsafe -> - No_effects, No_coeffects (* Will not raise [Division_by_zero]. *) - | Pdivbint { is_safe = Safe } - | Pmodbint { is_safe = Safe } - | Pdivint Safe - | Pmodint Safe -> - Arbitrary_effects, No_coeffects - | Poffsetint _ -> No_effects, No_coeffects - | Poffsetref _ -> Arbitrary_effects, Has_coeffects - | Pintoffloat - | Pfloatofint - | Pnegfloat - | Pabsfloat - | Paddfloat - | Psubfloat - | Pmulfloat - | Pdivfloat - | Pfloatcomp _ -> No_effects, No_coeffects - | Pstringlength | Pbyteslength - | Parraylength _ -> - No_effects, Has_coeffects (* That old chestnut: [Obj.truncate]. *) - | Pisint - | Pisout - | Pbintofint _ - | Pintofbint _ - | Pcvtbint _ - | Pnegbint _ - | Paddbint _ - | Psubbint _ - | Pmulbint _ - | Pandbint _ - | Porbint _ - | Pxorbint _ - | Plslbint _ - | Plsrbint _ - | Pasrbint _ - | Pbintcomp _ -> No_effects, No_coeffects - | Pbigarraydim _ -> - No_effects, Has_coeffects (* Some people resize bigarrays in place. *) - | Pfield _ - | Pfield_computed - | Pfloatfield _ - | Pgetglobal _ - | Parrayrefu _ - | Pstringrefu - | Pbytesrefu - | Pstring_load_16 true - | Pstring_load_32 true - | Pstring_load_64 true - | Pbytes_load_16 true - | Pbytes_load_32 true - | Pbytes_load_64 true - | Pbigarrayref (true, _, _, _) - | Pbigstring_load_16 true - | Pbigstring_load_32 true - | Pbigstring_load_64 true -> - No_effects, Has_coeffects - | Parrayrefs _ - | Pstringrefs - | Pbytesrefs - | Pstring_load_16 false - | Pstring_load_32 false - | Pstring_load_64 false - | Pbytes_load_16 false - | Pbytes_load_32 false - | Pbytes_load_64 false - | Pbigarrayref (false, _, _, _) - | Pbigstring_load_16 false - | Pbigstring_load_32 false - | Pbigstring_load_64 false -> - (* May trigger a bounds check exception. *) - Arbitrary_effects, Has_coeffects - | Psetfield _ - | Psetfield_computed _ - | Psetfloatfield _ - | Psetglobal _ - | Parraysetu _ - | Parraysets _ - | Pbytessetu - | Pbytessets - | Pbytes_set_16 _ - | Pbytes_set_32 _ - | Pbytes_set_64 _ - | Pbigarrayset _ - | Pbigstring_set_16 _ - | Pbigstring_set_32 _ - | Pbigstring_set_64 _ -> - (* Whether or not some of these are "unsafe" is irrelevant; they always - have an effect. *) - Arbitrary_effects, No_coeffects - | Pctconst _ -> No_effects, No_coeffects - | Pbswap16 - | Pbbswap _ -> No_effects, No_coeffects - | Pint_as_pointer -> No_effects, No_coeffects - | Popaque -> Arbitrary_effects, Has_coeffects - | Prevapply - | Pdirapply -> - (* Removed by [Simplif], but there is no reason to prevent using - the current analysis function before/during Simplif. *) - Arbitrary_effects, Has_coeffects - | Psequand - | Psequor -> - (* Removed by [Closure_conversion] in the flambda pipeline. *) - No_effects, No_coeffects - -type return_type = - | Float - | Other - -let return_type_of_primitive (prim:Lambda.primitive) = - match prim with - | Pfloatofint - | Pnegfloat - | Pabsfloat - | Paddfloat - | Psubfloat - | Pmulfloat - | Pdivfloat - | Pfloatfield _ - | Parrayrefu Pfloatarray - | Parrayrefs Pfloatarray -> - Float - | _ -> - Other diff --git a/bytecomp/semantics_of_primitives.mli b/bytecomp/semantics_of_primitives.mli deleted file mode 100644 index c0c2b9aa8f..0000000000 --- a/bytecomp/semantics_of_primitives.mli +++ /dev/null @@ -1,69 +0,0 @@ -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Pierre Chambart, OCamlPro *) -(* Mark Shinwell and Leo White, Jane Street Europe *) -(* *) -(* Copyright 2013--2016 OCamlPro SAS *) -(* Copyright 2014--2016 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. *) -(* *) -(**************************************************************************) - -[@@@ocaml.warning "+a-4-9-30-40-41-42"] - -(** Description of the semantics of primitives, to be used for optimization - purposes. - - "No effects" means that the primitive does not change the observable state - of the world. For example, it must not write to any mutable storage, - call arbitrary external functions or change control flow (e.g. by raising - an exception). Note that allocation is not "No effects" (see below). - - It is assumed in the compiler that applications of primitives with no - effects, whose results are not used, may be eliminated. It is further - assumed that applications of primitives with no effects may be - duplicated (and thus possibly executed more than once). - - (Exceptions arising from allocation points, for example "out of memory" or - exceptions propagated from finalizers or signal handlers, are treated as - "effects out of the ether" and thus ignored for our determination here - of effectfulness. The same goes for floating point operations that may - cause hardware traps on some platforms.) - - "Only generative effects" means that a primitive does not change the - observable state of the world save for possibly affecting the state of - the garbage collector by performing an allocation. Applications of - primitives that only have generative effects and whose results are unused - may be eliminated by the compiler. However, unlike "No effects" - primitives, such applications will never be eligible for duplication. - - "Arbitrary effects" covers all other primitives. - - "No coeffects" means that the primitive does not observe the effects (in - the sense described above) of other expressions. For example, it must not - read from any mutable storage or call arbitrary external functions. - - It is assumed in the compiler that, subject to data dependencies, - expressions with neither effects nor coeffects may be reordered with - respect to other expressions. -*) - -type effects = No_effects | Only_generative_effects | Arbitrary_effects -type coeffects = No_coeffects | Has_coeffects - -(** Describe the semantics of a primitive. This does not take into account of - the (non-)(co)effectfulness of the arguments in a primitive application. - To determine whether such an application is (co)effectful, the arguments - must also be analysed. *) -val for_primitive: Lambda.primitive -> effects * coeffects - -type return_type = - | Float - | Other - -val return_type_of_primitive: Lambda.primitive -> return_type |