Skip to content

Instantly share code, notes, and snippets.

@binji
Created January 16, 2020 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binji/ab7c460da186d8c69e4d10b52c513527 to your computer and use it in GitHub Desktop.
Save binji/ab7c460da186d8c69e4d10b52c513527 to your computer and use it in GitHub Desktop.
sign-extension-ops.diff
diff -r -u spec/document/core/appendix/index-instructions.rst sign-extension-ops/document/core/appendix/index-instructions.rst
--- spec/document/core/appendix/index-instructions.rst 2019-03-30 12:56:50.472907052 -0700
+++ sign-extension-ops/document/core/appendix/index-instructions.rst 2020-01-16 10:29:11.379288914 -0800
@@ -199,4 +199,10 @@
:math:`\I64.\REINTERPRET\K{\_}\F64` :math:`\hex{BD}` :math:`[\F64] \to [\I64]` :ref:`validation <valid-cvtop>` :ref:`execution <exec-cvtop>`, :ref:`operator <op-reinterpret>`
:math:`\F32.\REINTERPRET\K{\_}\I32` :math:`\hex{BE}` :math:`[\I32] \to [\F32]` :ref:`validation <valid-cvtop>` :ref:`execution <exec-cvtop>`, :ref:`operator <op-reinterpret>`
:math:`\F64.\REINTERPRET\K{\_}\I64` :math:`\hex{BF}` :math:`[\I64] \to [\F64]` :ref:`validation <valid-cvtop>` :ref:`execution <exec-cvtop>`, :ref:`operator <op-reinterpret>`
+:math:`\I32.\EXTEND\K{8\_s}` :math:`\hex{C0}` :math:`[\I32] \to [\I32]` :ref:`validation <valid-unop>` :ref:`execution <exec-unop>`, :ref:`operator <op-iextendn_s>`
+:math:`\I32.\EXTEND\K{16\_s}` :math:`\hex{C1}` :math:`[\I32] \to [\I32]` :ref:`validation <valid-unop>` :ref:`execution <exec-unop>`, :ref:`operator <op-iextendn_s>`
+:math:`\I64.\EXTEND\K{8\_s}` :math:`\hex{C2}` :math:`[\I64] \to [\I64]` :ref:`validation <valid-unop>` :ref:`execution <exec-unop>`, :ref:`operator <op-iextendn_s>`
+:math:`\I64.\EXTEND\K{16\_s}` :math:`\hex{C3}` :math:`[\I64] \to [\I64]` :ref:`validation <valid-unop>` :ref:`execution <exec-unop>`, :ref:`operator <op-iextendn_s>`
+:math:`\I64.\EXTEND\K{32\_s}` :math:`\hex{C4}` :math:`[\I64] \to [\I64]` :ref:`validation <valid-unop>` :ref:`execution <exec-unop>`, :ref:`operator <op-iextendn_s>`
+
====================================== ================ ========================================== ======================================== ===============================================================
diff -r -u spec/document/core/binary/instructions.rst sign-extension-ops/document/core/binary/instructions.rst
--- spec/document/core/binary/instructions.rst 2018-12-12 12:03:33.645874794 -0800
+++ sign-extension-ops/document/core/binary/instructions.rst 2020-01-16 10:29:11.379288914 -0800
@@ -364,6 +364,17 @@
\end{array}
+.. math::
+ \begin{array}{llclll}
+ \phantom{\production{instruction}} & \phantom{\Binstr} &\phantom{::=}& \phantom{\dots} && \phantom{thisshouldbeenough} \\[-2ex] &&|&
+ \hex{C0} &\Rightarrow& \I32.\EXTEND\K{8\_s} \\ &&|&
+ \hex{C1} &\Rightarrow& \I32.\EXTEND\K{16\_s} \\ &&|&
+ \hex{C2} &\Rightarrow& \I64.\EXTEND\K{8\_s} \\ &&|&
+ \hex{C3} &\Rightarrow& \I64.\EXTEND\K{16\_s} \\ &&|&
+ \hex{C4} &\Rightarrow& \I64.\EXTEND\K{32\_s} \\
+ \end{array}
+
+
.. index:: expression
pair: binary format; expression
single: expression; constant
diff -r -u spec/document/core/exec/numerics.rst sign-extension-ops/document/core/exec/numerics.rst
--- spec/document/core/exec/numerics.rst 2020-01-09 10:27:38.631512960 -0800
+++ sign-extension-ops/document/core/exec/numerics.rst 2020-01-16 10:29:11.383288920 -0800
@@ -612,6 +612,19 @@
\end{array}
+.. _op-iextendn_s:
+
+:math:`\iextendns_N(i)`
+.......................
+
+* Return :math:`\extends_{M,N}(i)`.
+
+.. math::
+ \begin{array}{lll@{\qquad}l}
+ \iextendns_{N}(i) &=& \extends_{M,N}(i) \\
+ \end{array}
+
+
.. index:: floating-point, IEEE 754
.. _float-ops:
diff -r -u spec/document/core/syntax/instructions.rst sign-extension-ops/document/core/syntax/instructions.rst
--- spec/document/core/syntax/instructions.rst 2020-01-09 10:27:38.631512960 -0800
+++ sign-extension-ops/document/core/syntax/instructions.rst 2020-01-16 10:29:11.387288926 -0800
@@ -64,6 +64,9 @@
\K{i}\X{nn}\K{.}\itestop \\&&|&
\K{i}\X{nn}\K{.}\irelop ~|~
\K{f}\X{nn}\K{.}\frelop \\&&|&
+ \K{i}\X{nn}\K{.}\EXTEND\K{8\_s} ~|~
+ \K{i}\X{nn}\K{.}\EXTEND\K{16\_s} ~|~
+ \K{i64.}\EXTEND\K{32\_s} \\&&|&
\K{i32.}\WRAP\K{\_i64} ~|~
\K{i64.}\EXTEND\K{\_i32}\K{\_}\sx ~|~
\K{i}\X{nn}\K{.}\TRUNC\K{\_f}\X{mm}\K{\_}\sx \\&&|&
@@ -152,7 +155,10 @@
.. math::
\begin{array}{llll}
- \production{unary operator} & \unop &::=& \iunop ~|~ \funop \\
+ \production{unary operator} & \unop &::=&
+ \iunop ~|~
+ \funop ~|~
+ \EXTEND{N}\K{\_s} ~|~ \\
\production{binary operator} & \binop &::=& \ibinop ~|~ \fbinop \\
\production{test operator} & \testop &::=& \itestop \\
\production{relational operator} & \relop &::=& \irelop ~|~ \frelop \\
diff -r -u spec/document/core/text/instructions.rst sign-extension-ops/document/core/text/instructions.rst
--- spec/document/core/text/instructions.rst 2019-04-12 14:41:02.000494203 -0700
+++ sign-extension-ops/document/core/text/instructions.rst 2020-01-16 10:29:11.391288933 -0800
@@ -413,6 +413,16 @@
\text{f64.reinterpret\_i64} &\Rightarrow& \F64.\REINTERPRET\K{\_}\I64 \\
\end{array}
+.. math::
+ \begin{array}{llclll}
+ \phantom{\production{instruction}} & \phantom{\Tplaininstr_I} &\phantom{::=}& \phantom{thisisenough} && \phantom{thisshouldbeenough} \\[-2ex] &&|&
+ \text{i32.extend8\_s} &\Rightarrow& \I32.\EXTEND\K{8\_s} \\ &&|&
+ \text{i32.extend16\_s} &\Rightarrow& \I32.\EXTEND\K{16\_s} \\ &&|&
+ \text{i64.extend8\_s} &\Rightarrow& \I64.\EXTEND\K{8\_s} \\ &&|&
+ \text{i64.extend16\_s} &\Rightarrow& \I64.\EXTEND\K{16\_s} \\ &&|&
+ \text{i64.extend32\_s} &\Rightarrow& \I64.\EXTEND\K{32\_s} \\
+ \end{array}
+
.. index:: ! folded instruction, S-expression
.. _text-foldedinstr:
diff -r -u spec/document/core/util/macros.def sign-extension-ops/document/core/util/macros.def
--- spec/document/core/util/macros.def 2020-01-09 10:27:38.635512968 -0800
+++ sign-extension-ops/document/core/util/macros.def 2020-01-16 10:29:11.391288933 -0800
@@ -920,6 +920,7 @@
.. |iles| mathdef:: \xref{exec/numerics}{op-ile_s}{\F{ile\_s}}
.. |igeu| mathdef:: \xref{exec/numerics}{op-ige_u}{\F{ige\_u}}
.. |iges| mathdef:: \xref{exec/numerics}{op-ige_s}{\F{ige\_s}}
+.. |iextendns| mathdef:: \xref{exec/numerics}{op-iextendn_s}{\F{iextend}M\F{\_s}}
.. |fadd| mathdef:: \xref{exec/numerics}{op-fadd}{\F{fadd}}
.. |fsub| mathdef:: \xref{exec/numerics}{op-fsub}{\F{fsub}}
diff -r -u spec/interpreter/binary/decode.ml sign-extension-ops/interpreter/binary/decode.ml
--- spec/interpreter/binary/decode.ml 2019-02-27 13:41:13.403702062 -0800
+++ sign-extension-ops/interpreter/binary/decode.ml 2020-01-16 10:29:11.399288944 -0800
@@ -432,6 +432,12 @@
| 0xbe -> f32_reinterpret_i32
| 0xbf -> f64_reinterpret_i64
+ | 0xc0 -> i32_extend8_s
+ | 0xc1 -> i32_extend16_s
+ | 0xc2 -> i64_extend8_s
+ | 0xc3 -> i64_extend16_s
+ | 0xc4 -> i64_extend32_s
+
| b -> illegal s pos b
and instr_block s = List.rev (instr_block' s [])
diff -r -u spec/interpreter/binary/encode.ml sign-extension-ops/interpreter/binary/encode.ml
--- spec/interpreter/binary/encode.ml 2019-02-27 13:41:13.403702062 -0800
+++ sign-extension-ops/interpreter/binary/encode.ml 2020-01-16 10:29:11.399288944 -0800
@@ -260,10 +260,16 @@
| Unary (I32 I32Op.Clz) -> op 0x67
| Unary (I32 I32Op.Ctz) -> op 0x68
| Unary (I32 I32Op.Popcnt) -> op 0x69
+ | Unary (I32 I32Op.Extend8S) -> op 0xc0
+ | Unary (I32 I32Op.Extend16S) -> op 0xc1
+ | Unary (I32 I32Op.Extend32S) -> assert false
| Unary (I64 I64Op.Clz) -> op 0x79
| Unary (I64 I64Op.Ctz) -> op 0x7a
| Unary (I64 I64Op.Popcnt) -> op 0x7b
+ | Unary (I64 I64Op.Extend8S) -> op 0xc2
+ | Unary (I64 I64Op.Extend16S) -> op 0xc3
+ | Unary (I64 I64Op.Extend32S) -> op 0xc4
| Unary (F32 F32Op.Abs) -> op 0x8b
| Unary (F32 F32Op.Neg) -> op 0x8c
diff -r -u spec/interpreter/exec/eval_numeric.ml sign-extension-ops/interpreter/exec/eval_numeric.ml
--- spec/interpreter/exec/eval_numeric.ml 2018-12-12 12:03:33.653874799 -0800
+++ sign-extension-ops/interpreter/exec/eval_numeric.ml 2020-01-16 10:29:11.399288944 -0800
@@ -24,6 +24,9 @@
| Clz -> IXX.clz
| Ctz -> IXX.ctz
| Popcnt -> IXX.popcnt
+ | Extend8S -> IXX.extend8_s
+ | Extend16S -> IXX.extend16_s
+ | Extend32S -> IXX.extend32_s
in fun v -> to_value (f (of_value 1 v))
let binop op =
diff -r -u spec/interpreter/exec/int.ml sign-extension-ops/interpreter/exec/int.ml
--- spec/interpreter/exec/int.ml 2019-06-09 10:34:30.928302434 -0700
+++ sign-extension-ops/interpreter/exec/int.ml 2020-01-16 10:29:11.399288944 -0800
@@ -58,6 +58,9 @@
val clz : t -> t
val ctz : t -> t
val popcnt : t -> t
+ val extend8_s : t -> t
+ val extend16_s : t -> t
+ val extend32_s : t -> t
val eqz : t -> bool
val eq : t -> t -> bool
val ne : t -> t -> bool
@@ -201,6 +204,14 @@
loop acc' (i - 1) (Rep.shift_right_logical n 1)
in Rep.of_int (loop 0 Rep.bitwidth x)
+ let extendn_s n x =
+ let shift = Rep.bitwidth - n in
+ Rep.shift_right (Rep.shift_left x shift) shift
+
+ let extend8_s x = extendn_s 8 x
+ let extend16_s x = extendn_s 16 x
+ let extend32_s x = extendn_s 32 x
+
let eqz x = x = Rep.zero
let eq x y = x = y
diff -r -u spec/interpreter/syntax/ast.ml sign-extension-ops/interpreter/syntax/ast.ml
--- spec/interpreter/syntax/ast.ml 2019-02-27 13:41:13.407702063 -0800
+++ sign-extension-ops/interpreter/syntax/ast.ml 2020-01-16 10:29:11.407288956 -0800
@@ -23,7 +23,7 @@
module IntOp =
struct
- type unop = Clz | Ctz | Popcnt
+ type unop = Clz | Ctz | Popcnt | Extend8S | Extend16S | Extend32S
type binop = Add | Sub | Mul | DivS | DivU | RemS | RemU
| And | Or | Xor | Shl | ShrS | ShrU | Rotl | Rotr
type testop = Eqz
diff -r -u spec/interpreter/syntax/operators.ml sign-extension-ops/interpreter/syntax/operators.ml
--- spec/interpreter/syntax/operators.ml 2019-02-27 13:41:13.407702063 -0800
+++ sign-extension-ops/interpreter/syntax/operators.ml 2020-01-16 10:29:11.407288956 -0800
@@ -199,6 +199,12 @@
let f32_reinterpret_i32 = Convert (F32 F32Op.ReinterpretInt)
let f64_reinterpret_i64 = Convert (F64 F64Op.ReinterpretInt)
+let i32_extend8_s = Unary (I32 I32Op.Extend8S)
+let i32_extend16_s = Unary (I32 I32Op.Extend16S)
+let i64_extend8_s = Unary (I64 I64Op.Extend8S)
+let i64_extend16_s = Unary (I64 I64Op.Extend16S)
+let i64_extend32_s = Unary (I64 I64Op.Extend32S)
+
let memory_size = MemorySize
let memory_grow = MemoryGrow
diff -r -u spec/interpreter/text/arrange.ml sign-extension-ops/interpreter/text/arrange.ml
--- spec/interpreter/text/arrange.ml 2020-01-09 10:27:38.635512968 -0800
+++ sign-extension-ops/interpreter/text/arrange.ml 2020-01-16 10:29:11.407288956 -0800
@@ -101,6 +101,9 @@
| Clz -> "clz"
| Ctz -> "ctz"
| Popcnt -> "popcnt"
+ | Extend8S -> "extend8_s"
+ | Extend16S -> "extend16_s"
+ | Extend32S -> "extend32_s"
let binop xx = function
| Add -> "add"
diff -r -u spec/interpreter/text/lexer.mll sign-extension-ops/interpreter/text/lexer.mll
--- spec/interpreter/text/lexer.mll 2020-01-09 10:27:38.635512968 -0800
+++ sign-extension-ops/interpreter/text/lexer.mll 2020-01-16 10:29:11.407288956 -0800
@@ -238,6 +238,9 @@
| (ixx as t)".clz" { UNARY (intop t i32_clz i64_clz) }
| (ixx as t)".ctz" { UNARY (intop t i32_ctz i64_ctz) }
| (ixx as t)".popcnt" { UNARY (intop t i32_popcnt i64_popcnt) }
+ | (ixx as t)".extend8_s" { UNARY (intop t i32_extend8_s i64_extend8_s) }
+ | (ixx as t)".extend16_s" { UNARY (intop t i32_extend16_s i64_extend16_s) }
+ | "i64.extend32_s" { UNARY i64_extend32_s }
| (fxx as t)".neg" { UNARY (floatop t f32_neg f64_neg) }
| (fxx as t)".abs" { UNARY (floatop t f32_abs f64_abs) }
| (fxx as t)".sqrt" { UNARY (floatop t f32_sqrt f64_sqrt) }
diff -r -u spec/interpreter/valid/valid.ml sign-extension-ops/interpreter/valid/valid.ml
--- spec/interpreter/valid/valid.ml 2019-02-27 13:41:13.407702063 -0800
+++ sign-extension-ops/interpreter/valid/valid.ml 2020-01-16 10:29:11.407288956 -0800
@@ -137,6 +137,11 @@
(* Expressions *)
+let check_unop unop at =
+ match unop with
+ | Values.I32 I32Op.Extend32S -> error at "invalid unary operator"
+ | _ -> ()
+
let check_memop (c : context) (memop : 'a memop) get_sz at =
ignore (memory c (0l @@ at));
let size =
@@ -277,6 +282,7 @@
[t; t] --> [I32Type]
| Unary unop ->
+ check_unop unop e.at;
let t = type_unop unop in
[t] --> [t]
diff -r -u spec/README.md sign-extension-ops/README.md
--- spec/README.md 2018-03-28 12:00:29.874390130 -0700
+++ sign-extension-ops/README.md 2020-01-16 10:29:11.375288908 -0800
@@ -1,4 +1,20 @@
-[![Build Status](https://travis-ci.org/WebAssembly/spec.svg?branch=master)](https://travis-ci.org/WebAssembly/spec)
+[![Standardize phase](https://img.shields.io/badge/phase-standardize-yellow.svg)](https://github.com/WebAssembly/meetings/blob/master/process/phases.md#3-implementation-phase-community--working-group)
+
+[![Build Status](https://travis-ci.org/WebAssembly/sign-extension-ops.svg?branch=master)](https://travis-ci.org/WebAssembly/sign-extension-ops)
+
+# Sign Extension Operators Proposal for WebAssembly
+
+This repository is a clone of github.com/WebAssembly/spec/. It is meant for
+discussion, prototype specification and implementation of a proposal to add
+sign-extension operators to WebAssembly.
+
+See the [overview](proposals/sign-extension-ops/Overview.md) for a summary of
+the proposal.
+
+A formatted version of the spec, including this propsal, is available here:
+[webassembly.github.io/sign-extension-ops](https://webassembly.github.io/sign-extension-ops/)
+
+Original README from upstream repository follows...
# spec
diff -r -u spec/test/core/i32.wast sign-extension-ops/test/core/i32.wast
--- spec/test/core/i32.wast 2020-01-09 10:27:38.639512976 -0800
+++ sign-extension-ops/test/core/i32.wast 2020-01-16 10:29:11.467289045 -0800
@@ -19,6 +19,8 @@
(func (export "clz") (param $x i32) (result i32) (i32.clz (local.get $x)))
(func (export "ctz") (param $x i32) (result i32) (i32.ctz (local.get $x)))
(func (export "popcnt") (param $x i32) (result i32) (i32.popcnt (local.get $x)))
+ (func (export "extend8_s") (param $x i32) (result i32) (i32.extend8_s (local.get $x)))
+ (func (export "extend16_s") (param $x i32) (result i32) (i32.extend16_s (local.get $x)))
(func (export "eqz") (param $x i32) (result i32) (i32.eqz (local.get $x)))
(func (export "eq") (param $x i32) (param $y i32) (result i32) (i32.eq (local.get $x) (local.get $y)))
(func (export "ne") (param $x i32) (param $y i32) (result i32) (i32.ne (local.get $x) (local.get $y)))
@@ -265,6 +267,22 @@
(assert_return (invoke "popcnt" (i32.const 0x55555555)) (i32.const 16))
(assert_return (invoke "popcnt" (i32.const 0xDEADBEEF)) (i32.const 24))
+(assert_return (invoke "extend8_s" (i32.const 0)) (i32.const 0))
+(assert_return (invoke "extend8_s" (i32.const 0x7f)) (i32.const 127))
+(assert_return (invoke "extend8_s" (i32.const 0x80)) (i32.const -128))
+(assert_return (invoke "extend8_s" (i32.const 0xff)) (i32.const -1))
+(assert_return (invoke "extend8_s" (i32.const 0x012345_00)) (i32.const 0))
+(assert_return (invoke "extend8_s" (i32.const 0xfedcba_80)) (i32.const -0x80))
+(assert_return (invoke "extend8_s" (i32.const -1)) (i32.const -1))
+
+(assert_return (invoke "extend16_s" (i32.const 0)) (i32.const 0))
+(assert_return (invoke "extend16_s" (i32.const 0x7fff)) (i32.const 32767))
+(assert_return (invoke "extend16_s" (i32.const 0x8000)) (i32.const -32768))
+(assert_return (invoke "extend16_s" (i32.const 0xffff)) (i32.const -1))
+(assert_return (invoke "extend16_s" (i32.const 0x0123_0000)) (i32.const 0))
+(assert_return (invoke "extend16_s" (i32.const 0xfedc_8000)) (i32.const -0x8000))
+(assert_return (invoke "extend16_s" (i32.const -1)) (i32.const -1))
+
(assert_return (invoke "eqz" (i32.const 0)) (i32.const 1))
(assert_return (invoke "eqz" (i32.const 1)) (i32.const 0))
(assert_return (invoke "eqz" (i32.const 0x80000000)) (i32.const 0))
diff -r -u spec/test/core/i64.wast sign-extension-ops/test/core/i64.wast
--- spec/test/core/i64.wast 2020-01-09 10:27:38.643512984 -0800
+++ sign-extension-ops/test/core/i64.wast 2020-01-16 10:29:11.467289045 -0800
@@ -19,6 +19,9 @@
(func (export "clz") (param $x i64) (result i64) (i64.clz (local.get $x)))
(func (export "ctz") (param $x i64) (result i64) (i64.ctz (local.get $x)))
(func (export "popcnt") (param $x i64) (result i64) (i64.popcnt (local.get $x)))
+ (func (export "extend8_s") (param $x i64) (result i64) (i64.extend8_s (local.get $x)))
+ (func (export "extend16_s") (param $x i64) (result i64) (i64.extend16_s (local.get $x)))
+ (func (export "extend32_s") (param $x i64) (result i64) (i64.extend32_s (local.get $x)))
(func (export "eqz") (param $x i64) (result i32) (i64.eqz (local.get $x)))
(func (export "eq") (param $x i64) (param $y i64) (result i32) (i64.eq (local.get $x) (local.get $y)))
(func (export "ne") (param $x i64) (param $y i64) (result i32) (i64.ne (local.get $x) (local.get $y)))
@@ -256,7 +259,7 @@
(assert_return (invoke "ctz" (i64.const 0x8000000000000000)) (i64.const 63))
(assert_return (invoke "ctz" (i64.const 0x7fffffffffffffff)) (i64.const 0))
-(assert_return (invoke "popcnt" (i64.const -1)) (i64.const 64))
+(assert_return (invoke "local.get" (i64.const -1)) (i64.const 64))
(assert_return (invoke "popcnt" (i64.const 0)) (i64.const 0))
(assert_return (invoke "popcnt" (i64.const 0x00008000)) (i64.const 1))
(assert_return (invoke "popcnt" (i64.const 0x8000800080008000)) (i64.const 4))
@@ -265,6 +268,33 @@
(assert_return (invoke "popcnt" (i64.const 0x99999999AAAAAAAA)) (i64.const 32))
(assert_return (invoke "popcnt" (i64.const 0xDEADBEEFDEADBEEF)) (i64.const 48))
+(assert_return (invoke "extend8_s" (i64.const 0)) (i64.const 0))
+(assert_return (invoke "extend8_s" (i64.const 0x7f)) (i64.const 127))
+(assert_return (invoke "extend8_s" (i64.const 0x80)) (i64.const -128))
+(assert_return (invoke "extend8_s" (i64.const 0xff)) (i64.const -1))
+(assert_return (invoke "extend8_s" (i64.const 0x01234567_89abcd_00)) (i64.const 0))
+(assert_return (invoke "extend8_s" (i64.const 0xfedcba98_765432_80)) (i64.const -0x80))
+(assert_return (invoke "extend8_s" (i64.const -1)) (i64.const -1))
+
+(assert_return (invoke "extend16_s" (i64.const 0)) (i64.const 0))
+(assert_return (invoke "extend16_s" (i64.const 0x7fff)) (i64.const 32767))
+(assert_return (invoke "extend16_s" (i64.const 0x8000)) (i64.const -32768))
+(assert_return (invoke "extend16_s" (i64.const 0xffff)) (i64.const -1))
+(assert_return (invoke "extend16_s" (i64.const 0x12345678_9abc_0000)) (i64.const 0))
+(assert_return (invoke "extend16_s" (i64.const 0xfedcba98_7654_8000)) (i64.const -0x8000))
+(assert_return (invoke "extend16_s" (i64.const -1)) (i64.const -1))
+
+(assert_return (invoke "extend32_s" (i64.const 0)) (i64.const 0))
+(assert_return (invoke "extend32_s" (i64.const 0x7fff)) (i64.const 32767))
+(assert_return (invoke "extend32_s" (i64.const 0x8000)) (i64.const 32768))
+(assert_return (invoke "extend32_s" (i64.const 0xffff)) (i64.const 65535))
+(assert_return (invoke "extend32_s" (i64.const 0x7fffffff)) (i64.const 0x7fffffff))
+(assert_return (invoke "extend32_s" (i64.const 0x80000000)) (i64.const -0x80000000))
+(assert_return (invoke "extend32_s" (i64.const 0xffffffff)) (i64.const -1))
+(assert_return (invoke "extend32_s" (i64.const 0x01234567_00000000)) (i64.const 0))
+(assert_return (invoke "extend32_s" (i64.const 0xfedcba98_80000000)) (i64.const -0x80000000))
+(assert_return (invoke "extend32_s" (i64.const -1)) (i64.const -1))
+
(assert_return (invoke "eqz" (i64.const 0)) (i32.const 1))
(assert_return (invoke "eqz" (i64.const 1)) (i32.const 0))
(assert_return (invoke "eqz" (i64.const 0x8000000000000000)) (i32.const 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment