Skip to content

Commit 64127d1

Browse files
committed
squash for review
1 parent 6aa3b7a commit 64127d1

Some content is hidden

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

46 files changed

+2691
-75
lines changed

middle_end/flambda2/from_lambda/closure_conversion.ml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ type close_functions_result =
5353
type declare_const_result =
5454
| Field of Field_of_static_block.t
5555
| Unboxed_float of Numeric_types.Float_by_bit_pattern.t
56+
| Unboxed_float32 of Numeric_types.Float32_by_bit_pattern.t
5657
| Unboxed_int32 of Numeric_types.Int32.t
5758
| Unboxed_int64 of Numeric_types.Int64.t
5859
| Unboxed_nativeint of Targetint_32_64.t
@@ -111,8 +112,11 @@ let rec declare_const acc (const : Lambda.structured_constant) :
111112
| Const_base (Const_char c) ->
112113
acc, Field (Tagged_immediate (Targetint_31_63.of_char c)), "char"
113114
| Const_base (Const_unboxed_float c) ->
114-
let c = Numeric_types.Float_by_bit_pattern.create (float_of_string c) in
115+
let c = Numeric_types.Float_by_bit_pattern.of_string c in
115116
acc, Unboxed_float c, "unboxed_float"
117+
| Const_base (Const_unboxed_float32 c) ->
118+
let c = Numeric_types.Float32_by_bit_pattern.of_string c in
119+
acc, Unboxed_float32 c, "unboxed_float32"
116120
| Const_base (Const_string (s, _, _)) ->
117121
register_const acc (SC.immutable_string s) "immstring"
118122
| Const_base (Const_float c) ->
@@ -165,8 +169,8 @@ let rec declare_const acc (const : Lambda.structured_constant) :
165169
let acc, f, _ = declare_const acc c in
166170
match f with
167171
| Field f -> acc, f
168-
| Unboxed_float _ | Unboxed_int32 _ | Unboxed_int64 _
169-
| Unboxed_nativeint _ ->
172+
| Unboxed_float _ | Unboxed_float32 _ | Unboxed_int32 _
173+
| Unboxed_int64 _ | Unboxed_nativeint _ ->
170174
Misc.fatal_errorf
171175
"Unboxed constants are not allowed inside of Const_block: %a"
172176
Printlambda.structured_constant const)
@@ -190,6 +194,11 @@ let close_const0 acc (const : Lambda.structured_constant) =
190194
Simple.const (Reg_width_const.naked_float f),
191195
name,
192196
Flambda_kind.With_subkind.naked_float )
197+
| Unboxed_float32 f ->
198+
( acc,
199+
Simple.const (Reg_width_const.naked_float32 f),
200+
name,
201+
Flambda_kind.With_subkind.naked_float32 )
193202
| Unboxed_int32 i ->
194203
( acc,
195204
Simple.const (Reg_width_const.naked_int32 i),

middle_end/flambda2/to_cmm/to_cmm_shared.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ let machtype_of_kind (kind : Flambda_kind.With_subkind.t) =
5151
| Immediate_array | Unboxed_int32_array | Unboxed_int64_array
5252
| Unboxed_nativeint_array | Value_array | Generic_array ->
5353
Cmm.typ_val)
54-
| Naked_number (Naked_float | Naked_float32) -> Cmm.typ_float
54+
| Naked_number Naked_float -> Cmm.typ_float
55+
| Naked_number Naked_float32 -> Cmm.typ_float32
5556
| Naked_number Naked_vec128 -> Cmm.typ_vec128
5657
| Naked_number (Naked_immediate | Naked_int32 | Naked_int64 | Naked_nativeint)
5758
->
@@ -68,7 +69,8 @@ let extended_machtype_of_kind (kind : Flambda_kind.With_subkind.t) =
6869
| Immediate_array | Unboxed_int32_array | Unboxed_int64_array
6970
| Unboxed_nativeint_array | Value_array | Generic_array ->
7071
Extended_machtype.typ_val)
71-
| Naked_number (Naked_float32 | Naked_float) -> Extended_machtype.typ_float
72+
| Naked_number Naked_float -> Extended_machtype.typ_float
73+
| Naked_number Naked_float32 -> Extended_machtype.typ_float32
7274
| Naked_number Naked_vec128 -> Extended_machtype.typ_vec128
7375
| Naked_number (Naked_immediate | Naked_int32 | Naked_int64 | Naked_nativeint)
7476
->

