Skip to content

Commit

Permalink
flambda-backend: Implement unboxed int literals (ocaml-flambda#2139)
Browse files Browse the repository at this point in the history
* add unboxed int literals

* workaround for matching

* add tests and missing parmatch cases

* fix matching bug

* allocation tests

* mark tests as flambda2

* update native test

* add lambda primitive

* fix test name

* move format function to misc

* correct test flags and remove unused functions

* fix literal roundtrip and add test

* alloc test with large values

* add tests for invalid literals

* refactor constant_integer to not build string all the time

* define and use unboxed_integer alias
  • Loading branch information
alanechang authored Dec 28, 2023
1 parent 4bb4b96 commit 56067cc
Show file tree
Hide file tree
Showing 38 changed files with 586 additions and 174 deletions.
13 changes: 9 additions & 4 deletions asmcomp/cmmgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ let rec transl env e =
| Pbintofint _ | Pintofbint _ | Pcvtbint _ | Pnegbint _
| Paddbint _ | Psubbint _ | Pmulbint _ | Pdivbint _ | Pmodbint _
| Pandbint _ | Porbint _ | Pxorbint _ | Plslbint _ | Plsrbint _
| Pasrbint _ | Pbintcomp (_, _) | Pstring_load _ | Pbytes_load _
| Pbytes_set _ | Pbigstring_load _ | Pbigstring_set _
| Pasrbint _ | Pbintcomp (_, _) | Punboxed_int_comp (_, _) | Pstring_load _
| Pbytes_load _ | Pbytes_set _ | Pbigstring_load _ | Pbigstring_set _
| Punbox_float | Pbox_float _ | Punbox_int _ | Pbox_int _
| Pbbswap _ | Pget_header _), _)
->
Expand Down Expand Up @@ -1030,7 +1030,7 @@ and transl_prim_1 env p arg dbg =
| Pduparray (_, _) | Parrayrefu _ | Parraysetu _
| Parrayrefs _ | Parraysets _ | Paddbint _ | Psubbint _ | Pmulbint _
| Pdivbint _ | Pmodbint _ | Pandbint _ | Porbint _ | Pxorbint _
| Plslbint _ | Plsrbint _ | Pasrbint _ | Pbintcomp (_, _)
| Plslbint _ | Plsrbint _ | Pasrbint _ | Pbintcomp (_, _) | Punboxed_int_comp (_, _)
| Pbigarrayref (_, _, _, _) | Pbigarrayset (_, _, _, _)
| Pbigarraydim _ | Pstring_load _ | Pbytes_load _ | Pbytes_set _
| Pbigstring_load _ | Pbigstring_set _ | Pprobe_is_enabled _)
Expand Down Expand Up @@ -1209,6 +1209,10 @@ and transl_prim_2 env p arg1 arg2 dbg =
tag_int (Cop(Ccmpi cmp,
[transl_unbox_int dbg env bi arg1;
transl_unbox_int dbg env bi arg2], dbg)) dbg
| Punboxed_int_comp(_, cmp) ->
tag_int (Cop(Ccmpi cmp,
[transl env arg1;
transl env arg2], dbg)) dbg
| Patomic_exchange ->
Cop (Cextcall ("caml_atomic_exchange", typ_val, [], false),
[transl env arg1; transl env arg2], dbg)
Expand Down Expand Up @@ -1325,7 +1329,8 @@ and transl_prim_3 env p arg1 arg2 arg3 dbg =
| Pduparray (_, _) | Parraylength _ | Parrayrefu _ | Parrayrefs _
| Pbintofint _ | Pintofbint _ | Pcvtbint _ | Pnegbint _ | Paddbint _
| Psubbint _ | Pmulbint _ | Pdivbint _ | Pmodbint _ | Pandbint _ | Porbint _
| Pxorbint _ | Plslbint _ | Plsrbint _ | Pasrbint _ | Pbintcomp (_, _)
| Pxorbint _ | Plslbint _ | Plsrbint _ | Pasrbint _
| Pbintcomp (_, _) | Punboxed_int_comp (_, _)
| Pbigarrayref (_, _, _, _) | Pbigarrayset (_, _, _, _) | Pbigarraydim _
| Pstring_load _ | Pbytes_load _ | Pbigstring_load _ | Pbbswap _
| Pprobe_is_enabled _
Expand Down
15 changes: 8 additions & 7 deletions bytecomp/bytegen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ let preserve_tailcall_for_prim = function
| Parrayrefs _ | Parraysets _ | Pisint _ | Pisout | Pbintofint _ | Pintofbint _
| Pcvtbint _ | Pnegbint _ | Paddbint _ | Psubbint _ | Pmulbint _ | Pdivbint _
| Pmodbint _ | Pandbint _ | Porbint _ | Pxorbint _ | Plslbint _ | Plsrbint _
| Pasrbint _ | Pbintcomp _ | Pbigarrayref _ | Pbigarrayset _ | Pbigarraydim _
| Pasrbint _ | Pbintcomp _ | Punboxed_int_comp _
| Pbigarrayref _ | Pbigarrayset _ | Pbigarraydim _
| Pstring_load_16 _ | Pstring_load_32 _ | Pstring_load_64 _ | Pstring_load_128 _
| Pbytes_load_16 _ | Pbytes_load_32 _ | Pbytes_load_64 _ | Pbytes_load_128 _
| Pbytes_set_16 _ | Pbytes_set_32 _ | Pbytes_set_64 _ | Pbytes_set_128 _
Expand Down Expand Up @@ -540,12 +541,12 @@ let comp_primitive stack_info p sz args =
| Plslbint(bi,_) -> comp_bint_primitive bi "shift_left" args
| Plsrbint(bi,_) -> comp_bint_primitive bi "shift_right_unsigned" args
| Pasrbint(bi,_) -> comp_bint_primitive bi "shift_right" args
| Pbintcomp(_, Ceq) -> Kccall("caml_equal", 2)
| Pbintcomp(_, Cne) -> Kccall("caml_notequal", 2)
| Pbintcomp(_, Clt) -> Kccall("caml_lessthan", 2)
| Pbintcomp(_, Cgt) -> Kccall("caml_greaterthan", 2)
| Pbintcomp(_, Cle) -> Kccall("caml_lessequal", 2)
| Pbintcomp(_, Cge) -> Kccall("caml_greaterequal", 2)
| Pbintcomp(_, Ceq) | Punboxed_int_comp(_, Ceq) -> Kccall("caml_equal", 2)
| Pbintcomp(_, Cne) | Punboxed_int_comp(_, Cne) -> Kccall("caml_notequal", 2)
| Pbintcomp(_, Clt) | Punboxed_int_comp(_, Clt) -> Kccall("caml_lessthan", 2)
| Pbintcomp(_, Cgt) | Punboxed_int_comp(_, Cgt) -> Kccall("caml_greaterthan", 2)
| Pbintcomp(_, Cle) | Punboxed_int_comp(_, Cle) -> Kccall("caml_lessequal", 2)
| Pbintcomp(_, Cge) | Punboxed_int_comp(_, Cge) -> Kccall("caml_greaterequal", 2)
| Pbigarrayref(_, n, _, _) -> Kccall("caml_ba_get_" ^ Int.to_string n, n + 1)
| Pbigarrayset(_, n, _, _) -> Kccall("caml_ba_set_" ^ Int.to_string n, n + 2)
| Pbigarraydim(n) -> Kccall("caml_ba_dim_" ^ Int.to_string n, 1)
Expand Down
9 changes: 6 additions & 3 deletions bytecomp/symtable.ml
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,12 @@ let rec transl_const = function
| Const_base(Const_string (s, _, _)) -> Obj.repr s
| Const_base(Const_float f)
| Const_base(Const_unboxed_float f) -> Obj.repr (float_of_string f)
| Const_base(Const_int32 i) -> Obj.repr i
| Const_base(Const_int64 i) -> Obj.repr i
| Const_base(Const_nativeint i) -> Obj.repr i
| Const_base(Const_int32 i)
| Const_base(Const_unboxed_int32 i) -> Obj.repr i
| Const_base(Const_int64 i)
| Const_base(Const_unboxed_int64 i) -> Obj.repr i
| Const_base(Const_nativeint i)
| Const_base(Const_unboxed_nativeint i) -> Obj.repr i
| Const_immstring s -> Obj.repr s
| Const_block(tag, fields) ->
let block = Obj.new_block tag (List.length fields) in
Expand Down
12 changes: 8 additions & 4 deletions lambda/lambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ type primitive =
| Plsrbint of boxed_integer * alloc_mode
| Pasrbint of boxed_integer * alloc_mode
| Pbintcomp of boxed_integer * integer_comparison
| Punboxed_int_comp of unboxed_integer * integer_comparison
(* Operations on Bigarrays: (unsafe, #dimensions, kind, layout) *)
| Pbigarrayref of bool * int * bigarray_kind * bigarray_layout
| Pbigarrayset of bool * int * bigarray_kind * bigarray_layout
Expand Down Expand Up @@ -320,6 +321,8 @@ and array_set_kind =
and boxed_integer = Primitive.boxed_integer =
Pnativeint | Pint32 | Pint64

and unboxed_integer = boxed_integer

and vec128_type =
| Unknown128
| Int8x16
Expand Down Expand Up @@ -1523,7 +1526,7 @@ let primitive_may_allocate : primitive -> alloc_mode option = function
| Plslbint (_, m)
| Plsrbint (_, m)
| Pasrbint (_, m) -> Some m
| Pbintcomp _ -> None
| Pbintcomp _ | Punboxed_int_comp _ -> None
| Pbigarrayset _ | Pbigarraydim _ -> None
| Pbigarrayref (_, _, _, _) ->
(* Boxes arising from Bigarray access are always Alloc_heap *)
Expand Down Expand Up @@ -1563,6 +1566,9 @@ let constant_layout: constant -> layout = function
| Const_int32 _ -> Pvalue (Pboxedintval Pint32)
| Const_int64 _ -> Pvalue (Pboxedintval Pint64)
| Const_nativeint _ -> Pvalue (Pboxedintval Pnativeint)
| Const_unboxed_int32 _ -> Punboxed_int Pint32
| Const_unboxed_int64 _ -> Punboxed_int Pint64
| Const_unboxed_nativeint _ -> Punboxed_int Pnativeint
| Const_float _ -> Pvalue Pfloatval
| Const_unboxed_float _ -> Punboxed_float

Expand Down Expand Up @@ -1626,7 +1632,7 @@ let primitive_result_layout (p : primitive) =
| Pstringlength | Pstringrefu | Pstringrefs
| Pbyteslength | Pbytesrefu | Pbytesrefs
| Parraylength _ | Pisint _ | Pisout | Pintofbint _
| Pbintcomp _
| Pbintcomp _ | Punboxed_int_comp _
| Pstring_load_16 _ | Pbytes_load_16 _ | Pbigstring_load_16 _
| Pprobe_is_enabled _ | Pbswap16
-> layout_int
Expand Down Expand Up @@ -1785,5 +1791,3 @@ let may_allocate_in_region lam =
| () -> false
| exception Exit -> true
end


3 changes: 3 additions & 0 deletions lambda/lambda.mli
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ type primitive =
| Plsrbint of boxed_integer * alloc_mode
| Pasrbint of boxed_integer * alloc_mode
| Pbintcomp of boxed_integer * integer_comparison
| Punboxed_int_comp of unboxed_integer * integer_comparison
(* Operations on Bigarrays: (unsafe, #dimensions, kind, layout) *)
| Pbigarrayref of bool * int * bigarray_kind * bigarray_layout
| Pbigarrayset of bool * int * bigarray_kind * bigarray_layout
Expand Down Expand Up @@ -297,6 +298,8 @@ and block_shape =
and boxed_integer = Primitive.boxed_integer =
Pnativeint | Pint32 | Pint64

and unboxed_integer = boxed_integer

and vec128_type =
| Unknown128
| Int8x16
Expand Down
23 changes: 21 additions & 2 deletions lambda/matching.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,10 @@ let can_group discr pat =
| Constant (Const_unboxed_float _), Constant (Const_unboxed_float _)
| Constant (Const_int32 _), Constant (Const_int32 _)
| Constant (Const_int64 _), Constant (Const_int64 _)
| Constant (Const_nativeint _), Constant (Const_nativeint _) ->
| Constant (Const_nativeint _), Constant (Const_nativeint _)
| Constant (Const_unboxed_int32 _), Constant (Const_unboxed_int32 _)
| Constant (Const_unboxed_int64 _), Constant (Const_unboxed_int64 _)
| Constant (Const_unboxed_nativeint _), Constant (Const_unboxed_nativeint _)->
true
| Construct { cstr_tag = Extension _ as discr_tag }, Construct pat_cstr
->
Expand All @@ -1198,7 +1201,8 @@ let can_group discr pat =
( Any
| Constant
( Const_int _ | Const_char _ | Const_string _ | Const_float _
| Const_unboxed_float _ | Const_int32 _ | Const_int64 _ | Const_nativeint _ )
| Const_unboxed_float _ | Const_int32 _ | Const_int64 _ | Const_nativeint _
| Const_unboxed_int32 _ | Const_unboxed_int64 _ | Const_unboxed_nativeint _ )
| Construct _ | Tuple _ | Record _ | Array _ | Variant _ | Lazy ) ) ->
false

Expand Down Expand Up @@ -2889,6 +2893,21 @@ let combine_constant value_kind loc arg cst partial ctx def
(Pbintcomp (Pnativeint, Cne))
(Pbintcomp (Pnativeint, Clt))
arg const_lambda_list
| Const_unboxed_int32 _ ->
make_test_sequence value_kind loc fail
(Punboxed_int_comp (Pint32, Cne))
(Punboxed_int_comp (Pint32, Clt))
arg const_lambda_list
| Const_unboxed_int64 _ ->
make_test_sequence value_kind loc fail
(Punboxed_int_comp (Pint64, Cne))
(Punboxed_int_comp (Pint64, Clt))
arg const_lambda_list
| Const_unboxed_nativeint _ ->
make_test_sequence value_kind loc fail
(Punboxed_int_comp (Pnativeint, Cne))
(Punboxed_int_comp (Pnativeint, Clt))
arg const_lambda_list
in
(lambda1, Jumps.union local_jumps total)

Expand Down
31 changes: 23 additions & 8 deletions lambda/printlambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,23 @@ open Primitive
open Types
open Lambda


let rec struct_const ppf = function
| Const_base(Const_int n) -> fprintf ppf "%i" n
| Const_base(Const_char c) -> fprintf ppf "%C" c
| Const_base(Const_string (s, _, _)) -> fprintf ppf "%S" s
| Const_immstring s -> fprintf ppf "#%S" s
| Const_base(Const_float f) -> fprintf ppf "%s" f
| Const_base(Const_unboxed_float f) ->
let s =
match String.split_on_char '-' f with
| [""; f] -> "-#" ^ f
| [f] -> "#" ^ f
| _ -> Misc.fatal_errorf "Invalid Const_unboxed_float constant: %s" f
in
fprintf ppf "%s" s
fprintf ppf "%s" (Misc.format_as_unboxed_literal f)
| Const_base(Const_int32 n) -> fprintf ppf "%lil" n
| Const_base(Const_int64 n) -> fprintf ppf "%LiL" n
| Const_base(Const_nativeint n) -> fprintf ppf "%nin" n
| Const_base(Const_unboxed_int32 i) ->
fprintf ppf "%sl" (Misc.format_as_unboxed_literal (Int32.to_string i))
| Const_base(Const_unboxed_int64 i) ->
fprintf ppf "%sL" (Misc.format_as_unboxed_literal (Int64.to_string i))
| Const_base(Const_unboxed_nativeint i) ->
fprintf ppf "%sn" (Misc.format_as_unboxed_literal (Nativeint.to_string i))
| Const_block(tag, []) ->
fprintf ppf "[%i]" tag
| Const_block(tag, sc1::scl) ->
Expand Down Expand Up @@ -205,6 +204,15 @@ let boxed_integer_mark name bi m =
let print_boxed_integer name ppf bi m =
fprintf ppf "%s" (boxed_integer_mark name bi m);;

let unboxed_integer_mark name bi m =
match bi with
| Pnativeint -> Printf.sprintf "Nativeint_u.%s%s" name (alloc_kind m)
| Pint32 -> Printf.sprintf "Int32_u.%s%s" name (alloc_kind m)
| Pint64 -> Printf.sprintf "Int64_u.%s%s" name (alloc_kind m)

let print_unboxed_integer name ppf bi m =
fprintf ppf "%s" (unboxed_integer_mark name bi m);;

let print_bigarray name unsafe kind ppf layout =
fprintf ppf "Bigarray.%s[%s,%s]"
(if unsafe then "unsafe_"^ name else name)
Expand Down Expand Up @@ -480,6 +488,12 @@ let primitive ppf = function
| Pbintcomp(bi, Cgt) -> print_boxed_integer ">" ppf bi alloc_heap
| Pbintcomp(bi, Cle) -> print_boxed_integer "<=" ppf bi alloc_heap
| Pbintcomp(bi, Cge) -> print_boxed_integer ">=" ppf bi alloc_heap
| Punboxed_int_comp(bi, Ceq) -> print_unboxed_integer "==" ppf bi alloc_heap
| Punboxed_int_comp(bi, Cne) -> print_unboxed_integer "!=" ppf bi alloc_heap
| Punboxed_int_comp(bi, Clt) -> print_unboxed_integer "<" ppf bi alloc_heap
| Punboxed_int_comp(bi, Cgt) -> print_unboxed_integer ">" ppf bi alloc_heap
| Punboxed_int_comp(bi, Cle) -> print_unboxed_integer "<=" ppf bi alloc_heap
| Punboxed_int_comp(bi, Cge) -> print_unboxed_integer ">=" ppf bi alloc_heap
| Pbigarrayref(unsafe, _n, kind, layout) ->
print_bigarray "get" unsafe kind ppf layout
| Pbigarrayset(unsafe, _n, kind, layout) ->
Expand Down Expand Up @@ -671,6 +685,7 @@ let name_of_primitive = function
| Plsrbint _ -> "Plsrbint"
| Pasrbint _ -> "Pasrbint"
| Pbintcomp _ -> "Pbintcomp"
| Punboxed_int_comp _ -> "Punboxed_int_comp"
| Pbigarrayref _ -> "Pbigarrayref"
| Pbigarrayset _ -> "Pbigarrayset"
| Pbigarraydim _ -> "Pbigarraydim"
Expand Down
2 changes: 1 addition & 1 deletion lambda/tmc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ let rec choice ctx t =
| Pnegint | Paddint | Psubint | Pmulint | Pdivint _ | Pmodint _
| Pandint | Porint | Pxorint
| Plslint | Plsrint | Pasrint
| Pintcomp _
| Pintcomp _ | Punboxed_int_comp _
| Poffsetint _ | Poffsetref _
| Pintoffloat | Pfloatofint _
| Pnegfloat _ | Pabsfloat _
Expand Down
4 changes: 2 additions & 2 deletions lambda/translprim.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1058,8 +1058,8 @@ let lambda_primitive_needs_event_after = function
| Parrayrefu (Pgenarray_ref _ | Pfloatarray_ref _)
| Parrayrefs _ | Parraysets _ | Pbintofint _ | Pcvtbint _ | Pnegbint _
| Paddbint _ | Psubbint _ | Pmulbint _ | Pdivbint _ | Pmodbint _ | Pandbint _
| Porbint _ | Pxorbint _ | Plslbint _ | Plsrbint _ | Pasrbint _ | Pbintcomp _
| Pcompare_bints _
| Porbint _ | Pxorbint _ | Plslbint _ | Plsrbint _ | Pasrbint _
| Pbintcomp _ | Punboxed_int_comp _ | Pcompare_bints _
| Pbigarrayref _ | Pbigarrayset _ | Pbigarraydim _ | Pstring_load_16 _
| Pstring_load_32 _ | Pstring_load_64 _ | Pstring_load_128 _ | Pbytes_load_16 _
| Pbytes_load_32 _ | Pbytes_load_64 _ | Pbytes_load_128 _ | Pbytes_set_16 _
Expand Down
5 changes: 4 additions & 1 deletion middle_end/clambda_primitives.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type primitive =
| Plsrbint of boxed_integer * alloc_mode
| Pasrbint of boxed_integer * alloc_mode
| Pbintcomp of boxed_integer * integer_comparison
| Punboxed_int_comp of unboxed_integer * integer_comparison
(* Operations on big arrays: (unsafe, #dimensions, kind, layout) *)
| Pbigarrayref of bool * int * bigarray_kind * bigarray_layout
| Pbigarrayset of bool * int * bigarray_kind * bigarray_layout
Expand Down Expand Up @@ -191,6 +192,8 @@ and block_shape = Lambda.block_shape
and boxed_integer = Lambda.boxed_integer =
Pnativeint | Pint32 | Pint64

and unboxed_integer = boxed_integer

and vec128_type = Lambda.vec128_type =
| Unknown128
| Int8x16
Expand Down Expand Up @@ -251,7 +254,7 @@ let result_layout (p : primitive) =
| Pstringlength | Pstringrefu | Pstringrefs
| Pbyteslength | Pbytesrefu | Pbytesrefs
| Parraylength _ | Pisint | Pisout | Pintofbint _
| Pbintcomp _
| Pbintcomp _ | Punboxed_int_comp _
| Pprobe_is_enabled _ | Pbswap16
-> Lambda.layout_int
| Parrayrefu array_ref_kind | Parrayrefs array_ref_kind ->
Expand Down
3 changes: 3 additions & 0 deletions middle_end/clambda_primitives.mli
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type primitive =
| Plsrbint of boxed_integer * alloc_mode
| Pasrbint of boxed_integer * alloc_mode
| Pbintcomp of boxed_integer * integer_comparison
| Punboxed_int_comp of unboxed_integer * integer_comparison
(* Operations on big arrays: (unsafe, #dimensions, kind, layout) *)
| Pbigarrayref of bool * int * bigarray_kind * bigarray_layout
| Pbigarrayset of bool * int * bigarray_kind * bigarray_layout
Expand Down Expand Up @@ -195,6 +196,8 @@ and block_shape = Lambda.block_shape
and boxed_integer = Lambda.boxed_integer =
Pnativeint | Pint32 | Pint64

and unboxed_integer = boxed_integer

and vec128_type = Lambda.vec128_type =
| Unknown128
| Int8x16
Expand Down
7 changes: 4 additions & 3 deletions middle_end/closure/closure.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1027,9 +1027,10 @@ let rec close ({ backend; fenv; cenv ; mutable_vars; kinds; catch_env } as env)
| Const_base (Const_string (s, _, _)) ->
str (Uconst_string s)
| Const_base(Const_float x) -> str (Uconst_float (float_of_string x))
| Const_base(Const_unboxed_float _) ->
(* CR alanechang: implement unboxed float constants in closure *)
Misc.fatal_error "Unboxed float constants are not supported in closure. Consider using flambda2."
| Const_base (Const_unboxed_float _ | Const_unboxed_int32 _
| Const_unboxed_int64 _ | Const_unboxed_nativeint _) ->
(* CR alanechang: implement unboxed constants in closure *)
Misc.fatal_error "Unboxed constants are not supported in closure. Consider using flambda2."
| Const_base(Const_int32 x) -> str (Uconst_int32 x)
| Const_base(Const_int64 x) -> str (Uconst_int64 x)
| Const_base(Const_nativeint x) -> str (Uconst_nativeint x)
Expand Down
1 change: 1 addition & 0 deletions middle_end/convert_primitives.ml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ let convert (prim : Lambda.primitive) : Clambda_primitives.primitive =
| Pdivbint { size; is_safe; mode } -> Pdivbint { size; is_safe; mode }
| Pmodbint { size; is_safe; mode } -> Pmodbint { size; is_safe; mode }
| Pbintcomp (bi, comp) -> Pbintcomp (bi, comp)
| Punboxed_int_comp (bi, comp) -> Punboxed_int_comp (bi, comp)
| Pbigarrayref (safe, dims, kind, layout) ->
Pbigarrayref (safe, dims, kind, layout)
| Pbigarrayset (safe, dims, kind, layout) ->
Expand Down
7 changes: 4 additions & 3 deletions middle_end/flambda/closure_conversion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ let rec declare_const t (const : Lambda.structured_constant)
match const with
| Const_base (Const_int c) -> (Const (Int c), Names.const_int)
| Const_base (Const_char c) -> (Const (Char c), Names.const_char)
| Const_base (Const_unboxed_float _) ->
(* CR alanechang: implement unboxed float constants in flambda *)
Misc.fatal_error "Unboxed float constants are not supported in flambda. Consider using flambda2."
| Const_base (Const_unboxed_float _ | Const_unboxed_int32 _
| Const_unboxed_int64 _ | Const_unboxed_nativeint _) ->
(* CR alanechang: implement unboxed constants in flambda *)
Misc.fatal_error "Unboxed constants are not supported in flambda. Consider using flambda2."
| Const_base (Const_string (s, _, _)) ->
let const, name =
(Flambda.Allocated_const (Immutable_string s),
Expand Down
4 changes: 4 additions & 0 deletions middle_end/internal_variable_names.ml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ let pbigstring_set_32 = "Pbigstring_set_32"
let pbigstring_set_64 = "Pbigstring_set_64"
let pbigstring_set_128 = "Pbigstring_set_128"
let pbintcomp = "Pbintcomp"
let punboxed_int_comp = "Punboxed_int_comp"
let pbintofint = "Pbintofint"
let pbswap16 = "Pbswap16"
let pbytes_of_string = "Pbytes_of_string"
Expand Down Expand Up @@ -223,6 +224,7 @@ let pbigstring_set_32_arg = "Pbigstring_set_32_arg"
let pbigstring_set_64_arg = "Pbigstring_set_64_arg"
let pbigstring_set_128_arg = "Pbigstring_set_128_arg"
let pbintcomp_arg = "Pbintcomp_arg"
let punboxed_int_comp_arg = "Punboxed_int_comp_arg"
let pbintofint_arg = "Pbintofint_arg"
let pbswap16_arg = "Pbswap16_arg"
let pbytes_of_string_arg = "Pbytes_of_string_arg"
Expand Down Expand Up @@ -456,6 +458,7 @@ let of_primitive : Lambda.primitive -> string = function
| Plsrbint _ -> plsrbint
| Pasrbint _ -> pasrbint
| Pbintcomp _ -> pbintcomp
| Punboxed_int_comp _ -> punboxed_int_comp
| Pbigarrayref _ -> pbigarrayref
| Pbigarrayset _ -> pbigarrayset
| Pbigarraydim _ -> pbigarraydim
Expand Down Expand Up @@ -591,6 +594,7 @@ let of_primitive_arg : Lambda.primitive -> string = function
| Plsrbint _ -> plsrbint_arg
| Pasrbint _ -> pasrbint_arg
| Pbintcomp _ -> pbintcomp_arg
| Punboxed_int_comp _ -> punboxed_int_comp_arg
| Pbigarrayref _ -> pbigarrayref_arg
| Pbigarrayset _ -> pbigarrayset_arg
| Pbigarraydim _ -> pbigarraydim_arg
Expand Down
Loading

0 comments on commit 56067cc

Please sign in to comment.