Skip to content

Commit 6392eea

Browse files
committed
Refactored cmm helpers to handle many integer widths
#Squashed commit of the following: #commit c9d7aa6 #Author: Jacob Van Buren <[email protected]> #Date: Thu Jan 2 14:49:45 2025 -0500 #cleaned up div/mod #commit 4d9f427 #Author: Jacob Van Buren <[email protected]> #Date: Thu Jan 2 14:45:42 2025 -0500 #address feedback and simplify division interface #unified unboxed field getters/setters. This will be useful once we have unboxed integers of different sizes #formatted #updated cmm_helpers interface to be more amenable to adding other integer sizes #Separate test for vectorizer in the CI (#3414) #* Separate test for vectorizer in the CI #* Remove vectorizer from "gi" CI job #CI: simplify the regalloc jobs (#3389) #ASR 64-bit lane not available in sse instruction (#3413) #Fix case where parser drops attributes in packed module types. (#3262) #* Demonstrate dropped attributes in test. #Signed-off-by: Thomas Del Vecchio <[email protected]> #* Syntax error on misplaced attribute in packed module types. #Signed-off-by: Thomas Del Vecchio <[email protected]> #--------- #Signed-off-by: Thomas Del Vecchio <[email protected]> #Add attributes to (unsafely) skip jkind check (#3385) #* Add attributes to (unsafely) skip jkind check #Add a pair of attributes, [@@unsafe_allow_any_kind_in_intf] and #[@@unsafe_allow_any_kind_in_impl], which if set on both the impl and the intf #respectively, skip checking the jkind of the type in a signature against the #jkind of the type in a struct entirely. This is a more-selective version of the #`--allow-illegal-crossing` flag, and likely eventually subsumes it. #Signed-off-by: Aspen Smith <[email protected]> #* Emit a warning when unsafe_allow_any_kind is added unnecessarily #Note that this is /only/ done if the attribute is set in both signatures but not #used - also this is a little over-sensitive (sadly) since this is done during #sigature inclusion too. A new test covers the over-sensitivity. #Signed-off-by: Aspen Smith <[email protected]> #--------- #Signed-off-by: Aspen Smith <[email protected]> #Add `Variant_with_null` and `Null` variant constructors (#2870) #* `Variant_with_null` #* `Null` tagged constructors #* precise value kind #* No private re-export #--------- #Co-authored-by: Diana Kalinichenko <[email protected]> #Revert "Implement %makearray_dynamic{,_uninit}" (#3408) #Revert "Implement %makearray_dynamic{,_uninit} (#3317)" #This reverts commit 6da1dde. #Upload core files etc upon CI failure (#3405) #Fix IRC and Greedy allocators (arm64) (#3388) #Convert float32 constants to int32 in first stage compiler (#3371) #* convert float32 constants in bytecode output #* edit #* edit #* blocks + test #* compare against float64 constants #* tests check proper custom ops #--------- #Co-authored-by: Diana Kalinichenko <[email protected]> Squashed commit of the following: commit 16f1b23 Author: Jacob Van Buren <[email protected]> Date: Wed Jan 22 15:25:23 2025 -0500 Squashed commit of the following: commit 7c5c7f0 Author: Jacob Van Buren <[email protected]> Date: Wed Jan 22 15:24:10 2025 -0500 Squashed commit of the following: commit a53391d Author: Max Slater <[email protected]> Date: Wed Jan 22 13:53:02 2025 -0500 Rename `atomic_cas`/`Compare_and_swap` (#3491) commit 92b327c Author: Max Slater <[email protected]> Date: Tue Jan 21 14:18:56 2025 -0500 Additional operations for int atomics (#3490) commit 38e792c Author: Luke Maurer <[email protected]> Date: Tue Jan 21 17:09:23 2025 +0000 Support `-open Foo` where `Foo` is parameterised (#3489) The command line ``` ocamlopt -open Foo -parameter P -c bar.ml ``` should be fine, even if `Foo` is itself parameterised by `P`: as usual, we compile `bar.ml` as if it began with `open! Foo`, and by the subset rule, `Bar` can refer to `Foo` because it takes at least the same parameters. Unfortunately, currently we process `-open` before `-parameter`, so when we go to check the implicit reference to `Foo`, we think there are no parameters, and we report an error. (Confusingly, the error suggests that the user add `-parameter P` to the command line.) The fix is simple: move the code that processes `-parameter` earlier so that the initial environment is constructed with the parameters already available. commit 784dc96 Author: Greta Yorsh <[email protected]> Date: Tue Jan 21 14:07:41 2025 +0000 Rename [emit.mlp] to [emit.ml] on amd64 (#3488) commit f3b720a Author: Zesen Qian <[email protected]> Date: Tue Jan 21 10:35:35 2025 +0000 Module aliases save locks instead of walking them immediately (#3398) commit 389a7c3 Author: Nick Barnes <[email protected]> Date: Mon Jan 20 17:55:51 2025 +0000 Add OCAMLRUNPARAM d= parameter for max # domains (#3487) Allow maximum number of domains to be specified as a OCAMLRUNPARAM parameter. (cherry picked from commit f92715f) Co-authored-by: KC Sivaramakrishnan <[email protected]> commit 63767d7 Author: Nick Barnes <[email protected]> Date: Mon Jan 20 17:45:30 2025 +0000 Add caml_runtime_parameters back (#3468) Add caml_runtime_parameters back. commit 5e9975e Author: Greta Yorsh <[email protected]> Date: Mon Jan 20 17:15:15 2025 +0000 Emit atomic compare and exchange (#3486) commit a9821e8 Author: Basile Clément <[email protected]> Date: Mon Jan 20 15:36:09 2025 +0100 Make patricia trees big-endian (#3438) This patch switches up the implementation of the `Patricia_tree` module from little-endian to big-endian, with the main motivation to be able to implement in-order traversal. The `caml_int_clz_tagged_to_untagged` and `caml_int_tagged_to_tagged` C stubs are recognized and replaced with the `clz` instruction when compiling with flambda2, so they are only used in the boot compiler. commit b8a9789 Author: Leo White <[email protected]> Date: Fri Jan 17 13:35:19 2025 +0000 Generate specific instructions for atomics on immediates (#3477) * Generate specific instructions for atomics on immediates * Fix formatting commit 7b93134 Author: Greta Yorsh <[email protected]> Date: Fri Jan 17 09:30:30 2025 +0000 Vectorizer: add tests (#3456) * Add tests * Disable ocamlformat on unboxed tests * Increase -vectorize-max-block-size for tests * Fix asssertion failure when vectorizing unboxed int32 * Disable float32 on arm64 (not yet implemented) * improve gen_dune.ml for the vectorizer tests Co-authored-by: Xavier Clerc <[email protected]> commit 6379678 Author: Mark Shinwell <[email protected]> Date: Thu Jan 16 16:08:29 2025 +0000 Add "-ocamlrunparam" linker flag (#3483) commit f7b2cbe Author: Xavier Clerc <[email protected]> Date: Thu Jan 16 15:25:28 2025 +0000 Bump the version of `actions/upload-artifact` (#3474) * Bump the version of actions/upload-artifact. * Ensure artifact names are unique. * To trigger CI. * Try with commit hash. commit afb8a55 Author: Mark Shinwell <[email protected]> Date: Thu Jan 16 14:03:37 2025 +0000 Move two macOS CI controllers to runtime5 (#3482) commit aae5c40 Author: Mark Shinwell <[email protected]> Date: Thu Jan 16 13:50:34 2025 +0000 Fix error in caml_get_init_stack_wsize (#3481) commit 525868c Author: dkalinichenko-js <[email protected]> Date: Wed Jan 15 17:47:30 2025 -0500 Use null pointers for `or_null` (#3267) * runtime changes * runtime4 changes * Change `CODE_UNBOXED_INT64` and `CODE_NULL` * make `Is_block` an inline function * redefine `Is_long` * fix * Change `CODE_UNBOXED_INT64` back * optimize `Is_block`/`Is_long` * `null_tag` for `caml_obj_tag` * consistent naming * slightly more reassuring comment * `inline` is unnecessary and might break `#define inline` * optimization incorrect in presence of nulls * Constructors and pattern-matching * Bytecode compilation * `or_null` is `Variant_or_null` * Accept tests * Runtime tests * Delete obsolete or_null test --------- Co-authored-by: Diana Kalinichenko <[email protected]> commit 9796b21 Author: dkalinichenko-js <[email protected]> Date: Wed Jan 15 17:47:13 2025 -0500 Runtime changes for `or_null` (#3265) * runtime changes * runtime4 changes * Change `CODE_UNBOXED_INT64` and `CODE_NULL` * make `Is_block` an inline function * redefine `Is_long` * fix * Change `CODE_UNBOXED_INT64` back * optimize `Is_block`/`Is_long` * `null_tag` for `caml_obj_tag` * consistent naming * slightly more reassuring comment * `inline` is unnecessary and might break `#define inline` * optimization incorrect in presence of nulls --------- Co-authored-by: Diana Kalinichenko <[email protected]> commit df4a6e0 Author: Chris Casinghino <[email protected]> Date: Wed Jan 15 13:08:53 2025 -0500 Bump magic numbers for 5.2.0minus-5 (#3478) commit d1c8d85 Author: Mark Shinwell <[email protected]> Date: Wed Jan 15 16:44:39 2025 +0000 Peek and poke (#3309) commit f8caad4 Author: Greta Yorsh <[email protected]> Date: Wed Jan 15 16:00:39 2025 +0000 Vectorizer: xmm register can hold ocaml values (#3455) * Add [Valx2] to [Cmm.machtype_component] * Vectorizer generates [Valx2] * Record live offsets of [Valx2] in the frametable For runtime4, xmm register are below [gc_regs], use negative offsets. * Move [types_are_compatible] from [Reg] to [Proc] This information has to be in sync with register classes, stack slock classes, and emit for move instructions. commit 34a7873 Author: Zesen Qian <[email protected]> Date: Wed Jan 15 13:13:18 2025 +0000 Improve coherence of modality zapping (#3462) commit 1a6a9d3 Author: Mark Shinwell <[email protected]> Date: Wed Jan 15 12:06:24 2025 +0000 Fix caml_obj_with_tag (#3465) commit bc5110a Author: Nick Barnes <[email protected]> Date: Wed Jan 15 11:52:25 2025 +0000 Reset the pacing of major collection after any synchronous major GC (#3463) Reset the pacing of major collection at the end of any synchronous major collection. commit 9faf700 Author: Mark Shinwell <[email protected]> Date: Wed Jan 15 11:32:59 2025 +0000 Remove remnants of caml_obj_truncate (#3469) commit ff9430b Author: Luke Maurer <[email protected]> Date: Wed Jan 15 11:31:22 2025 +0000 Mangle instance symbol names using `____` rather than `___` (#3472) Apparently there are libraries around that have names ending in single underscores, leading to ambiguous symbol names if we use triple underscores to delimit instances. Other choices are possible but this PR opts for newly-developed quadruple-underscore technology. commit 9984700 Author: Vincent Laviron <[email protected]> Date: Wed Jan 15 11:03:43 2025 +0100 Port upstream PRs 11542 and 12505 to runtime4 (#3431) fix #11482: random crash in large closure allocation (#11542) Co-authored-by: Damien Doligez <[email protected]> commit 058c4db Author: Mark Shinwell <[email protected]> Date: Tue Jan 14 22:19:32 2025 +0000 Enable all makearray_dynamic tests on runtime4 (#3470) commit ba15ee5 Author: Greta Yorsh <[email protected]> Date: Tue Jan 14 20:08:31 2025 +0000 Vectorize [Ifloatarithmem] (#3452) * Add [Isimd_mem] to [Arch.Specific] and emit [addpd] with memory arg and similar instructions * Vectorize [Ifloatarithmem] When the memory alignment is known to be 128-bit (currently, never) emits [addpd], otherwise emits a vector load followed by an arithmetic instruction. commit 9755b39 Author: Greta Yorsh <[email protected]> Date: Tue Jan 14 18:57:39 2025 +0000 Fix CI failure (#3473) commit 859949c Author: Greta Yorsh <[email protected]> Date: Tue Jan 14 17:56:53 2025 +0000 Vectorize [Specific.Istore_int] (#3450) Used for array initialization (amd64) commit 50f73cb Author: Greta Yorsh <[email protected]> Date: Tue Jan 14 17:38:39 2025 +0000 Do not allow naked pointers (remove configure option) (#3448) commit b7c8ad3 Author: Greta Yorsh <[email protected]> Date: Tue Jan 14 17:07:39 2025 +0000 Vectorizer refactor heuristic for select_and_join (#3449) * Refactor [Block.find_last_instruction], cache [Computation.last_pos] * Improve heuristics in [Computation.select_and_join] using [last_pos] commit 22f81d8 Author: Mark Shinwell <[email protected]> Date: Tue Jan 14 17:00:29 2025 +0000 Fix mistake in conditional for makearray_dynamic array initialization (#3466) commit aaaddfb Author: Greta Yorsh <[email protected]> Date: Tue Jan 14 14:57:17 2025 +0000 Vectorizer: propagate alignment of memory accesses (#3451) Currently it's always 8 but having this argument will help us consider alignment for new vector sequences. commit b15d44e Author: Greta Yorsh <[email protected]> Date: Tue Jan 14 14:55:29 2025 +0000 vectorizer: improve debug printout (#3445) commit 6239156 Author: Stephen Dolan <[email protected]> Date: Tue Jan 14 13:43:21 2025 +0000 Better hugepage alignment of stacks and heap (#3384) Co-authored-by: Mark Shinwell <[email protected]> commit 677d79a Author: Greta Yorsh <[email protected]> Date: Tue Jan 14 13:23:56 2025 +0000 Backend dune copy and directive (#3467) * Remove unused line directive from [dune] * Use [copy_files#] to copy files from ARCH and add a file directive * Remove existing file directives commit 314b131 Author: Stephen Dolan <[email protected]> Date: Tue Jan 14 11:58:41 2025 +0000 Bound stack size in expect tests (#3439) commit 02774f8 Author: Greta Yorsh <[email protected]> Date: Tue Jan 14 10:52:50 2025 +0000 all_deps is reflexive (#3464) commit 117a0a0 Author: Stephen Dolan <[email protected]> Date: Tue Jan 14 10:44:15 2025 +0000 Stub implementation of new custom memory API (#3437) commit 4f30aac Author: Greta Yorsh <[email protected]> Date: Tue Jan 14 10:31:48 2025 +0000 Vectorizer bug fix: address argument of memory operations (#3446) Fix bug: use address arg of the first instruction in a group ... not the last! Only matters for arrays at the moment, where the address offset argument is not always the same register. commit cc91e2b Author: Vincent Laviron <[email protected]> Date: Tue Jan 14 11:26:59 2025 +0100 caml_update_dummy: fail on closure blocks (#3429) commit 17a01a9 Author: Mark Shinwell <[email protected]> Date: Tue Jan 14 10:07:39 2025 +0000 Implement %array_element_size_in_bytes (#3367) Co-authored-by: Chris Casinghino <[email protected]> commit b487f71 Author: Greta Yorsh <[email protected]> Date: Mon Jan 13 14:05:25 2025 +0000 Runtime: make types explicit when reading [gc_regs] (#3453) Runtime4: make types explicit when reading [gc_regs]. commit 67e6eb3 Author: Max Slater <[email protected]> Date: Fri Jan 10 16:17:32 2025 -0500 More capsule API updates (#3440) commit c7f573f Author: Mark Shinwell <[email protected]> Date: Fri Jan 10 18:26:15 2025 +0000 Reinstate %makearray_dynamic (#3460) commit e1e4fb8 Author: Zesen Qian <[email protected]> Date: Fri Jan 10 16:15:48 2025 +0000 `portable` lazy allows `nonportable` thunk (#3436) * portable lazy allows nonportable thunk * add documentation * improve documentation * add examples * improve comments in test * say "not stronger" commit c30ec74 Author: Ryan Tjoa <[email protected]> Date: Fri Jan 10 10:41:08 2025 -0500 Check for type recursion without boxing (#3407) commit cb290c5 Author: Greta Yorsh <[email protected]> Date: Fri Jan 10 11:00:32 2025 +0000 Vectorizer: rename New (#3454) Rename New to New_vec128 to make the type clear and distinguish it from the upcoming Valx2 commit bd39e02 Author: Greta Yorsh <[email protected]> Date: Fri Jan 10 10:24:48 2025 +0000 Add function [DLL.for_all_i] (#3442) * Add function [DLL.for_all_i] * Rename to [for_alli] to match existing [mapi] and [iteri] * Remove unused argument of [aux] in [DLL.for_all*] commit c048920 Author: Greta Yorsh <[email protected]> Date: Thu Jan 9 13:16:36 2025 +0000 Cleanup machtype_component size (#3441) Cleanup size_component commit 830d5e7 Author: Greta Yorsh <[email protected]> Date: Thu Jan 9 13:15:59 2025 +0000 Add "dump-vectorize" to OCAMLPARAM (#3443) Add [dump-vectorize] to OCAMLPARAM for debugging commit 157c95e Author: Greta Yorsh <[email protected]> Date: Thu Jan 9 13:15:33 2025 +0000 Vectorizer bug fix: 128-bit vectorized constant (#3447) Fix bug: 128-bit vectorized constant high/low correctly ordered commit 648155d Author: Greta Yorsh <[email protected]> Date: Thu Jan 9 13:09:48 2025 +0000 Add [Printreg.reglist] for debugging (#3444) commit d40254f Author: Stephen Dolan <[email protected]> Date: Tue Jan 7 21:25:45 2025 +0000 Move two misplaced files (#3435) commit 4a0bb69 Author: dkalinichenko-js <[email protected]> Date: Tue Jan 7 15:34:27 2025 -0500 `Yielding` mode axis (#3283) * `Yielding` mode axis * Tests * fix printing --------- Co-authored-by: Diana Kalinichenko <[email protected]> commit 00275e0 Author: Max Slater <[email protected]> Date: Mon Jan 6 13:05:58 2025 -0500 Unbox_float32 should check custom ops name (#3433) check sym name commit 2e49469 Author: Max Slater <[email protected]> Date: Mon Jan 6 13:05:03 2025 -0500 Make Capsule preserve wrapped exception backtraces (#3421) * with_password * portable * don't use polymorphic parameters * review * protect encapsulated from other capsule * raise wrapped exceptions with existing backtrace * cr commit 2de23a5 Author: Ryan Tjoa <[email protected]> Date: Mon Jan 6 04:04:29 2025 -0500 Fix CI by using `setup-ocaml` v3 for ocamlformat workflow (#3426) [CI] Use setup-ocaml v3 for ocamlformat workflow commit eada0f1 Author: Ryan Tjoa <[email protected]> Date: Fri Jan 3 21:23:23 2025 -0500 Move unboxed records to stable (#3419) commit a273a33 Author: Jacob Van Buren <[email protected]> Date: Fri Jan 3 11:17:18 2025 -0500 Changed make fmt to run in parallel (#3422) changed make fmt to run in parallel commit 4de5a72 Author: Max Slater <[email protected]> Date: Thu Jan 2 20:10:08 2025 -0500 Add `Capsule.with_password` (#3420) commit b084ff3 Author: Greta Yorsh <[email protected]> Date: Wed Jan 1 15:34:11 2025 +0000 vectorizer: new test (#3418) Add test for register compatiblity commit 5549015 Author: Greta Yorsh <[email protected]> Date: Tue Dec 31 17:20:56 2024 +0000 Vectorizer: check register compatibility (#3412) Check that registers are compatible when joining computations
1 parent 443a81c commit 6392eea