ocaml/asmcomp/cmmgen.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,15 @@ let exttype_of_sort (s : Jkind.Sort.const) =
363363
| Bits32 -> XInt32
364364
| Bits64 -> XInt64
365365
| Void -> Misc.fatal_error "Cmmgen.exttype_of_sort: void encountered"
366+
| Float32 -> Misc.fatal_error "Cmmgen.machtype_of_sort: float32 encountered"
366367

367368
let machtype_of_sort (s : Jkind.Sort.const) =
368369
match s with
369370
| Value -> typ_val
370371
| Float64 -> typ_float
371372
| Word | Bits32 | Bits64 -> typ_int
372373
| Void -> Misc.fatal_error "Cmmgen.machtype_of_sort: void encountered"
374+
| Float32 -> Misc.fatal_error "Cmmgen.machtype_of_sort: float32 encountered"
373375

374376
let is_unboxed_number_cmm ~strict cmm =
375377
let r = ref No_result in

ocaml/bytecomp/symtable.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ let rec transl_const = function
152152
Const_base(Const_int i) -> Obj.repr i
153153
| Const_base(Const_char c) -> Obj.repr c
154154
| Const_base(Const_string (s, _, _)) -> Obj.repr s
155-
| Const_base(Const_float32 f) -> float32_of_string f
155+
| Const_base(Const_float32 f)
156+
| Const_base(Const_unboxed_float32 f) -> float32_of_string f
156157
| Const_base(Const_float f)
157158
| Const_base(Const_unboxed_float f) -> Obj.repr (float_of_string f)
158159
| Const_base(Const_int32 i)

ocaml/lambda/lambda.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,7 @@ let constant_layout: constant -> layout = function
17481748
| Const_float _ -> Pvalue (Pboxedfloatval Pfloat64)
17491749
| Const_float32 _ -> Pvalue (Pboxedfloatval Pfloat32)
17501750
| Const_unboxed_float _ -> Punboxed_float Pfloat64
1751+
| Const_unboxed_float32 _ -> Punboxed_float Pfloat32
17511752

17521753
let structured_constant_layout = function
17531754
| Const_base const -> constant_layout const
@@ -1763,6 +1764,7 @@ let layout_of_extern_repr : extern_repr -> _ = function
17631764
begin match s with
17641765
| Value -> layout_any_value
17651766
| Float64 -> layout_unboxed_float Pfloat64
1767+
| Float32 -> layout_unboxed_float Pfloat32
17661768
| Word -> layout_unboxed_nativeint
17671769
| Bits32 -> layout_unboxed_int32
17681770
| Bits64 -> layout_unboxed_int64

ocaml/lambda/matching.ml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,7 @@ let can_group discr pat =
11601160
| Constant (Const_float _), Constant (Const_float _)
11611161
| Constant (Const_float32 _), Constant (Const_float32 _)
11621162
| Constant (Const_unboxed_float _), Constant (Const_unboxed_float _)
1163+
| Constant (Const_unboxed_float32 _), Constant (Const_unboxed_float32 _)
11631164
| Constant (Const_int32 _), Constant (Const_int32 _)
11641165
| Constant (Const_int64 _), Constant (Const_int64 _)
11651166
| Constant (Const_nativeint _), Constant (Const_nativeint _)
@@ -1186,9 +1187,10 @@ let can_group discr pat =
11861187
( Any
11871188
| Constant
11881189
( Const_int _ | Const_char _ | Const_string _ | Const_float _
1189-
| Const_float32 _ | Const_unboxed_float _ | Const_int32 _
1190-
| Const_int64 _ | Const_nativeint _ | Const_unboxed_int32 _
1191-
| Const_unboxed_int64 _ | Const_unboxed_nativeint _ )
1190+
| Const_float32 _ | Const_unboxed_float _ | Const_unboxed_float32 _
1191+
| Const_int32 _ | Const_int64 _ | Const_nativeint _
1192+
| Const_unboxed_int32 _ | Const_unboxed_int64 _
1193+
| Const_unboxed_nativeint _ )
11921194
| Construct _ | Tuple _ | Record _ | Array _ | Variant _ | Lazy ) ) ->
11931195
false
11941196

