Skip to content

Commit

Permalink
WebAssembly#372 Integer Sign/Zero Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
omnisip committed Nov 8, 2020
1 parent d154084 commit e24b7a7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions proposals/simd/BinarySIMD.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,9 @@ For example, `ImmLaneIdx16` is a byte with values in the range 0-15 (inclusive).
| `f32x4.convert_i32x4_u` | `0xfb`| - |
| `v128.load32_zero` | `0xfc`| - |
| `v128.load64_zero` | `0xfd`| - |
| `i32x4.widen_i8x16_u` | | - |
| `i32x4.widen_i8x16_s` | | - |
| `i64x2.widen_i8x16_u` | | - |
| `i64x2.widen_i8x16_s` | | - |
| `i64x2.widen_i16x8_u` | | - |
| `i64x2.widen_i16x8_s` | | - |
6 changes: 6 additions & 0 deletions proposals/simd/ImplementationStatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@
| `f32x4.convert_i32x4_u` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
| `v128.load32_zero` | | :heavy_check_mark: | | | :heavy_check_mark: |
| `v128.load64_zero` | | :heavy_check_mark: | | | :heavy_check_mark: |
| `i32x4.widen_i8x16_u` | | - | | | |
| `i32x4.widen_i8x16_s` | | - | | | |
| `i64x2.widen_i8x16_u` | | - | | | |
| `i64x2.widen_i8x16_s` | | - | | | |
| `i64x2.widen_i16x8_u` | | - | | | |
| `i64x2.widen_i16x8_s` | | - | | | |

[1] Tip of tree LLVM as of May 20, 2020

Expand Down
22 changes: 22 additions & 0 deletions proposals/simd/SIMD.md
Original file line number Diff line number Diff line change
Expand Up @@ -1046,3 +1046,25 @@ def S.widen_low_T_u(a):
def S.widen_high_T_u(a):
return S.widen_high_T(Zext, a)
```
### Integer to integer Widening (Constant Immediate)
* `i32x4.widen_i8x16_u(v128: a, ImmLaneIdx4: c) -> v128`
* `i32x4.widen_i8x16_s(v128: a, ImmLaneIdx4: c) -> v128`
* `i64x2.widen_i8x16_u(v128: a, ImmLaneIdx8: c) -> v128`
* `i64x2.widen_i8x16_s(v128: a, ImmLaneIdx8: c) -> v128`
* `i64x2.widen_i16x8_u(v128: a, ImmLaneIdx4: c) -> v128`
* `i64x2.widen_i16x8_s(v128: a, ImmLaneIdx4: c) -> v128`

Using the constant immediate, widens selected integers with zero or sign extension.
```python
def S.widen_T_u(a,c):
result = S.New()
for i in range(S.Lanes):
result[i] = Zext(a[S.Lanes + i + c])
return result

def S.widen_T_s(a,c):
result = S.New()
for i in range(S.Lanes):
result[i] = Sext(a[S.Lanes + i + c])
return result
```

0 comments on commit e24b7a7

Please sign in to comment.