|
| 1 | +# Binary encoding of SIMD |
| 2 | + |
| 3 | +This document describes the binary encoding of the SIMD value type and |
| 4 | +instructions. |
| 5 | + |
| 6 | +## SIMD value type |
| 7 | + |
| 8 | +The `v128` value type is encoded as 0x7b: |
| 9 | + |
| 10 | +``` |
| 11 | +valtype ::= ... |
| 12 | + | 0x7B => v128 |
| 13 | +``` |
| 14 | + |
| 15 | +## SIMD instruction encodings |
| 16 | + |
| 17 | +All SIMD instructions are encoded as a 0xfd prefix byte followed by a |
| 18 | +SIMD-specific opcode in LEB128 format: |
| 19 | + |
| 20 | +``` |
| 21 | +instr ::= ... |
| 22 | + | 0xFB simdop:varuint32 ... |
| 23 | +``` |
| 24 | + |
| 25 | +Some SIMD instructions have additional immediate operands following `simdop`. |
| 26 | +The `v8x16.shuffle` instruction has 16 bytes after `simdop`. |
| 27 | + |
| 28 | +| Instruction | `simdop` | Immediate operands | |
| 29 | +| --------------------------|---------:|--------------------| |
| 30 | +| `v128.const` | 0 | - | |
| 31 | +| `v128.load` | 1 | m:memarg | |
| 32 | +| `v128.store` | 2 | m:memarg | |
| 33 | +| `i8x16.splat` | 3 | - | |
| 34 | +| `i16x8.splat` | 4 | - | |
| 35 | +| `i32x4.splat` | 5 | - | |
| 36 | +| `i64x2.splat` | 6 | - | |
| 37 | +| `f32x4.splat` | 7 | - | |
| 38 | +| `f64x2.splat` | 8 | - | |
| 39 | +| `i8x16.extract_lane_s` | 9 | i:LaneIdx16 | |
| 40 | +| `i8x16.extract_lane_u` | 10 | i:LaneIdx16 | |
| 41 | +| `i16x8.extract_lane_s` | 11 | i:LaneIdx8 | |
| 42 | +| `i16x8.extract_lane_u` | 12 | i:LaneIdx8 | |
| 43 | +| `i32x4.extract_lane` | 13 | i:LaneIdx4 | |
| 44 | +| `i64x2.extract_lane` | 14 | i:LaneIdx2 | |
| 45 | +| `f32x4.extract_lane` | 15 | i:LaneIdx4 | |
| 46 | +| `f64x2.extract_lane` | 16 | i:LaneIdx2 | |
| 47 | +| `i8x16.replace_lane` | 17 | i:LaneIdx16 | |
| 48 | +| `i16x8.replace_lane` | 18 | i:LaneIdx8 | |
| 49 | +| `i32x4.replace_lane` | 19 | i:LaneIdx4 | |
| 50 | +| `i64x2.replace_lane` | 20 | i:LaneIdx2 | |
| 51 | +| `f32x4.replace_lane` | 21 | i:LaneIdx4 | |
| 52 | +| `f64x2.replace_lane` | 22 | i:LaneIdx2 | |
| 53 | +| `v8x16.shuffle` | 23 | s:LaneIdx32[16] | |
| 54 | +| `i8x16.add` | 24 | - | |
| 55 | +| `i16x8.add` | 25 | - | |
| 56 | +| `i32x4.add` | 26 | - | |
| 57 | +| `i64x2.add` | 27 | - | |
| 58 | +| `i8x16.sub` | 28 | - | |
| 59 | +| `i16x8.sub` | 29 | - | |
| 60 | +| `i32x4.sub` | 30 | - | |
| 61 | +| `i64x2.sub` | 31 | - | |
| 62 | +| `i8x16.mul` | 32 | - | |
| 63 | +| `i16x8.mul` | 33 | - | |
| 64 | +| `i32x4.mul` | 34 | - | |
| 65 | +| `i8x16.neg` | 35 | - | |
| 66 | +| `i16x8.neg` | 36 | - | |
| 67 | +| `i32x4.neg` | 37 | - | |
| 68 | +| `i64x2.neg` | 38 | - | |
| 69 | +| `i8x16.add_saturate_s` | 39 | - | |
| 70 | +| `i8x16.add_saturate_u` | 40 | - | |
| 71 | +| `i16x8.add_saturate_s` | 41 | - | |
| 72 | +| `i16x8.add_saturate_u` | 42 | - | |
| 73 | +| `i8x16.sub_saturate_s` | 43 | - | |
| 74 | +| `i8x16.sub_saturate_u` | 44 | - | |
| 75 | +| `i16x8.sub_saturate_s` | 45 | - | |
| 76 | +| `i16x8.sub_saturate_u` | 46 | - | |
| 77 | +| `i8x16.shl` | 47 | - | |
| 78 | +| `i16x8.shl` | 48 | - | |
| 79 | +| `i32x4.shl` | 49 | - | |
| 80 | +| `i64x2.shl` | 50 | - | |
| 81 | +| `i8x16.shr_s` | 51 | - | |
| 82 | +| `i8x16.shr_u` | 52 | - | |
| 83 | +| `i16x8.shr_s` | 53 | - | |
| 84 | +| `i16x8.shr_u` | 54 | - | |
| 85 | +| `i32x4.shr_s` | 55 | - | |
| 86 | +| `i32x4.shr_u` | 56 | - | |
| 87 | +| `i64x2.shr_s` | 57 | - | |
| 88 | +| `i64x2.shr_u` | 58 | - | |
| 89 | +| `v128.and` | 59 | - | |
| 90 | +| `v128.or` | 60 | - | |
| 91 | +| `v128.xor` | 61 | - | |
| 92 | +| `v128.not` | 62 | - | |
| 93 | +| `v128.bitselect` | 63 | - | |
| 94 | +| `i8x16.any_true` | 64 | - | |
| 95 | +| `i16x8.any_true` | 65 | - | |
| 96 | +| `i32x4.any_true` | 66 | - | |
| 97 | +| `i64x2.any_true` | 67 | - | |
| 98 | +| `i8x16.all_true` | 68 | - | |
| 99 | +| `i16x8.all_true` | 69 | - | |
| 100 | +| `i32x4.all_true` | 70 | - | |
| 101 | +| `i64x2.all_true` | 71 | - | |
| 102 | +| `i8x16.eq` | 72 | - | |
| 103 | +| `i16x8.eq` | 73 | - | |
| 104 | +| `i32x4.eq` | 74 | - | |
| 105 | +| `f32x4.eq` | 75 | - | |
| 106 | +| `f64x2.eq` | 76 | - | |
| 107 | +| `i8x16.ne` | 77 | - | |
| 108 | +| `i16x8.ne` | 78 | - | |
| 109 | +| `i32x4.ne` | 79 | - | |
| 110 | +| `f32x4.ne` | 80 | - | |
| 111 | +| `f64x2.ne` | 81 | - | |
| 112 | +| `i8x16.lt_s` | 82 | - | |
| 113 | +| `i8x16.lt_u` | 83 | - | |
| 114 | +| `i16x8.lt_s` | 84 | - | |
| 115 | +| `i16x8.lt_u` | 85 | - | |
| 116 | +| `i32x4.lt_s` | 86 | - | |
| 117 | +| `i32x4.lt_u` | 87 | - | |
| 118 | +| `f32x4.lt` | 88 | - | |
| 119 | +| `f64x2.lt` | 89 | - | |
| 120 | +| `i8x16.le_s` | 90 | - | |
| 121 | +| `i8x16.le_u` | 91 | - | |
| 122 | +| `i16x8.le_s` | 92 | - | |
| 123 | +| `i16x8.le_u` | 93 | - | |
| 124 | +| `i32x4.le_s` | 94 | - | |
| 125 | +| `i32x4.le_u` | 95 | - | |
| 126 | +| `f32x4.le` | 96 | - | |
| 127 | +| `f64x2.le` | 97 | - | |
| 128 | +| `i8x16.gt_s` | 98 | - | |
| 129 | +| `i8x16.gt_u` | 99 | - | |
| 130 | +| `i16x8.gt_s` | 100 | - | |
| 131 | +| `i16x8.gt_u` | 101 | - | |
| 132 | +| `i32x4.gt_s` | 102 | - | |
| 133 | +| `i32x4.gt_u` | 103 | - | |
| 134 | +| `f32x4.gt` | 104 | - | |
| 135 | +| `f64x2.gt` | 105 | - | |
| 136 | +| `i8x16.ge_s` | 106 | - | |
| 137 | +| `i8x16.ge_u` | 107 | - | |
| 138 | +| `i16x8.ge_s` | 108 | - | |
| 139 | +| `i16x8.ge_u` | 109 | - | |
| 140 | +| `i32x4.ge_s` | 110 | - | |
| 141 | +| `i32x4.ge_u` | 111 | - | |
| 142 | +| `f32x4.ge` | 112 | - | |
| 143 | +| `f64x2.ge` | 113 | - | |
| 144 | +| `f32x4.neg` | 114 | - | |
| 145 | +| `f64x2.neg` | 115 | - | |
| 146 | +| `f32x4.abs` | 116 | - | |
| 147 | +| `f64x2.abs` | 117 | - | |
| 148 | +| `f32x4.min` | 118 | - | |
| 149 | +| `f64x2.min` | 119 | - | |
| 150 | +| `f32x4.max` | 120 | - | |
| 151 | +| `f64x2.max` | 121 | - | |
| 152 | +| `f32x4.add` | 122 | - | |
| 153 | +| `f64x2.add` | 123 | - | |
| 154 | +| `f32x4.sub` | 124 | - | |
| 155 | +| `f64x2.sub` | 125 | - | |
| 156 | +| `f32x4.div` | 126 | - | |
| 157 | +| `f64x2.div` | 127 | - | |
| 158 | +| `f32x4.mul` | 128 | - | |
| 159 | +| `f64x2.mul` | 129 | - | |
| 160 | +| `f32x4.sqrt` | 130 | - | |
| 161 | +| `f64x2.sqrt` | 131 | - | |
| 162 | +| `f32x4.convert_s/i32x4` | 132 | - | |
| 163 | +| `f32x4.convert_u/i32x4` | 133 | - | |
| 164 | +| `f64x2.convert_s/i64x2` | 134 | - | |
| 165 | +| `f64x2.convert_u/i64x2` | 135 | - | |
| 166 | +| `i32x4.trunc_s/f32x4:sat` | 136 | - | |
| 167 | +| `i32x4.trunc_u/f32x4:sat` | 137 | - | |
| 168 | +| `i64x2.trunc_s/f64x2:sat` | 138 | - | |
| 169 | +| `i64x2.trunc_u/f64x2:sat` | 139 | - | |
0 commit comments