@@ -2891,7 +2893,7 @@ let combine_constant value_kind loc arg cst partial ctx def
28912893
make_test_sequence value_kind loc fail (Pfloatcomp (Pfloat64, CFneq))
28922894
(Pfloatcomp (Pfloat64, CFlt)) arg
28932895
const_lambda_list
2894-
| Const_float32 _ ->
2896+
| Const_float32 _ | Const_unboxed_float32 _ ->
28952897
(* Should be caught in do_compile_matching. *)
28962898
Misc.fatal_error "Found unexpected float32 literal pattern."
28972899
| Const_unboxed_float _ ->
@@ -3567,7 +3569,8 @@ and do_compile_matching ~scopes value_kind repr partial ctx pmh =
35673569
compile_no_test ~scopes value_kind
35683570
(divide_record ~scopes lbl.lbl_all ph)
35693571
Context.combine repr partial ctx pm
3570-
| Constant (Const_float32 _) -> Parmatch.raise_matched_float32 ()
3572+
| Constant (Const_float32 _ | Const_unboxed_float32 _) ->
3573+
Parmatch.raise_matched_float32 ()
35713574
| Constant cst ->
35723575
compile_test
35733576
(compile_match ~scopes value_kind repr partial)

ocaml/lambda/printlambda.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ let rec struct_const ppf = function
2525
| Const_base(Const_string (s, _, _)) -> fprintf ppf "%S" s
2626
| Const_immstring s -> fprintf ppf "#%S" s
2727
| Const_base(Const_float f) -> fprintf ppf "%s" f
28-
| Const_base(Const_float32 f) -> fprintf ppf "%s" f
28+
| Const_base(Const_float32 f) -> fprintf ppf "%ss" f
2929
| Const_base(Const_unboxed_float f) ->
3030
fprintf ppf "%s" (Misc.format_as_unboxed_literal f)
31+
| Const_base(Const_unboxed_float32 f) ->
32+
fprintf ppf "%ss" (Misc.format_as_unboxed_literal f)
3133
| Const_base(Const_int32 n) -> fprintf ppf "%lil" n
3234
| Const_base(Const_int64 n) -> fprintf ppf "%LiL" n
3335
| Const_base(Const_nativeint n) -> fprintf ppf "%nin" n

