From 4b6c3bdcf07903e7afefe32f730f04f35a16cc12 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 25 Sep 2015 06:39:56 -0700 Subject: [PATCH 1/7] Incorporate several tests from unsigned.wasm into i32.wasm and i64.wasm. --- ml-proto/test/i32.wasm | 4 ++ ml-proto/test/i64.wasm | 5 ++ ml-proto/test/unsigned.wasm | 92 ------------------------------------- 3 files changed, 9 insertions(+), 92 deletions(-) diff --git a/ml-proto/test/i32.wasm b/ml-proto/test/i32.wasm index 376a99faf3..646a32b29f 100644 --- a/ml-proto/test/i32.wasm +++ b/ml-proto/test/i32.wasm @@ -86,6 +86,7 @@ (assert_eq (invoke "div_s" (i32.const 0) (i32.const 1)) (i32.const 0)) (assert_eq (invoke "div_s" (i32.const -1) (i32.const -1)) (i32.const 1)) (assert_eq (invoke "div_s" (i32.const 0x80000000) (i32.const 2)) (i32.const 0xc0000000)) +(assert_eq (invoke "div_s" (i32.const 0x80000001) (i32.const 1000)) (i32.const 0xffdf3b65)) (assert_eq (invoke "div_s" (i32.const 5) (i32.const 2)) (i32.const 2)) (assert_eq (invoke "div_s" (i32.const -5) (i32.const 2)) (i32.const -2)) (assert_eq (invoke "div_s" (i32.const 5) (i32.const -2)) (i32.const -2)) @@ -105,6 +106,7 @@ (assert_eq (invoke "div_u" (i32.const 0x80000000) (i32.const -1)) (i32.const 0)) (assert_eq (invoke "div_u" (i32.const 0x80000000) (i32.const 2)) (i32.const 0x40000000)) (assert_eq (invoke "div_u" (i32.const 0x8ff00ff0) (i32.const 0x10001)) (i32.const 0x8fef)) +(assert_eq (invoke "div_u" (i32.const 0x80000001) (i32.const 1000)) (i32.const 0x20c49b)) (assert_eq (invoke "div_u" (i32.const 5) (i32.const 2)) (i32.const 2)) (assert_eq (invoke "div_u" (i32.const -5) (i32.const 2)) (i32.const 0x7ffffffd)) (assert_eq (invoke "div_u" (i32.const 5) (i32.const -2)) (i32.const 0)) @@ -121,6 +123,7 @@ (assert_eq (invoke "rem_s" (i32.const -1) (i32.const -1)) (i32.const 0)) (assert_eq (invoke "rem_s" (i32.const 0x80000000) (i32.const -1)) (i32.const 0)) (assert_eq (invoke "rem_s" (i32.const 0x80000000) (i32.const 2)) (i32.const 0)) +(assert_eq (invoke "rem_s" (i32.const 0x80000001) (i32.const 1000)) (i32.const -647)) (assert_eq (invoke "rem_s" (i32.const 5) (i32.const 2)) (i32.const 1)) (assert_eq (invoke "rem_s" (i32.const -5) (i32.const 2)) (i32.const -1)) (assert_eq (invoke "rem_s" (i32.const 5) (i32.const -2)) (i32.const 1)) @@ -140,6 +143,7 @@ (assert_eq (invoke "rem_u" (i32.const 0x80000000) (i32.const -1)) (i32.const 0x80000000)) (assert_eq (invoke "rem_u" (i32.const 0x80000000) (i32.const 2)) (i32.const 0)) (assert_eq (invoke "rem_u" (i32.const 0x8ff00ff0) (i32.const 0x10001)) (i32.const 0x8001)) +(assert_eq (invoke "rem_u" (i32.const 0x80000001) (i32.const 1000)) (i32.const 649)) (assert_eq (invoke "rem_u" (i32.const 5) (i32.const 2)) (i32.const 1)) (assert_eq (invoke "rem_u" (i32.const -5) (i32.const 2)) (i32.const 1)) (assert_eq (invoke "rem_u" (i32.const 5) (i32.const -2)) (i32.const 5)) diff --git a/ml-proto/test/i64.wasm b/ml-proto/test/i64.wasm index dd569577a4..4e6633b689 100644 --- a/ml-proto/test/i64.wasm +++ b/ml-proto/test/i64.wasm @@ -86,6 +86,7 @@ (assert_eq (invoke "div_s" (i64.const 0) (i64.const 1)) (i64.const 0)) (assert_eq (invoke "div_s" (i64.const -1) (i64.const -1)) (i64.const 1)) (assert_eq (invoke "div_s" (i64.const 0x8000000000000000) (i64.const 2)) (i64.const 0xc000000000000000)) +(assert_eq (invoke "div_s" (i64.const 0x8000000000000001) (i64.const 1000)) (i64.const 0xffdf3b645a1cac09)) (assert_eq (invoke "div_s" (i64.const 5) (i64.const 2)) (i64.const 2)) (assert_eq (invoke "div_s" (i64.const -5) (i64.const 2)) (i64.const -2)) (assert_eq (invoke "div_s" (i64.const 5) (i64.const -2)) (i64.const -2)) @@ -97,6 +98,7 @@ (assert_eq (invoke "div_s" (i64.const 11) (i64.const 5)) (i64.const 2)) (assert_eq (invoke "div_s" (i64.const 17) (i64.const 7)) (i64.const 2)) + (assert_trap (invoke "div_u" (i64.const 1) (i64.const 0)) "runtime: integer divide by zero") (assert_trap (invoke "div_u" (i64.const 0) (i64.const 0)) "runtime: integer divide by zero") (assert_eq (invoke "div_u" (i64.const 1) (i64.const 1)) (i64.const 1)) @@ -105,6 +107,7 @@ (assert_eq (invoke "div_u" (i64.const 0x8000000000000000) (i64.const -1)) (i64.const 0)) (assert_eq (invoke "div_u" (i64.const 0x8000000000000000) (i64.const 2)) (i64.const 0x4000000000000000)) (assert_eq (invoke "div_u" (i64.const 0x8ff00ff00ff00ff0) (i64.const 0x100000001)) (i64.const 0x8ff00fef)) +(assert_eq (invoke "div_u" (i64.const 0x8000000000000001) (i64.const 1000)) (i64.const 0x20c49ba5e353f7)) (assert_eq (invoke "div_u" (i64.const 5) (i64.const 2)) (i64.const 2)) (assert_eq (invoke "div_u" (i64.const -5) (i64.const 2)) (i64.const 0x7ffffffffffffffd)) (assert_eq (invoke "div_u" (i64.const 5) (i64.const -2)) (i64.const 0)) @@ -121,6 +124,7 @@ (assert_eq (invoke "rem_s" (i64.const -1) (i64.const -1)) (i64.const 0)) (assert_eq (invoke "rem_s" (i64.const 0x8000000000000000) (i64.const -1)) (i64.const 0)) (assert_eq (invoke "rem_s" (i64.const 0x8000000000000000) (i64.const 2)) (i64.const 0)) +(assert_eq (invoke "rem_s" (i64.const 0x8000000000000001) (i64.const 1000)) (i64.const -807)) (assert_eq (invoke "rem_s" (i64.const 5) (i64.const 2)) (i64.const 1)) (assert_eq (invoke "rem_s" (i64.const -5) (i64.const 2)) (i64.const -1)) (assert_eq (invoke "rem_s" (i64.const 5) (i64.const -2)) (i64.const 1)) @@ -140,6 +144,7 @@ (assert_eq (invoke "rem_u" (i64.const 0x8000000000000000) (i64.const -1)) (i64.const 0x8000000000000000)) (assert_eq (invoke "rem_u" (i64.const 0x8000000000000000) (i64.const 2)) (i64.const 0)) (assert_eq (invoke "rem_u" (i64.const 0x8ff00ff00ff00ff0) (i64.const 0x100000001)) (i64.const 0x80000001)) +(assert_eq (invoke "rem_u" (i64.const 0x8000000000000001) (i64.const 1000)) (i64.const 809)) (assert_eq (invoke "rem_u" (i64.const 5) (i64.const 2)) (i64.const 1)) (assert_eq (invoke "rem_u" (i64.const -5) (i64.const 2)) (i64.const 1)) (assert_eq (invoke "rem_u" (i64.const 5) (i64.const -2)) (i64.const 5)) diff --git a/ml-proto/test/unsigned.wasm b/ml-proto/test/unsigned.wasm index ab3b9e7068..492e123588 100644 --- a/ml-proto/test/unsigned.wasm +++ b/ml-proto/test/unsigned.wasm @@ -1,30 +1,4 @@ (module - (func $div_s (param $i i64) (param $j i64) (result i64) - (return (i64.div_s (get_local $i) (get_local $j))) - ) - (func $div_u (param $i i64) (param $j i64) (result i64) - (return (i64.div_u (get_local $i) (get_local $j))) - ) - (func $rem_s (param $i i64) (param $j i64) (result i64) - (return (i64.rem_s (get_local $i) (get_local $j))) - ) - (func $rem_u (param $i i64) (param $j i64) (result i64) - (return (i64.rem_u (get_local $i) (get_local $j))) - ) - - (func $lt_s (param $i i64) (param $j i64) (result i32) - (return (i64.lt_s (get_local $i) (get_local $j))) - ) - (func $lt_u (param $i i64) (param $j i64) (result i32) - (return (i64.lt_u (get_local $i) (get_local $j))) - ) - (func $ge_s (param $i i64) (param $j i64) (result i32) - (return (i64.ge_s (get_local $i) (get_local $j))) - ) - (func $ge_u (param $i i64) (param $j i64) (result i32) - (return (i64.ge_u (get_local $i) (get_local $j))) - ) - (func $i32_trunc_u (param $x f64) (result i32) (return (i32.trunc_u/f64 (get_local $x))) ) @@ -32,76 +6,10 @@ (return (i64.trunc_u/f64 (get_local $x))) ) - (export "div_s" $div_s) - (export "div_u" $div_u) - (export "rem_s" $rem_s) - (export "rem_u" $rem_u) - (export "lt_s" $lt_s) - (export "lt_u" $lt_u) - (export "ge_s" $ge_s) - (export "ge_u" $ge_u) (export "i32.trunc_u" $i32_trunc_u) (export "i64.trunc_u" $i64_trunc_u) ) -(assert_eq - (invoke "div_s" - (i64.add (i64.const 9223372036854775807) (i64.const 2)) ;; max_int64+2 - (i64.const 1000) - ) - (i64.const -9223372036854775) ;; div_s -) -(assert_eq - (invoke "div_u" - (i64.add (i64.const 9223372036854775807) (i64.const 2)) ;; max_int64+2 - (i64.const 1000) - ) - (i64.const 9223372036854775) ;; div_u -) -(assert_eq - (invoke "rem_s" - (i64.add (i64.const 9223372036854775807) (i64.const 2)) ;; max_int64+2 - (i64.const 1000) - ) - (i64.const -807) ;; rem_s -) -(assert_eq - (invoke "rem_u" - (i64.add (i64.const 9223372036854775807) (i64.const 2)) ;; max_int64+2 - (i64.const 1000) - ) - (i64.const 809) ;; rem_u -) - -(assert_eq - (invoke "lt_s" - (i64.add (i64.const 9223372036854775807) (i64.const 1)) ;; max_int64+1 - (i64.const 9223372036854775807) - ) - (i32.const 1) ;; lt_s -) -(assert_eq - (invoke "lt_u" - (i64.add (i64.const 9223372036854775807) (i64.const 1)) ;; max_int64+1 - (i64.const 9223372036854775807) - ) - (i32.const 0) ;; lt_u -) -(assert_eq - (invoke "ge_s" - (i64.add (i64.const 9223372036854775807) (i64.const 1)) ;; max_int64+1 - (i64.const 9223372036854775807) - ) - (i32.const 0) ;; ge_s -) -(assert_eq - (invoke "ge_u" - (i64.add (i64.const 9223372036854775807) (i64.const 1)) ;; max_int64+1 - (i64.const 9223372036854775807) - ) - (i32.const 1) ;; ge_u -) - (assert_eq (invoke "i32.trunc_u" (f64.const 1e8)) (i32.const 100000000)) (assert_eq (invoke "i64.trunc_u" (f64.const 1e8)) (i64.const 100000000)) From d6e9084ed5c5ae84d2d57182f14c257a62dd79bd Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 25 Sep 2015 06:41:53 -0700 Subject: [PATCH 2/7] Delete uninteresting comments. --- ml-proto/test/conversions.wasm | 44 ---------------------------------- 1 file changed, 44 deletions(-) diff --git a/ml-proto/test/conversions.wasm b/ml-proto/test/conversions.wasm index b2ea46f4c3..0f8443ef37 100644 --- a/ml-proto/test/conversions.wasm +++ b/ml-proto/test/conversions.wasm @@ -1,102 +1,76 @@ (module - - ;; i64.extend_s/i32 (func $i64_extend_s_i32 (param $x i32) (result i64) (i64.extend_s/i32 (get_local $x))) (export "$i64_extend_s_i32" $i64_extend_s_i32) - ;; i64.extend_u/i32 (func $i64_extend_u_i32 (param $x i32) (result i64) (i64.extend_u/i32 (get_local $x))) (export "$i64_extend_u_i32" $i64_extend_u_i32) - ;; i32.wrap/i64 (func $i32_wrap_i64 (param $x i64) (result i32) (i32.wrap/i64 (get_local $x))) (export "$i32_wrap_i64" $i32_wrap_i64) - ;; i32.trunc_s/f32 (func $i32_trunc_s_f32 (param $x f32) (result i32) (i32.trunc_s/f32 (get_local $x))) (export "$i32_trunc_s_f32" $i32_trunc_s_f32) - ;; i32.trunc_u/f32 (func $i32_trunc_u_f32 (param $x f32) (result i32) (i32.trunc_u/f32 (get_local $x))) (export "$i32_trunc_u_f32" $i32_trunc_u_f32) - ;; i64.trunc_s/f32 (func $i64_trunc_s_f32 (param $x f32) (result i64) (i64.trunc_s/f32 (get_local $x))) (export "$i64_trunc_s_f32" $i64_trunc_s_f32) - ;; i64.trunc_u/f32 (func $i64_trunc_u_f32 (param $x f32) (result i64) (i64.trunc_u/f32 (get_local $x))) (export "$i64_trunc_u_f32" $i64_trunc_u_f32) - ;; f32.convert_s/i32 (func $f32_convert_s_i32 (param $x i32) (result f32) (f32.convert_s/i32 (get_local $x))) (export "$f32_convert_s_i32" $f32_convert_s_i32) - ;; f32.convert_s/i64 (func $f32_convert_s_i64 (param $x i64) (result f32) (f32.convert_s/i64 (get_local $x))) (export "$f32_convert_s_i64" $f32_convert_s_i64) - ;; f64.convert_s/i32 (func $f64_convert_s_i32 (param $x i32) (result f64) (f64.convert_s/i32 (get_local $x))) (export "$f64_convert_s_i32" $f64_convert_s_i32) - ;; f64.convert_s/i64 (func $f64_convert_s_i64 (param $x i64) (result f64) (f64.convert_s/i64 (get_local $x))) (export "$f64_convert_s_i64" $f64_convert_s_i64) - ;; f32.convert_u/i32 (func $f32_convert_u_i32 (param $x i32) (result f32) (f32.convert_u/i32 (get_local $x))) (export "$f32_convert_u_i32" $f32_convert_u_i32) - ;; f32.convert_u/i64 (func $f32_convert_u_i64 (param $x i64) (result f32) (f32.convert_u/i64 (get_local $x))) (export "$f32_convert_u_i64" $f32_convert_u_i64) - ;; f64.convert_u/i32 (func $f64_convert_u_i32 (param $x i32) (result f64) (f64.convert_u/i32 (get_local $x))) (export "$f64_convert_u_i32" $f64_convert_u_i32) - ;; f64.convert_u/i64 (func $f64_convert_u_i64 (param $x i64) (result f64) (f64.convert_u/i64 (get_local $x))) (export "$f64_convert_u_i64" $f64_convert_u_i64) - ;; f64.promote/f32 (func $f64_promote_f32 (param $x f32) (result f64) (f64.promote/f32 (get_local $x))) (export "$f64_promote_f32" $f64_promote_f32) - ;; f32.demote/f64 (func $f32_demote_f64 (param $x f64) (result f32) (f32.demote/f64 (get_local $x))) (export "$f32_demote_f64" $f32_demote_f64) - ;; f32.reinterpret/i32 (func $f32_reinterpret_i32 (param $x i32) (result f32) (f32.reinterpret/i32 (get_local $x))) (export "$f32_reinterpret_i32" $f32_reinterpret_i32) - ;; f64.reinterpret/i64 (func $f64_reinterpret_i64 (param $x i64) (result f64) (f64.reinterpret/i64 (get_local $x))) (export "$f64_reinterpret_i64" $f64_reinterpret_i64) - ;; i32.reinterpret/f32 (func $i32_reinterpret_f32 (param $x f32) (result i32) (i32.reinterpret/f32 (get_local $x))) (export "$i32_reinterpret_f32" $i32_reinterpret_f32) - ;; i64.reinterpret/f64 (func $i64_reinterpret_f64 (param $x f64) (result i64) (i64.reinterpret/f64 (get_local $x))) (export "$i64_reinterpret_f64" $i64_reinterpret_f64) - ) -;; i64.extend_s/i32 (assert_eq (invoke "$i64_extend_s_i32" (i32.const 0)) (i64.const 0)) (assert_eq (invoke "$i64_extend_s_i32" (i32.const 10000)) (i64.const 10000)) (assert_eq (invoke "$i64_extend_s_i32" (i32.const -10000)) (i64.const -10000)) -;; i64.extend_u/i32 (assert_eq (invoke "$i64_extend_u_i32" (i32.const 0)) (i64.const 0)) (assert_eq (invoke "$i64_extend_u_i32" (i32.const 10000)) (i64.const 10000)) (assert_eq (invoke "$i64_extend_u_i32" (i32.const -10000)) (i64.const 4294957296)) ;; ffff ffff ffff d8f0 -;; i32.wrap/i64 (assert_eq (invoke "$i32_wrap_i64" (i64.const -1)) (i32.const -1)) (assert_eq (invoke "$i32_wrap_i64" (i64.const -100000)) (i32.const -100000)) (assert_eq (invoke "$i32_wrap_i64" (i64.const -2147483648)) (i32.const -2147483648)) ;; ffff ffff 8000 0000 @@ -110,7 +84,6 @@ (assert_eq (invoke "$i32_wrap_i64" (i64.const 4294967296)) (i32.const 0)) ;; 0000 0001 0000 0000 (assert_eq (invoke "$i32_wrap_i64" (i64.const 4294967297)) (i32.const 1)) ;; 0000 0001 0000 0001 -;; i32.trunc_s/f32 (assert_eq (invoke "$i32_trunc_s_f32" (f32.const 1.0)) (i32.const 1)) (assert_eq (invoke "$i32_trunc_s_f32" (f32.const 1.1)) (i32.const 1)) (assert_eq (invoke "$i32_trunc_s_f32" (f32.const 1.5)) (i32.const 1)) @@ -120,7 +93,6 @@ (assert_eq (invoke "$i32_trunc_s_f32" (f32.const -1.9)) (i32.const -1)) (assert_eq (invoke "$i32_trunc_s_f32" (f32.const -2.0)) (i32.const -2)) -;; i32.trunc_u/f32 (assert_eq (invoke "$i32_trunc_u_f32" (f32.const 1.0)) (i32.const 1)) (assert_eq (invoke "$i32_trunc_u_f32" (f32.const 1.1)) (i32.const 1)) (assert_eq (invoke "$i32_trunc_u_f32" (f32.const 1.5)) (i32.const 1)) @@ -128,7 +100,6 @@ (assert_eq (invoke "$i32_trunc_u_f32" (f32.const 2.0)) (i32.const 2)) (assert_eq (invoke "$i32_trunc_u_f32" (f32.const 2147483648)) (i32.const -2147483648)) ;; 0x1.00000p+31 -> 8000 0000 -;; i64.trunc_s/f32 (assert_eq (invoke "$i64_trunc_s_f32" (f32.const 1.0)) (i64.const 1)) (assert_eq (invoke "$i64_trunc_s_f32" (f32.const 1.1)) (i64.const 1)) (assert_eq (invoke "$i64_trunc_s_f32" (f32.const 1.5)) (i64.const 1)) @@ -140,13 +111,11 @@ (assert_eq (invoke "$i64_trunc_s_f32" (f32.const 4294967296)) (i64.const 4294967296)) ;; 0x1.00000p+32 -> 1 0000 0000 (assert_eq (invoke "$i64_trunc_s_f32" (f32.const -4294967296)) (i64.const -4294967296)) ;; -0x1.00000p+32 -> ffff ffff 0000 0000 -;; i64.trunc_u/f32 (assert_eq (invoke "$i64_trunc_u_f32" (f32.const 1.0)) (i64.const 1)) (assert_eq (invoke "$i64_trunc_u_f32" (f32.const 1.1)) (i64.const 1)) (assert_eq (invoke "$i64_trunc_u_f32" (f32.const 1.5)) (i64.const 1)) (assert_eq (invoke "$i64_trunc_u_f32" (f32.const 4294967296)) (i64.const 4294967296)) -;; f32.convert_s/i32 (assert_eq (invoke "$f32_convert_s_i32" (i32.const 1)) (f32.const 1.0)) (assert_eq (invoke "$f32_convert_s_i32" (i32.const -1)) (f32.const -1.0)) (assert_eq (invoke "$f32_convert_s_i32" (i32.const 0)) (f32.const 0.0)) @@ -154,7 +123,6 @@ (assert_eq (invoke "$f32_convert_s_i32" (i32.const -2147483648)) (f32.const -2147483648)) (assert_eq (invoke "$f32_convert_s_i32" (i32.const 1234567890)) (f32.const 1234567890)) -;; f32.convert_s/i64 (assert_eq (invoke "$f32_convert_s_i64" (i64.const 1)) (f32.const 1.0)) (assert_eq (invoke "$f32_convert_s_i64" (i64.const -1)) (f32.const -1.0)) (assert_eq (invoke "$f32_convert_s_i64" (i64.const 0)) (f32.const 0.0)) @@ -162,7 +130,6 @@ (assert_eq (invoke "$f32_convert_s_i64" (i64.const -9223372036854775808)) (f32.const -9223372036854775808)) (assert_eq (invoke "$f32_convert_s_i64" (i64.const 314159265358979)) (f32.const 314159265358979)) ;; PI -;; f64.convert_s/i32 (assert_eq (invoke "$f64_convert_s_i32" (i32.const 1)) (f64.const 1.0)) (assert_eq (invoke "$f64_convert_s_i32" (i32.const -1)) (f64.const -1.0)) (assert_eq (invoke "$f64_convert_s_i32" (i32.const 0)) (f64.const 0.0)) @@ -170,7 +137,6 @@ (assert_eq (invoke "$f64_convert_s_i32" (i32.const -2147483648)) (f64.const -2147483648)) (assert_eq (invoke "$f64_convert_s_i32" (i32.const 987654321)) (f64.const 987654321)) -;; f64.convert_s/i64 (assert_eq (invoke "$f64_convert_s_i64" (i64.const 1)) (f64.const 1.0)) (assert_eq (invoke "$f64_convert_s_i64" (i64.const -1)) (f64.const -1.0)) (assert_eq (invoke "$f64_convert_s_i64" (i64.const 0)) (f64.const 0.0)) @@ -178,32 +144,27 @@ (assert_eq (invoke "$f64_convert_s_i64" (i64.const -9223372036854775808)) (f64.const -9223372036854775808)) (assert_eq (invoke "$f64_convert_s_i64" (i64.const 4669201609102990)) (f64.const 4669201609102990)) ;; Feigenbaum -;; f32.convert_u/i32 (assert_eq (invoke "$f32_convert_u_i32" (i32.const 1)) (f32.const 1.0)) (assert_eq (invoke "$f32_convert_u_i32" (i32.const 0)) (f32.const 0.0)) (assert_eq (invoke "$f32_convert_u_i32" (i32.const 2147483647)) (f32.const 2147483647)) (assert_eq (invoke "$f32_convert_u_i32" (i32.const -2147483648)) (f32.const 2147483648)) (assert_eq (invoke "$f32_convert_u_i32" (i32.const 305419896)) (f32.const 305419896)) ;; 0x12345678 -;; f32.convert_u/i64 (assert_eq (invoke "$f32_convert_u_i64" (i64.const 1)) (f32.const 1.0)) (assert_eq (invoke "$f32_convert_u_i64" (i64.const 0)) (f32.const 0.0)) (assert_eq (invoke "$f32_convert_u_i64" (i64.const 9223372036854775807)) (f32.const 9223372036854775807)) (assert_eq (invoke "$f32_convert_u_i64" (i64.const -9223372036854775808)) (f32.const 9223372036854775808)) -;; f64.convert_u/i32 (assert_eq (invoke "$f64_convert_u_i32" (i32.const 1)) (f64.const 1.0)) (assert_eq (invoke "$f64_convert_u_i32" (i32.const 0)) (f64.const 0.0)) (assert_eq (invoke "$f64_convert_u_i32" (i32.const 2147483647)) (f64.const 2147483647)) (assert_eq (invoke "$f64_convert_u_i32" (i32.const -2147483648)) (f64.const 2147483648)) -;; f64.convert_u/i64 (assert_eq (invoke "$f64_convert_u_i64" (i64.const 1)) (f64.const 1.0)) (assert_eq (invoke "$f64_convert_u_i64" (i64.const 0)) (f64.const 0.0)) (assert_eq (invoke "$f64_convert_u_i64" (i64.const 9223372036854775807)) (f64.const 9223372036854775807)) (assert_eq (invoke "$f64_convert_u_i64" (i64.const -9223372036854775808)) (f64.const 9223372036854775808)) -;; f64.promote/f32 (assert_eq (invoke "$f64_promote_f32" (f32.const 0.0)) (f64.const 0.0)) (assert_eq (invoke "$f64_promote_f32" (f32.const 1.0)) (f64.const 1.0)) (assert_eq (invoke "$f64_promote_f32" (f32.const -1.0)) (f64.const -1.0)) @@ -216,7 +177,6 @@ ;; Generated randomly by picking a random float. (assert_eq (invoke "$f64_promote_f32" (f32.const 6.6382537e+37)) (f64.const 6.6382536710104395e+37)) -;; f32.demote/f64 (assert_eq (invoke "$f32_demote_f64" (f64.const 0.0)) (f32.const 0.0)) (assert_eq (invoke "$f32_demote_f64" (f64.const 1.0)) (f32.const 1.0)) (assert_eq (invoke "$f32_demote_f64" (f64.const -1.0)) (f32.const -1.0)) @@ -227,19 +187,16 @@ (assert_eq (invoke "$f32_demote_f64" (f64.const 1.504632769052528e-36)) (f32.const 1.5046328e-36)) (assert_eq (invoke "$f32_demote_f64" (f64.const 6.6382536710104395e+37)) (f32.const 6.6382537e+37)) -;; f32.reinterpret/i32 (assert_eq (invoke "$f32_reinterpret_i32" (i32.const 0)) (f32.const 0.0)) (assert_eq (invoke "$f32_reinterpret_i32" (i32.const 1)) (f32.const 1.4012984e-45)) (assert_eq (invoke "$f32_reinterpret_i32" (i32.const 123456789)) (f32.const 1.6535997e-34)) (assert_eq (invoke "$f32_reinterpret_i32" (i32.const -2147483647)) (f32.const -1.4012984e-45)) -;; f64.reinterpret/i64 (assert_eq (invoke "$f64_reinterpret_i64" (i64.const 0)) (f64.const 0.0)) (assert_eq (invoke "$f64_reinterpret_i64" (i64.const 1)) (f64.const 4.94066e-324)) (assert_eq (invoke "$f64_reinterpret_i64" (i64.const 1234567890)) (f64.const 6.099575819077150e-315)) (assert_eq (invoke "$f64_reinterpret_i64" (i64.const -9223372036854775807)) (f64.const -4.940656458412465e-324)) -;; i32.reinterpret/f32 (assert_eq (invoke "$i32_reinterpret_f32" (f32.const 0.0)) (i32.const 0)) (assert_eq (invoke "$i32_reinterpret_f32" (f32.const 1.0)) (i32.const 1065353216)) (assert_eq (invoke "$i32_reinterpret_f32" (f32.const 3.1415926)) (i32.const 1078530010)) @@ -248,7 +205,6 @@ (assert_eq (invoke "$i32_reinterpret_f32" (f32.const 1.4012984e-45)) (i32.const 1)) (assert_eq (invoke "$i32_reinterpret_f32" (f32.const -1.4012984e-45)) (i32.const -2147483647)) -;; i64.reinterpret/f64 (assert_eq (invoke "$i64_reinterpret_f64" (f64.const 0.0)) (i64.const 0)) (assert_eq (invoke "$i64_reinterpret_f64" (f64.const 1.0)) (i64.const 4607182418800017408)) (assert_eq (invoke "$i64_reinterpret_f64" (f64.const 3.14159265358979)) (i64.const 4614256656552045841)) From f336633ed273c1cf1fa470cb6a216a7e4d825b77 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 25 Sep 2015 06:54:42 -0700 Subject: [PATCH 3/7] Remove unnecessary '$'s and use '.'s in identifiers to match opcode names. --- ml-proto/src/host/lexer.mll | 2 +- ml-proto/test/conversions.wasm | 378 ++++++++++++++++----------------- 2 files changed, 190 insertions(+), 190 deletions(-) diff --git a/ml-proto/src/host/lexer.mll b/ml-proto/src/host/lexer.mll index 7686927a2d..3483b5803a 100644 --- a/ml-proto/src/host/lexer.mll +++ b/ml-proto/src/host/lexer.mll @@ -85,7 +85,7 @@ let space = [' ''\t'] let digit = ['0'-'9'] let hexdigit = ['0'-'9''a'-'f''A'-'F'] let letter = ['a'-'z''A'-'Z'] -let symbol = ['+''-''*''/''\\''^''~''=''<''>''!''?''@''#''$''%''&''|'':''`'] +let symbol = ['+''-''*''/''\\''^''~''=''<''>''!''?''@''#''$''%''&''|'':''`''.'] let tick = '\'' let escape = ['n''t''\\''\'''\"'] let character = [^'"''\\''\n'] | '\\'escape | '\\'hexdigit hexdigit diff --git a/ml-proto/test/conversions.wasm b/ml-proto/test/conversions.wasm index 0f8443ef37..2f3469f31e 100644 --- a/ml-proto/test/conversions.wasm +++ b/ml-proto/test/conversions.wasm @@ -1,214 +1,214 @@ (module - (func $i64_extend_s_i32 (param $x i32) (result i64) (i64.extend_s/i32 (get_local $x))) - (export "$i64_extend_s_i32" $i64_extend_s_i32) + (func $i64.extend_s_i32 (param $x i32) (result i64) (i64.extend_s/i32 (get_local $x))) + (export "i64.extend_s_i32" $i64.extend_s_i32) - (func $i64_extend_u_i32 (param $x i32) (result i64) (i64.extend_u/i32 (get_local $x))) - (export "$i64_extend_u_i32" $i64_extend_u_i32) + (func $i64.extend_u_i32 (param $x i32) (result i64) (i64.extend_u/i32 (get_local $x))) + (export "i64.extend_u_i32" $i64.extend_u_i32) - (func $i32_wrap_i64 (param $x i64) (result i32) (i32.wrap/i64 (get_local $x))) - (export "$i32_wrap_i64" $i32_wrap_i64) + (func $i32.wrap_i64 (param $x i64) (result i32) (i32.wrap/i64 (get_local $x))) + (export "i32.wrap_i64" $i32.wrap_i64) - (func $i32_trunc_s_f32 (param $x f32) (result i32) (i32.trunc_s/f32 (get_local $x))) - (export "$i32_trunc_s_f32" $i32_trunc_s_f32) + (func $i32.trunc_s_f32 (param $x f32) (result i32) (i32.trunc_s/f32 (get_local $x))) + (export "i32.trunc_s_f32" $i32.trunc_s_f32) - (func $i32_trunc_u_f32 (param $x f32) (result i32) (i32.trunc_u/f32 (get_local $x))) - (export "$i32_trunc_u_f32" $i32_trunc_u_f32) + (func $i32.trunc_u_f32 (param $x f32) (result i32) (i32.trunc_u/f32 (get_local $x))) + (export "i32.trunc_u_f32" $i32.trunc_u_f32) - (func $i64_trunc_s_f32 (param $x f32) (result i64) (i64.trunc_s/f32 (get_local $x))) - (export "$i64_trunc_s_f32" $i64_trunc_s_f32) + (func $i64.trunc_s_f32 (param $x f32) (result i64) (i64.trunc_s/f32 (get_local $x))) + (export "i64.trunc_s_f32" $i64.trunc_s_f32) - (func $i64_trunc_u_f32 (param $x f32) (result i64) (i64.trunc_u/f32 (get_local $x))) - (export "$i64_trunc_u_f32" $i64_trunc_u_f32) + (func $i64.trunc_u_f32 (param $x f32) (result i64) (i64.trunc_u/f32 (get_local $x))) + (export "i64.trunc_u_f32" $i64.trunc_u_f32) - (func $f32_convert_s_i32 (param $x i32) (result f32) (f32.convert_s/i32 (get_local $x))) - (export "$f32_convert_s_i32" $f32_convert_s_i32) + (func $f32.convert_s_i32 (param $x i32) (result f32) (f32.convert_s/i32 (get_local $x))) + (export "f32.convert_s_i32" $f32.convert_s_i32) - (func $f32_convert_s_i64 (param $x i64) (result f32) (f32.convert_s/i64 (get_local $x))) - (export "$f32_convert_s_i64" $f32_convert_s_i64) + (func $f32.convert_s_i64 (param $x i64) (result f32) (f32.convert_s/i64 (get_local $x))) + (export "f32.convert_s_i64" $f32.convert_s_i64) - (func $f64_convert_s_i32 (param $x i32) (result f64) (f64.convert_s/i32 (get_local $x))) - (export "$f64_convert_s_i32" $f64_convert_s_i32) + (func $f64.convert_s_i32 (param $x i32) (result f64) (f64.convert_s/i32 (get_local $x))) + (export "f64.convert_s_i32" $f64.convert_s_i32) - (func $f64_convert_s_i64 (param $x i64) (result f64) (f64.convert_s/i64 (get_local $x))) - (export "$f64_convert_s_i64" $f64_convert_s_i64) + (func $f64.convert_s_i64 (param $x i64) (result f64) (f64.convert_s/i64 (get_local $x))) + (export "f64.convert_s_i64" $f64.convert_s_i64) - (func $f32_convert_u_i32 (param $x i32) (result f32) (f32.convert_u/i32 (get_local $x))) - (export "$f32_convert_u_i32" $f32_convert_u_i32) + (func $f32.convert_u_i32 (param $x i32) (result f32) (f32.convert_u/i32 (get_local $x))) + (export "f32.convert_u_i32" $f32.convert_u_i32) - (func $f32_convert_u_i64 (param $x i64) (result f32) (f32.convert_u/i64 (get_local $x))) - (export "$f32_convert_u_i64" $f32_convert_u_i64) + (func $f32.convert_u_i64 (param $x i64) (result f32) (f32.convert_u/i64 (get_local $x))) + (export "f32.convert_u_i64" $f32.convert_u_i64) - (func $f64_convert_u_i32 (param $x i32) (result f64) (f64.convert_u/i32 (get_local $x))) - (export "$f64_convert_u_i32" $f64_convert_u_i32) + (func $f64.convert_u_i32 (param $x i32) (result f64) (f64.convert_u/i32 (get_local $x))) + (export "f64.convert_u_i32" $f64.convert_u_i32) - (func $f64_convert_u_i64 (param $x i64) (result f64) (f64.convert_u/i64 (get_local $x))) - (export "$f64_convert_u_i64" $f64_convert_u_i64) + (func $f64.convert_u_i64 (param $x i64) (result f64) (f64.convert_u/i64 (get_local $x))) + (export "f64.convert_u_i64" $f64.convert_u_i64) - (func $f64_promote_f32 (param $x f32) (result f64) (f64.promote/f32 (get_local $x))) - (export "$f64_promote_f32" $f64_promote_f32) + (func $f64.promote_f32 (param $x f32) (result f64) (f64.promote/f32 (get_local $x))) + (export "f64.promote_f32" $f64.promote_f32) - (func $f32_demote_f64 (param $x f64) (result f32) (f32.demote/f64 (get_local $x))) - (export "$f32_demote_f64" $f32_demote_f64) + (func $f32.demote_f64 (param $x f64) (result f32) (f32.demote/f64 (get_local $x))) + (export "f32.demote_f64" $f32.demote_f64) - (func $f32_reinterpret_i32 (param $x i32) (result f32) (f32.reinterpret/i32 (get_local $x))) - (export "$f32_reinterpret_i32" $f32_reinterpret_i32) + (func $f32.reinterpret_i32 (param $x i32) (result f32) (f32.reinterpret/i32 (get_local $x))) + (export "f32.reinterpret_i32" $f32.reinterpret_i32) - (func $f64_reinterpret_i64 (param $x i64) (result f64) (f64.reinterpret/i64 (get_local $x))) - (export "$f64_reinterpret_i64" $f64_reinterpret_i64) + (func $f64.reinterpret_i64 (param $x i64) (result f64) (f64.reinterpret/i64 (get_local $x))) + (export "f64.reinterpret_i64" $f64.reinterpret_i64) - (func $i32_reinterpret_f32 (param $x f32) (result i32) (i32.reinterpret/f32 (get_local $x))) - (export "$i32_reinterpret_f32" $i32_reinterpret_f32) + (func $i32.reinterpret_f32 (param $x f32) (result i32) (i32.reinterpret/f32 (get_local $x))) + (export "i32.reinterpret_f32" $i32.reinterpret_f32) - (func $i64_reinterpret_f64 (param $x f64) (result i64) (i64.reinterpret/f64 (get_local $x))) - (export "$i64_reinterpret_f64" $i64_reinterpret_f64) + (func $i64.reinterpret_f64 (param $x f64) (result i64) (i64.reinterpret/f64 (get_local $x))) + (export "i64.reinterpret_f64" $i64.reinterpret_f64) ) -(assert_eq (invoke "$i64_extend_s_i32" (i32.const 0)) (i64.const 0)) -(assert_eq (invoke "$i64_extend_s_i32" (i32.const 10000)) (i64.const 10000)) -(assert_eq (invoke "$i64_extend_s_i32" (i32.const -10000)) (i64.const -10000)) - -(assert_eq (invoke "$i64_extend_u_i32" (i32.const 0)) (i64.const 0)) -(assert_eq (invoke "$i64_extend_u_i32" (i32.const 10000)) (i64.const 10000)) -(assert_eq (invoke "$i64_extend_u_i32" (i32.const -10000)) (i64.const 4294957296)) ;; ffff ffff ffff d8f0 - -(assert_eq (invoke "$i32_wrap_i64" (i64.const -1)) (i32.const -1)) -(assert_eq (invoke "$i32_wrap_i64" (i64.const -100000)) (i32.const -100000)) -(assert_eq (invoke "$i32_wrap_i64" (i64.const -2147483648)) (i32.const -2147483648)) ;; ffff ffff 8000 0000 -(assert_eq (invoke "$i32_wrap_i64" (i64.const -2147483649)) (i32.const 2147483647)) ;; ffff ffff 7fff ffff -(assert_eq (invoke "$i32_wrap_i64" (i64.const -4294967296)) (i32.const 0)) ;; ffff ffff 0000 0000 -(assert_eq (invoke "$i32_wrap_i64" (i64.const -4294967297)) (i32.const -1)) ;; ffff fffe ffff ffff -(assert_eq (invoke "$i32_wrap_i64" (i64.const -4294967295)) (i32.const 1)) ;; ffff ffff 0000 0001 -(assert_eq (invoke "$i32_wrap_i64" (i64.const 0)) (i32.const 0)) -(assert_eq (invoke "$i32_wrap_i64" (i64.const 1311768467463790320)) (i32.const -1698898192)) ;; 1234 5678 9abc def0 -(assert_eq (invoke "$i32_wrap_i64" (i64.const 4294967295)) (i32.const -1)) ;; 0000 0000 ffff ffff -(assert_eq (invoke "$i32_wrap_i64" (i64.const 4294967296)) (i32.const 0)) ;; 0000 0001 0000 0000 -(assert_eq (invoke "$i32_wrap_i64" (i64.const 4294967297)) (i32.const 1)) ;; 0000 0001 0000 0001 - -(assert_eq (invoke "$i32_trunc_s_f32" (f32.const 1.0)) (i32.const 1)) -(assert_eq (invoke "$i32_trunc_s_f32" (f32.const 1.1)) (i32.const 1)) -(assert_eq (invoke "$i32_trunc_s_f32" (f32.const 1.5)) (i32.const 1)) -(assert_eq (invoke "$i32_trunc_s_f32" (f32.const -1.0)) (i32.const -1)) -(assert_eq (invoke "$i32_trunc_s_f32" (f32.const -1.1)) (i32.const -1)) -(assert_eq (invoke "$i32_trunc_s_f32" (f32.const -1.5)) (i32.const -1)) -(assert_eq (invoke "$i32_trunc_s_f32" (f32.const -1.9)) (i32.const -1)) -(assert_eq (invoke "$i32_trunc_s_f32" (f32.const -2.0)) (i32.const -2)) - -(assert_eq (invoke "$i32_trunc_u_f32" (f32.const 1.0)) (i32.const 1)) -(assert_eq (invoke "$i32_trunc_u_f32" (f32.const 1.1)) (i32.const 1)) -(assert_eq (invoke "$i32_trunc_u_f32" (f32.const 1.5)) (i32.const 1)) -(assert_eq (invoke "$i32_trunc_u_f32" (f32.const 1.9)) (i32.const 1)) -(assert_eq (invoke "$i32_trunc_u_f32" (f32.const 2.0)) (i32.const 2)) -(assert_eq (invoke "$i32_trunc_u_f32" (f32.const 2147483648)) (i32.const -2147483648)) ;; 0x1.00000p+31 -> 8000 0000 - -(assert_eq (invoke "$i64_trunc_s_f32" (f32.const 1.0)) (i64.const 1)) -(assert_eq (invoke "$i64_trunc_s_f32" (f32.const 1.1)) (i64.const 1)) -(assert_eq (invoke "$i64_trunc_s_f32" (f32.const 1.5)) (i64.const 1)) -(assert_eq (invoke "$i64_trunc_s_f32" (f32.const -1.0)) (i64.const -1)) -(assert_eq (invoke "$i64_trunc_s_f32" (f32.const -1.1)) (i64.const -1)) -(assert_eq (invoke "$i64_trunc_s_f32" (f32.const -1.5)) (i64.const -1)) -(assert_eq (invoke "$i64_trunc_s_f32" (f32.const -1.9)) (i64.const -1)) -(assert_eq (invoke "$i64_trunc_s_f32" (f32.const -2.0)) (i64.const -2)) -(assert_eq (invoke "$i64_trunc_s_f32" (f32.const 4294967296)) (i64.const 4294967296)) ;; 0x1.00000p+32 -> 1 0000 0000 -(assert_eq (invoke "$i64_trunc_s_f32" (f32.const -4294967296)) (i64.const -4294967296)) ;; -0x1.00000p+32 -> ffff ffff 0000 0000 - -(assert_eq (invoke "$i64_trunc_u_f32" (f32.const 1.0)) (i64.const 1)) -(assert_eq (invoke "$i64_trunc_u_f32" (f32.const 1.1)) (i64.const 1)) -(assert_eq (invoke "$i64_trunc_u_f32" (f32.const 1.5)) (i64.const 1)) -(assert_eq (invoke "$i64_trunc_u_f32" (f32.const 4294967296)) (i64.const 4294967296)) - -(assert_eq (invoke "$f32_convert_s_i32" (i32.const 1)) (f32.const 1.0)) -(assert_eq (invoke "$f32_convert_s_i32" (i32.const -1)) (f32.const -1.0)) -(assert_eq (invoke "$f32_convert_s_i32" (i32.const 0)) (f32.const 0.0)) -(assert_eq (invoke "$f32_convert_s_i32" (i32.const 2147483647)) (f32.const 2147483647)) -(assert_eq (invoke "$f32_convert_s_i32" (i32.const -2147483648)) (f32.const -2147483648)) -(assert_eq (invoke "$f32_convert_s_i32" (i32.const 1234567890)) (f32.const 1234567890)) - -(assert_eq (invoke "$f32_convert_s_i64" (i64.const 1)) (f32.const 1.0)) -(assert_eq (invoke "$f32_convert_s_i64" (i64.const -1)) (f32.const -1.0)) -(assert_eq (invoke "$f32_convert_s_i64" (i64.const 0)) (f32.const 0.0)) -(assert_eq (invoke "$f32_convert_s_i64" (i64.const 9223372036854775807)) (f32.const 9223372036854775807)) -(assert_eq (invoke "$f32_convert_s_i64" (i64.const -9223372036854775808)) (f32.const -9223372036854775808)) -(assert_eq (invoke "$f32_convert_s_i64" (i64.const 314159265358979)) (f32.const 314159265358979)) ;; PI - -(assert_eq (invoke "$f64_convert_s_i32" (i32.const 1)) (f64.const 1.0)) -(assert_eq (invoke "$f64_convert_s_i32" (i32.const -1)) (f64.const -1.0)) -(assert_eq (invoke "$f64_convert_s_i32" (i32.const 0)) (f64.const 0.0)) -(assert_eq (invoke "$f64_convert_s_i32" (i32.const 2147483647)) (f64.const 2147483647)) -(assert_eq (invoke "$f64_convert_s_i32" (i32.const -2147483648)) (f64.const -2147483648)) -(assert_eq (invoke "$f64_convert_s_i32" (i32.const 987654321)) (f64.const 987654321)) - -(assert_eq (invoke "$f64_convert_s_i64" (i64.const 1)) (f64.const 1.0)) -(assert_eq (invoke "$f64_convert_s_i64" (i64.const -1)) (f64.const -1.0)) -(assert_eq (invoke "$f64_convert_s_i64" (i64.const 0)) (f64.const 0.0)) -(assert_eq (invoke "$f64_convert_s_i64" (i64.const 9223372036854775807)) (f64.const 9223372036854775807)) -(assert_eq (invoke "$f64_convert_s_i64" (i64.const -9223372036854775808)) (f64.const -9223372036854775808)) -(assert_eq (invoke "$f64_convert_s_i64" (i64.const 4669201609102990)) (f64.const 4669201609102990)) ;; Feigenbaum - -(assert_eq (invoke "$f32_convert_u_i32" (i32.const 1)) (f32.const 1.0)) -(assert_eq (invoke "$f32_convert_u_i32" (i32.const 0)) (f32.const 0.0)) -(assert_eq (invoke "$f32_convert_u_i32" (i32.const 2147483647)) (f32.const 2147483647)) -(assert_eq (invoke "$f32_convert_u_i32" (i32.const -2147483648)) (f32.const 2147483648)) -(assert_eq (invoke "$f32_convert_u_i32" (i32.const 305419896)) (f32.const 305419896)) ;; 0x12345678 - -(assert_eq (invoke "$f32_convert_u_i64" (i64.const 1)) (f32.const 1.0)) -(assert_eq (invoke "$f32_convert_u_i64" (i64.const 0)) (f32.const 0.0)) -(assert_eq (invoke "$f32_convert_u_i64" (i64.const 9223372036854775807)) (f32.const 9223372036854775807)) -(assert_eq (invoke "$f32_convert_u_i64" (i64.const -9223372036854775808)) (f32.const 9223372036854775808)) - -(assert_eq (invoke "$f64_convert_u_i32" (i32.const 1)) (f64.const 1.0)) -(assert_eq (invoke "$f64_convert_u_i32" (i32.const 0)) (f64.const 0.0)) -(assert_eq (invoke "$f64_convert_u_i32" (i32.const 2147483647)) (f64.const 2147483647)) -(assert_eq (invoke "$f64_convert_u_i32" (i32.const -2147483648)) (f64.const 2147483648)) - -(assert_eq (invoke "$f64_convert_u_i64" (i64.const 1)) (f64.const 1.0)) -(assert_eq (invoke "$f64_convert_u_i64" (i64.const 0)) (f64.const 0.0)) -(assert_eq (invoke "$f64_convert_u_i64" (i64.const 9223372036854775807)) (f64.const 9223372036854775807)) -(assert_eq (invoke "$f64_convert_u_i64" (i64.const -9223372036854775808)) (f64.const 9223372036854775808)) - -(assert_eq (invoke "$f64_promote_f32" (f32.const 0.0)) (f64.const 0.0)) -(assert_eq (invoke "$f64_promote_f32" (f32.const 1.0)) (f64.const 1.0)) -(assert_eq (invoke "$f64_promote_f32" (f32.const -1.0)) (f64.const -1.0)) -(assert_eq (invoke "$f64_promote_f32" (f32.const 1.4012985e-45)) (f64.const 1.401298464324817e-45)) -(assert_eq (invoke "$f64_promote_f32" (f32.const -1.4012985e-45)) (f64.const -1.401298464324817e-45)) -(assert_eq (invoke "$f64_promote_f32" (f32.const -3.4028235e+38)) (f64.const -3.4028234663852886e+38)) -(assert_eq (invoke "$f64_promote_f32" (f32.const 3.4028235e+38)) (f64.const 3.4028234663852886e+38)) +(assert_eq (invoke "i64.extend_s_i32" (i32.const 0)) (i64.const 0)) +(assert_eq (invoke "i64.extend_s_i32" (i32.const 10000)) (i64.const 10000)) +(assert_eq (invoke "i64.extend_s_i32" (i32.const -10000)) (i64.const -10000)) + +(assert_eq (invoke "i64.extend_u_i32" (i32.const 0)) (i64.const 0)) +(assert_eq (invoke "i64.extend_u_i32" (i32.const 10000)) (i64.const 10000)) +(assert_eq (invoke "i64.extend_u_i32" (i32.const -10000)) (i64.const 4294957296)) ;; ffff ffff ffff d8f0 + +(assert_eq (invoke "i32.wrap_i64" (i64.const -1)) (i32.const -1)) +(assert_eq (invoke "i32.wrap_i64" (i64.const -100000)) (i32.const -100000)) +(assert_eq (invoke "i32.wrap_i64" (i64.const -2147483648)) (i32.const -2147483648)) ;; ffff ffff 8000 0000 +(assert_eq (invoke "i32.wrap_i64" (i64.const -2147483649)) (i32.const 2147483647)) ;; ffff ffff 7fff ffff +(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967296)) (i32.const 0)) ;; ffff ffff 0000 0000 +(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967297)) (i32.const -1)) ;; ffff fffe ffff ffff +(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967295)) (i32.const 1)) ;; ffff ffff 0000 0001 +(assert_eq (invoke "i32.wrap_i64" (i64.const 0)) (i32.const 0)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 1311768467463790320)) (i32.const -1698898192)) ;; 1234 5678 9abc def0 +(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967295)) (i32.const -1)) ;; 0000 0000 ffff ffff +(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967296)) (i32.const 0)) ;; 0000 0001 0000 0000 +(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967297)) (i32.const 1)) ;; 0000 0001 0000 0001 + +(assert_eq (invoke "i32.trunc_s_f32" (f32.const 1.0)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const 1.1)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const 1.5)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const -1.0)) (i32.const -1)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const -1.1)) (i32.const -1)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const -1.5)) (i32.const -1)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const -1.9)) (i32.const -1)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const -2.0)) (i32.const -2)) + +(assert_eq (invoke "i32.trunc_u_f32" (f32.const 1.0)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_u_f32" (f32.const 1.1)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_u_f32" (f32.const 1.5)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_u_f32" (f32.const 1.9)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_u_f32" (f32.const 2.0)) (i32.const 2)) +(assert_eq (invoke "i32.trunc_u_f32" (f32.const 2147483648)) (i32.const -2147483648)) ;; 0x1.00000p+31 -> 8000 0000 + +(assert_eq (invoke "i64.trunc_s_f32" (f32.const 1.0)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const 1.1)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const 1.5)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const -1.0)) (i64.const -1)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const -1.1)) (i64.const -1)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const -1.5)) (i64.const -1)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const -1.9)) (i64.const -1)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const -2.0)) (i64.const -2)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const 4294967296)) (i64.const 4294967296)) ;; 0x1.00000p+32 -> 1 0000 0000 +(assert_eq (invoke "i64.trunc_s_f32" (f32.const -4294967296)) (i64.const -4294967296)) ;; -0x1.00000p+32 -> ffff ffff 0000 0000 + +(assert_eq (invoke "i64.trunc_u_f32" (f32.const 1.0)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_u_f32" (f32.const 1.1)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_u_f32" (f32.const 1.5)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_u_f32" (f32.const 4294967296)) (i64.const 4294967296)) + +(assert_eq (invoke "f32.convert_s_i32" (i32.const 1)) (f32.const 1.0)) +(assert_eq (invoke "f32.convert_s_i32" (i32.const -1)) (f32.const -1.0)) +(assert_eq (invoke "f32.convert_s_i32" (i32.const 0)) (f32.const 0.0)) +(assert_eq (invoke "f32.convert_s_i32" (i32.const 2147483647)) (f32.const 2147483647)) +(assert_eq (invoke "f32.convert_s_i32" (i32.const -2147483648)) (f32.const -2147483648)) +(assert_eq (invoke "f32.convert_s_i32" (i32.const 1234567890)) (f32.const 1234567890)) + +(assert_eq (invoke "f32.convert_s_i64" (i64.const 1)) (f32.const 1.0)) +(assert_eq (invoke "f32.convert_s_i64" (i64.const -1)) (f32.const -1.0)) +(assert_eq (invoke "f32.convert_s_i64" (i64.const 0)) (f32.const 0.0)) +(assert_eq (invoke "f32.convert_s_i64" (i64.const 9223372036854775807)) (f32.const 9223372036854775807)) +(assert_eq (invoke "f32.convert_s_i64" (i64.const -9223372036854775808)) (f32.const -9223372036854775808)) +(assert_eq (invoke "f32.convert_s_i64" (i64.const 314159265358979)) (f32.const 314159265358979)) ;; PI + +(assert_eq (invoke "f64.convert_s_i32" (i32.const 1)) (f64.const 1.0)) +(assert_eq (invoke "f64.convert_s_i32" (i32.const -1)) (f64.const -1.0)) +(assert_eq (invoke "f64.convert_s_i32" (i32.const 0)) (f64.const 0.0)) +(assert_eq (invoke "f64.convert_s_i32" (i32.const 2147483647)) (f64.const 2147483647)) +(assert_eq (invoke "f64.convert_s_i32" (i32.const -2147483648)) (f64.const -2147483648)) +(assert_eq (invoke "f64.convert_s_i32" (i32.const 987654321)) (f64.const 987654321)) + +(assert_eq (invoke "f64.convert_s_i64" (i64.const 1)) (f64.const 1.0)) +(assert_eq (invoke "f64.convert_s_i64" (i64.const -1)) (f64.const -1.0)) +(assert_eq (invoke "f64.convert_s_i64" (i64.const 0)) (f64.const 0.0)) +(assert_eq (invoke "f64.convert_s_i64" (i64.const 9223372036854775807)) (f64.const 9223372036854775807)) +(assert_eq (invoke "f64.convert_s_i64" (i64.const -9223372036854775808)) (f64.const -9223372036854775808)) +(assert_eq (invoke "f64.convert_s_i64" (i64.const 4669201609102990)) (f64.const 4669201609102990)) ;; Feigenbaum + +(assert_eq (invoke "f32.convert_u_i32" (i32.const 1)) (f32.const 1.0)) +(assert_eq (invoke "f32.convert_u_i32" (i32.const 0)) (f32.const 0.0)) +(assert_eq (invoke "f32.convert_u_i32" (i32.const 2147483647)) (f32.const 2147483647)) +(assert_eq (invoke "f32.convert_u_i32" (i32.const -2147483648)) (f32.const 2147483648)) +(assert_eq (invoke "f32.convert_u_i32" (i32.const 305419896)) (f32.const 305419896)) ;; 0x12345678 + +(assert_eq (invoke "f32.convert_u_i64" (i64.const 1)) (f32.const 1.0)) +(assert_eq (invoke "f32.convert_u_i64" (i64.const 0)) (f32.const 0.0)) +(assert_eq (invoke "f32.convert_u_i64" (i64.const 9223372036854775807)) (f32.const 9223372036854775807)) +(assert_eq (invoke "f32.convert_u_i64" (i64.const -9223372036854775808)) (f32.const 9223372036854775808)) + +(assert_eq (invoke "f64.convert_u_i32" (i32.const 1)) (f64.const 1.0)) +(assert_eq (invoke "f64.convert_u_i32" (i32.const 0)) (f64.const 0.0)) +(assert_eq (invoke "f64.convert_u_i32" (i32.const 2147483647)) (f64.const 2147483647)) +(assert_eq (invoke "f64.convert_u_i32" (i32.const -2147483648)) (f64.const 2147483648)) + +(assert_eq (invoke "f64.convert_u_i64" (i64.const 1)) (f64.const 1.0)) +(assert_eq (invoke "f64.convert_u_i64" (i64.const 0)) (f64.const 0.0)) +(assert_eq (invoke "f64.convert_u_i64" (i64.const 9223372036854775807)) (f64.const 9223372036854775807)) +(assert_eq (invoke "f64.convert_u_i64" (i64.const -9223372036854775808)) (f64.const 9223372036854775808)) + +(assert_eq (invoke "f64.promote_f32" (f32.const 0.0)) (f64.const 0.0)) +(assert_eq (invoke "f64.promote_f32" (f32.const 1.0)) (f64.const 1.0)) +(assert_eq (invoke "f64.promote_f32" (f32.const -1.0)) (f64.const -1.0)) +(assert_eq (invoke "f64.promote_f32" (f32.const 1.4012985e-45)) (f64.const 1.401298464324817e-45)) +(assert_eq (invoke "f64.promote_f32" (f32.const -1.4012985e-45)) (f64.const -1.401298464324817e-45)) +(assert_eq (invoke "f64.promote_f32" (f32.const -3.4028235e+38)) (f64.const -3.4028234663852886e+38)) +(assert_eq (invoke "f64.promote_f32" (f32.const 3.4028235e+38)) (f64.const 3.4028234663852886e+38)) ;; Generated randomly by picking a random int and reinterpret it to float. -(assert_eq (invoke "$f64_promote_f32" (f32.const 1.5046328e-36)) (f64.const 1.504632769052528e-36)) +(assert_eq (invoke "f64.promote_f32" (f32.const 1.5046328e-36)) (f64.const 1.504632769052528e-36)) ;; Generated randomly by picking a random float. -(assert_eq (invoke "$f64_promote_f32" (f32.const 6.6382537e+37)) (f64.const 6.6382536710104395e+37)) - -(assert_eq (invoke "$f32_demote_f64" (f64.const 0.0)) (f32.const 0.0)) -(assert_eq (invoke "$f32_demote_f64" (f64.const 1.0)) (f32.const 1.0)) -(assert_eq (invoke "$f32_demote_f64" (f64.const -1.0)) (f32.const -1.0)) -(assert_eq (invoke "$f32_demote_f64" (f64.const -1.401298464324817e-45)) (f32.const -1.4012985e-45)) -(assert_eq (invoke "$f32_demote_f64" (f64.const 1.401298464324817e-45)) (f32.const 1.4012985e-45)) -(assert_eq (invoke "$f32_demote_f64" (f64.const 3.402823466385289e+38)) (f32.const 3.4028235e+38)) -(assert_eq (invoke "$f32_demote_f64" (f64.const -3.402823466385289e+38)) (f32.const -3.4028235e+38)) -(assert_eq (invoke "$f32_demote_f64" (f64.const 1.504632769052528e-36)) (f32.const 1.5046328e-36)) -(assert_eq (invoke "$f32_demote_f64" (f64.const 6.6382536710104395e+37)) (f32.const 6.6382537e+37)) - -(assert_eq (invoke "$f32_reinterpret_i32" (i32.const 0)) (f32.const 0.0)) -(assert_eq (invoke "$f32_reinterpret_i32" (i32.const 1)) (f32.const 1.4012984e-45)) -(assert_eq (invoke "$f32_reinterpret_i32" (i32.const 123456789)) (f32.const 1.6535997e-34)) -(assert_eq (invoke "$f32_reinterpret_i32" (i32.const -2147483647)) (f32.const -1.4012984e-45)) - -(assert_eq (invoke "$f64_reinterpret_i64" (i64.const 0)) (f64.const 0.0)) -(assert_eq (invoke "$f64_reinterpret_i64" (i64.const 1)) (f64.const 4.94066e-324)) -(assert_eq (invoke "$f64_reinterpret_i64" (i64.const 1234567890)) (f64.const 6.099575819077150e-315)) -(assert_eq (invoke "$f64_reinterpret_i64" (i64.const -9223372036854775807)) (f64.const -4.940656458412465e-324)) - -(assert_eq (invoke "$i32_reinterpret_f32" (f32.const 0.0)) (i32.const 0)) -(assert_eq (invoke "$i32_reinterpret_f32" (f32.const 1.0)) (i32.const 1065353216)) -(assert_eq (invoke "$i32_reinterpret_f32" (f32.const 3.1415926)) (i32.const 1078530010)) -(assert_eq (invoke "$i32_reinterpret_f32" (f32.const 3.4028235e+38)) (i32.const 2139095039)) -(assert_eq (invoke "$i32_reinterpret_f32" (f32.const -3.4028235e+38)) (i32.const -8388609)) -(assert_eq (invoke "$i32_reinterpret_f32" (f32.const 1.4012984e-45)) (i32.const 1)) -(assert_eq (invoke "$i32_reinterpret_f32" (f32.const -1.4012984e-45)) (i32.const -2147483647)) - -(assert_eq (invoke "$i64_reinterpret_f64" (f64.const 0.0)) (i64.const 0)) -(assert_eq (invoke "$i64_reinterpret_f64" (f64.const 1.0)) (i64.const 4607182418800017408)) -(assert_eq (invoke "$i64_reinterpret_f64" (f64.const 3.14159265358979)) (i64.const 4614256656552045841)) -(assert_eq (invoke "$i64_reinterpret_f64" (f64.const 1.7976931348623157e+308)) (i64.const 9218868437227405311)) -(assert_eq (invoke "$i64_reinterpret_f64" (f64.const -1.7976931348623157e+308)) (i64.const -4503599627370497)) -(assert_eq (invoke "$i64_reinterpret_f64" (f64.const 4.9406565e-324)) (i64.const 1)) -(assert_eq (invoke "$i64_reinterpret_f64" (f64.const -4.9406565e-324)) (i64.const -9223372036854775807)) +(assert_eq (invoke "f64.promote_f32" (f32.const 6.6382537e+37)) (f64.const 6.6382536710104395e+37)) + +(assert_eq (invoke "f32.demote_f64" (f64.const 0.0)) (f32.const 0.0)) +(assert_eq (invoke "f32.demote_f64" (f64.const 1.0)) (f32.const 1.0)) +(assert_eq (invoke "f32.demote_f64" (f64.const -1.0)) (f32.const -1.0)) +(assert_eq (invoke "f32.demote_f64" (f64.const -1.401298464324817e-45)) (f32.const -1.4012985e-45)) +(assert_eq (invoke "f32.demote_f64" (f64.const 1.401298464324817e-45)) (f32.const 1.4012985e-45)) +(assert_eq (invoke "f32.demote_f64" (f64.const 3.402823466385289e+38)) (f32.const 3.4028235e+38)) +(assert_eq (invoke "f32.demote_f64" (f64.const -3.402823466385289e+38)) (f32.const -3.4028235e+38)) +(assert_eq (invoke "f32.demote_f64" (f64.const 1.504632769052528e-36)) (f32.const 1.5046328e-36)) +(assert_eq (invoke "f32.demote_f64" (f64.const 6.6382536710104395e+37)) (f32.const 6.6382537e+37)) + +(assert_eq (invoke "f32.reinterpret_i32" (i32.const 0)) (f32.const 0.0)) +(assert_eq (invoke "f32.reinterpret_i32" (i32.const 1)) (f32.const 1.4012984e-45)) +(assert_eq (invoke "f32.reinterpret_i32" (i32.const 123456789)) (f32.const 1.6535997e-34)) +(assert_eq (invoke "f32.reinterpret_i32" (i32.const -2147483647)) (f32.const -1.4012984e-45)) + +(assert_eq (invoke "f64.reinterpret_i64" (i64.const 0)) (f64.const 0.0)) +(assert_eq (invoke "f64.reinterpret_i64" (i64.const 1)) (f64.const 4.94066e-324)) +(assert_eq (invoke "f64.reinterpret_i64" (i64.const 1234567890)) (f64.const 6.099575819077150e-315)) +(assert_eq (invoke "f64.reinterpret_i64" (i64.const -9223372036854775807)) (f64.const -4.940656458412465e-324)) + +(assert_eq (invoke "i32.reinterpret_f32" (f32.const 0.0)) (i32.const 0)) +(assert_eq (invoke "i32.reinterpret_f32" (f32.const 1.0)) (i32.const 1065353216)) +(assert_eq (invoke "i32.reinterpret_f32" (f32.const 3.1415926)) (i32.const 1078530010)) +(assert_eq (invoke "i32.reinterpret_f32" (f32.const 3.4028235e+38)) (i32.const 2139095039)) +(assert_eq (invoke "i32.reinterpret_f32" (f32.const -3.4028235e+38)) (i32.const -8388609)) +(assert_eq (invoke "i32.reinterpret_f32" (f32.const 1.4012984e-45)) (i32.const 1)) +(assert_eq (invoke "i32.reinterpret_f32" (f32.const -1.4012984e-45)) (i32.const -2147483647)) + +(assert_eq (invoke "i64.reinterpret_f64" (f64.const 0.0)) (i64.const 0)) +(assert_eq (invoke "i64.reinterpret_f64" (f64.const 1.0)) (i64.const 4607182418800017408)) +(assert_eq (invoke "i64.reinterpret_f64" (f64.const 3.14159265358979)) (i64.const 4614256656552045841)) +(assert_eq (invoke "i64.reinterpret_f64" (f64.const 1.7976931348623157e+308)) (i64.const 9218868437227405311)) +(assert_eq (invoke "i64.reinterpret_f64" (f64.const -1.7976931348623157e+308)) (i64.const -4503599627370497)) +(assert_eq (invoke "i64.reinterpret_f64" (f64.const 4.9406565e-324)) (i64.const 1)) +(assert_eq (invoke "i64.reinterpret_f64" (f64.const -4.9406565e-324)) (i64.const -9223372036854775807)) From b4c9079c7529bcd4e133d0eb339aac5d64a3e747 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 25 Sep 2015 06:59:38 -0700 Subject: [PATCH 4/7] Hex literals are now supported so use them instead of comments. --- ml-proto/test/conversions.wasm | 22 +++++++++++----------- ml-proto/test/i32.wasm | 16 ++++++++-------- ml-proto/test/i64.wasm | 16 ++++++++-------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ml-proto/test/conversions.wasm b/ml-proto/test/conversions.wasm index 2f3469f31e..be3e9d12aa 100644 --- a/ml-proto/test/conversions.wasm +++ b/ml-proto/test/conversions.wasm @@ -69,20 +69,20 @@ (assert_eq (invoke "i64.extend_u_i32" (i32.const 0)) (i64.const 0)) (assert_eq (invoke "i64.extend_u_i32" (i32.const 10000)) (i64.const 10000)) -(assert_eq (invoke "i64.extend_u_i32" (i32.const -10000)) (i64.const 4294957296)) ;; ffff ffff ffff d8f0 +(assert_eq (invoke "i64.extend_u_i32" (i32.const -10000)) (i64.const 0x00000000ffffd8f0)) (assert_eq (invoke "i32.wrap_i64" (i64.const -1)) (i32.const -1)) (assert_eq (invoke "i32.wrap_i64" (i64.const -100000)) (i32.const -100000)) -(assert_eq (invoke "i32.wrap_i64" (i64.const -2147483648)) (i32.const -2147483648)) ;; ffff ffff 8000 0000 -(assert_eq (invoke "i32.wrap_i64" (i64.const -2147483649)) (i32.const 2147483647)) ;; ffff ffff 7fff ffff -(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967296)) (i32.const 0)) ;; ffff ffff 0000 0000 -(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967297)) (i32.const -1)) ;; ffff fffe ffff ffff -(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967295)) (i32.const 1)) ;; ffff ffff 0000 0001 +(assert_eq (invoke "i32.wrap_i64" (i64.const -2147483648)) (i32.const 0x80000000)) +(assert_eq (invoke "i32.wrap_i64" (i64.const -2147483649)) (i32.const 0x7fffffff)) +(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967296)) (i32.const 0x00000000)) +(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967297)) (i32.const 0xffffffff)) +(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967295)) (i32.const 0x00000001)) (assert_eq (invoke "i32.wrap_i64" (i64.const 0)) (i32.const 0)) -(assert_eq (invoke "i32.wrap_i64" (i64.const 1311768467463790320)) (i32.const -1698898192)) ;; 1234 5678 9abc def0 -(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967295)) (i32.const -1)) ;; 0000 0000 ffff ffff -(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967296)) (i32.const 0)) ;; 0000 0001 0000 0000 -(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967297)) (i32.const 1)) ;; 0000 0001 0000 0001 +(assert_eq (invoke "i32.wrap_i64" (i64.const 1311768467463790320)) (i32.const 0x9abcdef0)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967295)) (i32.const 0xffffffff)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967296)) (i32.const 0x00000000)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967297)) (i32.const 0x00000001)) (assert_eq (invoke "i32.trunc_s_f32" (f32.const 1.0)) (i32.const 1)) (assert_eq (invoke "i32.trunc_s_f32" (f32.const 1.1)) (i32.const 1)) @@ -148,7 +148,7 @@ (assert_eq (invoke "f32.convert_u_i32" (i32.const 0)) (f32.const 0.0)) (assert_eq (invoke "f32.convert_u_i32" (i32.const 2147483647)) (f32.const 2147483647)) (assert_eq (invoke "f32.convert_u_i32" (i32.const -2147483648)) (f32.const 2147483648)) -(assert_eq (invoke "f32.convert_u_i32" (i32.const 305419896)) (f32.const 305419896)) ;; 0x12345678 +(assert_eq (invoke "f32.convert_u_i32" (i32.const 0x12345678)) (f32.const 305419896)) ;; 0x12345678 (assert_eq (invoke "f32.convert_u_i64" (i64.const 1)) (f32.const 1.0)) (assert_eq (invoke "f32.convert_u_i64" (i64.const 0)) (f32.const 0.0)) diff --git a/ml-proto/test/i32.wasm b/ml-proto/test/i32.wasm index 646a32b29f..fc23ac869b 100644 --- a/ml-proto/test/i32.wasm +++ b/ml-proto/test/i32.wasm @@ -229,23 +229,23 @@ (assert_eq (invoke "shr_u" (i32.const -1) (i32.const 0x7fffffff)) (i32.const 0)) (assert_eq (invoke "shr_u" (i32.const -1) (i32.const 0x80000000)) (i32.const 0)) -(assert_eq (invoke "clz" (i32.const -1)) (i32.const 0)) ;; 0xFFFFFFFF +(assert_eq (invoke "clz" (i32.const 0xffffffff)) (i32.const 0)) (assert_eq (invoke "clz" (i32.const 0)) (i32.const 32)) -(assert_eq (invoke "clz" (i32.const 32768)) (i32.const 16)) ;; 0x00008000 -(assert_eq (invoke "clz" (i32.const 255)) (i32.const 24)) ;; 0xFF -(assert_eq (invoke "clz" (i32.const -2147483648)) (i32.const 0)) ;; 0x80000000 +(assert_eq (invoke "clz" (i32.const 0x00008000)) (i32.const 16)) +(assert_eq (invoke "clz" (i32.const 0xff)) (i32.const 24)) +(assert_eq (invoke "clz" (i32.const 0x80000000)) (i32.const 0)) (assert_eq (invoke "clz" (i32.const 1)) (i32.const 31)) (assert_eq (invoke "clz" (i32.const 2)) (i32.const 30)) (assert_eq (invoke "ctz" (i32.const -1)) (i32.const 0)) (assert_eq (invoke "ctz" (i32.const 0)) (i32.const 32)) -(assert_eq (invoke "ctz" (i32.const 32768)) (i32.const 15)) ;; 0x00008000 -(assert_eq (invoke "ctz" (i32.const 65536)) (i32.const 16)) ;; 0x00010000 -(assert_eq (invoke "ctz" (i32.const -2147483648)) (i32.const 31)) ;; 0x80000000 +(assert_eq (invoke "ctz" (i32.const 0x00008000)) (i32.const 15)) +(assert_eq (invoke "ctz" (i32.const 0x00010000)) (i32.const 16)) +(assert_eq (invoke "ctz" (i32.const 0x80000000)) (i32.const 31)) (assert_eq (invoke "popcnt" (i32.const -1)) (i32.const 32)) (assert_eq (invoke "popcnt" (i32.const 0)) (i32.const 0)) -(assert_eq (invoke "popcnt" (i32.const 32768)) (i32.const 1)) ;; 0x00008000 +(assert_eq (invoke "popcnt" (i32.const 0x00008000)) (i32.const 1)) (assert_eq (invoke "eq" (i32.const 0) (i32.const 0)) (i32.const 1)) (assert_eq (invoke "eq" (i32.const 1) (i32.const 1)) (i32.const 1)) diff --git a/ml-proto/test/i64.wasm b/ml-proto/test/i64.wasm index 4e6633b689..044ec4a262 100644 --- a/ml-proto/test/i64.wasm +++ b/ml-proto/test/i64.wasm @@ -230,23 +230,23 @@ (assert_eq (invoke "shr_u" (i64.const -1) (i64.const 0x7fffffffffffffff)) (i64.const 0)) (assert_eq (invoke "shr_u" (i64.const -1) (i64.const 0x8000000000000000)) (i64.const 0)) -(assert_eq (invoke "clz" (i64.const -1)) (i64.const 0)) ;; 0xFFFFFFFF +(assert_eq (invoke "clz" (i64.const 0xffffffffffffffff)) (i64.const 0)) (assert_eq (invoke "clz" (i64.const 0)) (i64.const 64)) -(assert_eq (invoke "clz" (i64.const 64768)) (i64.const 48)) ;; 0x00008000 -(assert_eq (invoke "clz" (i64.const 255)) (i64.const 56)) ;; 0xFF -(assert_eq (invoke "clz" (i64.const -9223372036854775808)) (i64.const 0)) ;; 0x8000000000000000 +(assert_eq (invoke "clz" (i64.const 0x00008000)) (i64.const 48)) +(assert_eq (invoke "clz" (i64.const 0xff)) (i64.const 56)) +(assert_eq (invoke "clz" (i64.const 0x8000000000000000)) (i64.const 0)) (assert_eq (invoke "clz" (i64.const 1)) (i64.const 63)) (assert_eq (invoke "clz" (i64.const 2)) (i64.const 62)) (assert_eq (invoke "ctz" (i64.const -1)) (i64.const 0)) (assert_eq (invoke "ctz" (i64.const 0)) (i64.const 64)) -(assert_eq (invoke "ctz" (i64.const 32768)) (i64.const 15)) ;; 0x00008000 -(assert_eq (invoke "ctz" (i64.const 65536)) (i64.const 16)) ;; 0x00010000 -(assert_eq (invoke "ctz" (i64.const -9223372036854775808)) (i64.const 63)) ;; 0x8000000000000000 +(assert_eq (invoke "ctz" (i64.const 0x00008000)) (i64.const 15)) +(assert_eq (invoke "ctz" (i64.const 0x00010000)) (i64.const 16)) +(assert_eq (invoke "ctz" (i64.const 0x8000000000000000)) (i64.const 63)) (assert_eq (invoke "popcnt" (i64.const -1)) (i64.const 64)) (assert_eq (invoke "popcnt" (i64.const 0)) (i64.const 0)) -(assert_eq (invoke "popcnt" (i64.const 32768)) (i64.const 1)) ;; 0x00008000 +(assert_eq (invoke "popcnt" (i64.const 0x00008000)) (i64.const 1)) (assert_eq (invoke "eq" (i64.const 0) (i64.const 0)) (i32.const 1)) (assert_eq (invoke "eq" (i64.const 1) (i64.const 1)) (i32.const 1)) From d431d59c610bfbf88e396c8fe4aa5ab5b712bb6b Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 25 Sep 2015 10:05:56 -0700 Subject: [PATCH 5/7] Add more extend testcases and convert the wrap testcases to hex constants. --- ml-proto/test/conversions.wasm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ml-proto/test/conversions.wasm b/ml-proto/test/conversions.wasm index be3e9d12aa..aa7bd0dd43 100644 --- a/ml-proto/test/conversions.wasm +++ b/ml-proto/test/conversions.wasm @@ -66,23 +66,29 @@ (assert_eq (invoke "i64.extend_s_i32" (i32.const 0)) (i64.const 0)) (assert_eq (invoke "i64.extend_s_i32" (i32.const 10000)) (i64.const 10000)) (assert_eq (invoke "i64.extend_s_i32" (i32.const -10000)) (i64.const -10000)) +(assert_eq (invoke "i64.extend_s_i32" (i32.const -1)) (i64.const -1)) +(assert_eq (invoke "i64.extend_s_i32" (i32.const 0x7fffffff)) (i64.const 0x000000007fffffff)) +(assert_eq (invoke "i64.extend_s_i32" (i32.const 0x80000000)) (i64.const 0xffffffff80000000)) (assert_eq (invoke "i64.extend_u_i32" (i32.const 0)) (i64.const 0)) (assert_eq (invoke "i64.extend_u_i32" (i32.const 10000)) (i64.const 10000)) (assert_eq (invoke "i64.extend_u_i32" (i32.const -10000)) (i64.const 0x00000000ffffd8f0)) +(assert_eq (invoke "i64.extend_u_i32" (i32.const -1)) (i64.const 0xffffffff)) +(assert_eq (invoke "i64.extend_u_i32" (i32.const 0x7fffffff)) (i64.const 0x000000007fffffff)) +(assert_eq (invoke "i64.extend_u_i32" (i32.const 0x80000000)) (i64.const 0x0000000080000000)) (assert_eq (invoke "i32.wrap_i64" (i64.const -1)) (i32.const -1)) (assert_eq (invoke "i32.wrap_i64" (i64.const -100000)) (i32.const -100000)) -(assert_eq (invoke "i32.wrap_i64" (i64.const -2147483648)) (i32.const 0x80000000)) -(assert_eq (invoke "i32.wrap_i64" (i64.const -2147483649)) (i32.const 0x7fffffff)) -(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967296)) (i32.const 0x00000000)) -(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967297)) (i32.const 0xffffffff)) -(assert_eq (invoke "i32.wrap_i64" (i64.const -4294967295)) (i32.const 0x00000001)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 0x80000000)) (i32.const 0x80000000)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 0xffffffff7fffffff)) (i32.const 0x7fffffff)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 0xffffffff00000000)) (i32.const 0x00000000)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 0xfffffffeffffffff)) (i32.const 0xffffffff)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 0xffffffff00000001)) (i32.const 0x00000001)) (assert_eq (invoke "i32.wrap_i64" (i64.const 0)) (i32.const 0)) (assert_eq (invoke "i32.wrap_i64" (i64.const 1311768467463790320)) (i32.const 0x9abcdef0)) -(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967295)) (i32.const 0xffffffff)) -(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967296)) (i32.const 0x00000000)) -(assert_eq (invoke "i32.wrap_i64" (i64.const 4294967297)) (i32.const 0x00000001)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 0x00000000ffffffff)) (i32.const 0xffffffff)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 0x0000000100000000)) (i32.const 0x00000000)) +(assert_eq (invoke "i32.wrap_i64" (i64.const 0x0000000100000001)) (i32.const 0x00000001)) (assert_eq (invoke "i32.trunc_s_f32" (f32.const 1.0)) (i32.const 1)) (assert_eq (invoke "i32.trunc_s_f32" (f32.const 1.1)) (i32.const 1)) From 95f96920d9351c8cf1121386965444ddc4c8d39a Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 25 Sep 2015 13:18:53 -0700 Subject: [PATCH 6/7] Fix range checking for trunc conversions, f64.convert_u_i32, and add tests. --- ml-proto/src/spec/f32_convert.ml | 10 +++ ml-proto/src/spec/f64_convert.ml | 17 +++- ml-proto/src/spec/i32_convert.ml | 16 ++-- ml-proto/src/spec/i64_convert.ml | 20 ++--- ml-proto/test/conversions.wasm | 132 ++++++++++++++++++++++++++++++- 5 files changed, 170 insertions(+), 25 deletions(-) diff --git a/ml-proto/src/spec/f32_convert.ml b/ml-proto/src/spec/f32_convert.ml index 078d88d5bb..7dacfbcb1e 100644 --- a/ml-proto/src/spec/f32_convert.ml +++ b/ml-proto/src/spec/f32_convert.ml @@ -8,6 +8,10 @@ let demote_f64 x = let convert_s_i32 x = make_nan_nondeterministic (F32.of_float (Int32.to_float x)) +(* + * Similar to convert_u_i64 below, the high half of the i32 range are beyond + * the range where f32 can represent odd numbers. + *) let convert_u_i32 x = make_nan_nondeterministic (F32.of_float (if x >= Int32.zero then @@ -18,6 +22,12 @@ let convert_u_i32 x = let convert_s_i64 x = make_nan_nondeterministic (F32.of_float (Int64.to_float x)) +(* + * Values in the low half of the int64 range can be converted with a signed + * conversion. The high half is beyond the range where f32 can represent odd + * numbers, so we can shift the value right, do a conversion, and then scale it + * back up, without worrying about losing the least-significant digit. + *) let convert_u_i64 x = make_nan_nondeterministic (F32.of_float (if x >= Int64.zero then diff --git a/ml-proto/src/spec/f64_convert.ml b/ml-proto/src/spec/f64_convert.ml index dc572e0a5c..2f9d5bdad9 100644 --- a/ml-proto/src/spec/f64_convert.ml +++ b/ml-proto/src/spec/f64_convert.ml @@ -8,16 +8,25 @@ let promote_f32 x = let convert_s_i32 x = make_nan_nondeterministic (F64.of_float (Int32.to_float x)) +(* + * Unlike the other convert_u functions, the high half of the i32 range is + * within the range where f32 can represent odd numbers, so we can't do the + * shift. Instead, we can use int64 signed arithmetic. + *) let convert_u_i32 x = make_nan_nondeterministic - (F64.of_float (if x >= Int32.zero then - Int32.to_float x - else - Int32.to_float (Int32.shift_right_logical x 1) *. 2.)) + (F64.of_float + (Int64.to_float (Int64.logand (Int64.of_int32 x) 0x00000000ffffffffL))) let convert_s_i64 x = make_nan_nondeterministic (F64.of_float (Int64.to_float x)) +(* + * Values in the low half of the int64 range can be converted with a signed + * conversion. The high half is beyond the range where f64 can represent odd + * numbers, so we can shift the value right, do a conversion, and then scale it + * back up, without worrying about losing the least-significant digit. + *) let convert_u_i64 x = make_nan_nondeterministic (F64.of_float (if x >= Int64.zero then diff --git a/ml-proto/src/spec/i32_convert.ml b/ml-proto/src/spec/i32_convert.ml index dd4b3f2bcf..4ea0c0f772 100644 --- a/ml-proto/src/spec/i32_convert.ml +++ b/ml-proto/src/spec/i32_convert.ml @@ -6,8 +6,8 @@ let trunc_s_f32 x = if F32.ne x x then raise Numerics.InvalidConversionToInteger else let xf = F32.to_float x in - if xf >= (Int32.to_float Int32.max_int) +. 1. || - xf <= (Int32.to_float Int32.min_int) -. 1. then + if xf >= -.(Int32.to_float Int32.min_int) || + xf < (Int32.to_float Int32.min_int) then raise Numerics.IntegerOverflow else Int32.of_float xf @@ -16,8 +16,8 @@ let trunc_u_f32 x = if F32.ne x x then raise Numerics.InvalidConversionToInteger else let xf = F32.to_float x in - if xf >= (Int32.to_float Int32.max_int) *. 2. +. 2. || - xf <= -1. then + if xf >= -.(Int32.to_float Int32.min_int) *. 2. || + xf <= -1. then raise Numerics.IntegerOverflow else Int64.to_int32 (Int64.of_float xf) @@ -26,8 +26,8 @@ let trunc_s_f64 x = if F64.ne x x then raise Numerics.InvalidConversionToInteger else let xf = F64.to_float x in - if xf >= (Int32.to_float Int32.max_int) +. 1. || - xf <= (Int32.to_float Int32.min_int) -. 1. then + if xf >= -.(Int32.to_float Int32.min_int) || + xf < (Int32.to_float Int32.min_int) then raise Numerics.IntegerOverflow else Int32.of_float xf @@ -36,8 +36,8 @@ let trunc_u_f64 x = if F64.ne x x then raise Numerics.InvalidConversionToInteger else let xf = F64.to_float x in - if xf >= (Int32.to_float Int32.max_int) *. 2. +. 2. || - xf <= -1. then + if xf >= -.(Int32.to_float Int32.min_int) *. 2. || + xf <= -1. then raise Numerics.IntegerOverflow else Int64.to_int32 (Int64.of_float xf) diff --git a/ml-proto/src/spec/i64_convert.ml b/ml-proto/src/spec/i64_convert.ml index 2a509cf758..0cf32f8c36 100644 --- a/ml-proto/src/spec/i64_convert.ml +++ b/ml-proto/src/spec/i64_convert.ml @@ -8,8 +8,8 @@ let trunc_s_f32 x = if F32.ne x x then raise Numerics.InvalidConversionToInteger else let xf = F32.to_float x in - if xf >= (Int64.to_float Int64.max_int) +. 1. || - xf <= (Int64.to_float Int64.min_int) -. 1. then + if xf >= -.(Int64.to_float Int64.min_int) || + xf < (Int64.to_float Int64.min_int) then raise Numerics.IntegerOverflow else Int64.of_float xf @@ -18,10 +18,10 @@ let trunc_u_f32 x = if F32.ne x x then raise Numerics.InvalidConversionToInteger else let xf = F32.to_float x in - if xf >= (Int64.to_float Int64.max_int) *. 2. +. 2. || - xf <= -1. then + if xf >= -.(Int64.to_float Int64.min_int) *. 2. || + xf <= -1. then raise Numerics.IntegerOverflow - else if xf >= (Int64.to_float Int64.max_int) +. 1. then + else if xf >= -.(Int64.to_float Int64.min_int) then Int64.logxor (Int64.of_float (xf -. 9223372036854775808.)) Int64.min_int else Int64.of_float xf @@ -30,8 +30,8 @@ let trunc_s_f64 x = if F64.ne x x then raise Numerics.InvalidConversionToInteger else let xf = F64.to_float x in - if xf >= (Int64.to_float Int64.max_int) +. 1. || - xf <= (Int64.to_float Int64.min_int) -. 1. then + if xf >= -.(Int64.to_float Int64.min_int) || + xf < (Int64.to_float Int64.min_int) then raise Numerics.IntegerOverflow else Int64.of_float xf @@ -40,10 +40,10 @@ let trunc_u_f64 x = if F64.ne x x then raise Numerics.InvalidConversionToInteger else let xf = F64.to_float x in - if xf >= (Int64.to_float Int64.max_int) *. 2. +. 2. || - xf <= -1. then + if xf >= -.(Int64.to_float Int64.min_int) *. 2. || + xf <= -1. then raise Numerics.IntegerOverflow - else if xf >= (Int64.to_float Int64.max_int) +. 1. then + else if xf >= -.(Int64.to_float Int64.min_int) then Int64.logxor (Int64.of_float (xf -. 9223372036854775808.)) Int64.min_int else Int64.of_float xf diff --git a/ml-proto/test/conversions.wasm b/ml-proto/test/conversions.wasm index aa7bd0dd43..67cb24a2bc 100644 --- a/ml-proto/test/conversions.wasm +++ b/ml-proto/test/conversions.wasm @@ -14,12 +14,24 @@ (func $i32.trunc_u_f32 (param $x f32) (result i32) (i32.trunc_u/f32 (get_local $x))) (export "i32.trunc_u_f32" $i32.trunc_u_f32) + (func $i32.trunc_s_f64 (param $x f64) (result i32) (i32.trunc_s/f64 (get_local $x))) + (export "i32.trunc_s_f64" $i32.trunc_s_f64) + + (func $i32.trunc_u_f64 (param $x f64) (result i32) (i32.trunc_u/f64 (get_local $x))) + (export "i32.trunc_u_f64" $i32.trunc_u_f64) + (func $i64.trunc_s_f32 (param $x f32) (result i64) (i64.trunc_s/f32 (get_local $x))) (export "i64.trunc_s_f32" $i64.trunc_s_f32) (func $i64.trunc_u_f32 (param $x f32) (result i64) (i64.trunc_u/f32 (get_local $x))) (export "i64.trunc_u_f32" $i64.trunc_u_f32) + (func $i64.trunc_s_f64 (param $x f64) (result i64) (i64.trunc_s/f64 (get_local $x))) + (export "i64.trunc_s_f64" $i64.trunc_s_f64) + + (func $i64.trunc_u_f64 (param $x f64) (result i64) (i64.trunc_u/f64 (get_local $x))) + (export "i64.trunc_u_f64" $i64.trunc_u_f64) + (func $f32.convert_s_i32 (param $x i32) (result f32) (f32.convert_s/i32 (get_local $x))) (export "f32.convert_s_i32" $f32.convert_s_i32) @@ -90,6 +102,10 @@ (assert_eq (invoke "i32.wrap_i64" (i64.const 0x0000000100000000)) (i32.const 0x00000000)) (assert_eq (invoke "i32.wrap_i64" (i64.const 0x0000000100000001)) (i32.const 0x00000001)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const 0.0)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const -0.0)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const 1.401298e-45)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const -1.401298e-45)) (i32.const 0)) (assert_eq (invoke "i32.trunc_s_f32" (f32.const 1.0)) (i32.const 1)) (assert_eq (invoke "i32.trunc_s_f32" (f32.const 1.1)) (i32.const 1)) (assert_eq (invoke "i32.trunc_s_f32" (f32.const 1.5)) (i32.const 1)) @@ -98,14 +114,62 @@ (assert_eq (invoke "i32.trunc_s_f32" (f32.const -1.5)) (i32.const -1)) (assert_eq (invoke "i32.trunc_s_f32" (f32.const -1.9)) (i32.const -1)) (assert_eq (invoke "i32.trunc_s_f32" (f32.const -2.0)) (i32.const -2)) - +(assert_eq (invoke "i32.trunc_s_f32" (f32.const 2147483520.0)) (i32.const 2147483520)) +(assert_eq (invoke "i32.trunc_s_f32" (f32.const -2147483648.0)) (i32.const -2147483648)) +(assert_trap (invoke "i32.trunc_s_f32" (f32.const 2147483648.0)) "runtime: integer overflow") +(assert_trap (invoke "i32.trunc_s_f32" (f32.const -2147483904.0)) "runtime: integer overflow") + +(assert_eq (invoke "i32.trunc_u_f32" (f32.const 0.0)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_u_f32" (f32.const -0.0)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_u_f32" (f32.const 1.401298e-45)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_u_f32" (f32.const -1.401298e-45)) (i32.const 0)) (assert_eq (invoke "i32.trunc_u_f32" (f32.const 1.0)) (i32.const 1)) (assert_eq (invoke "i32.trunc_u_f32" (f32.const 1.1)) (i32.const 1)) (assert_eq (invoke "i32.trunc_u_f32" (f32.const 1.5)) (i32.const 1)) (assert_eq (invoke "i32.trunc_u_f32" (f32.const 1.9)) (i32.const 1)) (assert_eq (invoke "i32.trunc_u_f32" (f32.const 2.0)) (i32.const 2)) (assert_eq (invoke "i32.trunc_u_f32" (f32.const 2147483648)) (i32.const -2147483648)) ;; 0x1.00000p+31 -> 8000 0000 - +(assert_eq (invoke "i32.trunc_u_f32" (f32.const 4294967040.0)) (i32.const -256)) +(assert_eq (invoke "i32.trunc_u_f32" (f32.const -0.9)) (i32.const 0)) +(assert_trap (invoke "i32.trunc_u_f32" (f32.const 4294967296.0)) "runtime: integer overflow") +(assert_trap (invoke "i32.trunc_u_f32" (f32.const -1.0)) "runtime: integer overflow") + +(assert_eq (invoke "i32.trunc_s_f64" (f64.const 0.0)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const -0.0)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const 4.940656e-324)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const -4.940656e-324)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const 1.0)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const 1.1)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const 1.5)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const -1.0)) (i32.const -1)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const -1.1)) (i32.const -1)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const -1.5)) (i32.const -1)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const -1.9)) (i32.const -1)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const -2.0)) (i32.const -2)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const 2147483647.0)) (i32.const 2147483647)) +(assert_eq (invoke "i32.trunc_s_f64" (f64.const -2147483648.0)) (i32.const -2147483648)) +(assert_trap (invoke "i32.trunc_s_f64" (f64.const 2147483648.0)) "runtime: integer overflow") +(assert_trap (invoke "i32.trunc_s_f64" (f64.const -2147483649.0)) "runtime: integer overflow") + +(assert_eq (invoke "i32.trunc_u_f64" (f64.const 0.0)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_u_f64" (f64.const -0.0)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_u_f64" (f64.const 4.940656e-324)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_u_f64" (f64.const -4.940656e-324)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_u_f64" (f64.const 1.0)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_u_f64" (f64.const 1.1)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_u_f64" (f64.const 1.5)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_u_f64" (f64.const 1.9)) (i32.const 1)) +(assert_eq (invoke "i32.trunc_u_f64" (f64.const 2.0)) (i32.const 2)) +(assert_eq (invoke "i32.trunc_u_f64" (f64.const 2147483648)) (i32.const -2147483648)) ;; 0x1.00000p+31 -> 8000 0000 +(assert_eq (invoke "i32.trunc_u_f64" (f64.const 4294967295.0)) (i32.const -1)) +(assert_eq (invoke "i32.trunc_u_f64" (f64.const -0.9)) (i32.const 0)) +(assert_trap (invoke "i32.trunc_u_f64" (f64.const 4294967296.0)) "runtime: integer overflow") +(assert_trap (invoke "i32.trunc_u_f64" (f64.const -1.0)) "runtime: integer overflow") + +(assert_eq (invoke "i64.trunc_s_f32" (f32.const 0.0)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const -0.0)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const 1.401298e-45)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const -1.401298e-45)) (i64.const 0)) (assert_eq (invoke "i64.trunc_s_f32" (f32.const 1.0)) (i64.const 1)) (assert_eq (invoke "i64.trunc_s_f32" (f32.const 1.1)) (i64.const 1)) (assert_eq (invoke "i64.trunc_s_f32" (f32.const 1.5)) (i64.const 1)) @@ -116,11 +180,55 @@ (assert_eq (invoke "i64.trunc_s_f32" (f32.const -2.0)) (i64.const -2)) (assert_eq (invoke "i64.trunc_s_f32" (f32.const 4294967296)) (i64.const 4294967296)) ;; 0x1.00000p+32 -> 1 0000 0000 (assert_eq (invoke "i64.trunc_s_f32" (f32.const -4294967296)) (i64.const -4294967296)) ;; -0x1.00000p+32 -> ffff ffff 0000 0000 - +(assert_eq (invoke "i64.trunc_s_f32" (f32.const 9223371487098961920.0)) (i64.const 9223371487098961920)) +(assert_eq (invoke "i64.trunc_s_f32" (f32.const -9223372036854775808.0)) (i64.const -9223372036854775808)) +(assert_trap (invoke "i64.trunc_s_f32" (f32.const 9223372036854775808.0)) "runtime: integer overflow") +(assert_trap (invoke "i64.trunc_s_f32" (f32.const -9223373136366403584.0)) "runtime: integer overflow") + +(assert_eq (invoke "i64.trunc_u_f32" (f32.const 0.0)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_u_f32" (f32.const -0.0)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_u_f32" (f32.const 1.401298e-45)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_u_f32" (f32.const -1.401298e-45)) (i64.const 0)) (assert_eq (invoke "i64.trunc_u_f32" (f32.const 1.0)) (i64.const 1)) (assert_eq (invoke "i64.trunc_u_f32" (f32.const 1.1)) (i64.const 1)) (assert_eq (invoke "i64.trunc_u_f32" (f32.const 1.5)) (i64.const 1)) (assert_eq (invoke "i64.trunc_u_f32" (f32.const 4294967296)) (i64.const 4294967296)) +(assert_eq (invoke "i64.trunc_u_f32" (f32.const 18446742974197923840.0)) (i64.const -1099511627776)) +(assert_eq (invoke "i64.trunc_u_f32" (f32.const -0.9)) (i64.const 0)) +(assert_trap (invoke "i64.trunc_u_f32" (f32.const 18446744073709551616.0)) "runtime: integer overflow") +(assert_trap (invoke "i64.trunc_u_f32" (f32.const -1.0)) "runtime: integer overflow") + +(assert_eq (invoke "i64.trunc_s_f64" (f64.const 0.0)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const -0.0)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const 4.940656e-324)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const -4.940656e-324)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const 1.0)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const 1.1)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const 1.5)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const -1.0)) (i64.const -1)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const -1.1)) (i64.const -1)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const -1.5)) (i64.const -1)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const -1.9)) (i64.const -1)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const -2.0)) (i64.const -2)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const 4294967296)) (i64.const 4294967296)) ;; 0x1.00000p+32 -> 1 0000 0000 +(assert_eq (invoke "i64.trunc_s_f64" (f64.const -4294967296)) (i64.const -4294967296)) ;; -0x1.00000p+32 -> ffff ffff 0000 0000 +(assert_eq (invoke "i64.trunc_s_f64" (f64.const 9223372036854774784.0)) (i64.const 9223372036854774784)) +(assert_eq (invoke "i64.trunc_s_f64" (f64.const -9223372036854775808.0)) (i64.const -9223372036854775808)) +(assert_trap (invoke "i64.trunc_s_f64" (f64.const 9223372036854775808.0)) "runtime: integer overflow") +(assert_trap (invoke "i64.trunc_s_f64" (f64.const -9223372036854777856.0)) "runtime: integer overflow") + +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 0.0)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const -0.0)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 4.940656e-324)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const -4.940656e-324)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 1.0)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 1.1)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 1.5)) (i64.const 1)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 4294967296)) (i64.const 4294967296)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 18446744073709549568.0)) (i64.const -2048)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const -0.9)) (i64.const 0)) +(assert_trap (invoke "i64.trunc_u_f64" (f64.const 18446744073709551616.0)) "runtime: integer overflow") +(assert_trap (invoke "i64.trunc_u_f64" (f64.const -1.0)) "runtime: integer overflow") (assert_eq (invoke "f32.convert_s_i32" (i32.const 1)) (f32.const 1.0)) (assert_eq (invoke "f32.convert_s_i32" (i32.const -1)) (f32.const -1.0)) @@ -155,23 +263,30 @@ (assert_eq (invoke "f32.convert_u_i32" (i32.const 2147483647)) (f32.const 2147483647)) (assert_eq (invoke "f32.convert_u_i32" (i32.const -2147483648)) (f32.const 2147483648)) (assert_eq (invoke "f32.convert_u_i32" (i32.const 0x12345678)) (f32.const 305419896)) ;; 0x12345678 +(assert_eq (invoke "f32.convert_u_i32" (i32.const 0xffffffff)) (f32.const 4294967296.0)) (assert_eq (invoke "f32.convert_u_i64" (i64.const 1)) (f32.const 1.0)) (assert_eq (invoke "f32.convert_u_i64" (i64.const 0)) (f32.const 0.0)) (assert_eq (invoke "f32.convert_u_i64" (i64.const 9223372036854775807)) (f32.const 9223372036854775807)) (assert_eq (invoke "f32.convert_u_i64" (i64.const -9223372036854775808)) (f32.const 9223372036854775808)) +(assert_eq (invoke "f32.convert_u_i64" (i64.const 0xffffffffffffffff)) (f32.const 18446744073709551616.0)) (assert_eq (invoke "f64.convert_u_i32" (i32.const 1)) (f64.const 1.0)) (assert_eq (invoke "f64.convert_u_i32" (i32.const 0)) (f64.const 0.0)) (assert_eq (invoke "f64.convert_u_i32" (i32.const 2147483647)) (f64.const 2147483647)) (assert_eq (invoke "f64.convert_u_i32" (i32.const -2147483648)) (f64.const 2147483648)) +(assert_eq (invoke "f64.convert_u_i32" (i32.const 0xffffffff)) (f64.const 4294967295.0)) (assert_eq (invoke "f64.convert_u_i64" (i64.const 1)) (f64.const 1.0)) (assert_eq (invoke "f64.convert_u_i64" (i64.const 0)) (f64.const 0.0)) (assert_eq (invoke "f64.convert_u_i64" (i64.const 9223372036854775807)) (f64.const 9223372036854775807)) (assert_eq (invoke "f64.convert_u_i64" (i64.const -9223372036854775808)) (f64.const 9223372036854775808)) +(assert_eq (invoke "f64.convert_u_i64" (i64.const 0xffffffffffffffff)) (f64.const 18446744073709551616.0)) (assert_eq (invoke "f64.promote_f32" (f32.const 0.0)) (f64.const 0.0)) +(assert_eq (invoke "f64.promote_f32" (f32.const -0.0)) (f64.const -0.0)) +(assert_eq (invoke "f64.promote_f32" (f32.const 1.401298e-45)) (f64.const 1.401298464324817e-45)) +(assert_eq (invoke "f64.promote_f32" (f32.const -1.401298e-45)) (f64.const -1.401298464324817e-45)) (assert_eq (invoke "f64.promote_f32" (f32.const 1.0)) (f64.const 1.0)) (assert_eq (invoke "f64.promote_f32" (f32.const -1.0)) (f64.const -1.0)) (assert_eq (invoke "f64.promote_f32" (f32.const 1.4012985e-45)) (f64.const 1.401298464324817e-45)) @@ -184,6 +299,9 @@ (assert_eq (invoke "f64.promote_f32" (f32.const 6.6382537e+37)) (f64.const 6.6382536710104395e+37)) (assert_eq (invoke "f32.demote_f64" (f64.const 0.0)) (f32.const 0.0)) +(assert_eq (invoke "f32.demote_f64" (f64.const -0.0)) (f32.const -0.0)) +(assert_eq (invoke "f32.demote_f64" (f64.const 4.940656e-324)) (f32.const 0.0)) +(assert_eq (invoke "f32.demote_f64" (f64.const -4.940656e-324)) (f32.const -0.0)) (assert_eq (invoke "f32.demote_f64" (f64.const 1.0)) (f32.const 1.0)) (assert_eq (invoke "f32.demote_f64" (f64.const -1.0)) (f32.const -1.0)) (assert_eq (invoke "f32.demote_f64" (f64.const -1.401298464324817e-45)) (f32.const -1.4012985e-45)) @@ -194,16 +312,21 @@ (assert_eq (invoke "f32.demote_f64" (f64.const 6.6382536710104395e+37)) (f32.const 6.6382537e+37)) (assert_eq (invoke "f32.reinterpret_i32" (i32.const 0)) (f32.const 0.0)) +(assert_eq (invoke "f32.reinterpret_i32" (i32.const 0x80000000)) (f32.const -0.0)) (assert_eq (invoke "f32.reinterpret_i32" (i32.const 1)) (f32.const 1.4012984e-45)) (assert_eq (invoke "f32.reinterpret_i32" (i32.const 123456789)) (f32.const 1.6535997e-34)) (assert_eq (invoke "f32.reinterpret_i32" (i32.const -2147483647)) (f32.const -1.4012984e-45)) (assert_eq (invoke "f64.reinterpret_i64" (i64.const 0)) (f64.const 0.0)) (assert_eq (invoke "f64.reinterpret_i64" (i64.const 1)) (f64.const 4.94066e-324)) +(assert_eq (invoke "f64.reinterpret_i64" (i64.const 0x8000000000000000)) (f64.const -0.0)) (assert_eq (invoke "f64.reinterpret_i64" (i64.const 1234567890)) (f64.const 6.099575819077150e-315)) (assert_eq (invoke "f64.reinterpret_i64" (i64.const -9223372036854775807)) (f64.const -4.940656458412465e-324)) (assert_eq (invoke "i32.reinterpret_f32" (f32.const 0.0)) (i32.const 0)) +(assert_eq (invoke "i32.reinterpret_f32" (f32.const -0.0)) (i32.const 0x80000000)) +(assert_eq (invoke "i32.reinterpret_f32" (f32.const 1.401298e-45)) (i32.const 1)) +(assert_eq (invoke "i32.reinterpret_f32" (f32.const -1.401298e-45)) (i32.const 0x80000001)) (assert_eq (invoke "i32.reinterpret_f32" (f32.const 1.0)) (i32.const 1065353216)) (assert_eq (invoke "i32.reinterpret_f32" (f32.const 3.1415926)) (i32.const 1078530010)) (assert_eq (invoke "i32.reinterpret_f32" (f32.const 3.4028235e+38)) (i32.const 2139095039)) @@ -212,6 +335,9 @@ (assert_eq (invoke "i32.reinterpret_f32" (f32.const -1.4012984e-45)) (i32.const -2147483647)) (assert_eq (invoke "i64.reinterpret_f64" (f64.const 0.0)) (i64.const 0)) +(assert_eq (invoke "i64.reinterpret_f64" (f64.const -0.0)) (i64.const 0x8000000000000000)) +(assert_eq (invoke "i64.reinterpret_f64" (f64.const 4.940656e-324)) (i64.const 1)) +(assert_eq (invoke "i64.reinterpret_f64" (f64.const -4.940656e-324)) (i64.const 0x8000000000000001)) (assert_eq (invoke "i64.reinterpret_f64" (f64.const 1.0)) (i64.const 4607182418800017408)) (assert_eq (invoke "i64.reinterpret_f64" (f64.const 3.14159265358979)) (i64.const 4614256656552045841)) (assert_eq (invoke "i64.reinterpret_f64" (f64.const 1.7976931348623157e+308)) (i64.const 9218868437227405311)) From 1d3ebbb4ddb9e526b5c665eeb8d9c6f42b5bffbe Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 25 Sep 2015 13:30:08 -0700 Subject: [PATCH 7/7] Incorporate the remaining tests from unsigned.wasm into conversions.wasm. --- ml-proto/test/conversions.wasm | 10 +++++++++- ml-proto/test/unsigned.wasm | 28 ---------------------------- 2 files changed, 9 insertions(+), 29 deletions(-) delete mode 100644 ml-proto/test/unsigned.wasm diff --git a/ml-proto/test/conversions.wasm b/ml-proto/test/conversions.wasm index 67cb24a2bc..0b6b08e25b 100644 --- a/ml-proto/test/conversions.wasm +++ b/ml-proto/test/conversions.wasm @@ -163,8 +163,12 @@ (assert_eq (invoke "i32.trunc_u_f64" (f64.const 2147483648)) (i32.const -2147483648)) ;; 0x1.00000p+31 -> 8000 0000 (assert_eq (invoke "i32.trunc_u_f64" (f64.const 4294967295.0)) (i32.const -1)) (assert_eq (invoke "i32.trunc_u_f64" (f64.const -0.9)) (i32.const 0)) +(assert_eq (invoke "i32.trunc_u_f64" (f64.const 1e8)) (i32.const 100000000)) (assert_trap (invoke "i32.trunc_u_f64" (f64.const 4294967296.0)) "runtime: integer overflow") (assert_trap (invoke "i32.trunc_u_f64" (f64.const -1.0)) "runtime: integer overflow") +(assert_trap (invoke "i32.trunc_u_f64" (f64.const 1e16)) "runtime: integer overflow") +(assert_trap (invoke "i32.trunc_u_f64" (f64.const 1e30)) "runtime: integer overflow") +(assert_trap (invoke "i32.trunc_u_f64" (f64.const 9223372036854775808)) "runtime: integer overflow") (assert_eq (invoke "i64.trunc_s_f32" (f32.const 0.0)) (i64.const 0)) (assert_eq (invoke "i64.trunc_s_f32" (f32.const -0.0)) (i64.const 0)) @@ -224,9 +228,13 @@ (assert_eq (invoke "i64.trunc_u_f64" (f64.const 1.0)) (i64.const 1)) (assert_eq (invoke "i64.trunc_u_f64" (f64.const 1.1)) (i64.const 1)) (assert_eq (invoke "i64.trunc_u_f64" (f64.const 1.5)) (i64.const 1)) -(assert_eq (invoke "i64.trunc_u_f64" (f64.const 4294967296)) (i64.const 4294967296)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 4294967295)) (i64.const 0xffffffff)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 4294967296)) (i64.const 0x100000000)) (assert_eq (invoke "i64.trunc_u_f64" (f64.const 18446744073709549568.0)) (i64.const -2048)) (assert_eq (invoke "i64.trunc_u_f64" (f64.const -0.9)) (i64.const 0)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 1e8)) (i64.const 100000000)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 1e16)) (i64.const 10000000000000000)) +(assert_eq (invoke "i64.trunc_u_f64" (f64.const 9223372036854775808)) (i64.const -9223372036854775808)) (assert_trap (invoke "i64.trunc_u_f64" (f64.const 18446744073709551616.0)) "runtime: integer overflow") (assert_trap (invoke "i64.trunc_u_f64" (f64.const -1.0)) "runtime: integer overflow") diff --git a/ml-proto/test/unsigned.wasm b/ml-proto/test/unsigned.wasm deleted file mode 100644 index 492e123588..0000000000 --- a/ml-proto/test/unsigned.wasm +++ /dev/null @@ -1,28 +0,0 @@ -(module - (func $i32_trunc_u (param $x f64) (result i32) - (return (i32.trunc_u/f64 (get_local $x))) - ) - (func $i64_trunc_u (param $x f64) (result i64) - (return (i64.trunc_u/f64 (get_local $x))) - ) - - (export "i32.trunc_u" $i32_trunc_u) - (export "i64.trunc_u" $i64_trunc_u) -) - -(assert_eq (invoke "i32.trunc_u" (f64.const 1e8)) (i32.const 100000000)) -(assert_eq (invoke "i64.trunc_u" (f64.const 1e8)) (i64.const 100000000)) - -(assert_trap (invoke "i32.trunc_u" (f64.const 1e16)) "runtime: integer overflow") -(assert_eq (invoke "i64.trunc_u" (f64.const 1e16)) (i64.const 10000000000000000)) - -(assert_trap (invoke "i32.trunc_u" (f64.const 1e30)) "runtime: integer overflow") -(assert_trap (invoke "i64.trunc_u" (f64.const -1)) "runtime: integer overflow") - -;; max_uint32 -(assert_eq (invoke "i32.trunc_u" (f64.const 4294967295)) (i32.const -1)) -(assert_eq (invoke "i64.trunc_u" (f64.const 4294967295)) (i64.const 4294967295)) - -;; max_int64+1 -(assert_trap (invoke "i32.trunc_u" (f64.const 9223372036854775808)) "runtime: integer overflow") -(assert_eq (invoke "i64.trunc_u" (f64.const 9223372036854775808)) (i64.const -9223372036854775808))