Skip to content

Commit 5401722

Browse files
authored
Rename Float to Float_boxed in flat suffix variant (#2590)
* Rename identifiers * make fmt
1 parent a42782f commit 5401722

File tree

16 files changed

+82
-50
lines changed

16 files changed

+82
-50
lines changed

backend/cmm_helpers.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ let make_mixed_alloc ~mode dbg tag shape args =
15941594
else
15951595
match flat_suffix.(idx - value_prefix_len) with
15961596
| Imm -> int_array_set arr ofs newval dbg
1597-
| Float | Float64 -> float_array_set arr ofs newval dbg
1597+
| Float_boxed | Float64 -> float_array_set arr ofs newval dbg
15981598
| Float32 -> setfield_unboxed_float32 arr ofs newval dbg
15991599
| Bits32 -> setfield_unboxed_int32 arr ofs newval dbg
16001600
| Bits64 | Word -> setfield_unboxed_int64_or_nativeint arr ofs newval dbg

middle_end/flambda2/from_lambda/lambda_to_flambda_primitives.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ let convert_lprim ~big_endian (prim : L.primitive) (args : Simple.t list list)
994994
| Value_prefix
995995
| Flat_suffix (Float64 | Float32 | Imm | Bits32 | Bits64 | Word) ->
996996
arg
997-
| Flat_suffix Float -> unbox_float arg)
997+
| Flat_suffix Float_boxed -> unbox_float arg)
998998
args
999999
in
10001000
let mode = Alloc_mode.For_allocations.from_lambda mode ~current_region in
@@ -1463,7 +1463,7 @@ let convert_lprim ~big_endian (prim : L.primitive) (args : Simple.t list list)
14631463
(match read with
14641464
| Flat_read flat_element ->
14651465
P.Mixed_block_flat_element.from_lambda flat_element
1466-
| Flat_read_float _ -> Float)
1466+
| Flat_read_float_boxed _ -> Float_boxed)
14671467
in
14681468
Mixed { tag = Unknown; field_kind; size = Unknown }
14691469
in
@@ -1472,7 +1472,7 @@ let convert_lprim ~big_endian (prim : L.primitive) (args : Simple.t list list)
14721472
in
14731473
match read with
14741474
| Mread_value_prefix _ | Mread_flat_suffix (Flat_read _) -> [block_access]
1475-
| Mread_flat_suffix (Flat_read_float mode) ->
1475+
| Mread_flat_suffix (Flat_read_float_boxed mode) ->
14761476
[box_float mode block_access ~current_region])
14771477
| ( Psetfield (index, immediate_or_pointer, initialization_or_assignment),
14781478
[[block]; [value]] ) ->
@@ -1535,7 +1535,7 @@ let convert_lprim ~big_endian (prim : L.primitive) (args : Simple.t list list)
15351535
| Mwrite_value_prefix _
15361536
| Mwrite_flat_suffix (Imm | Float64 | Float32 | Bits32 | Bits64 | Word) ->
15371537
value
1538-
| Mwrite_flat_suffix Float -> unbox_float value
1538+
| Mwrite_flat_suffix Float_boxed -> unbox_float value
15391539
in
15401540
[ Ternary
15411541
(Block_set (block_access, init_or_assign), block, Simple field, value)

middle_end/flambda2/terms/code_size.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ let block_set (kind : Flambda_primitive.Block_access_kind.t)
163163
{ field_kind =
164164
( Value_prefix _
165165
| Flat_suffix
166-
(Imm | Float | Float64 | Float32 | Bits32 | Bits64 | Word) );
166+
(Imm | Float_boxed | Float64 | Float32 | Bits32 | Bits64 | Word)
167+
);
167168
_
168169
},
169170
(Assignment _ | Initialization) ) ->

middle_end/flambda2/terms/flambda_primitive.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ end
6161
module Mixed_block_flat_element = struct
6262
type t =
6363
| Imm
64-
| Float
64+
| Float_boxed
6565
| Float64
6666
| Float32
6767
| Bits32
@@ -70,7 +70,7 @@ module Mixed_block_flat_element = struct
7070

7171
let from_lambda : Lambda.flat_element -> t = function
7272
| Imm -> Imm
73-
| Float -> Float
73+
| Float_boxed -> Float_boxed
7474
| Float64 -> Float64
7575
| Float32 -> Float32
7676
| Bits32 -> Bits32
@@ -79,7 +79,7 @@ module Mixed_block_flat_element = struct
7979

