Skip to content

Allow unboxed float32s in mixed blocks #2550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 216 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
216 commits
Select commit Hold shift + click to select a range
430b6b7
float32 in flambda2
TheNumbat Mar 14, 2024
627203b
fixes
TheNumbat Mar 14, 2024
296e7b8
arm
TheNumbat Mar 14, 2024
a0a2282
more crs
TheNumbat Mar 14, 2024
7458491
primitives
TheNumbat Mar 14, 2024
8644e75
format
TheNumbat Mar 14, 2024
d0342f1
upstream build
TheNumbat Mar 14, 2024
797a7a6
delete array case
TheNumbat Mar 19, 2024
fad1816
casts
TheNumbat Mar 19, 2024
0bd3e82
format
TheNumbat Mar 19, 2024
f195d02
Merge branch 'f32-fl2' into f32-backend
TheNumbat Mar 19, 2024
9c8d442
testsuite cmm parser
TheNumbat Mar 19, 2024
a2af96d
format
TheNumbat Mar 19, 2024
9451a8f
cast fl2
TheNumbat Mar 19, 2024
84e23ff
num conv
TheNumbat Mar 19, 2024
39b36ca
merge
TheNumbat Mar 19, 2024
e42799a
fix name in cfg
TheNumbat Mar 19, 2024
0b86abd
float32 static consts
TheNumbat Mar 19, 2024
2fe6ea4
add test
TheNumbat Mar 19, 2024
7e93f52
fixes
TheNumbat Mar 19, 2024
8d56965
Merge branch 'f32-fl2' into f32-backend
TheNumbat Mar 19, 2024
8ade880
another fix
TheNumbat Mar 19, 2024
7f64da8
Merge branch 'f32-fl2' into f32-backend
TheNumbat Mar 19, 2024
0d24bdd
fix nan test
TheNumbat Mar 19, 2024
0937fc4
actually use cconst_float32
TheNumbat Mar 20, 2024
e7f7b9e
float32 operations
TheNumbat Mar 21, 2024
28c4360
cmm stubs
TheNumbat Mar 21, 2024
ed13892
fix asserts
TheNumbat Mar 21, 2024
2ea3d51
separate storage single and actual float32
TheNumbat Mar 22, 2024
4375a5d
merge
TheNumbat Mar 22, 2024
1da7d02
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Mar 22, 2024
b6662e4
fix cmm test parser again
TheNumbat Mar 22, 2024
3e436c4
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Mar 22, 2024
5b81480
fix operation unboxing
TheNumbat Mar 22, 2024
170a192
oops
TheNumbat Mar 22, 2024
d83be31
comments
TheNumbat Mar 22, 2024
ca93bd7
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Mar 22, 2024
d8663f1
parsecmm again
TheNumbat Mar 22, 2024
e8e169c
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Mar 22, 2024
96403b6
Merge branch 'main' into f32-fl2
TheNumbat Mar 22, 2024
4068688
merge
TheNumbat Mar 22, 2024
15944f5
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Mar 22, 2024
4ff6ad9
fix
TheNumbat Mar 22, 2024
2d2498d
parsecmm again
TheNumbat Mar 22, 2024
52f66d8
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Mar 22, 2024
5ea8e3e
arm
TheNumbat Mar 22, 2024
0ef407b
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Mar 22, 2024
7fbbae6
clean up commit history
TheNumbat Mar 25, 2024
6663075
normalize zero/nan in hash
TheNumbat Mar 26, 2024
3785d6a
Apply suggestions from code review
TheNumbat Mar 26, 2024
62ad563
Update backend/x86_binary_emitter.ml
TheNumbat Apr 1, 2024
3387841
address comments
TheNumbat Apr 2, 2024
134c753
restore copyright headers
TheNumbat Apr 2, 2024
9fa47cd
unify single mem chunks
TheNumbat Apr 2, 2024
d9347fe
fix size_expr f32 const
TheNumbat Apr 2, 2024
a8d5321
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 2, 2024
50aa877
merge
TheNumbat Apr 2, 2024
ccfbe36
merge fix from later pr
TheNumbat Apr 2, 2024
b0d5f27
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 2, 2024
a8f23ed
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 2, 2024
c7437ba
fix comment
TheNumbat Apr 2, 2024
ae04a8e
parsecmm...
TheNumbat Apr 2, 2024
7ea280e
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 2, 2024
d218a6f
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 2, 2024
01c848f
arm build
TheNumbat Apr 2, 2024
ac35a97
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 2, 2024
1f47ecd
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 2, 2024
b13bd15
new machtype component
TheNumbat Apr 2, 2024
300c75a
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 2, 2024
b6f6391
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 2, 2024
062b106
add ext arg test
TheNumbat Apr 2, 2024
1b19d02
fix ext args
TheNumbat Apr 2, 2024
f1daf13
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 2, 2024
bb186b2
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 2, 2024
7eaa6ec
Apply suggestions from code review
TheNumbat Apr 3, 2024
f5766a3
comments
TheNumbat Apr 3, 2024
a42f8f7
use 4b size in selectgen
TheNumbat Apr 3, 2024
380c715
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 3, 2024
9cb2f0f
merge
TheNumbat Apr 3, 2024
e38b256
real f32 ops in f32_by_bit_pattern
TheNumbat Apr 8, 2024
a7b32de
float32 parsing (untested)
TheNumbat Apr 8, 2024
050b46b
install stubs for testsuite
TheNumbat Apr 8, 2024
f899698
merge
TheNumbat Apr 8, 2024
d08462a
merge
TheNumbat Apr 8, 2024
b2ff074
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 8, 2024
5c150cd
merge arm changes
TheNumbat Apr 8, 2024
95bb9b6
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 8, 2024
7d45d1f
Update ocaml/middle_end/flambda/closure_conversion.ml
TheNumbat Apr 9, 2024
64b2663
address comments
TheNumbat Apr 9, 2024
d165586
Merge branch 'f32-fl2' of github.com:ocaml-flambda/flambda-backend in…
TheNumbat Apr 9, 2024
62d2c75
Merge branch 'f32-fl2' into f32-backend
TheNumbat Apr 9, 2024
9eec365
comment
TheNumbat Apr 9, 2024
0f9dae1
Merge branch 'f32-fl2' into f32-backend
TheNumbat Apr 9, 2024
bb618c0
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 9, 2024
66187bb
merge
TheNumbat Apr 9, 2024
cbd71a1
simplify locale defs
TheNumbat Apr 9, 2024
fa7870b
Merge branch 'f32-fl2' into f32-backend
TheNumbat Apr 9, 2024
ebb0d6a
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 9, 2024
5834a7c
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 9, 2024
03ad39a
fix f32 alloc size
TheNumbat Apr 9, 2024
c219e35
fmt
TheNumbat Apr 9, 2024
8e9bdf8
move f32 lib to external
TheNumbat Apr 11, 2024
7f69249
fix build system
TheNumbat Apr 11, 2024
9ac6060
format
TheNumbat Apr 11, 2024
eacd280
Merge branch 'f32-fl2' into f32-backend
TheNumbat Apr 11, 2024
3b9867a
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 11, 2024
983b270
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 11, 2024
b78a2e4
fix compare
TheNumbat Apr 16, 2024
f551594
Merge branch 'f32-fl2' into f32-backend
TheNumbat Apr 16, 2024
4daf82d
fix static const
TheNumbat Apr 16, 2024
203d218
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 16, 2024
2925238
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 16, 2024
df8abe2
add neq_float32
TheNumbat Apr 16, 2024
ae3d4a5
preserve width in simplify comparison
TheNumbat Apr 16, 2024
e2bac20
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 16, 2024
04bd989
typo
TheNumbat Apr 16, 2024
77e83d9
Merge branch 'f32-fl2' into f32-backend
TheNumbat Apr 16, 2024
a12ba29
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 16, 2024
ff8762c
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 16, 2024
2a3a4f2
typo
TheNumbat Apr 16, 2024
fc02a69
Merge branch 'f32-fl2' into f32-backend
TheNumbat Apr 16, 2024
0cfb535
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 16, 2024
191df17
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 16, 2024
df6688e
another tagging fix
TheNumbat Apr 16, 2024
c50b64f
Merge branch 'f32-fl2' into f32-backend
TheNumbat Apr 16, 2024
555c85b
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 16, 2024
dc60a19
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 16, 2024
8528bab
squash
TheNumbat Apr 16, 2024
612beb2
remove pattern match
TheNumbat Apr 17, 2024
9146703
update test
TheNumbat Apr 17, 2024
4bdc1de
adjustment
TheNumbat Apr 17, 2024
ea62c43
adjustment
TheNumbat Apr 17, 2024
089a0ea
address comment
TheNumbat Apr 19, 2024
cbe341b
whitespace
TheNumbat Apr 19, 2024
d482728
preserve width in negation of other side
TheNumbat Apr 24, 2024
994435e
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 24, 2024
4bbcab3
Merge branch 'f32-backend-ops' into f32-lit
TheNumbat Apr 24, 2024
b0ed404
merge
TheNumbat Apr 26, 2024
3db086b
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 26, 2024
4aaa542
merge
TheNumbat Apr 26, 2024
261bc62
Merge branch 'f32-backend-ops' into f32-lit
TheNumbat Apr 26, 2024
ac288c1
fix arm build
TheNumbat Apr 26, 2024
1792a07
Merge branch 'f32-backend' into f32-fl2-ops
TheNumbat Apr 26, 2024
76ff55f
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 26, 2024
14d6d16
Merge branch 'f32-backend-ops' into f32-lit
TheNumbat Apr 26, 2024
99b0fa8
Merge branch 'main' into f32-fl2-ops
TheNumbat Apr 26, 2024
d1908f5
caml_hash_exn
TheNumbat Apr 26, 2024
096c550
Merge branch 'f32-backend-ops' into f32-lit
TheNumbat Apr 26, 2024
205d415
fix test
TheNumbat Apr 26, 2024
6015401
Merge branch 'f32-backend-ops' into f32-lit
TheNumbat Apr 26, 2024
736b9b4
Refactor otherlibs build (#2477)
TheNumbat Apr 29, 2024
ef742ca
Merge branch 'main' into f32-fl2-ops
TheNumbat Apr 29, 2024
dc44058
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 29, 2024
81ed6dd
Merge branch 'f32-backend-ops' into f32-lit
TheNumbat Apr 29, 2024
28c0b53
Merge branch 'main' into f32-fl2-ops
TheNumbat Apr 30, 2024
e6292a6
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat Apr 30, 2024
9c97040
Merge branch 'f32-backend-ops' into f32-lit
TheNumbat Apr 30, 2024
d36692d
squash
TheNumbat Apr 30, 2024
437e322
add toplevel printing for float32
TheNumbat Apr 30, 2024
5f6c62c
fix deps
TheNumbat Apr 30, 2024
676fe93
delete f32 lit crs
TheNumbat Apr 30, 2024
0767acd
promote tests
TheNumbat Apr 30, 2024
bcab4d2
install floats stubs lib
TheNumbat May 1, 2024
294beaf
intrins
TheNumbat May 1, 2024
3ce16c1
add s suffix to printer
TheNumbat May 1, 2024
97b165a
test
TheNumbat May 1, 2024
153d894
operator module
TheNumbat May 1, 2024
5f24a88
Merge branch 'f32-lib2' into f32-intrin
TheNumbat May 1, 2024
dff064a
test min_max
TheNumbat May 1, 2024
f041549
Merge branch 'f32-lib2' into f32-intrin
TheNumbat May 1, 2024
31be758
fix test
TheNumbat May 1, 2024
ff1dd31
fix float_arith kinds
TheNumbat May 1, 2024
f796c15
Merge branch 'f32-fl2-ops' into f32-backend-ops
TheNumbat May 1, 2024
ecf95a5
Merge branch 'f32-backend-ops' into f32-lit
TheNumbat May 1, 2024
ad615d5
Merge branch 'f32-lit' into f32-lib2
TheNumbat May 1, 2024
337fd81
Merge branch 'f32-lib2' into f32-intrin
TheNumbat May 1, 2024
14721af
allow int<->f32 mov
TheNumbat May 1, 2024
081a27c
also allow bits in binary emitter
TheNumbat May 1, 2024
c7ab12d
normal intrin path
TheNumbat May 2, 2024
25b4d80
unify intrins
TheNumbat May 2, 2024
7a72101
simplify emit mov
TheNumbat May 2, 2024
b5718d2
fixes
TheNumbat May 2, 2024
e405c4e
import fl2 fixes
TheNumbat May 2, 2024
47ae8e7
squash
TheNumbat May 2, 2024
a799f8f
fix fl2 kind
TheNumbat May 2, 2024
715bb11
test
TheNumbat May 2, 2024
8ed29b6
fix reg behavior
TheNumbat May 3, 2024
ba97d7f
Merge branch 'f32-intrin' into f32#
TheNumbat May 3, 2024
6c72e85
don't use catchall
TheNumbat May 3, 2024
3524b17
address comments
TheNumbat May 6, 2024
e884aab
Merge branch 'f32-lib2' into f32-intrin
TheNumbat May 6, 2024
7423f39
Merge branch 'f32-intrin' into f32#
TheNumbat May 6, 2024
568a043
add ldexp test
TheNumbat May 6, 2024
2be8eda
fix
TheNumbat May 6, 2024
37f8675
move to beta
TheNumbat May 6, 2024
664faaf
add more string tests
TheNumbat May 7, 2024
58c751d
squash for review
TheNumbat May 7, 2024
0ca2a02
functorize binary_float_comp
TheNumbat May 7, 2024
a0b462d
merge
TheNumbat May 7, 2024
d5a8ce4
Merge branch 'f32-backend-ops' into f32-lit
TheNumbat May 7, 2024
219d2dc
merge
TheNumbat May 7, 2024
59332b4
merge
TheNumbat May 7, 2024
bd048ba
merge
TheNumbat May 7, 2024
2126ad5
fix error messages
TheNumbat May 7, 2024
cee72c8
Merge branch 'f32#' into f32-beta
TheNumbat May 7, 2024
c32e359
blocks
TheNumbat May 8, 2024
cbd35ea
fix selectgen f32 fields
TheNumbat May 8, 2024
69184df
promote test
TheNumbat May 8, 2024
99e5ff0
update generated tests
TheNumbat May 8, 2024
16f3f8d
Move code around, no code changes
mshinwell May 9, 2024
30223af
Update comment
mshinwell May 9, 2024
1b5af5d
address comments
TheNumbat May 9, 2024
f847b90
don't need disabled ref
TheNumbat May 9, 2024
883771f
merge
TheNumbat May 9, 2024
c98ab98
promote
TheNumbat May 9, 2024
ef80e49
basics test consistency
TheNumbat May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions backend/cmm_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,35 @@ let setfield_unboxed_int64_or_nativeint arr ofs newval dbg =
[array_indexing log2_size_addr arr ofs dbg; newval],
dbg ))