ocaml/lambda/translcore.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ let layout_pat sort p = layout p.pat_env p.pat_loc sort p.pat_type
5656
let check_record_field_sort loc sort =
5757
match Jkind.Sort.get_default_value sort with
5858
| Value | Float64 | Bits32 | Bits64 | Word -> ()
59+
| Float32 ->
60+
(* CR mslater: (float32) float32# records *)
61+
Misc.fatal_error "Found unboxed float32 record field."
5962
| Void -> raise (Error (loc, Illegal_void_record_field))
6063

6164
(* Forward declaration -- to be filled in by Translmod.transl_module *)

ocaml/lambda/translprim.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,10 @@ let lookup_primitive loc ~poly_mode ~poly_sort pos p =
700700
| "%obj_magic" -> Primitive(Pobj_magic layout, 1)
701701
| "%array_to_iarray" -> Primitive (Parray_to_iarray, 1)
702702
| "%array_of_iarray" -> Primitive (Parray_of_iarray, 1)
703-
(* CR mslater: (float32) unboxed *)
704703
| "%unbox_float" -> Primitive(Punbox_float Pfloat64, 1)
705704
| "%box_float" -> Primitive(Pbox_float (Pfloat64, mode), 1)
705+
| "%unbox_float32" -> Primitive(Punbox_float Pfloat32, 1)
706+
| "%box_float32" -> Primitive(Pbox_float (Pfloat32, mode), 1)
706707
| "%get_header" -> Primitive (Pget_header mode, 1)
707708
| "%atomic_load" ->
708709
Primitive ((Patomic_load {immediate_or_pointer=Pointer}), 1)

ocaml/middle_end/closure/closure.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ let rec close ({ backend; fenv; cenv ; mutable_vars; kinds; catch_env } as env)
10271027
| Const_base (Const_string (s, _, _)) ->
10281028
str (Uconst_string s)
10291029
| Const_base(Const_float x) -> str (Uconst_float (float_of_string x))
1030-
| Const_base(Const_float32 _) ->
1030+
| Const_base(Const_float32 _ | Const_unboxed_float32 _) ->
10311031
Misc.fatal_error "float32 is not supported in closure. Consider using flambda2."
10321032
| Const_base (Const_unboxed_float _ | Const_unboxed_int32 _
10331033
| Const_unboxed_int64 _ | Const_unboxed_nativeint _) ->

ocaml/middle_end/flambda/closure_conversion.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ let rec declare_const t (const : Lambda.structured_constant)
137137
register_const t
138138
(Allocated_const (Float (float_of_string c)))
139139
Names.const_float
140-
| Const_base (Const_float32 _) ->
141-
Misc.fatal_error "float32 is not supported in closure. Consider using flambda2."
140+
| Const_base (Const_float32 _ | Const_unboxed_float32 _) ->
141+
Misc.fatal_error "float32 is not supported in flambda. Consider using flambda2."
142142
| Const_base (Const_int32 c) ->
143143
register_const t (Allocated_const (Int32 c))
144144
Names.const_int32

ocaml/otherlibs/alpha/alpha.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
module Float32 = Float32
2+
module Float32_u = Float32_u

ocaml/otherlibs/alpha/alpha.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
module Float32 = Float32
2+
module Float32_u = Float32_u

ocaml/otherlibs/alpha/dune

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,18 @@
4242
(alpha.cma as alpha/alpha.cma)
4343
(alpha.mli as alpha/alpha.mli)
4444
(float32.mli as alpha/float32.mli)
45+
(float32_u.mli as alpha/float32_u.mli)
4546
(.alpha.objs/byte/alpha.cmi as alpha/alpha.cmi)
4647
(.alpha.objs/byte/alpha.cmt as alpha/alpha.cmt)
4748
(.alpha.objs/byte/alpha.cmti as alpha/alpha.cmti)
4849
(.alpha.objs/native/alpha.cmx as alpha/alpha.cmx)
4950
(.alpha.objs/byte/float32.cmi as alpha/float32.cmi)
5051
(.alpha.objs/byte/float32.cmt as alpha/float32.cmt)
5152
(.alpha.objs/byte/float32.cmti as alpha/float32.cmti)
52-
(.alpha.objs/native/float32.cmx as alpha/float32.cmx))
53+
(.alpha.objs/native/float32.cmx as alpha/float32.cmx)
54+
(.alpha.objs/byte/float32_u.cmi as alpha/float32_u.cmi)
55+
(.alpha.objs/byte/float32_u.cmt as alpha/float32_u.cmt)
56+
(.alpha.objs/byte/float32_u.cmti as alpha/float32_u.cmti)
57+
(.alpha.objs/native/float32_u.cmx as alpha/float32_u.cmx))
5358
(section lib)
5459
(package ocaml))

0 commit comments

Comments
 (0)