Skip to content

Commit 5bf0a9a

Browse files
committed
WIP
1 parent 4142b2f commit 5bf0a9a

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

compiler/lib-wasm/gc_target.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ module Bigarray = struct
14081408
let* ty = Type.bigarray_type in
14091409
let* ta = Memory.wasm_struct_get ty (Memory.wasm_cast ty a) 1 in
14101410
let* i = Value.int_val i in
1411-
Value.val_int (return (W.Call (f, [ ta; i ])))
1411+
return (W.Call (f, [ ta; i ]))
14121412
| _ -> assert false
14131413

14141414
let set ~kind a i v =

compiler/lib-wasm/typing.ml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,17 @@ let update_deps st { blocks; _ } =
223223
List.iter block.body ~f:(fun i ->
224224
match i with
225225
| Let (x, Block (_, lst, _, _)) -> Array.iter ~f:(fun y -> add_dep st x y) lst
226-
| Let (x, Prim (Extern ("%int_and" | "%int_or" | "%int_xor"), lst)) ->
226+
| Let
227+
( x
228+
, Prim
229+
( Extern
230+
( "%int_and"
231+
| "%int_or"
232+
| "%int_xor"
233+
| "caml_ba_get_1"
234+
| "caml_ba_get_2"
235+
| "caml_ba_get_3" )
236+
, lst ) ) ->
227237
(* The return type of these primitives depend on the input type *)
228238
List.iter
229239
~f:(fun p ->
@@ -424,6 +434,35 @@ let prim_type ~approx prim args =
424434
| "caml_nativeint_to_int" -> Int Unnormalized
425435
| "caml_nativeint_of_int" -> Number Nativeint
426436
| "caml_int_compare" -> Int Normalized
437+
| "caml_ba_create" -> (
438+
match args with
439+
| [ Pc (Int kind); Pc (Int layout); _ ] ->
440+
Bigarray
441+
(Bigarray.make
442+
~kind:(Targetint.to_int_exn kind)
443+
~layout:(Targetint.to_int_exn layout))
444+
| _ -> Top)
445+
(*ZZZ *)
446+
| "caml_ba_get_1" (*| "caml_ba_get_2" | "caml_ba_get_3"*) -> (
447+
match args with
448+
| ba :: _ -> (
449+
match arg_type ~approx ba with
450+
| Bot -> Bot
451+
| Bigarray { kind = Int8_unsigned | Char; layout = C } -> Int Normalized
452+
(*ZZZ
453+
| Bigarray { kind; _ } -> (
454+
match kind with
455+
| Float16 | Float32 | Float64 -> Number Float
456+
| Int8_signed | Int8_unsigned | Int16_signed | Int16_unsigned | Char ->
457+
Int Normalized
458+
| Int -> Int Unnormalized
459+
| Int32 -> Number Int32
460+
| Int64 -> Number Int64
461+
| Nativeint -> Number Nativeint
462+
| Complex32 | Complex64 -> Tuple [Number Float; Number Float])
463+
*)
464+
| _ -> Top)
465+
| [] -> Top)
427466
| _ -> Top
428467

429468
let propagate st approx x : Domain.t =

0 commit comments

Comments
 (0)