(* Getters and setters for unboxed float32 fields *)

let get_field_unboxed_float32 mutability ~block ~index dbg =
(* CR layouts v5.1: Properly support big-endian. *)
if Arch.big_endian
then
Misc.fatal_error
"Unboxed float32 fields only supported on little-endian architectures";
let memory_chunk = Single { reg = Float32 } in
(* CR layouts v5.1: We'll need to vary log2_size_addr to efficiently pack
* float32s *)
let field_address = array_indexing log2_size_addr block index dbg in
Cop
(Cload { memory_chunk; mutability; is_atomic = false }, [field_address], dbg)

let setfield_unboxed_float32 arr ofs newval dbg =
(* CR layouts v5.1: Properly support big-endian. *)
if Arch.big_endian
then
Misc.fatal_error
"Unboxed float32 fields only supported on little-endian architectures";
(* CR layouts v5.1: We will need to vary log2_size_addr when float32 fields
are efficiently packed. *)
return_unit dbg
(Cop
( Cstore (Single { reg = Float32 }, Assignment),
[array_indexing log2_size_addr arr ofs dbg; newval],
dbg ))

(* String length *)

(* Length of string block *)
Expand Down Expand Up @@ -1566,12 +1595,13 @@ let make_mixed_alloc ~mode dbg tag shape args =
match flat_suffix.(idx - value_prefix_len) with
| Imm -> int_array_set arr ofs newval dbg
| Float | Float64 -> float_array_set arr ofs newval dbg
| Float32 -> setfield_unboxed_float32 arr ofs newval dbg
| Bits32 -> setfield_unboxed_int32 arr ofs newval dbg
| Bits64 | Word -> setfield_unboxed_int64_or_nativeint arr ofs newval dbg
in
let size =
(* CR layouts 5.1: When we pack int32s more efficiently, this code will need
to change. *)
(* CR layouts 5.1: When we pack int32s/float32s more efficiently, this code
will need to change. *)
value_prefix_len + Array.length flat_suffix
in
if size_float <> size_addr
Expand Down
12 changes: 11 additions & 1 deletion backend/cmm_helpers.mli
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,8 @@ val unboxed_int64_or_nativeint_array_set :
Debuginfo.t ->
expression

