forked from WebAssembly/simd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[interpreter] Add i64x2.eq and i64x2.ne
These instructions were added in WebAssembly#381 and WebAssembly#411 respectively. The binary opcodes for these are still not finalized, I'm using what V8 is using for now.
- Loading branch information
Showing
9 changed files
with
189 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from simd_compare import SimdCmpCase | ||
|
||
|
||
# Generate i64x2 test case | ||
class Simdi64x2CmpCase(SimdCmpCase): | ||
LANE_TYPE = 'i64x2' | ||
|
||
BINARY_OPS = ['eq', 'ne'] | ||
|
||
# Override this since i64x2 does not support as many comparison instructions. | ||
CASE_TXT = """ | ||
;; Test all the {lane_type} comparison operators on major boundary values and all special values. | ||
(module | ||
(func (export "eq") (param $x v128) (param $y v128) (result v128) ({lane_type}.eq (local.get $x) (local.get $y))) | ||
(func (export "ne") (param $x v128) (param $y v128) (result v128) ({lane_type}.ne (local.get $x) (local.get $y))) | ||
) | ||
{normal_case} | ||
;; Type check | ||
(assert_invalid (module (func (result v128) ({lane_type}.eq (i32.const 0) (f32.const 0)))) "type mismatch") | ||
(assert_invalid (module (func (result v128) ({lane_type}.ne (i32.const 0) (f32.const 0)))) "type mismatch") | ||
""" | ||
|
||
def get_case_data(self): | ||
forms = ['i64x2'] * 3 | ||
case_data = [] | ||
|
||
case_data.append(['#', 'eq']) | ||
case_data.append(['#', 'i64x2.eq (i64x2) (i64x2)']) | ||
case_data.append(['eq', ['0xFFFFFFFFFFFFFFFF', '0xFFFFFFFFFFFFFFFF'], '-1', forms]) | ||
case_data.append(['eq', ['0x0000000000000000', '0x0000000000000000'], '-1', forms]) | ||
case_data.append(['eq', ['0xF0F0F0F0F0F0F0F0', '0xF0F0F0F0F0F0F0F0'], '-1', forms]) | ||
case_data.append(['eq', ['0x0F0F0F0F0F0F0F0F', '0x0F0F0F0F0F0F0F0F'], '-1', forms]) | ||
case_data.append(['eq', [['0xFFFFFFFFFFFFFFFF', '0x0000000000000000'], ['0xFFFFFFFFFFFFFFFF', '0x0000000000000000']], '-1', forms]) | ||
case_data.append(['eq', [['0x0000000000000000', '0xFFFFFFFFFFFFFFFF'], ['0x0000000000000000', '0xFFFFFFFFFFFFFFFF']], '-1', forms]) | ||
case_data.append(['eq', [['0x03020100', '0x11100904', '0x1A0B0A12', '0xFFABAA1B'], | ||
['0x03020100', '0x11100904', '0x1A0B0A12', '0xFFABAA1B']], '-1', forms]) | ||
case_data.append(['eq', ['0xFFFFFFFFFFFFFFFF', '0x0FFFFFFFFFFFFFFF'], '0', forms]) | ||
case_data.append(['eq', ['0x1', '0x2'], '0', forms]) | ||
|
||
case_data.append(['#', 'ne']) | ||
case_data.append(['#', 'i64x2.ne (i64x2) (i64x2)']) | ||
|
||
# hex vs hex | ||
case_data.append(['#', 'hex vs hex']) | ||
case_data.append(['ne', ['0xFFFFFFFFFFFFFFFF', '0xFFFFFFFFFFFFFFFF'], '0', forms]) | ||
case_data.append(['ne', ['0x0000000000000000', '0x0000000000000000'], '0', forms]) | ||
case_data.append(['ne', ['0xF0F0F0F0F0F0F0F0', '0xF0F0F0F0F0F0F0F0'], '0', forms]) | ||
case_data.append(['ne', ['0x0F0F0F0F0F0F0F0F', '0x0F0F0F0F0F0F0F0F'], '0', forms]) | ||
case_data.append(['ne', [['0xFFFFFFFFFFFFFFFF', '0x0000000000000000'], ['0xFFFFFFFFFFFFFFFF', '0x0000000000000000']], '0', forms]) | ||
case_data.append(['ne', [['0x0000000000000000', '0xFFFFFFFFFFFFFFFF'], ['0x0000000000000000', '0xFFFFFFFFFFFFFFFF']], '0', forms]) | ||
case_data.append(['ne', [['0x03020100', '0x11100904', '0x1A0B0A12', '0xFFABAA1B'], | ||
['0x03020100', '0x11100904', '0x1A0B0A12', '0xFFABAA1B']], '0', forms]) | ||
|
||
return case_data | ||
|
||
|
||
def gen_test_cases(): | ||
i64x2 = Simdi64x2CmpCase() | ||
i64x2.gen_test_cases() | ||
|
||
|
||
if __name__ == '__main__': | ||
i64x2 = Simdi64x2CmpCase() | ||
i64x2.gen_test_cases() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
|
||
;; Test all the i64x2 comparison operators on major boundary values and all special values. | ||
|
||
(module | ||
(func (export "eq") (param $x v128) (param $y v128) (result v128) (i64x2.eq (local.get $x) (local.get $y))) | ||
(func (export "ne") (param $x v128) (param $y v128) (result v128) (i64x2.ne (local.get $x) (local.get $y))) | ||
) | ||
|
||
|
||
;; eq | ||
|
||
;; i64x2.eq (i64x2) (i64x2) | ||
(assert_return (invoke "eq" (v128.const i64x2 0xFFFFFFFFFFFFFFFF 0xFFFFFFFFFFFFFFFF) | ||
(v128.const i64x2 0xFFFFFFFFFFFFFFFF 0xFFFFFFFFFFFFFFFF)) | ||
(v128.const i64x2 -1 -1)) | ||
(assert_return (invoke "eq" (v128.const i64x2 0x0000000000000000 0x0000000000000000) | ||
(v128.const i64x2 0x0000000000000000 0x0000000000000000)) | ||
(v128.const i64x2 -1 -1)) | ||
(assert_return (invoke "eq" (v128.const i64x2 0xF0F0F0F0F0F0F0F0 0xF0F0F0F0F0F0F0F0) | ||
(v128.const i64x2 0xF0F0F0F0F0F0F0F0 0xF0F0F0F0F0F0F0F0)) | ||
(v128.const i64x2 -1 -1)) | ||
(assert_return (invoke "eq" (v128.const i64x2 0x0F0F0F0F0F0F0F0F 0x0F0F0F0F0F0F0F0F) | ||
(v128.const i64x2 0x0F0F0F0F0F0F0F0F 0x0F0F0F0F0F0F0F0F)) | ||
(v128.const i64x2 -1 -1)) | ||
(assert_return (invoke "eq" (v128.const i64x2 0xFFFFFFFFFFFFFFFF 0x0000000000000000) | ||
(v128.const i64x2 0xFFFFFFFFFFFFFFFF 0x0000000000000000)) | ||
(v128.const i64x2 -1 -1)) | ||
(assert_return (invoke "eq" (v128.const i64x2 0x0000000000000000 0xFFFFFFFFFFFFFFFF) | ||
(v128.const i64x2 0x0000000000000000 0xFFFFFFFFFFFFFFFF)) | ||
(v128.const i64x2 -1 -1)) | ||
(assert_return (invoke "eq" (v128.const i64x2 0x03020100 0x11100904) | ||
(v128.const i64x2 0x03020100 0x11100904)) | ||
(v128.const i64x2 -1 -1)) | ||
(assert_return (invoke "eq" (v128.const i64x2 0xFFFFFFFFFFFFFFFF 0xFFFFFFFFFFFFFFFF) | ||
(v128.const i64x2 0x0FFFFFFFFFFFFFFF 0x0FFFFFFFFFFFFFFF)) | ||
(v128.const i64x2 0 0)) | ||
(assert_return (invoke "eq" (v128.const i64x2 0x1 0x1) | ||
(v128.const i64x2 0x2 0x2)) | ||
(v128.const i64x2 0 0)) | ||
|
||
;; ne | ||
|
||
;; i64x2.ne (i64x2) (i64x2) | ||
|
||
;; hex vs hex | ||
(assert_return (invoke "ne" (v128.const i64x2 0xFFFFFFFF 0xFFFFFFFF) | ||
(v128.const i64x2 0xFFFFFFFF 0xFFFFFFFF)) | ||
(v128.const i64x2 0 0)) | ||
(assert_return (invoke "ne" (v128.const i64x2 0x00000000 0x00000000) | ||
(v128.const i64x2 0x00000000 0x00000000)) | ||
(v128.const i64x2 0 0)) | ||
(assert_return (invoke "ne" (v128.const i64x2 0xF0F0F0F0 0xF0F0F0F0) | ||
(v128.const i64x2 0xF0F0F0F0 0xF0F0F0F0)) | ||
(v128.const i64x2 0 0)) | ||
(assert_return (invoke "ne" (v128.const i64x2 0x0F0F0F0F 0x0F0F0F0F) | ||
(v128.const i64x2 0x0F0F0F0F 0x0F0F0F0F)) | ||
(v128.const i64x2 0 0)) | ||
(assert_return (invoke "ne" (v128.const i64x2 0xFFFFFFFF 0x00000000) | ||
(v128.const i64x2 0xFFFFFFFF 0x00000000)) | ||
(v128.const i64x2 0 0)) | ||
(assert_return (invoke "ne" (v128.const i64x2 0x00000000 0xFFFFFFFF) | ||
(v128.const i64x2 0x00000000 0xFFFFFFFF)) | ||
(v128.const i64x2 0 0)) | ||
(assert_return (invoke "ne" (v128.const i64x2 0x03020100 0x11100904) | ||
(v128.const i64x2 0x03020100 0x11100904)) | ||
(v128.const i64x2 0 0)) | ||
|
||
;; Type check | ||
|
||
(assert_invalid (module (func (result v128) (i64x2.eq (i32.const 0) (f32.const 0)))) "type mismatch") | ||
(assert_invalid (module (func (result v128) (i64x2.ne (i32.const 0) (f32.const 0)))) "type mismatch") | ||
|
||
;; Test operation with empty argument | ||
|
||
(assert_invalid | ||
(module | ||
(func $i64x2.eq-1st-arg-empty (result v128) | ||
(i64x2.eq (v128.const i64x2 0 0)) | ||
) | ||
) | ||
"type mismatch" | ||
) | ||
(assert_invalid | ||
(module | ||
(func $i64x2.eq-arg-empty (result v128) | ||
(i64x2.eq) | ||
) | ||
) | ||
"type mismatch" | ||
) | ||
(assert_invalid | ||
(module | ||
(func $i64x2.ne-1st-arg-empty (result v128) | ||
(i64x2.ne (v128.const i64x2 0 0)) | ||
) | ||
) | ||
"type mismatch" | ||
) | ||
(assert_invalid | ||
(module | ||
(func $i64x2.ne-arg-empty (result v128) | ||
(i64x2.ne) | ||
) | ||
) | ||
"type mismatch" | ||
) |