8080
let to_lambda : t -> Lambda.flat_element = function
8181
| Imm -> Imm
82-
| Float -> Float
82+
| Float_boxed -> Float_boxed
8383
| Float64 -> Float64
8484
| Float32 -> Float32
8585
| Bits32 -> Bits32
@@ -88,7 +88,7 @@ module Mixed_block_flat_element = struct
8888

8989
let to_string = function
9090
| Imm -> "Imm"
91-
| Float -> "Float"
91+
| Float_boxed -> "Float_boxed"
9292
| Float64 -> "Float64"
9393
| Float32 -> "Float32"
9494
| Bits32 -> "Bits32"
@@ -98,7 +98,7 @@ module Mixed_block_flat_element = struct
9898
let compare t1 t2 =
9999
match t1, t2 with
100100
| Imm, Imm
101-
| Float, Float
101+
| Float_boxed, Float_boxed
102102
| Float64, Float64
103103
| Float32, Float32
104104
| Word, Word
@@ -107,8 +107,8 @@ module Mixed_block_flat_element = struct
107107
0
108108
| Imm, _ -> -1
109109
| _, Imm -> 1
110-
| Float, _ -> -1
111-
| _, Float -> 1
110+
| Float_boxed, _ -> -1
111+
| _, Float_boxed -> 1
112112
| Float64, _ -> -1
113113
| _, Float64 -> 1
114114
| Float32, _ -> -1
@@ -122,7 +122,7 @@ module Mixed_block_flat_element = struct
122122

