Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions ml-proto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LIBS = str bigarray

OCB_FLAGS += -quiet
OCB_FLAGS += # -use-ocamlfind
OCB_FLAGS += # -cflags -w
OCB_FLAGS += # -cflags -w
OCB_FLAGS += # -cflags +a-4-41-42-44-45
OCB_FLAGS += $(DIRS:%=-I %)
OCB_FLAGS += $(LIBS:%=-libs %)
Expand Down Expand Up @@ -42,7 +42,7 @@ test: $(NAME)
./runtests.py

.PHONY: zip
zip:
zip:
git archive --format=zip --prefix=$(NAME)/ \
-o $(NAME).zip HEAD

Expand Down
2 changes: 1 addition & 1 deletion ml-proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mingw64-x86_64-binutils
-winpthreads
```

The set of packages may be different on 32-bit Windows.
The set of packages may be different on 32-bit Windows.

The current set of prototypes does not rely on opam or ocaml packages, but be aware that opam does not work on Windows.

Expand Down
2 changes: 1 addition & 1 deletion ml-proto/host/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let convert_pos pos =

let region lexbuf =
let left = convert_pos (Lexing.lexeme_start_p lexbuf) in
let right = convert_pos (Lexing.lexeme_end_p lexbuf) in
let right = convert_pos (Lexing.lexeme_end_p lexbuf) in
{Source.left = left; Source.right = right}

let error lexbuf msg = raise (Script.Syntax (region lexbuf, msg))
Expand Down
14 changes: 7 additions & 7 deletions ml-proto/spec/int.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

module type RepresentationType =
sig
type t
type t
val add : t -> t -> t
val min_int : t
val zero : t
val one : t
val minus_one : t
val minus_one : t
val shift_left : t -> int -> t
val shift_right : t -> int -> t
val logand : t -> t -> t
val lognot : t -> t
val logor : t -> t -> t
val logxor : t -> t -> t
val logxor : t -> t -> t
val sub : t -> t -> t
val div : t -> t -> t
val mul : t -> t -> t
val rem : t -> t -> t
val rem : t -> t -> t
val shift_right_logical : t -> int -> t
val of_int : int -> t
val to_int : t -> int
val to_int : t -> int
val of_string : string -> t
val to_string : t -> string

Expand All @@ -30,7 +30,7 @@ end
module type S =
sig
type t
type bits
type bits

val of_bits : bits -> t
val to_bits : t -> bits
Expand Down Expand Up @@ -68,7 +68,7 @@ sig
val of_string : string -> t
val to_string : t -> string
end

module Make(Rep : RepresentationType) : S with type bits = Rep.t and type t = Rep.t =
struct
(*
Expand Down
58 changes: 29 additions & 29 deletions ml-proto/test/endianness.wast
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(i32.store8 (get_local $address) (get_local $value))
(i32.store8 (i32.add (get_local $address) (i32.const 1)) (i32.shr_u (get_local $value) (i32.const 8)))
)

;; Stores an i32 value in little-endian format
(func $i32_store_little (param $address i32) (param $value i32)
(call $i16_store_little (get_local $address) (get_local $value))
Expand All @@ -18,138 +18,138 @@
(call $i32_store_little (get_local $address) (i32.wrap/i64 (get_local $value)))
(call $i32_store_little (i32.add (get_local $address) (i32.const 4)) (i32.wrap/i64 (i64.shr_u (get_local $value) (i64.const 32))))
)

;; Loads an i16 value in little-endian format
(func $i16_load_little (param $address i32) (result i32)
(i32.or
(i32.load8_u (get_local $address))
(i32.shl (i32.load8_u (i32.add (get_local $address) (i32.const 1))) (i32.const 8))
)
)

;; Loads an i32 value in little-endian format
(func $i32_load_little (param $address i32) (result i32)
(i32.or
(call $i16_load_little (get_local $address))
(i32.shl (call $i16_load_little (i32.add (get_local $address) (i32.const 2))) (i32.const 16))
)
)

;; Loads an i64 value in little-endian format
(func $i64_load_little (param $address i32) (result i64)
(i64.or
(i64.extend_u/i32 (call $i32_load_little (get_local $address)))
(i64.shl (i64.extend_u/i32 (call $i32_load_little (i32.add (get_local $address) (i32.const 4)))) (i64.const 32))
)
)

(func $i32_load16_s (param $value i32) (result i32)
(call $i16_store_little (i32.const 0) (get_local $value))
(i32.load16_s (i32.const 0))
)

(func $i32_load16_u (param $value i32) (result i32)
(call $i16_store_little (i32.const 0) (get_local $value))
(i32.load16_u (i32.const 0))
)

(func $i32_load (param $value i32) (result i32)
(call $i32_store_little (i32.const 0) (get_local $value))
(i32.load (i32.const 0))
)

(func $i64_load16_s (param $value i64) (result i64)
(call $i16_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
(i64.load16_s (i32.const 0))
)

(func $i64_load16_u (param $value i64) (result i64)
(call $i16_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
(i64.load16_u (i32.const 0))
)

(func $i64_load32_s (param $value i64) (result i64)
(call $i32_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
(i64.load32_s (i32.const 0))
)

(func $i64_load32_u (param $value i64) (result i64)
(call $i32_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
(i64.load32_u (i32.const 0))
)

(func $i64_load (param $value i64) (result i64)
(call $i64_store_little (i32.const 0) (get_local $value))
(i64.load (i32.const 0))
)

(func $f32_load (param $value f32) (result f32)
(call $i32_store_little (i32.const 0) (i32.reinterpret/f32 (get_local $value)))
(f32.load (i32.const 0))
)

(func $f64_load (param $value f64) (result f64)
(call $i64_store_little (i32.const 0) (i64.reinterpret/f64 (get_local $value)))
(f64.load (i32.const 0))
)


(func $i32_store16 (param $value i32) (result i32)
(i32.store16 (i32.const 0) (get_local $value))
(call $i16_load_little (i32.const 0))
)

(func $i32_store (param $value i32) (result i32)
(i32.store (i32.const 0) (get_local $value))
(call $i32_load_little (i32.const 0))
)

(func $i64_store16 (param $value i64) (result i64)
(i64.store16 (i32.const 0) (get_local $value))
(i64.extend_u/i32 (call $i16_load_little (i32.const 0)))
)

(func $i64_store32 (param $value i64) (result i64)
(i64.store32 (i32.const 0) (get_local $value))
(i64.extend_u/i32 (call $i32_load_little (i32.const 0)))
)

(func $i64_store (param $value i64) (result i64)
(i64.store (i32.const 0) (get_local $value))
(call $i64_load_little (i32.const 0))
)

(func $f32_store (param $value f32) (result f32)
(f32.store (i32.const 0) (get_local $value))
(f32.reinterpret/i32 (call $i32_load_little (i32.const 0)))
)

(func $f64_store (param $value f64) (result f64)
(f64.store (i32.const 0) (get_local $value))
(f64.reinterpret/i64 (call $i64_load_little (i32.const 0)))
)

(export "i32_load16_s" $i32_load16_s)
(export "i32_load16_u" $i32_load16_u)
(export "i32_load" $i32_load)

(export "i64_load16_s" $i64_load16_s)
(export "i64_load16_u" $i64_load16_u)
(export "i64_load32_s" $i64_load32_s)
(export "i64_load32_u" $i64_load32_u)
(export "i64_load" $i64_load)

(export "f32_load" $f32_load)
(export "f64_load" $f64_load)


(export "i32_store16" $i32_store16)
(export "i32_store" $i32_store)

(export "i64_store16" $i64_store16)
(export "i64_store32" $i64_store32)
(export "i64_store" $i64_store)

(export "f32_store" $f32_store)
(export "f64_store" $f64_store)
)
Expand Down
6 changes: 3 additions & 3 deletions ml-proto/test/float_exprs.wast
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,15 @@
(func $i32.no_fold_f32_s (param i32) (result i32)
(i32.trunc_s/f32 (f32.convert_s/i32 (get_local 0))))
(export "i32.no_fold_f32_s" $i32.no_fold_f32_s)

(func $i32.no_fold_f32_u (param i32) (result i32)
(i32.trunc_u/f32 (f32.convert_u/i32 (get_local 0))))
(export "i32.no_fold_f32_u" $i32.no_fold_f32_u)

(func $i64.no_fold_f64_s (param i64) (result i64)
(i64.trunc_s/f64 (f64.convert_s/i64 (get_local 0))))
(export "i64.no_fold_f64_s" $i64.no_fold_f64_s)

(func $i64.no_fold_f64_u (param i64) (result i64)
(i64.trunc_u/f64 (f64.convert_u/i64 (get_local 0))))
(export "i64.no_fold_f64_u" $i64.no_fold_f64_u)
Expand Down
2 changes: 1 addition & 1 deletion ml-proto/test/imports.wast
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(module
(module
(import $print_i32 "stdio" "print" (param i32))
(import $print_i64 "stdio" "print" (param i64))
(import $print_i32_f32 "stdio" "print" (param i32 f32))
Expand Down
74 changes: 37 additions & 37 deletions ml-proto/test/left-to-right.wast
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(module
(memory 9)

;; The idea is: We reset the memory, then the arithmetic instruction calls $*_left and $*_right.
;; $*_left stores the number 1, and $*_right stores the number 2 (both at address 8)
;; Then we read the value at address 8. If it's 0, the VM did an unwanted optimzation.
Expand Down Expand Up @@ -110,48 +110,48 @@
(func $f64_call (result i32) (call $reset) (call $f64_dummy (call $f64_left) (call $f64_right)) (call $get))


(export "i32_add" $i32_add) (export "i64_add" $i64_add)
(export "i32_sub" $i32_sub) (export "i64_sub" $i64_sub)
(export "i32_mul" $i32_mul) (export "i64_mul" $i64_mul)
(export "i32_div_s" $i32_div_s) (export "i64_div_s" $i64_div_s)
(export "i32_div_u" $i32_div_u) (export "i64_div_u" $i64_div_u)
(export "i32_rem_s" $i32_rem_s) (export "i64_rem_s" $i64_rem_s)
(export "i32_rem_u" $i32_rem_u) (export "i64_rem_u" $i64_rem_u)
(export "i32_and" $i32_and) (export "i64_and" $i64_and)
(export "i32_or" $i32_or) (export "i64_or" $i64_or)
(export "i32_xor" $i32_xor) (export "i64_xor" $i64_xor)
(export "i32_shl" $i32_shl) (export "i64_shl" $i64_shl)
(export "i32_shr_u" $i32_shr_u) (export "i64_shr_u" $i64_shr_u)
(export "i32_shr_s" $i32_shr_s) (export "i64_shr_s" $i64_shr_s)
(export "i32_eq" $i32_eq) (export "i64_eq" $i64_eq)
(export "i32_ne" $i32_ne) (export "i64_ne" $i64_ne)
(export "i32_lt_s" $i32_lt_s) (export "i64_lt_s" $i64_lt_s)
(export "i32_le_s" $i32_le_s) (export "i64_le_s" $i64_le_s)
(export "i32_lt_u" $i32_lt_u) (export "i64_lt_u" $i64_lt_u)
(export "i32_le_u" $i32_le_u) (export "i64_le_u" $i64_le_u)
(export "i32_gt_s" $i32_gt_s) (export "i64_gt_s" $i64_gt_s)
(export "i32_ge_s" $i32_ge_s) (export "i64_ge_s" $i64_ge_s)
(export "i32_gt_u" $i32_gt_u) (export "i64_gt_u" $i64_gt_u)
(export "i32_ge_u" $i32_ge_u) (export "i64_ge_u" $i64_ge_u)
(export "i32_add" $i32_add) (export "i64_add" $i64_add)
(export "i32_sub" $i32_sub) (export "i64_sub" $i64_sub)
(export "i32_mul" $i32_mul) (export "i64_mul" $i64_mul)
(export "i32_div_s" $i32_div_s) (export "i64_div_s" $i64_div_s)
(export "i32_div_u" $i32_div_u) (export "i64_div_u" $i64_div_u)
(export "i32_rem_s" $i32_rem_s) (export "i64_rem_s" $i64_rem_s)
(export "i32_rem_u" $i32_rem_u) (export "i64_rem_u" $i64_rem_u)
(export "i32_and" $i32_and) (export "i64_and" $i64_and)
(export "i32_or" $i32_or) (export "i64_or" $i64_or)
(export "i32_xor" $i32_xor) (export "i64_xor" $i64_xor)
(export "i32_shl" $i32_shl) (export "i64_shl" $i64_shl)
(export "i32_shr_u" $i32_shr_u) (export "i64_shr_u" $i64_shr_u)
(export "i32_shr_s" $i32_shr_s) (export "i64_shr_s" $i64_shr_s)
(export "i32_eq" $i32_eq) (export "i64_eq" $i64_eq)
(export "i32_ne" $i32_ne) (export "i64_ne" $i64_ne)
(export "i32_lt_s" $i32_lt_s) (export "i64_lt_s" $i64_lt_s)
(export "i32_le_s" $i32_le_s) (export "i64_le_s" $i64_le_s)
(export "i32_lt_u" $i32_lt_u) (export "i64_lt_u" $i64_lt_u)
(export "i32_le_u" $i32_le_u) (export "i64_le_u" $i64_le_u)
(export "i32_gt_s" $i32_gt_s) (export "i64_gt_s" $i64_gt_s)
(export "i32_ge_s" $i32_ge_s) (export "i64_ge_s" $i64_ge_s)
(export "i32_gt_u" $i32_gt_u) (export "i64_gt_u" $i64_gt_u)
(export "i32_ge_u" $i32_ge_u) (export "i64_ge_u" $i64_ge_u)
(export "i32_store" $i32_store) (export "i64_store" $i64_store)
(export "i32_store8" $i32_store8) (export "i64_store8" $i64_store8)
(export "i32_store16" $i32_store16) (export "i64_store16" $i64_store16)
(export "i64_store32" $i64_store32)
(export "i32_call" $i32_call) (export "i64_call" $i64_call)

(export "f32_add" $f32_add) (export "f64_add" $f64_add)
(export "f32_sub" $f32_sub) (export "f64_sub" $f64_sub)
(export "f32_mul" $f32_mul) (export "f64_mul" $f64_mul)
(export "f32_div" $f32_div) (export "f64_div" $f64_div)
(export "f32_copysign" $f32_copysign) (export "f64_copysign" $f64_copysign)
(export "f32_eq" $f32_eq) (export "f64_eq" $f64_eq)
(export "f32_ne" $f32_ne) (export "f64_ne" $f64_ne)
(export "f32_lt" $f32_lt) (export "f64_lt" $f64_lt)
(export "f32_le" $f32_le) (export "f64_le" $f64_le)
(export "f32_gt" $f32_gt) (export "f64_gt" $f64_gt)
(export "f32_ge" $f32_ge) (export "f64_ge" $f64_ge)
(export "f32_min" $f32_min) (export "f64_min" $f64_min)
(export "f32_max" $f32_max) (export "f64_max" $f64_max)
(export "f32_add" $f32_add) (export "f64_add" $f64_add)
(export "f32_sub" $f32_sub) (export "f64_sub" $f64_sub)
(export "f32_mul" $f32_mul) (export "f64_mul" $f64_mul)
(export "f32_div" $f32_div) (export "f64_div" $f64_div)
(export "f32_copysign" $f32_copysign) (export "f64_copysign" $f64_copysign)
(export "f32_eq" $f32_eq) (export "f64_eq" $f64_eq)
(export "f32_ne" $f32_ne) (export "f64_ne" $f64_ne)
(export "f32_lt" $f32_lt) (export "f64_lt" $f64_lt)
(export "f32_le" $f32_le) (export "f64_le" $f64_le)
(export "f32_gt" $f32_gt) (export "f64_gt" $f64_gt)
(export "f32_ge" $f32_ge) (export "f64_ge" $f64_ge)
(export "f32_min" $f32_min) (export "f64_min" $f64_min)
(export "f32_max" $f32_max) (export "f64_max" $f64_max)
(export "f32_store" $f32_store) (export "f64_store" $f64_store)
(export "f32_call" $f32_call) (export "f64_call" $f64_call)
)
Expand Down
2 changes: 1 addition & 1 deletion ml-proto/test/memory_trap.wast
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

(export "store" $store)
(func $store (param $i i32) (param $v i32) (result i32) (i32.store (i32.add (memory_size) (get_local $i)) (get_local $v)))

(export "load" $load)
(func $load (param $i i32) (result i32) (i32.load (i32.add (memory_size) (get_local $i))))

Expand Down
2 changes: 1 addition & 1 deletion ml-proto/test/resizing.wast
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(module
(memory 0)

(export "round_up_to_page" $round_up_to_page)
(func $round_up_to_page (param i32) (result i32)
(i32.and (i32.add (get_local 0) (i32.const 0xFFFF))
Expand Down
Loading