|
| 1 | +;;; --enable-wide-arithmetic |
1 | 2 | (module |
2 | 3 | (func (export "i64.add128") (param i64 i64 i64 i64) (result i64 i64) |
3 | 4 | local.get 0 |
|
113 | 114 | (i64.const 1) (i64.const 0)) |
114 | 115 | (i64.const 414720966820876429) (i64.const -1)) |
115 | 116 |
|
| 117 | +;; simple subtraction |
| 118 | +(assert_return (invoke "i64.sub128" |
| 119 | + (i64.const 0) (i64.const 0) |
| 120 | + (i64.const 0) (i64.const 0)) |
| 121 | + (i64.const 0) (i64.const 0)) |
| 122 | +(assert_return (invoke "i64.sub128" |
| 123 | + (i64.const 1) (i64.const 0) |
| 124 | + (i64.const 1) (i64.const 0)) |
| 125 | + (i64.const 0) (i64.const 0)) |
| 126 | +(assert_return (invoke "i64.sub128" |
| 127 | + (i64.const 0) (i64.const 0) |
| 128 | + (i64.const 1) (i64.const 0)) |
| 129 | + (i64.const 0xffffffffffffffff) (i64.const 0xffffffffffffffff)) |
| 130 | +(assert_return (invoke "i64.sub128" |
| 131 | + (i64.const 0) (i64.const 1) |
| 132 | + (i64.const 1) (i64.const 0)) |
| 133 | + (i64.const 0xffffffffffffffff) (i64.const 0)) |
| 134 | +(assert_return (invoke "i64.sub128" |
| 135 | + (i64.const 1) (i64.const 2) |
| 136 | + (i64.const 3) (i64.const 4)) |
| 137 | + (i64.const 0xfffffffffffffffe) (i64.const 0xfffffffffffffffd)) |
| 138 | + |
116 | 139 | ;; assert overlong encodings for each instruction's binary encoding are accepted |
117 | 140 | (module binary |
118 | 141 | "\00asm" "\01\00\00\00" |
|
171 | 194 | ) |
172 | 195 | "type mismatch") |
173 | 196 |
|
174 | | -;; simple subtraction |
175 | | -(assert_return (invoke "i64.sub128" |
176 | | - (i64.const 0) (i64.const 0) |
177 | | - (i64.const 0) (i64.const 0)) |
178 | | - (i64.const 0) (i64.const 0)) |
179 | | -(assert_return (invoke "i64.sub128" |
180 | | - (i64.const 1) (i64.const 0) |
181 | | - (i64.const 1) (i64.const 0)) |
182 | | - (i64.const 0) (i64.const 0)) |
183 | | -(assert_return (invoke "i64.sub128" |
184 | | - (i64.const 0) (i64.const 0) |
185 | | - (i64.const 1) (i64.const 0)) |
186 | | - (i64.const 0xffffffffffffffff) (i64.const 0xffffffffffffffff)) |
187 | | -(assert_return (invoke "i64.sub128" |
188 | | - (i64.const 0) (i64.const 1) |
189 | | - (i64.const 1) (i64.const 0)) |
190 | | - (i64.const 0xffffffffffffffff) (i64.const 0)) |
191 | | -(assert_return (invoke "i64.sub128" |
| 197 | +(assert_invalid |
| 198 | + (module |
| 199 | + (func (param i64 i64 i64 i64) (result i64) |
| 200 | + local.get 0 |
| 201 | + local.get 1 |
| 202 | + local.get 2 |
| 203 | + local.get 3 |
| 204 | + i64.sub128) |
| 205 | + ) |
| 206 | + "type mismatch") |
| 207 | +(assert_invalid |
| 208 | + (module |
| 209 | + (func (param i64 i64 i64) (result i64 i64) |
| 210 | + local.get 0 |
| 211 | + local.get 1 |
| 212 | + local.get 2 |
| 213 | + i64.sub128) |
| 214 | + ) |
| 215 | + "type mismatch") |
| 216 | + |
| 217 | +(module binary |
| 218 | + "\00asm" "\01\00\00\00" |
| 219 | + |
| 220 | + "\01\0a" ;; type section, 10 bytes |
| 221 | + "\01" ;; 1 count |
| 222 | + "\60" ;; type0 = function |
| 223 | + "\04\7e\7e\7e\7e" ;; 4 params - all i64 |
| 224 | + "\02\7e\7e" ;; 2 results - both i64 |
| 225 | + |
| 226 | + "\03\03" ;; function section, 3 byte |
| 227 | + "\02" ;; 2 count |
| 228 | + "\00\00" ;; types of each function (0, 0) |
| 229 | + |
| 230 | + "\07\1b" ;; export section 0x1b bytes |
| 231 | + "\02" ;; 2 count |
| 232 | + "\0ai64.add128\00\00" ;; "i64.add128" which is function 0 |
| 233 | + "\0ai64.sub128\00\01" ;; "i64.sub128" which is function 1 |
| 234 | + |
| 235 | + "\0a\1e" ;; code section + byte length |
| 236 | + "\02" ;; 2 count |
| 237 | + |
| 238 | + "\0e" ;; byte length |
| 239 | + "\00" ;; no locals |
| 240 | + "\20\00" ;; local.get 0 |
| 241 | + "\20\01" ;; local.get 1 |
| 242 | + "\20\02" ;; local.get 2 |
| 243 | + "\20\03" ;; local.get 3 |
| 244 | + "\fc\93\80\00" ;; i64.add128 (overlong) |
| 245 | + "\0b" ;; end |
| 246 | + |
| 247 | + "\0d" ;; byte length |
| 248 | + "\00" ;; no locals |
| 249 | + "\20\00" ;; local.get 0 |
| 250 | + "\20\01" ;; local.get 1 |
| 251 | + "\20\02" ;; local.get 2 |
| 252 | + "\20\03" ;; local.get 3 |
| 253 | + "\fc\94\00" ;; i64.sub128 (overlong) |
| 254 | + "\0b" ;; end |
| 255 | +) |
| 256 | + |
| 257 | +(assert_return (invoke "i64.add128" |
192 | 258 | (i64.const 1) (i64.const 2) |
193 | 259 | (i64.const 3) (i64.const 4)) |
194 | | - (i64.const 0xfffffffffffffffe) (i64.const 0xfffffffffffffffd)) |
| 260 | + (i64.const 4) (i64.const 6)) |
| 261 | +(assert_return (invoke "i64.sub128" |
| 262 | + (i64.const 2) (i64.const 5) |
| 263 | + (i64.const 1) (i64.const 2)) |
| 264 | + (i64.const 1) (i64.const 3)) |
0 commit comments