ocaml-flambda / flambda-backend

The Flambda backend project for OCaml
93 stars 67 forks source link

Float32 array load/store primitives #2697

Closed TheNumbat closed 1 day ago

TheNumbat commented 3 weeks ago

Adds %primitives for loading/storing float32s to/from strings, bytes, bigstrings, and float32_elt bigarrays. Also covers loading/storing unboxed float32s to/from bigstrings.

The string, bytes, and bigstring primitives have the same semantics as those for int32s; the only difference is that they operate on a float32 register directly. This did not require any compiler backend changes.

The bigarray functions are specialized copies of caml_ba_ref / caml_ba_set for float32. They require bigarrays with the float32_elt element kind, but purposefully ignore the bigarray's 'view' type. This allows the API functions to operate on e.g. (float, float32_elt, 'c) t bigarrays.

Tests for all new primitives have been added to float32_lib.ml and float32_u_lib.ml.

mshinwell commented 3 weeks ago

@TheNumbat please add a full PR description

TheNumbat commented 2 weeks ago

Yeah, added, but this still isn't ready for review. Something bad is going on with the cfg backends

mshinwell commented 1 week ago

Can we please pull out the fix for cvtsi2ss into a separate PR?

TheNumbat commented 1 week ago

Sure; #2758 Now merged

mshinwell commented 6 days ago

@ccasin did you read the tests? If not please do. I am reading everything else that you didn't.

ccasin commented 1 day ago

Yes, I read the tests, so this seems fine to merge once CI passes.