12 files changed

+182
-194
lines changed

backend/arm64/cfg_selection.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class selector =
171171
method! insert_move_extcall_arg env ty_arg src dst =
172172
let ty_arg_is_int32 =
173173
match ty_arg with
174-
| XInt32 -> true
174+
| XInt8 | XInt16 | XInt32 -> true
175175
| XInt | XInt64 | XFloat32 | XFloat | XVec128 -> false
176176
in
177177
if macosx && ty_arg_is_int32 && is_stack_slot dst

backend/arm64/proc.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ let external_calling_conventions
297297
begin match ty_arg with
298298
| XInt | XInt64 ->
299299
loc.(i) <- [| loc_int last_int make_stack int ofs |]
300-
| XInt32 ->
300+
| XInt32 | XInt16 | XInt8 ->
301301
loc.(i) <- [| loc_int32 last_int make_stack int ofs |]
302302
| XFloat ->
303303
loc.(i) <- [| loc_float last_float make_stack float ofs |]

backend/arm64/selection.ml

+6-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ class selector =
157157
| _ -> super#select_operation op args dbg
158158

159159
method! insert_move_extcall_arg env ty_arg src dst =
160-
if macosx && ty_arg = XInt32 && is_stack_slot dst
160+
let ty_arg_is_int32 =
161+
match ty_arg with
162+
| XInt8 | XInt16 | XInt32 -> true
163+
| XInt | XInt64 | XFloat32 | XFloat | XVec128 -> false
164+
in
165+
if macosx && ty_arg_is_int32 && is_stack_slot dst
161166
then self#insert env (Iop (Ispecific Imove32)) src dst
162167
else self#insert_moves env src dst
163168
end

