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

Commit f44e3a6

Browse files
ngzhiandtig
authored andcommitted
Add integer widen/narrow conversions (#89)
* Add integer widen/narrow conversions * Fix names, add explanation on signed/unsigned narrowing
1 parent 0d3fafd commit f44e3a6

File tree

3 files changed

+342
-294
lines changed

3 files changed

+342
-294
lines changed

proposals/simd/BinarySIMD.md

Lines changed: 159 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -25,150 +25,162 @@ instr ::= ...
2525
Some SIMD instructions have additional immediate operands following `simdop`.
2626
The `v8x16.shuffle` instruction has 16 bytes after `simdop`.
2727

28-
| Instruction | `simdop` | Immediate operands |
29-
| --------------------------|---------:|--------------------|
30-
| `v128.load` | `0x00`| m:memarg |
31-
| `v128.store` | `0x01`| m:memarg |
32-
| `v128.const` | `0x02`| i:ImmByte[16] |
33-
| `i8x16.splat` | `0x04`| - |
34-
| `i8x16.extract_lane_s` | `0x05`| i:LaneIdx16 |
35-
| `i8x16.extract_lane_u` | `0x06`| i:LaneIdx16 |
36-
| `i8x16.replace_lane` | `0x07`| i:LaneIdx16 |
37-
| `i16x8.splat` | `0x08`| - |
38-
| `i16x8.extract_lane_s` | `0x09`| i:LaneIdx8 |
39-
| `i16x8.extract_lane_u` | `0x0a`| i:LaneIdx8 |
40-
| `i16x8.replace_lane` | `0x0b`| i:LaneIdx8 |
41-
| `i32x4.splat` | `0x0c`| - |
42-
| `i32x4.extract_lane` | `0x0d`| i:LaneIdx4 |
43-
| `i32x4.replace_lane` | `0x0e`| i:LaneIdx4 |
44-
| `i64x2.splat` | `0x0f`| - |
45-
| `i64x2.extract_lane` | `0x10`| i:LaneIdx2 |
46-
| `i64x2.replace_lane` | `0x11`| i:LaneIdx2 |
47-
| `f32x4.splat` | `0x12`| - |
48-
| `f32x4.extract_lane` | `0x13`| i:LaneIdx4 |
49-
| `f32x4.replace_lane` | `0x14`| i:LaneIdx4 |
50-
| `f64x2.splat` | `0x15`| - |
51-
| `f64x2.extract_lane` | `0x16`| i:LaneIdx2 |
52-
| `f64x2.replace_lane` | `0x17`| i:LaneIdx2 |
53-
| `i8x16.eq` | `0x18`| - |
54-
| `i8x16.ne` | `0x19`| - |
55-
| `i8x16.lt_s` | `0x1a`| - |
56-
| `i8x16.lt_u` | `0x1b`| - |
57-
| `i8x16.gt_s` | `0x1c`| - |
58-
| `i8x16.gt_u` | `0x1d`| - |
59-
| `i8x16.le_s` | `0x1e`| - |
60-
| `i8x16.le_u` | `0x1f`| - |
61-
| `i8x16.ge_s` | `0x20`| - |
62-
| `i8x16.ge_u` | `0x21`| - |
63-
| `i16x8.eq` | `0x22`| - |
64-
| `i16x8.ne` | `0x23`| - |
65-
| `i16x8.lt_s` | `0x24`| - |
66-
| `i16x8.lt_u` | `0x25`| - |
67-
| `i16x8.gt_s` | `0x26`| - |
68-
| `i16x8.gt_u` | `0x27`| - |
69-
| `i16x8.le_s` | `0x28`| - |
70-
| `i16x8.le_u` | `0x29`| - |
71-
| `i16x8.ge_s` | `0x2a`| - |
72-
| `i16x8.ge_u` | `0x2b`| - |
73-
| `i32x4.eq` | `0x2c`| - |
74-
| `i32x4.ne` | `0x2d`| - |
75-
| `i32x4.lt_s` | `0x2e`| - |
76-
| `i32x4.lt_u` | `0x2f`| - |
77-
| `i32x4.gt_s` | `0x30`| - |
78-
| `i32x4.gt_u` | `0x31`| - |
79-
| `i32x4.le_s` | `0x32`| - |
80-
| `i32x4.le_u` | `0x33`| - |
81-
| `i32x4.ge_s` | `0x34`| - |
82-
| `i32x4.ge_u` | `0x35`| - |
83-
| `f32x4.eq` | `0x40`| - |
84-
| `f32x4.ne` | `0x41`| - |
85-
| `f32x4.lt` | `0x42`| - |
86-
| `f32x4.gt` | `0x43`| - |
87-
| `f32x4.le` | `0x44`| - |
88-
| `f32x4.ge` | `0x45`| - |
89-
| `f64x2.eq` | `0x46`| - |
90-
| `f64x2.ne` | `0x47`| - |
91-
| `f64x2.lt` | `0x48`| - |
92-
| `f64x2.gt` | `0x49`| - |
93-
| `f64x2.le` | `0x4a`| - |
94-
| `f64x2.ge` | `0x4b`| - |
95-
| `v128.not` | `0x4c`| - |
96-
| `v128.and` | `0x4d`| - |
97-
| `v128.or` | `0x4e`| - |
98-
| `v128.xor` | `0x4f`| - |
99-
| `v128.bitselect` | `0x50`| - |
100-
| `i8x16.neg` | `0x51`| - |
101-
| `i8x16.any_true` | `0x52`| - |
102-
| `i8x16.all_true` | `0x53`| - |
103-
| `i8x16.shl` | `0x54`| - |
104-
| `i8x16.shr_s` | `0x55`| - |
105-
| `i8x16.shr_u` | `0x56`| - |
106-
| `i8x16.add` | `0x57`| - |
107-
| `i8x16.add_saturate_s` | `0x58`| - |
108-
| `i8x16.add_saturate_u` | `0x59`| - |
109-
| `i8x16.sub` | `0x5a`| - |
110-
| `i8x16.sub_saturate_s` | `0x5b`| - |
111-
| `i8x16.sub_saturate_u` | `0x5c`| - |
112-
| `i8x16.mul` | `0x5d`| - |
113-
| `i16x8.neg` | `0x62`| - |
114-
| `i16x8.any_true` | `0x63`| - |
115-
| `i16x8.all_true` | `0x64`| - |
116-
| `i16x8.shl` | `0x65`| - |
117-
| `i16x8.shr_s` | `0x66`| - |
118-
| `i16x8.shr_u` | `0x67`| - |
119-
| `i16x8.add` | `0x68`| - |
120-
| `i16x8.add_saturate_s` | `0x69`| - |
121-
| `i16x8.add_saturate_u` | `0x6a`| - |
122-
| `i16x8.sub` | `0x6b`| - |
123-
| `i16x8.sub_saturate_s` | `0x6c`| - |
124-
| `i16x8.sub_saturate_u` | `0x6d`| - |
125-
| `i16x8.mul` | `0x6e`| - |
126-
| `i32x4.neg` | `0x73`| - |
127-
| `i32x4.any_true` | `0x74`| - |
128-
| `i32x4.all_true` | `0x75`| - |
129-
| `i32x4.shl` | `0x76`| - |
130-
| `i32x4.shr_s` | `0x77`| - |
131-
| `i32x4.shr_u` | `0x78`| - |
132-
| `i32x4.add` | `0x79`| - |
133-
| `i32x4.sub` | `0x7c`| - |
134-
| `i32x4.mul` | `0x7f`| - |
135-
| `i64x2.neg` | `0x84`| - |
136-
| `i64x2.any_true` | `0x85`| - |
137-
| `i64x2.all_true` | `0x86`| - |
138-
| `i64x2.shl` | `0x87`| - |
139-
| `i64x2.shr_s` | `0x88`| - |
140-
| `i64x2.shr_u` | `0x89`| - |
141-
| `i64x2.add` | `0x8a`| - |
142-
| `i64x2.sub` | `0x8d`| - |
143-
| `f32x4.abs` | `0x95`| - |
144-
| `f32x4.neg` | `0x96`| - |
145-
| `f32x4.sqrt` | `0x97`| - |
146-
| `f32x4.add` | `0x9a`| - |
147-
| `f32x4.sub` | `0x9b`| - |
148-
| `f32x4.mul` | `0x9c`| - |
149-
| `f32x4.div` | `0x9d`| - |
150-
| `f32x4.min` | `0x9e`| - |
151-
| `f32x4.max` | `0x9f`| - |
152-
| `f64x2.abs` | `0xa0`| - |
153-
| `f64x2.neg` | `0xa1`| - |
154-
| `f64x2.sqrt` | `0xa2`| - |
155-
| `f64x2.add` | `0xa5`| - |
156-
| `f64x2.sub` | `0xa6`| - |
157-
| `f64x2.mul` | `0xa7`| - |
158-
| `f64x2.div` | `0xa8`| - |
159-
| `f64x2.min` | `0xa9`| - |
160-
| `f64x2.max` | `0xaa`| - |
161-
| `i32x4.trunc_s/f32x4:sat` | `0xab`| - |
162-
| `i32x4.trunc_u/f32x4:sat` | `0xac`| - |
163-
| `i64x2.trunc_s/f64x2:sat` | `0xad`| - |
164-
| `i64x2.trunc_u/f64x2:sat` | `0xae`| - |
165-
| `f32x4.convert_s/i32x4` | `0xaf`| - |
166-
| `f32x4.convert_u/i32x4` | `0xb0`| - |
167-
| `f64x2.convert_s/i64x2` | `0xb1`| - |
168-
| `f64x2.convert_u/i64x2` | `0xb2`| - |
169-
| `v8x16.swizzle` | `0xc0`| - |
170-
| `v8x16.shuffle` | `0xc1`| s:LaneIdx32[16] |
171-
| `i8x16.load_splat` | `0xc2`| - |
172-
| `i16x8.load_splat` | `0xc3`| - |
173-
| `i32x4.load_splat` | `0xc4`| - |
174-
| `i64x2.load_splat` | `0xc5`| - |
28+
| Instruction | `simdop` | Immediate operands |
29+
| ---------------------------|---------:|--------------------|
30+
| `v128.load` | `0x00`| m:memarg |
31+
| `v128.store` | `0x01`| m:memarg |
32+
| `v128.const` | `0x02`| i:ImmByte[16] |
33+
| `i8x16.splat` | `0x04`| - |
34+
| `i8x16.extract_lane_s` | `0x05`| i:LaneIdx16 |
35+
| `i8x16.extract_lane_u` | `0x06`| i:LaneIdx16 |
36+
| `i8x16.replace_lane` | `0x07`| i:LaneIdx16 |
37+
| `i16x8.splat` | `0x08`| - |
38+
| `i16x8.extract_lane_s` | `0x09`| i:LaneIdx8 |
39+
| `i16x8.extract_lane_u` | `0x0a`| i:LaneIdx8 |
40+
| `i16x8.replace_lane` | `0x0b`| i:LaneIdx8 |
41+
| `i32x4.splat` | `0x0c`| - |
42+
| `i32x4.extract_lane` | `0x0d`| i:LaneIdx4 |
43+
| `i32x4.replace_lane` | `0x0e`| i:LaneIdx4 |
44+
| `i64x2.splat` | `0x0f`| - |
45+
| `i64x2.extract_lane` | `0x10`| i:LaneIdx2 |
46+
| `i64x2.replace_lane` | `0x11`| i:LaneIdx2 |
47+
| `f32x4.splat` | `0x12`| - |
48+
| `f32x4.extract_lane` | `0x13`| i:LaneIdx4 |
49+
| `f32x4.replace_lane` | `0x14`| i:LaneIdx4 |
50+
| `f64x2.splat` | `0x15`| - |
51+
| `f64x2.extract_lane` | `0x16`| i:LaneIdx2 |
52+
| `f64x2.replace_lane` | `0x17`| i:LaneIdx2 |
53+
| `i8x16.eq` | `0x18`| - |
54+
| `i8x16.ne` | `0x19`| - |
55+
| `i8x16.lt_s` | `0x1a`| - |
56+
| `i8x16.lt_u` | `0x1b`| - |
57+
| `i8x16.gt_s` | `0x1c`| - |
58+
| `i8x16.gt_u` | `0x1d`| - |
59+
| `i8x16.le_s` | `0x1e`| - |
60+
| `i8x16.le_u` | `0x1f`| - |
61+
| `i8x16.ge_s` | `0x20`| - |
62+
| `i8x16.ge_u` | `0x21`| - |
63+
| `i16x8.eq` | `0x22`| - |
64+
| `i16x8.ne` | `0x23`| - |
65+
| `i16x8.lt_s` | `0x24`| - |
66+
| `i16x8.lt_u` | `0x25`| - |
67+
| `i16x8.gt_s` | `0x26`| - |
68+
| `i16x8.gt_u` | `0x27`| - |
69+
| `i16x8.le_s` | `0x28`| - |
70+
| `i16x8.le_u` | `0x29`| - |
71+
| `i16x8.ge_s` | `0x2a`| - |
72+
| `i16x8.ge_u` | `0x2b`| - |
73+
| `i32x4.eq` | `0x2c`| - |
74+
| `i32x4.ne` | `0x2d`| - |
75+
| `i32x4.lt_s` | `0x2e`| - |
76+
| `i32x4.lt_u` | `0x2f`| - |
77+
| `i32x4.gt_s` | `0x30`| - |
78+
| `i32x4.gt_u` | `0x31`| - |
79+
| `i32x4.le_s` | `0x32`| - |
80+
| `i32x4.le_u` | `0x33`| - |
81+
| `i32x4.ge_s` | `0x34`| - |
82+
| `i32x4.ge_u` | `0x35`| - |
83+
| `f32x4.eq` | `0x40`| - |
84+
| `f32x4.ne` | `0x41`| - |
85+
| `f32x4.lt` | `0x42`| - |
86+
| `f32x4.gt` | `0x43`| - |
87+
| `f32x4.le` | `0x44`| - |
88+
| `f32x4.ge` | `0x45`| - |
89+
| `f64x2.eq` | `0x46`| - |
90+
| `f64x2.ne` | `0x47`| - |
91+
| `f64x2.lt` | `0x48`| - |
92+
| `f64x2.gt` | `0x49`| - |
93+
| `f64x2.le` | `0x4a`| - |
94+
| `f64x2.ge` | `0x4b`| - |
95+
| `v128.not` | `0x4c`| - |
96+
| `v128.and` | `0x4d`| - |
97+
| `v128.or` | `0x4e`| - |
98+
| `v128.xor` | `0x4f`| - |
99+
| `v128.bitselect` | `0x50`| - |
100+
| `i8x16.neg` | `0x51`| - |
101+
| `i8x16.any_true` | `0x52`| - |
102+
| `i8x16.all_true` | `0x53`| - |
103+
| `i8x16.shl` | `0x54`| - |
104+
| `i8x16.shr_s` | `0x55`| - |
105+
| `i8x16.shr_u` | `0x56`| - |
106+
| `i8x16.add` | `0x57`| - |
107+
| `i8x16.add_saturate_s` | `0x58`| - |
108+
| `i8x16.add_saturate_u` | `0x59`| - |
109+
| `i8x16.sub` | `0x5a`| - |
110+
| `i8x16.sub_saturate_s` | `0x5b`| - |
111+
| `i8x16.sub_saturate_u` | `0x5c`| - |
112+
| `i8x16.mul` | `0x5d`| - |
113+
| `i16x8.neg` | `0x62`| - |
114+
| `i16x8.any_true` | `0x63`| - |
115+
| `i16x8.all_true` | `0x64`| - |
116+
| `i16x8.shl` | `0x65`| - |
117+
| `i16x8.shr_s` | `0x66`| - |
118+
| `i16x8.shr_u` | `0x67`| - |
119+
| `i16x8.add` | `0x68`| - |
120+
| `i16x8.add_saturate_s` | `0x69`| - |
121+
| `i16x8.add_saturate_u` | `0x6a`| - |
122+
| `i16x8.sub` | `0x6b`| - |
123+
| `i16x8.sub_saturate_s` | `0x6c`| - |
124+
| `i16x8.sub_saturate_u` | `0x6d`| - |
125+
| `i16x8.mul` | `0x6e`| - |
126+
| `i32x4.neg` | `0x73`| - |
127+
| `i32x4.any_true` | `0x74`| - |
128+
| `i32x4.all_true` | `0x75`| - |
129+
| `i32x4.shl` | `0x76`| - |
130+
| `i32x4.shr_s` | `0x77`| - |
131+
| `i32x4.shr_u` | `0x78`| - |
132+
| `i32x4.add` | `0x79`| - |
133+
| `i32x4.sub` | `0x7c`| - |
134+
| `i32x4.mul` | `0x7f`| - |
135+
| `i64x2.neg` | `0x84`| - |
136+
| `i64x2.any_true` | `0x85`| - |
137+
| `i64x2.all_true` | `0x86`| - |
138+
| `i64x2.shl` | `0x87`| - |
139+
| `i64x2.shr_s` | `0x88`| - |
140+
| `i64x2.shr_u` | `0x89`| - |
141+
| `i64x2.add` | `0x8a`| - |
142+
| `i64x2.sub` | `0x8d`| - |
143+
| `f32x4.abs` | `0x95`| - |
144+
| `f32x4.neg` | `0x96`| - |
145+
| `f32x4.sqrt` | `0x97`| - |
146+
| `f32x4.add` | `0x9a`| - |
147+
| `f32x4.sub` | `0x9b`| - |
148+
| `f32x4.mul` | `0x9c`| - |
149+
| `f32x4.div` | `0x9d`| - |
150+
| `f32x4.min` | `0x9e`| - |
151+
| `f32x4.max` | `0x9f`| - |
152+
| `f64x2.abs` | `0xa0`| - |
153+
| `f64x2.neg` | `0xa1`| - |
154+
| `f64x2.sqrt` | `0xa2`| - |
155+
| `f64x2.add` | `0xa5`| - |
156+
| `f64x2.sub` | `0xa6`| - |
157+
| `f64x2.mul` | `0xa7`| - |
158+
| `f64x2.div` | `0xa8`| - |
159+
| `f64x2.min` | `0xa9`| - |
160+
| `f64x2.max` | `0xaa`| - |
161+
| `i32x4.trunc_s/f32x4:sat` | `0xab`| - |
162+
| `i32x4.trunc_u/f32x4:sat` | `0xac`| - |
163+
| `i64x2.trunc_s/f64x2:sat` | `0xad`| - |
164+
| `i64x2.trunc_u/f64x2:sat` | `0xae`| - |
165+
| `f32x4.convert_s/i32x4` | `0xaf`| - |
166+
| `f32x4.convert_u/i32x4` | `0xb0`| - |
167+
| `f64x2.convert_s/i64x2` | `0xb1`| - |
168+
| `f64x2.convert_u/i64x2` | `0xb2`| - |
169+
| `v8x16.swizzle` | `0xc0`| - |
170+
| `v8x16.shuffle` | `0xc1`| s:LaneIdx32[16] |
171+
| `i8x16.load_splat` | `0xc2`| - |
172+
| `i16x8.load_splat` | `0xc3`| - |
173+
| `i32x4.load_splat` | `0xc4`| - |
174+
| `i64x2.load_splat` | `0xc5`| - |
175+
| `i8x16.narrow_i16x8_s` | `0xc6`| - |
176+
| `i8x16.narrow_i16x8_u` | `0xc7`| - |
177+
| `i16x8.narrow_i32x4_s` | `0xc8`| - |
178+
| `i16x8.narrow_i32x4_u` | `0xc9`| - |
179+
| `i16x8.widen_low_i8x16_s` | `0xca`| - |
180+
| `i16x8.widen_high_i8x16_s` | `0xcb`| - |
181+
| `i16x8.widen_low_i8x16_u` | `0xcc`| - |
182+
| `i16x8.widen_high_i8x16_u` | `0xcd`| - |
183+
| `i32x4.widen_low_i16x8_s` | `0xce`| - |
184+
| `i32x4.widen_high_i16x8_s` | `0xcf`| - |
185+
| `i32x4.widen_low_i16x8_u` | `0xd0`| - |
186+
| `i32x4.widen_high_i16x8_u` | `0xd1`| - |

0 commit comments

Comments
 (0)