Skip to content

Commit 3ed2d4d

Browse files
authored
flambda-backend: Rename Float to Float_boxed in flat suffix variant (#2590)
* Rename identifiers * make fmt
1 parent 0b675b2 commit 3ed2d4d

File tree

10 files changed

+63
-32
lines changed

10 files changed

+63
-32
lines changed

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;

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

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

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"

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

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>")

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

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,

typing/types.ml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,15 @@ and abstract_reason =
283283
Abstract_def
284284
| Abstract_rec_check_regularity
285285

286-
and flat_element = Imm | Float | Float64 | Float32 | Bits32 | Bits64 | Word
286+
and flat_element =
287+
| Imm
288+
| Float_boxed
289+
| Float64
290+
| Float32
291+
| Bits32
292+
| Bits64
293+
| Word
294+
287295
and mixed_product_shape =
288296
{ value_prefix_len : int;
289297
flat_suffix : flat_element array;
@@ -579,20 +587,20 @@ let equal_tag t1 t2 =
579587

580588
let equal_flat_element e1 e2 =
581589
match e1, e2 with
582-
| Imm, Imm | Float64, Float64 | Float32, Float32 | Float, Float
590+
| Imm, Imm | Float64, Float64 | Float32, Float32 | Float_boxed, Float_boxed
583591
| Word, Word | Bits32, Bits32 | Bits64, Bits64
584592
-> true
585-
| (Imm | Float64 | Float32 | Float | Word | Bits32 | Bits64), _ -> false
593+
| (Imm | Float64 | Float32 | Float_boxed | Word | Bits32 | Bits64), _ -> false
586594

587595
let compare_flat_element e1 e2 =
588596
match e1, e2 with
589-
| Imm, Imm | Float, Float | Float64, Float64 | Float32, Float32
597+
| Imm, Imm | Float_boxed, Float_boxed | Float64, Float64 | Float32, Float32
590598
| Word, Word | Bits32, Bits32 | Bits64, Bits64
591599
-> 0
592600
| Imm, _ -> -1
593601
| _, Imm -> 1
594-
| Float, _ -> -1
595-
| _, Float -> 1
602+
| Float_boxed, _ -> -1
603+
| _, Float_boxed -> 1
596604
| Float64, _ -> -1
597605
| _, Float64 -> 1
598606
| Float32, _ -> -1
@@ -729,7 +737,7 @@ let get_mixed_product_element { value_prefix_len; flat_suffix } i =
729737

730738
let flat_element_to_string = function
731739
| Imm -> "Imm"
732-
| Float -> "Float"
740+
| Float_boxed -> "Float_boxed"
733741
| Float32 -> "Float32"
734742
| Float64 -> "Float64"
735743
| Bits32 -> "Bits32"
@@ -738,7 +746,7 @@ let flat_element_to_string = function
738746

739747
let flat_element_to_lowercase_string = function
740748
| Imm -> "imm"
741-
| Float -> "float"
749+
| Float_boxed -> "float"
742750
| Float32 -> "float32"
743751
| Float64 -> "float64"
744752
| Bits32 -> "bits32"

typing/types.mli

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,16 @@ and abstract_reason =
565565
non-empty suffix of "flat" elements. Intuitively, a flat element is one that
566566
need not be scanned by the garbage collector.
567567
*)
568-
and flat_element = Imm | Float | Float64 | Float32 | Bits32 | Bits64 | Word
568+
and flat_element =
569+
| Imm
570+
| Float_boxed
571+
(* A [Float_boxed] is a float that's stored flat but boxed upon projection. *)
572+
| Float64
573+
| Float32
574+
| Bits32
575+
| Bits64
576+
| Word
577+
569578
and mixed_product_shape =
570579
{ value_prefix_len : int;
571580
(* We use an array just so we can index into the middle. *)

0 commit comments

Comments
 (0)