(** {2 Getters and setters for unboxed int fields of mixed blocks} *)
(** {2 Getters and setters for unboxed int and float32 fields of mixed
blocks} *)

(** The argument structure for getters is parallel to [get_field_computed]. *)

Expand All @@ -1017,6 +1018,13 @@ val get_field_unboxed_int32 :
Debuginfo.t ->
expression

val get_field_unboxed_float32 :
Asttypes.mutable_flag ->
block:expression ->
index:expression ->
Debuginfo.t ->
expression

val get_field_unboxed_int64_or_nativeint :
Asttypes.mutable_flag ->
block:expression ->
Expand All @@ -1032,4 +1040,6 @@ val get_field_unboxed_int64_or_nativeint :

val setfield_unboxed_int32 : ternary_primitive

val setfield_unboxed_float32 : ternary_primitive

val setfield_unboxed_int64_or_nativeint : ternary_primitive
12 changes: 7 additions & 5 deletions backend/selectgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ let size_component : machtype_component -> int = function
| Int -> Arch.size_int
| Float -> Arch.size_float
| Float32 ->
assert (Arch.size_float = 8);
Arch.size_float / 2
(* CR layouts v5.1: reconsider when float32 fields are efficiently packed.
Note that packed float32# arrays are handled via a separate path. *)
Arch.size_float
| Vec128 -> Arch.size_vec128

let size_machtype mty =
Expand All @@ -222,10 +223,11 @@ let size_expr (env:environment) exp =
Cconst_int _ | Cconst_natint _ -> Arch.size_int
| Cconst_symbol _ ->
Arch.size_addr
| Cconst_float32 _ ->
assert (Arch.size_float = 8);
Arch.size_float / 2
| Cconst_float _ -> Arch.size_float
| Cconst_float32 _ ->
(* CR layouts v5.1: reconsider when float32 fields are efficiently packed.
Note that packed float32# arrays are handled via a separate path. *)
Arch.size_float
| Cconst_vec128 _ -> Arch.size_vec128
| Cvar id ->
begin try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,8 @@ let convert_lprim ~big_endian (prim : L.primitive) (args : Simple.t list list)
List.mapi
(fun i arg ->
match Lambda.get_mixed_block_element shape i with
| Value_prefix | Flat_suffix (Float64 | Imm | Bits32 | Bits64 | Word)
->
| Value_prefix
| Flat_suffix (Float64 | Float32 | Imm | Bits32 | Bits64 | Word) ->
arg
| Flat_suffix Float -> unbox_float arg)
args
Expand Down Expand Up @@ -1533,7 +1533,7 @@ let convert_lprim ~big_endian (prim : L.primitive) (args : Simple.t list list)
let value =
match write with
| Mwrite_value_prefix _
| Mwrite_flat_suffix (Imm | Float64 | Bits32 | Bits64 | Word) ->
| Mwrite_flat_suffix (Imm | Float64 | Float32 | Bits32 | Bits64 | Word) ->
value
| Mwrite_flat_suffix Float -> unbox_float value
in
Expand Down
3 changes: 2 additions & 1 deletion middle_end/flambda2/terms/code_size.ml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ let block_set (kind : Flambda_primitive.Block_access_kind.t)
| ( Mixed
{ field_kind =
( Value_prefix _
| Flat_suffix (Imm | Float | Float64 | Bits32 | Bits64 | Word) );
| Flat_suffix
(Imm | Float | Float64 | Float32 | Bits32 | Bits64 | Word) );
_
},
(Assignment _ | Initialization) ) ->
Expand Down
9 changes: 9 additions & 0 deletions middle_end/flambda2/terms/flambda_primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module Mixed_block_flat_element = struct
| Imm
| Float
| Float64
| Float32
| Bits32
| Bits64
| Word
Expand All @@ -71,6 +72,7 @@ module Mixed_block_flat_element = struct
| Imm -> Imm
| Float -> Float
| Float64 -> Float64
| Float32 -> Float32
| Bits32 -> Bits32
| Bits64 -> Bits64
| Word -> Word
Expand All @@ -79,6 +81,7 @@ module Mixed_block_flat_element = struct
| Imm -> Imm
| Float -> Float
| Float64 -> Float64
| Float32 -> Float32
| Bits32 -> Bits32
| Bits64 -> Bits64
| Word -> Word
Expand All @@ -87,6 +90,7 @@ module Mixed_block_flat_element = struct
| Imm -> "Imm"
| Float -> "Float"
| Float64 -> "Float64"
| Float32 -> "Float32"
| Bits32 -> "Bits32"
| Bits64 -> "Bits64"
| Word -> "Word"
Expand All @@ -96,6 +100,7 @@ module Mixed_block_flat_element = struct
| Imm, Imm
| Float, Float
| Float64, Float64
| Float32, Float32
| Word, Word
| Bits32, Bits32
| Bits64, Bits64 ->
Expand All @@ -106,6 +111,8 @@ module Mixed_block_flat_element = struct
| _, Float -> 1
| Float64, _ -> -1
| _, Float64 -> 1
| Float32, _ -> -1
| _, Float32 -> 1
| Word, _ -> -1
| _, Word -> 1
| Bits32, _ -> -1
Expand All @@ -116,6 +123,7 @@ module Mixed_block_flat_element = struct
let element_kind = function
| Imm -> K.value
| Float | Float64 -> K.naked_float
| Float32 -> K.naked_float32
| Bits32 -> K.naked_int32
| Bits64 -> K.naked_int64
| Word -> K.naked_nativeint
Expand Down Expand Up @@ -532,6 +540,7 @@ module Block_access_kind = struct
match field_kind with
| Imm -> K.With_subkind.tagged_immediate
| Float | Float64 -> K.With_subkind.naked_float
| Float32 -> K.With_subkind.naked_float32
| Bits32 -> K.With_subkind.naked_int32
| Bits64 -> K.With_subkind.naked_int64
| Word -> K.With_subkind.naked_nativeint)
Expand Down
1 change: 1 addition & 0 deletions middle_end/flambda2/terms/flambda_primitive.mli
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module Mixed_block_flat_element : sig
| Imm
| Float
| Float64
| Float32
| Bits32
| Bits64
| Word
Expand Down
2 changes: 2 additions & 0 deletions middle_end/flambda2/to_cmm/to_cmm_primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ let block_load ~dbg (kind : P.Block_access_kind.t) (mutability : Mutability.t)
(* CR layouts v5.1: We should use the mutability here to generate better
code if the load is immutable. *)
C.unboxed_float_array_ref block index dbg
| Float32 -> C.get_field_unboxed_float32 mutability ~block ~index dbg
| Bits32 -> C.get_field_unboxed_int32 mutability ~block ~index dbg
| Bits64 | Word ->
C.get_field_unboxed_int64_or_nativeint mutability ~block ~index dbg)
Expand All @@ -132,6 +133,7 @@ let block_set ~dbg (kind : P.Block_access_kind.t) (init : P.Init_or_assign.t)
| Imm ->
C.setfield_computed Immediate init_or_assign block index new_value dbg
| Float | Float64 -> C.float_array_set block index new_value dbg
| Float32 -> C.setfield_unboxed_float32 block index new_value dbg
| Bits32 -> C.setfield_unboxed_int32 block index new_value dbg
| Bits64 | Word ->
C.setfield_unboxed_int64_or_nativeint block index new_value dbg)
Expand Down
5 changes: 3 additions & 2 deletions ocaml/lambda/lambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ and block_shape =
value_kind list option