123123
let element_kind = function
124124
| Imm -> K.value
125-
| Float | Float64 -> K.naked_float
125+
| Float_boxed | Float64 -> K.naked_float
126126
| Float32 -> K.naked_float32
127127
| Bits32 -> K.naked_int32
128128
| Bits64 -> K.naked_int64
@@ -539,7 +539,7 @@ module Block_access_kind = struct
539539
| Mixed { field_kind = Flat_suffix field_kind; _ } -> (
540540
match field_kind with
541541
| Imm -> K.With_subkind.tagged_immediate
542-
| Float | Float64 -> K.With_subkind.naked_float
542+
| Float_boxed | Float64 -> K.With_subkind.naked_float
543543
| Float32 -> K.With_subkind.naked_float32
544544
| Bits32 -> K.With_subkind.naked_int32
545545
| Bits64 -> K.With_subkind.naked_int64

middle_end/flambda2/terms/flambda_primitive.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ end
6565
module Mixed_block_flat_element : sig
6666
type t =
6767
| Imm
68-
| Float
68+
| Float_boxed
6969
| Float64
7070
| Float32
7171
| Bits32

middle_end/flambda2/to_cmm/to_cmm_primitive.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ let block_load ~dbg (kind : P.Block_access_kind.t) (mutability : Mutability.t)
107107
| Mixed { field_kind = Flat_suffix field_kind; _ } -> (
108108
match field_kind with
109109
| Imm -> C.get_field_computed Immediate mutability ~block ~index dbg
110-
| Float | Float64 ->
110+
| Float_boxed | Float64 ->
111111
(* CR layouts v5.1: We should use the mutability here to generate better
112112
code if the load is immutable. *)
113113
C.unboxed_float_array_ref block index dbg
@@ -132,7 +132,7 @@ let block_set ~dbg (kind : P.Block_access_kind.t) (init : P.Init_or_assign.t)
132132
match field_kind with
133133
| Imm ->
134134
C.setfield_computed Immediate init_or_assign block index new_value dbg
135-
| Float | Float64 -> C.float_array_set block index new_value dbg
135+
| Float_boxed | Float64 -> C.float_array_set block index new_value dbg
136136
| Float32 -> C.setfield_unboxed_float32 block index new_value dbg
137137
| Bits32 -> C.setfield_unboxed_int32 block index new_value dbg
138138
| Bits64 | Word ->

ocaml/lambda/lambda.ml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,17 @@ and block_shape =
343343
value_kind list option
344344

345345
and flat_element = Types.flat_element =
346-
Imm | Float | Float64 | Float32 | Bits32 | Bits64 | Word
346+
| Imm
347+
| Float_boxed
348+
| Float64
349+
| Float32
350+
| Bits32
351+
| Bits64
352+
| Word
353+
347354
and flat_element_read =
348355
| Flat_read of flat_element (* invariant: not [Float] *)
349-
| Flat_read_float of alloc_mode
356+
| Flat_read_float_boxed of alloc_mode
350357
and mixed_block_read =
351358
| Mread_value_prefix of immediate_or_pointer
352359
| Mread_flat_suffix of flat_element_read
@@ -1264,11 +1271,11 @@ let get_mixed_block_element = Types.get_mixed_product_element
12641271

12651272
let flat_read_non_float flat_element =
12661273
match flat_element with
1267-
| Float -> Misc.fatal_error "flat_element_read_non_float Float"
1274+
| Float_boxed -> Misc.fatal_error "flat_element_read_non_float Float_boxed"
12681275
| Imm | Float64 | Float32 | Bits32 | Bits64 | Word as flat_element ->
12691276
Flat_read flat_element
12701277

1271-
let flat_read_float alloc_mode = Flat_read_float alloc_mode
1278+
let flat_read_float_boxed alloc_mode = Flat_read_float_boxed alloc_mode
12721279

12731280
(* Compile a sequence of expressions *)
12741281

@@ -1674,7 +1681,7 @@ let primitive_may_allocate : primitive -> alloc_mode option = function
16741681
| Pmixedfield (_, read, _) -> begin
16751682
match read with
16761683
| Mread_value_prefix _ -> None
1677-
| Mread_flat_suffix (Flat_read_float m) -> Some m
1684+
| Mread_flat_suffix (Flat_read_float_boxed m) -> Some m
16781685
| Mread_flat_suffix (Flat_read _) -> None
16791686
end
16801687
| Psetfloatfield _ -> None
@@ -1824,7 +1831,7 @@ let array_ref_kind_result_layout = function
18241831
let layout_of_mixed_field (kind : mixed_block_read) =
18251832
match kind with
18261833
| Mread_value_prefix _ -> layout_value_field
1827-
| Mread_flat_suffix (Flat_read_float (_ : alloc_mode)) ->
1834+
| Mread_flat_suffix (Flat_read_float_boxed (_ : alloc_mode)) ->
18281835
layout_boxed_float Pfloat64
18291836
| Mread_flat_suffix (Flat_read proj) ->
18301837
match proj with
@@ -1834,7 +1841,7 @@ let layout_of_mixed_field (kind : mixed_block_read) =
18341841
| Bits32 -> layout_unboxed_int32
18351842
| Bits64 -> layout_unboxed_int64
18361843
| Word -> layout_unboxed_nativeint
1837-
| Float -> layout_boxed_float Pfloat64
1844+
| Float_boxed -> layout_boxed_float Pfloat64
18381845

18391846
let primitive_result_layout (p : primitive) =
18401847
assert !Clflags.native_code;

ocaml/lambda/lambda.mli

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,17 @@ and block_shape =
351351
value_kind list option
352352

353353
and flat_element = Types.flat_element =
354-
Imm | Float | Float64 | Float32 | Bits32 | Bits64 | Word
354+
| Imm
355+
| Float_boxed
356+
| Float64
357+
| Float32
358+
| Bits32
359+
| Bits64
360+
| Word
361+
355362
and flat_element_read = private
356363
| Flat_read of flat_element (* invariant: not [Float] *)
357-
| Flat_read_float of alloc_mode
364+
| Flat_read_float_boxed of alloc_mode
358365
and mixed_block_read =
359366
| Mread_value_prefix of immediate_or_pointer
360367
| Mread_flat_suffix of flat_element_read
@@ -606,7 +613,7 @@ type lambda =
606613
a subset of those open at the point of the [Lstaticraise] that jumps to it,
607614
as we can't reopen closed regions. All regions that were open at the point of
608615
the [Lstaticraise] but not in the handler will be closed just before the [Lstaticraise].
609-
616+
610617
However, to be able to express the fact
611618
that the [Lstaticraise] might be under a [Lexclave], the [pop_region] flag
612619
is used to specify what regions are considered open in the handler. If it
@@ -838,9 +845,9 @@ type mixed_block_element =
838845
(** Raises if the int is out of bounds. *)
839846
val get_mixed_block_element : mixed_block_shape -> int -> mixed_block_element
840847

841-
(** Raises if [flat_element] is float. *)
848+
(** Raises if [flat_element] is [Float_boxed]. *)
842849
val flat_read_non_float : flat_element -> flat_element_read
843-
val flat_read_float : alloc_mode -> flat_element_read
850+
val flat_read_float_boxed : alloc_mode -> flat_element_read
844851

845852
val make_sequence: ('a -> lambda) -> 'a list -> lambda
846853

ocaml/lambda/matching.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,7 @@ let get_expr_args_constr ~scopes head (arg, _mut, sort, layout) rem =
18111811
| Flat_suffix flat ->
18121812
let flat_read =
18131813
match flat with
1814-
| Float ->
1814+
| Float_boxed ->
18151815
Misc.fatal_error
18161816
"unexpected flat float of layout value in \
18171817
constructor field"
@@ -2185,9 +2185,9 @@ let get_expr_args_record ~scopes head (arg, _mut, sort, layout) rem =
21852185
match flat_suffix.(pos - value_prefix_len) with
21862186
| Imm | Float64 | Float32 | Bits32 | Bits64 | Word as non_float ->
21872187
flat_read_non_float non_float
2188-
| Float ->
2188+
| Float_boxed ->
21892189
(* TODO: could optimise to Alloc_local sometimes *)
2190-
flat_read_float alloc_heap
2190+
flat_read_float_boxed alloc_heap
21912191
in
21922192
Mread_flat_suffix read
21932193
in

ocaml/lambda/printlambda.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ let flat_element ppf : flat_element -> unit = fun x ->
324324
let flat_element_read ppf : flat_element_read -> unit = function
325325
| Flat_read flat ->
326326
pp_print_string ppf (Types.flat_element_to_lowercase_string flat)
327-
| Flat_read_float m -> fprintf ppf "float[%a]" alloc_mode m
327+
| Flat_read_float_boxed m -> fprintf ppf "float[%a]" alloc_mode m
328328

329329
let mixed_block_read ppf : mixed_block_read -> unit = function
330330
| Mread_value_prefix Immediate -> pp_print_string ppf "value_int"

ocaml/lambda/translcore.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,10 +611,10 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
611611
else
612612
let flat_read =
613613
match flat_suffix.(lbl.lbl_num - value_prefix_len) with
614-
| Float ->
614+
| Float_boxed ->
615615
(match float with
616616
| Boxing (mode, _) ->
617-
flat_read_float (transl_alloc_mode_r mode)
617+
flat_read_float_boxed (transl_alloc_mode_r mode)
618618
| Non_boxing _ ->
619619
Misc.fatal_error
620620
"expected typechecking to make [float] boxing mode\
@@ -1734,11 +1734,11 @@ and transl_record ~scopes loc env mode fields repres opt_init_expr =
17341734
else
17351735
let read =
17361736
match flat_suffix.(lbl.lbl_num - value_prefix_len) with
1737-
| Float ->
1737+
| Float_boxed ->
17381738
(* See the handling of [Record_float] above for
17391739
why we choose Alloc_heap.
17401740
*)
1741-
flat_read_float alloc_heap
1741+
flat_read_float_boxed alloc_heap
17421742
| non_float -> flat_read_non_float non_float
17431743
in
17441744
Mread_flat_suffix read

ocaml/toplevel/genprintval.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ module Make(O : OBJ)(EVP : EVALPATH with type valu = O.t) = struct
580580
match Types.get_mixed_product_element shape pos with
581581
| Value_prefix -> `Continue (O.field obj pos)
582582
| Flat_suffix Imm -> `Continue (O.field obj pos)
583-
| Flat_suffix (Float | Float64) ->
583+
| Flat_suffix (Float_boxed | Float64) ->
584584
`Continue (O.repr (O.double_field obj pos))
585585
| Flat_suffix (Float32 | Bits32 | Bits64 | Word) ->
586586
`Stop (Oval_stuff "<abstr>")

ocaml/typing/typecore.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5738,7 +5738,7 @@ and type_expect_
57385738
| Record_float -> true
57395739
| Record_mixed mixed -> begin
57405740
match Types.get_mixed_product_element mixed label.lbl_num with
5741-
| Flat_suffix Float -> true
5741+
| Flat_suffix Float_boxed -> true
57425742
| Flat_suffix (Float64 | Float32 | Imm | Bits32 | Bits64 | Word) -> false
57435743
| Value_prefix -> false
57445744
end

ocaml/typing/typedecl.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ let update_decl_jkind env dpath decl =
14231423
List.map
14241424
(fun ((repr : Element_repr.t), _lbl) ->
14251425
match repr with
1426-
| Float_element -> Float
1426+
| Float_element -> Float_boxed
14271427
| Unboxed_element Float64 -> Float64
14281428
| Element_without_runtime_component { ty; loc } ->
14291429
raise (Error (loc,

0 commit comments

Comments
 (0)