backend/cmm.ml

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# 1 "backend/cmm.ml"
12
(**************************************************************************)
23
(* *)
34
(* OCaml *)
@@ -107,6 +108,8 @@ let ge_component comp1 comp2 =
107108

108109
type exttype =
109110
| XInt
111+
| XInt8
112+
| XInt16
110113
| XInt32
111114
| XInt64
112115
| XFloat32
@@ -115,6 +118,8 @@ type exttype =
115118

116119
let machtype_of_exttype = function
117120
| XInt -> typ_int
121+
| XInt8 -> typ_int
122+
| XInt16 -> typ_int
118123
| XInt32 -> typ_int
119124
| XInt64 -> typ_int
120125
| XFloat -> typ_float
@@ -590,21 +595,19 @@ let equal_machtype_component (left : machtype_component) (right : machtype_compo
590595
| Float32, (Val | Addr | Int | Float | Vec128 | Valx2) ->
591596
false
592597

593-
let equal_exttype left right =
594-
match left, right with
595-
| XInt, XInt -> true
596-
| XInt32, XInt32 -> true
597-
| XInt64, XInt64 -> true
598-
| XFloat32, XFloat32 -> true
599-
| XFloat, XFloat -> true
600-
| XVec128, XVec128 -> true
601-
| XInt, (XInt32 | XInt64 | XFloat | XFloat32 | XVec128)
602-
| XInt32, (XInt | XInt64 | XFloat | XFloat32 | XVec128)
603-
| XInt64, (XInt | XInt32 | XFloat | XFloat32 | XVec128)
604-
| XFloat, (XInt | XInt32 | XFloat32 | XInt64 | XVec128)
605-
| XVec128, (XInt | XInt32 | XInt64 | XFloat | XFloat32)
606-
| XFloat32, (XInt | XInt32 | XInt64 | XFloat | XVec128) ->
607-
false
598+
let equal_exttype
599+
((XInt
600+
| XInt8
601+
| XInt16
602+
| XInt32
603+
| XInt64
604+
| XFloat32
605+
| XFloat
606+
| XVec128) as left)
607+
right
608+
=
609+
(* we can use polymorphic compare as long as exttype is all constant constructors *)
610+
left = right
608611

609612
let equal_vec128_type v1 v2 =
610613
match v1, v2 with

backend/cmm.mli

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ val ge_component
7575

7676
type exttype =
7777
| XInt (**r OCaml value, word-sized integer *)
78+
| XInt8 (**r 8-bit integer *)
79+
| XInt16 (**r 16-bit integer *)
7880
| XInt32 (**r 32-bit integer *)
7981
| XInt64 (**r 64-bit integer *)
8082
| XFloat32 (**r single-precision FP number *)

0 commit comments

Comments
 (0)