and flat_element = Types.flat_element =
Imm | Float | Float64 | Bits32 | Bits64 | Word
Imm | Float | Float64 | Float32 | Bits32 | Bits64 | Word
and flat_element_read =
| Flat_read of flat_element (* invariant: not [Float] *)
| Flat_read_float of alloc_mode
Expand Down Expand Up @@ -1249,7 +1249,7 @@ let get_mixed_block_element = Types.get_mixed_product_element
let flat_read_non_float flat_element =
match flat_element with
| Float -> Misc.fatal_error "flat_element_read_non_float Float"
| Imm | Float64 | Bits32 | Bits64 | Word as flat_element ->
| Imm | Float64 | Float32 | Bits32 | Bits64 | Word as flat_element ->
Flat_read flat_element

let flat_read_float alloc_mode = Flat_read_float alloc_mode
Expand Down Expand Up @@ -1789,6 +1789,7 @@ let layout_of_mixed_field (kind : mixed_block_read) =
match proj with
| Imm -> layout_int
| Float64 -> layout_unboxed_float Pfloat64
| Float32 -> layout_unboxed_float Pfloat32
| Bits32 -> layout_unboxed_int32
| Bits64 -> layout_unboxed_int64
| Word -> layout_unboxed_nativeint
Expand Down
2 changes: 1 addition & 1 deletion ocaml/lambda/lambda.mli
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ and block_shape =
value_kind list option

