Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Add .bitmask instruction family #201

Merged
merged 2 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions proposals/simd/BinarySIMD.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ The `v8x16.shuffle` instruction has 16 bytes after `simdop`.
| `i8x16.neg` | `0x61`| - |
| `i8x16.any_true` | `0x62`| - |
| `i8x16.all_true` | `0x63`| - |
| `i8x16.bitmask` | `0x64`| - |
| `i8x16.narrow_i16x8_s` | `0x65`| - |
| `i8x16.narrow_i16x8_u` | `0x66`| - |
| `i8x16.shl` | `0x6b`| - |
Expand All @@ -134,6 +135,7 @@ The `v8x16.shuffle` instruction has 16 bytes after `simdop`.
| `i16x8.neg` | `0x81`| - |
| `i16x8.any_true` | `0x82`| - |
| `i16x8.all_true` | `0x83`| - |
| `i16x8.bitmask` | `0x84`| - |
| `i16x8.narrow_i32x4_s` | `0x85`| - |
| `i16x8.narrow_i32x4_u` | `0x86`| - |
| `i16x8.widen_low_i8x16_s` | `0x87`| - |
Expand All @@ -159,6 +161,7 @@ The `v8x16.shuffle` instruction has 16 bytes after `simdop`.
| `i32x4.neg` | `0xa1`| - |
| `i32x4.any_true` | `0xa2`| - |
| `i32x4.all_true` | `0xa3`| - |
| `i32x4.bitmask` | `0xa4`| - |
| `i32x4.widen_low_i16x8_s` | `0xa7`| - |
| `i32x4.widen_high_i16x8_s` | `0xa8`| - |
| `i32x4.widen_low_i16x8_u` | `0xa9`| - |
Expand Down
3 changes: 3 additions & 0 deletions proposals/simd/ImplementationStatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
| `i8x16.neg` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i8x16.any_true` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i8x16.all_true` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i8x16.bitmask` | `-munimplemented-simd128` | :heavy_check_mark: | | | |
| `i8x16.narrow_i16x8_s` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i8x16.narrow_i16x8_u` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i8x16.shl` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
Expand All @@ -107,6 +108,7 @@
| `i16x8.neg` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i16x8.any_true` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i16x8.all_true` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i16x8.bitmask` | `-munimplemented-simd128` | :heavy_check_mark: | | | |
| `i16x8.narrow_i32x4_s` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i16x8.narrow_i32x4_u` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i16x8.widen_low_i8x16_s` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
Expand All @@ -132,6 +134,7 @@
| `i32x4.neg` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i32x4.any_true` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i32x4.all_true` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i32x4.bitmask` | `-munimplemented-simd128` | :heavy_check_mark: | | | |
| `i32x4.widen_low_i16x8_s` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i32x4.widen_high_i16x8_s` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `i32x4.widen_low_i16x8_u` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
Expand Down
2 changes: 1 addition & 1 deletion proposals/simd/NewOpcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
| i8x16.neg | 0x61 | i16x8.neg | 0x81 | i32x4.neg | 0xa1 | i64x2.neg | 0xc1 |
| i8x16.any_true | 0x62 | i16x8.any_true | 0x82 | i32x4.any_true | 0xa2 | ---- | 0xc2 |
| i8x16.all_true | 0x63 | i16x8.all_true | 0x83 | i32x4.all_true | 0xa3 | ---- | 0xc3 |
| ---- bitmask ---- | 0x64 | ---- bitmask ---- | 0x84 | ---- bitmask ---- | 0xa4 | ---- | 0xc4 |
| i8x16.bitmask | 0x64 | i16x8.bitmask | 0x84 | i32x4.bitmask | 0xa4 | ---- | 0xc4 |
| i8x16.narrow_i16x8_s | 0x65 | i16x8.narrow_i32x4_s | 0x85 | ---- narrow ---- | 0xa5 | ---- | 0xc5 |
| i8x16.narrow_i16x8_u | 0x66 | i16x8.narrow_i32x4_u | 0x86 | ---- narrow ---- | 0xa6 | ---- | 0xc6 |
| ---- widen ---- | 0x67 | i16x8.widen_low_i8x16_s | 0x87 | i32x4.widen_low_i16x8_s | 0xa7 | ---- | 0xc7 |
Expand Down
18 changes: 18 additions & 0 deletions proposals/simd/SIMD.md
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,24 @@ def S.all_true(a):
return 1
```

## Bitmask extraction

* `i8x16.bitmask(a: v128) -> i32`
* `i16x8.bitmask(a: v128) -> i32`
* `i32x4.bitmask(a: v128) -> i32`

These operations extract the high bit for each lane in `a` and produce a scalar
mask with all bits concatenated.

```python
def S.bitmask(a):
result = 0
for i in range(S.Lanes):
if a[i] < 0:
result = result | (1 << i)
return result
```

## Comparisons

The comparison operations all compare two vectors lane-wise, and produce a mask
Expand Down