and flat_element = Types.flat_element =
Imm | Float | Float64 | Bits32 | Bits64 | Word
Imm | Float | Float64 | Float32 | Bits32 | Bits64 | Word
and flat_element_read = private
| Flat_read of flat_element (* invariant: not [Float] *)
| Flat_read_float of alloc_mode
Expand Down
2 changes: 1 addition & 1 deletion ocaml/lambda/matching.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2183,7 +2183,7 @@ let get_expr_args_record ~scopes head (arg, _mut, sort, layout) rem =
else
let read =
match flat_suffix.(pos - value_prefix_len) with
| Imm | Float64 | Bits32 | Bits64 | Word as non_float ->
| Imm | Float64 | Float32 | Bits32 | Bits64 | Word as non_float ->
flat_read_non_float non_float
| Float ->
(* TODO: could optimise to Alloc_local sometimes *)
Expand Down
5 changes: 1 addition & 4 deletions ocaml/lambda/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ let layout_pat sort p = layout p.pat_env p.pat_loc sort p.pat_type

let check_record_field_sort loc sort =
match Jkind.Sort.get_default_value sort with
| Value | Float64 | Bits32 | Bits64 | Word -> ()
| Float32 ->
(* CR mslater: (float32) float32# records *)
Misc.fatal_error "Found unboxed float32 record field."
| Value | Float64 | Float32 | Bits32 | Bits64 | Word -> ()
| Void -> raise (Error (loc, Illegal_void_record_field))

(* Forward declaration -- to be filled in by Translmod.transl_module *)
Expand Down
Loading
Loading