1 | /* |
2 | * Copyright (C) 2016-2017 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * |
8 | * 1. Redistributions of source code must retain the above copyright |
9 | * notice, this list of conditions and the following disclaimer. |
10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. |
13 | * |
14 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
17 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | // DO NO EDIT! - This file was generated by /opt/wk/webkit_cover/Source/JavaScriptCore/wasm/generateWasmValidateInlinesHeader.py |
27 | // This file is intended to be inlined by WasmValidate.cpp only! It should not be included elsewhere. |
28 | |
29 | #pragma once |
30 | |
31 | #if ENABLE(WEBASSEMBLY) |
32 | |
33 | #include <wtf/StdLibExtras.h> |
34 | |
35 | #if ASSERT_DISABLED |
36 | IGNORE_RETURN_TYPE_WARNINGS_BEGIN |
37 | #endif |
38 | |
39 | namespace JSC { namespace Wasm { |
40 | |
41 | |
42 | template<> auto Validate::addOp<OpType::F32Ceil>(ExpressionType value, ExpressionType& result) -> Result |
43 | { |
44 | if (UNLIKELY(value != F32)) |
45 | return Unexpected<Result::error_type>("validation failed: f32.ceil value type mismatch" ); |
46 | |
47 | result = F32; |
48 | return { }; |
49 | } |
50 | |
51 | template<> auto Validate::addOp<OpType::F32DemoteF64>(ExpressionType value, ExpressionType& result) -> Result |
52 | { |
53 | if (UNLIKELY(value != F64)) |
54 | return Unexpected<Result::error_type>("validation failed: f32.demote/f64 value type mismatch" ); |
55 | |
56 | result = F32; |
57 | return { }; |
58 | } |
59 | |
60 | template<> auto Validate::addOp<OpType::I64TruncSF32>(ExpressionType value, ExpressionType& result) -> Result |
61 | { |
62 | if (UNLIKELY(value != F32)) |
63 | return Unexpected<Result::error_type>("validation failed: i64.trunc_s/f32 value type mismatch" ); |
64 | |
65 | result = I64; |
66 | return { }; |
67 | } |
68 | |
69 | template<> auto Validate::addOp<OpType::F32ConvertUI64>(ExpressionType value, ExpressionType& result) -> Result |
70 | { |
71 | if (UNLIKELY(value != I64)) |
72 | return Unexpected<Result::error_type>("validation failed: f32.convert_u/i64 value type mismatch" ); |
73 | |
74 | result = F32; |
75 | return { }; |
76 | } |
77 | |
78 | template<> auto Validate::addOp<OpType::I32Clz>(ExpressionType value, ExpressionType& result) -> Result |
79 | { |
80 | if (UNLIKELY(value != I32)) |
81 | return Unexpected<Result::error_type>("validation failed: i32.clz value type mismatch" ); |
82 | |
83 | result = I32; |
84 | return { }; |
85 | } |
86 | |
87 | template<> auto Validate::addOp<OpType::F64ConvertUI32>(ExpressionType value, ExpressionType& result) -> Result |
88 | { |
89 | if (UNLIKELY(value != I32)) |
90 | return Unexpected<Result::error_type>("validation failed: f64.convert_u/i32 value type mismatch" ); |
91 | |
92 | result = F64; |
93 | return { }; |
94 | } |
95 | |
96 | template<> auto Validate::addOp<OpType::I32Ctz>(ExpressionType value, ExpressionType& result) -> Result |
97 | { |
98 | if (UNLIKELY(value != I32)) |
99 | return Unexpected<Result::error_type>("validation failed: i32.ctz value type mismatch" ); |
100 | |
101 | result = I32; |
102 | return { }; |
103 | } |
104 | |
105 | template<> auto Validate::addOp<OpType::F32ReinterpretI32>(ExpressionType value, ExpressionType& result) -> Result |
106 | { |
107 | if (UNLIKELY(value != I32)) |
108 | return Unexpected<Result::error_type>("validation failed: f32.reinterpret/i32 value type mismatch" ); |
109 | |
110 | result = F32; |
111 | return { }; |
112 | } |
113 | |
114 | template<> auto Validate::addOp<OpType::I32TruncSF64>(ExpressionType value, ExpressionType& result) -> Result |
115 | { |
116 | if (UNLIKELY(value != F64)) |
117 | return Unexpected<Result::error_type>("validation failed: i32.trunc_s/f64 value type mismatch" ); |
118 | |
119 | result = I32; |
120 | return { }; |
121 | } |
122 | |
123 | template<> auto Validate::addOp<OpType::F32Sqrt>(ExpressionType value, ExpressionType& result) -> Result |
124 | { |
125 | if (UNLIKELY(value != F32)) |
126 | return Unexpected<Result::error_type>("validation failed: f32.sqrt value type mismatch" ); |
127 | |
128 | result = F32; |
129 | return { }; |
130 | } |
131 | |
132 | template<> auto Validate::addOp<OpType::I32TruncUF64>(ExpressionType value, ExpressionType& result) -> Result |
133 | { |
134 | if (UNLIKELY(value != F64)) |
135 | return Unexpected<Result::error_type>("validation failed: i32.trunc_u/f64 value type mismatch" ); |
136 | |
137 | result = I32; |
138 | return { }; |
139 | } |
140 | |
141 | template<> auto Validate::addOp<OpType::I32Popcnt>(ExpressionType value, ExpressionType& result) -> Result |
142 | { |
143 | if (UNLIKELY(value != I32)) |
144 | return Unexpected<Result::error_type>("validation failed: i32.popcnt value type mismatch" ); |
145 | |
146 | result = I32; |
147 | return { }; |
148 | } |
149 | |
150 | template<> auto Validate::addOp<OpType::I64Popcnt>(ExpressionType value, ExpressionType& result) -> Result |
151 | { |
152 | if (UNLIKELY(value != I64)) |
153 | return Unexpected<Result::error_type>("validation failed: i64.popcnt value type mismatch" ); |
154 | |
155 | result = I64; |
156 | return { }; |
157 | } |
158 | |
159 | template<> auto Validate::addOp<OpType::I64Eqz>(ExpressionType value, ExpressionType& result) -> Result |
160 | { |
161 | if (UNLIKELY(value != I64)) |
162 | return Unexpected<Result::error_type>("validation failed: i64.eqz value type mismatch" ); |
163 | |
164 | result = I32; |
165 | return { }; |
166 | } |
167 | |
168 | template<> auto Validate::addOp<OpType::I64Clz>(ExpressionType value, ExpressionType& result) -> Result |
169 | { |
170 | if (UNLIKELY(value != I64)) |
171 | return Unexpected<Result::error_type>("validation failed: i64.clz value type mismatch" ); |
172 | |
173 | result = I64; |
174 | return { }; |
175 | } |
176 | |
177 | template<> auto Validate::addOp<OpType::F32Neg>(ExpressionType value, ExpressionType& result) -> Result |
178 | { |
179 | if (UNLIKELY(value != F32)) |
180 | return Unexpected<Result::error_type>("validation failed: f32.neg value type mismatch" ); |
181 | |
182 | result = F32; |
183 | return { }; |
184 | } |
185 | |
186 | template<> auto Validate::addOp<OpType::F64Abs>(ExpressionType value, ExpressionType& result) -> Result |
187 | { |
188 | if (UNLIKELY(value != F64)) |
189 | return Unexpected<Result::error_type>("validation failed: f64.abs value type mismatch" ); |
190 | |
191 | result = F64; |
192 | return { }; |
193 | } |
194 | |
195 | template<> auto Validate::addOp<OpType::F32ConvertSI64>(ExpressionType value, ExpressionType& result) -> Result |
196 | { |
197 | if (UNLIKELY(value != I64)) |
198 | return Unexpected<Result::error_type>("validation failed: f32.convert_s/i64 value type mismatch" ); |
199 | |
200 | result = F32; |
201 | return { }; |
202 | } |
203 | |
204 | template<> auto Validate::addOp<OpType::F64ConvertSI32>(ExpressionType value, ExpressionType& result) -> Result |
205 | { |
206 | if (UNLIKELY(value != I32)) |
207 | return Unexpected<Result::error_type>("validation failed: f64.convert_s/i32 value type mismatch" ); |
208 | |
209 | result = F64; |
210 | return { }; |
211 | } |
212 | |
213 | template<> auto Validate::addOp<OpType::I64Ctz>(ExpressionType value, ExpressionType& result) -> Result |
214 | { |
215 | if (UNLIKELY(value != I64)) |
216 | return Unexpected<Result::error_type>("validation failed: i64.ctz value type mismatch" ); |
217 | |
218 | result = I64; |
219 | return { }; |
220 | } |
221 | |
222 | template<> auto Validate::addOp<OpType::F32ConvertUI32>(ExpressionType value, ExpressionType& result) -> Result |
223 | { |
224 | if (UNLIKELY(value != I32)) |
225 | return Unexpected<Result::error_type>("validation failed: f32.convert_u/i32 value type mismatch" ); |
226 | |
227 | result = F32; |
228 | return { }; |
229 | } |
230 | |
231 | template<> auto Validate::addOp<OpType::F64Ceil>(ExpressionType value, ExpressionType& result) -> Result |
232 | { |
233 | if (UNLIKELY(value != F64)) |
234 | return Unexpected<Result::error_type>("validation failed: f64.ceil value type mismatch" ); |
235 | |
236 | result = F64; |
237 | return { }; |
238 | } |
239 | |
240 | template<> auto Validate::addOp<OpType::F64Floor>(ExpressionType value, ExpressionType& result) -> Result |
241 | { |
242 | if (UNLIKELY(value != F64)) |
243 | return Unexpected<Result::error_type>("validation failed: f64.floor value type mismatch" ); |
244 | |
245 | result = F64; |
246 | return { }; |
247 | } |
248 | |
249 | template<> auto Validate::addOp<OpType::F32Abs>(ExpressionType value, ExpressionType& result) -> Result |
250 | { |
251 | if (UNLIKELY(value != F32)) |
252 | return Unexpected<Result::error_type>("validation failed: f32.abs value type mismatch" ); |
253 | |
254 | result = F32; |
255 | return { }; |
256 | } |
257 | |
258 | template<> auto Validate::addOp<OpType::I32ReinterpretF32>(ExpressionType value, ExpressionType& result) -> Result |
259 | { |
260 | if (UNLIKELY(value != F32)) |
261 | return Unexpected<Result::error_type>("validation failed: i32.reinterpret/f32 value type mismatch" ); |
262 | |
263 | result = I32; |
264 | return { }; |
265 | } |
266 | |
267 | template<> auto Validate::addOp<OpType::F64ConvertSI64>(ExpressionType value, ExpressionType& result) -> Result |
268 | { |
269 | if (UNLIKELY(value != I64)) |
270 | return Unexpected<Result::error_type>("validation failed: f64.convert_s/i64 value type mismatch" ); |
271 | |
272 | result = F64; |
273 | return { }; |
274 | } |
275 | |
276 | template<> auto Validate::addOp<OpType::I32TruncSF32>(ExpressionType value, ExpressionType& result) -> Result |
277 | { |
278 | if (UNLIKELY(value != F32)) |
279 | return Unexpected<Result::error_type>("validation failed: i32.trunc_s/f32 value type mismatch" ); |
280 | |
281 | result = I32; |
282 | return { }; |
283 | } |
284 | |
285 | template<> auto Validate::addOp<OpType::I64TruncUF64>(ExpressionType value, ExpressionType& result) -> Result |
286 | { |
287 | if (UNLIKELY(value != F64)) |
288 | return Unexpected<Result::error_type>("validation failed: i64.trunc_u/f64 value type mismatch" ); |
289 | |
290 | result = I64; |
291 | return { }; |
292 | } |
293 | |
294 | template<> auto Validate::addOp<OpType::F64PromoteF32>(ExpressionType value, ExpressionType& result) -> Result |
295 | { |
296 | if (UNLIKELY(value != F32)) |
297 | return Unexpected<Result::error_type>("validation failed: f64.promote/f32 value type mismatch" ); |
298 | |
299 | result = F64; |
300 | return { }; |
301 | } |
302 | |
303 | template<> auto Validate::addOp<OpType::I64ExtendUI32>(ExpressionType value, ExpressionType& result) -> Result |
304 | { |
305 | if (UNLIKELY(value != I32)) |
306 | return Unexpected<Result::error_type>("validation failed: i64.extend_u/i32 value type mismatch" ); |
307 | |
308 | result = I64; |
309 | return { }; |
310 | } |
311 | |
312 | template<> auto Validate::addOp<OpType::F64ReinterpretI64>(ExpressionType value, ExpressionType& result) -> Result |
313 | { |
314 | if (UNLIKELY(value != I64)) |
315 | return Unexpected<Result::error_type>("validation failed: f64.reinterpret/i64 value type mismatch" ); |
316 | |
317 | result = F64; |
318 | return { }; |
319 | } |
320 | |
321 | template<> auto Validate::addOp<OpType::I64TruncSF64>(ExpressionType value, ExpressionType& result) -> Result |
322 | { |
323 | if (UNLIKELY(value != F64)) |
324 | return Unexpected<Result::error_type>("validation failed: i64.trunc_s/f64 value type mismatch" ); |
325 | |
326 | result = I64; |
327 | return { }; |
328 | } |
329 | |
330 | template<> auto Validate::addOp<OpType::F32Floor>(ExpressionType value, ExpressionType& result) -> Result |
331 | { |
332 | if (UNLIKELY(value != F32)) |
333 | return Unexpected<Result::error_type>("validation failed: f32.floor value type mismatch" ); |
334 | |
335 | result = F32; |
336 | return { }; |
337 | } |
338 | |
339 | template<> auto Validate::addOp<OpType::F32ConvertSI32>(ExpressionType value, ExpressionType& result) -> Result |
340 | { |
341 | if (UNLIKELY(value != I32)) |
342 | return Unexpected<Result::error_type>("validation failed: f32.convert_s/i32 value type mismatch" ); |
343 | |
344 | result = F32; |
345 | return { }; |
346 | } |
347 | |
348 | template<> auto Validate::addOp<OpType::F64ConvertUI64>(ExpressionType value, ExpressionType& result) -> Result |
349 | { |
350 | if (UNLIKELY(value != I64)) |
351 | return Unexpected<Result::error_type>("validation failed: f64.convert_u/i64 value type mismatch" ); |
352 | |
353 | result = F64; |
354 | return { }; |
355 | } |
356 | |
357 | template<> auto Validate::addOp<OpType::I32Eqz>(ExpressionType value, ExpressionType& result) -> Result |
358 | { |
359 | if (UNLIKELY(value != I32)) |
360 | return Unexpected<Result::error_type>("validation failed: i32.eqz value type mismatch" ); |
361 | |
362 | result = I32; |
363 | return { }; |
364 | } |
365 | |
366 | template<> auto Validate::addOp<OpType::I64ReinterpretF64>(ExpressionType value, ExpressionType& result) -> Result |
367 | { |
368 | if (UNLIKELY(value != F64)) |
369 | return Unexpected<Result::error_type>("validation failed: i64.reinterpret/f64 value type mismatch" ); |
370 | |
371 | result = I64; |
372 | return { }; |
373 | } |
374 | |
375 | template<> auto Validate::addOp<OpType::F64Nearest>(ExpressionType value, ExpressionType& result) -> Result |
376 | { |
377 | if (UNLIKELY(value != F64)) |
378 | return Unexpected<Result::error_type>("validation failed: f64.nearest value type mismatch" ); |
379 | |
380 | result = F64; |
381 | return { }; |
382 | } |
383 | |
384 | template<> auto Validate::addOp<OpType::F64Sqrt>(ExpressionType value, ExpressionType& result) -> Result |
385 | { |
386 | if (UNLIKELY(value != F64)) |
387 | return Unexpected<Result::error_type>("validation failed: f64.sqrt value type mismatch" ); |
388 | |
389 | result = F64; |
390 | return { }; |
391 | } |
392 | |
393 | template<> auto Validate::addOp<OpType::F64Trunc>(ExpressionType value, ExpressionType& result) -> Result |
394 | { |
395 | if (UNLIKELY(value != F64)) |
396 | return Unexpected<Result::error_type>("validation failed: f64.trunc value type mismatch" ); |
397 | |
398 | result = F64; |
399 | return { }; |
400 | } |
401 | |
402 | template<> auto Validate::addOp<OpType::I32WrapI64>(ExpressionType value, ExpressionType& result) -> Result |
403 | { |
404 | if (UNLIKELY(value != I64)) |
405 | return Unexpected<Result::error_type>("validation failed: i32.wrap/i64 value type mismatch" ); |
406 | |
407 | result = I32; |
408 | return { }; |
409 | } |
410 | |
411 | template<> auto Validate::addOp<OpType::F32Trunc>(ExpressionType value, ExpressionType& result) -> Result |
412 | { |
413 | if (UNLIKELY(value != F32)) |
414 | return Unexpected<Result::error_type>("validation failed: f32.trunc value type mismatch" ); |
415 | |
416 | result = F32; |
417 | return { }; |
418 | } |
419 | |
420 | template<> auto Validate::addOp<OpType::I32TruncUF32>(ExpressionType value, ExpressionType& result) -> Result |
421 | { |
422 | if (UNLIKELY(value != F32)) |
423 | return Unexpected<Result::error_type>("validation failed: i32.trunc_u/f32 value type mismatch" ); |
424 | |
425 | result = I32; |
426 | return { }; |
427 | } |
428 | |
429 | template<> auto Validate::addOp<OpType::I64TruncUF32>(ExpressionType value, ExpressionType& result) -> Result |
430 | { |
431 | if (UNLIKELY(value != F32)) |
432 | return Unexpected<Result::error_type>("validation failed: i64.trunc_u/f32 value type mismatch" ); |
433 | |
434 | result = I64; |
435 | return { }; |
436 | } |
437 | |
438 | template<> auto Validate::addOp<OpType::I64ExtendSI32>(ExpressionType value, ExpressionType& result) -> Result |
439 | { |
440 | if (UNLIKELY(value != I32)) |
441 | return Unexpected<Result::error_type>("validation failed: i64.extend_s/i32 value type mismatch" ); |
442 | |
443 | result = I64; |
444 | return { }; |
445 | } |
446 | |
447 | template<> auto Validate::addOp<OpType::F64Neg>(ExpressionType value, ExpressionType& result) -> Result |
448 | { |
449 | if (UNLIKELY(value != F64)) |
450 | return Unexpected<Result::error_type>("validation failed: f64.neg value type mismatch" ); |
451 | |
452 | result = F64; |
453 | return { }; |
454 | } |
455 | |
456 | template<> auto Validate::addOp<OpType::F32Nearest>(ExpressionType value, ExpressionType& result) -> Result |
457 | { |
458 | if (UNLIKELY(value != F32)) |
459 | return Unexpected<Result::error_type>("validation failed: f32.nearest value type mismatch" ); |
460 | |
461 | result = F32; |
462 | return { }; |
463 | } |
464 | |
465 | template<> auto Validate::addOp<OpType::I64ShrS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
466 | { |
467 | if (UNLIKELY(left != I64)) |
468 | return Unexpected<Result::error_type>("validation failed: i64.shr_s left value type mismatch" ); |
469 | |
470 | if (UNLIKELY(right != I64)) |
471 | return Unexpected<Result::error_type>("validation failed: i64.shr_s right value type mismatch" ); |
472 | |
473 | result = I64; |
474 | return { }; |
475 | } |
476 | |
477 | template<> auto Validate::addOp<OpType::I32Mul>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
478 | { |
479 | if (UNLIKELY(left != I32)) |
480 | return Unexpected<Result::error_type>("validation failed: i32.mul left value type mismatch" ); |
481 | |
482 | if (UNLIKELY(right != I32)) |
483 | return Unexpected<Result::error_type>("validation failed: i32.mul right value type mismatch" ); |
484 | |
485 | result = I32; |
486 | return { }; |
487 | } |
488 | |
489 | template<> auto Validate::addOp<OpType::I32Sub>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
490 | { |
491 | if (UNLIKELY(left != I32)) |
492 | return Unexpected<Result::error_type>("validation failed: i32.sub left value type mismatch" ); |
493 | |
494 | if (UNLIKELY(right != I32)) |
495 | return Unexpected<Result::error_type>("validation failed: i32.sub right value type mismatch" ); |
496 | |
497 | result = I32; |
498 | return { }; |
499 | } |
500 | |
501 | template<> auto Validate::addOp<OpType::F64Le>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
502 | { |
503 | if (UNLIKELY(left != F64)) |
504 | return Unexpected<Result::error_type>("validation failed: f64.le left value type mismatch" ); |
505 | |
506 | if (UNLIKELY(right != F64)) |
507 | return Unexpected<Result::error_type>("validation failed: f64.le right value type mismatch" ); |
508 | |
509 | result = I32; |
510 | return { }; |
511 | } |
512 | |
513 | template<> auto Validate::addOp<OpType::F64Ne>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
514 | { |
515 | if (UNLIKELY(left != F64)) |
516 | return Unexpected<Result::error_type>("validation failed: f64.ne left value type mismatch" ); |
517 | |
518 | if (UNLIKELY(right != F64)) |
519 | return Unexpected<Result::error_type>("validation failed: f64.ne right value type mismatch" ); |
520 | |
521 | result = I32; |
522 | return { }; |
523 | } |
524 | |
525 | template<> auto Validate::addOp<OpType::F64Lt>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
526 | { |
527 | if (UNLIKELY(left != F64)) |
528 | return Unexpected<Result::error_type>("validation failed: f64.lt left value type mismatch" ); |
529 | |
530 | if (UNLIKELY(right != F64)) |
531 | return Unexpected<Result::error_type>("validation failed: f64.lt right value type mismatch" ); |
532 | |
533 | result = I32; |
534 | return { }; |
535 | } |
536 | |
537 | template<> auto Validate::addOp<OpType::F32Max>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
538 | { |
539 | if (UNLIKELY(left != F32)) |
540 | return Unexpected<Result::error_type>("validation failed: f32.max left value type mismatch" ); |
541 | |
542 | if (UNLIKELY(right != F32)) |
543 | return Unexpected<Result::error_type>("validation failed: f32.max right value type mismatch" ); |
544 | |
545 | result = F32; |
546 | return { }; |
547 | } |
548 | |
549 | template<> auto Validate::addOp<OpType::F64Mul>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
550 | { |
551 | if (UNLIKELY(left != F64)) |
552 | return Unexpected<Result::error_type>("validation failed: f64.mul left value type mismatch" ); |
553 | |
554 | if (UNLIKELY(right != F64)) |
555 | return Unexpected<Result::error_type>("validation failed: f64.mul right value type mismatch" ); |
556 | |
557 | result = F64; |
558 | return { }; |
559 | } |
560 | |
561 | template<> auto Validate::addOp<OpType::F32Div>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
562 | { |
563 | if (UNLIKELY(left != F32)) |
564 | return Unexpected<Result::error_type>("validation failed: f32.div left value type mismatch" ); |
565 | |
566 | if (UNLIKELY(right != F32)) |
567 | return Unexpected<Result::error_type>("validation failed: f32.div right value type mismatch" ); |
568 | |
569 | result = F32; |
570 | return { }; |
571 | } |
572 | |
573 | template<> auto Validate::addOp<OpType::F32Copysign>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
574 | { |
575 | if (UNLIKELY(left != F32)) |
576 | return Unexpected<Result::error_type>("validation failed: f32.copysign left value type mismatch" ); |
577 | |
578 | if (UNLIKELY(right != F32)) |
579 | return Unexpected<Result::error_type>("validation failed: f32.copysign right value type mismatch" ); |
580 | |
581 | result = F32; |
582 | return { }; |
583 | } |
584 | |
585 | template<> auto Validate::addOp<OpType::I64And>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
586 | { |
587 | if (UNLIKELY(left != I64)) |
588 | return Unexpected<Result::error_type>("validation failed: i64.and left value type mismatch" ); |
589 | |
590 | if (UNLIKELY(right != I64)) |
591 | return Unexpected<Result::error_type>("validation failed: i64.and right value type mismatch" ); |
592 | |
593 | result = I64; |
594 | return { }; |
595 | } |
596 | |
597 | template<> auto Validate::addOp<OpType::F32Ne>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
598 | { |
599 | if (UNLIKELY(left != F32)) |
600 | return Unexpected<Result::error_type>("validation failed: f32.ne left value type mismatch" ); |
601 | |
602 | if (UNLIKELY(right != F32)) |
603 | return Unexpected<Result::error_type>("validation failed: f32.ne right value type mismatch" ); |
604 | |
605 | result = I32; |
606 | return { }; |
607 | } |
608 | |
609 | template<> auto Validate::addOp<OpType::F64Gt>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
610 | { |
611 | if (UNLIKELY(left != F64)) |
612 | return Unexpected<Result::error_type>("validation failed: f64.gt left value type mismatch" ); |
613 | |
614 | if (UNLIKELY(right != F64)) |
615 | return Unexpected<Result::error_type>("validation failed: f64.gt right value type mismatch" ); |
616 | |
617 | result = I32; |
618 | return { }; |
619 | } |
620 | |
621 | template<> auto Validate::addOp<OpType::I32DivU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
622 | { |
623 | if (UNLIKELY(left != I32)) |
624 | return Unexpected<Result::error_type>("validation failed: i32.div_u left value type mismatch" ); |
625 | |
626 | if (UNLIKELY(right != I32)) |
627 | return Unexpected<Result::error_type>("validation failed: i32.div_u right value type mismatch" ); |
628 | |
629 | result = I32; |
630 | return { }; |
631 | } |
632 | |
633 | template<> auto Validate::addOp<OpType::I32DivS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
634 | { |
635 | if (UNLIKELY(left != I32)) |
636 | return Unexpected<Result::error_type>("validation failed: i32.div_s left value type mismatch" ); |
637 | |
638 | if (UNLIKELY(right != I32)) |
639 | return Unexpected<Result::error_type>("validation failed: i32.div_s right value type mismatch" ); |
640 | |
641 | result = I32; |
642 | return { }; |
643 | } |
644 | |
645 | template<> auto Validate::addOp<OpType::F64Ge>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
646 | { |
647 | if (UNLIKELY(left != F64)) |
648 | return Unexpected<Result::error_type>("validation failed: f64.ge left value type mismatch" ); |
649 | |
650 | if (UNLIKELY(right != F64)) |
651 | return Unexpected<Result::error_type>("validation failed: f64.ge right value type mismatch" ); |
652 | |
653 | result = I32; |
654 | return { }; |
655 | } |
656 | |
657 | template<> auto Validate::addOp<OpType::I64GtS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
658 | { |
659 | if (UNLIKELY(left != I64)) |
660 | return Unexpected<Result::error_type>("validation failed: i64.gt_s left value type mismatch" ); |
661 | |
662 | if (UNLIKELY(right != I64)) |
663 | return Unexpected<Result::error_type>("validation failed: i64.gt_s right value type mismatch" ); |
664 | |
665 | result = I32; |
666 | return { }; |
667 | } |
668 | |
669 | template<> auto Validate::addOp<OpType::I32RemU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
670 | { |
671 | if (UNLIKELY(left != I32)) |
672 | return Unexpected<Result::error_type>("validation failed: i32.rem_u left value type mismatch" ); |
673 | |
674 | if (UNLIKELY(right != I32)) |
675 | return Unexpected<Result::error_type>("validation failed: i32.rem_u right value type mismatch" ); |
676 | |
677 | result = I32; |
678 | return { }; |
679 | } |
680 | |
681 | template<> auto Validate::addOp<OpType::I64GtU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
682 | { |
683 | if (UNLIKELY(left != I64)) |
684 | return Unexpected<Result::error_type>("validation failed: i64.gt_u left value type mismatch" ); |
685 | |
686 | if (UNLIKELY(right != I64)) |
687 | return Unexpected<Result::error_type>("validation failed: i64.gt_u right value type mismatch" ); |
688 | |
689 | result = I32; |
690 | return { }; |
691 | } |
692 | |
693 | template<> auto Validate::addOp<OpType::F64Div>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
694 | { |
695 | if (UNLIKELY(left != F64)) |
696 | return Unexpected<Result::error_type>("validation failed: f64.div left value type mismatch" ); |
697 | |
698 | if (UNLIKELY(right != F64)) |
699 | return Unexpected<Result::error_type>("validation failed: f64.div right value type mismatch" ); |
700 | |
701 | result = F64; |
702 | return { }; |
703 | } |
704 | |
705 | template<> auto Validate::addOp<OpType::F32Add>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
706 | { |
707 | if (UNLIKELY(left != F32)) |
708 | return Unexpected<Result::error_type>("validation failed: f32.add left value type mismatch" ); |
709 | |
710 | if (UNLIKELY(right != F32)) |
711 | return Unexpected<Result::error_type>("validation failed: f32.add right value type mismatch" ); |
712 | |
713 | result = F32; |
714 | return { }; |
715 | } |
716 | |
717 | template<> auto Validate::addOp<OpType::I64Or>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
718 | { |
719 | if (UNLIKELY(left != I64)) |
720 | return Unexpected<Result::error_type>("validation failed: i64.or left value type mismatch" ); |
721 | |
722 | if (UNLIKELY(right != I64)) |
723 | return Unexpected<Result::error_type>("validation failed: i64.or right value type mismatch" ); |
724 | |
725 | result = I64; |
726 | return { }; |
727 | } |
728 | |
729 | template<> auto Validate::addOp<OpType::I32LeU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
730 | { |
731 | if (UNLIKELY(left != I32)) |
732 | return Unexpected<Result::error_type>("validation failed: i32.le_u left value type mismatch" ); |
733 | |
734 | if (UNLIKELY(right != I32)) |
735 | return Unexpected<Result::error_type>("validation failed: i32.le_u right value type mismatch" ); |
736 | |
737 | result = I32; |
738 | return { }; |
739 | } |
740 | |
741 | template<> auto Validate::addOp<OpType::I32LeS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
742 | { |
743 | if (UNLIKELY(left != I32)) |
744 | return Unexpected<Result::error_type>("validation failed: i32.le_s left value type mismatch" ); |
745 | |
746 | if (UNLIKELY(right != I32)) |
747 | return Unexpected<Result::error_type>("validation failed: i32.le_s right value type mismatch" ); |
748 | |
749 | result = I32; |
750 | return { }; |
751 | } |
752 | |
753 | template<> auto Validate::addOp<OpType::I64Ne>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
754 | { |
755 | if (UNLIKELY(left != I64)) |
756 | return Unexpected<Result::error_type>("validation failed: i64.ne left value type mismatch" ); |
757 | |
758 | if (UNLIKELY(right != I64)) |
759 | return Unexpected<Result::error_type>("validation failed: i64.ne right value type mismatch" ); |
760 | |
761 | result = I32; |
762 | return { }; |
763 | } |
764 | |
765 | template<> auto Validate::addOp<OpType::I32And>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
766 | { |
767 | if (UNLIKELY(left != I32)) |
768 | return Unexpected<Result::error_type>("validation failed: i32.and left value type mismatch" ); |
769 | |
770 | if (UNLIKELY(right != I32)) |
771 | return Unexpected<Result::error_type>("validation failed: i32.and right value type mismatch" ); |
772 | |
773 | result = I32; |
774 | return { }; |
775 | } |
776 | |
777 | template<> auto Validate::addOp<OpType::I32LtU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
778 | { |
779 | if (UNLIKELY(left != I32)) |
780 | return Unexpected<Result::error_type>("validation failed: i32.lt_u left value type mismatch" ); |
781 | |
782 | if (UNLIKELY(right != I32)) |
783 | return Unexpected<Result::error_type>("validation failed: i32.lt_u right value type mismatch" ); |
784 | |
785 | result = I32; |
786 | return { }; |
787 | } |
788 | |
789 | template<> auto Validate::addOp<OpType::I64Rotr>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
790 | { |
791 | if (UNLIKELY(left != I64)) |
792 | return Unexpected<Result::error_type>("validation failed: i64.rotr left value type mismatch" ); |
793 | |
794 | if (UNLIKELY(right != I64)) |
795 | return Unexpected<Result::error_type>("validation failed: i64.rotr right value type mismatch" ); |
796 | |
797 | result = I64; |
798 | return { }; |
799 | } |
800 | |
801 | template<> auto Validate::addOp<OpType::I32LtS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
802 | { |
803 | if (UNLIKELY(left != I32)) |
804 | return Unexpected<Result::error_type>("validation failed: i32.lt_s left value type mismatch" ); |
805 | |
806 | if (UNLIKELY(right != I32)) |
807 | return Unexpected<Result::error_type>("validation failed: i32.lt_s right value type mismatch" ); |
808 | |
809 | result = I32; |
810 | return { }; |
811 | } |
812 | |
813 | template<> auto Validate::addOp<OpType::I32Eq>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
814 | { |
815 | if (UNLIKELY(left != I32)) |
816 | return Unexpected<Result::error_type>("validation failed: i32.eq left value type mismatch" ); |
817 | |
818 | if (UNLIKELY(right != I32)) |
819 | return Unexpected<Result::error_type>("validation failed: i32.eq right value type mismatch" ); |
820 | |
821 | result = I32; |
822 | return { }; |
823 | } |
824 | |
825 | template<> auto Validate::addOp<OpType::F64Copysign>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
826 | { |
827 | if (UNLIKELY(left != F64)) |
828 | return Unexpected<Result::error_type>("validation failed: f64.copysign left value type mismatch" ); |
829 | |
830 | if (UNLIKELY(right != F64)) |
831 | return Unexpected<Result::error_type>("validation failed: f64.copysign right value type mismatch" ); |
832 | |
833 | result = F64; |
834 | return { }; |
835 | } |
836 | |
837 | template<> auto Validate::addOp<OpType::I64Rotl>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
838 | { |
839 | if (UNLIKELY(left != I64)) |
840 | return Unexpected<Result::error_type>("validation failed: i64.rotl left value type mismatch" ); |
841 | |
842 | if (UNLIKELY(right != I64)) |
843 | return Unexpected<Result::error_type>("validation failed: i64.rotl right value type mismatch" ); |
844 | |
845 | result = I64; |
846 | return { }; |
847 | } |
848 | |
849 | template<> auto Validate::addOp<OpType::F32Lt>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
850 | { |
851 | if (UNLIKELY(left != F32)) |
852 | return Unexpected<Result::error_type>("validation failed: f32.lt left value type mismatch" ); |
853 | |
854 | if (UNLIKELY(right != F32)) |
855 | return Unexpected<Result::error_type>("validation failed: f32.lt right value type mismatch" ); |
856 | |
857 | result = I32; |
858 | return { }; |
859 | } |
860 | |
861 | template<> auto Validate::addOp<OpType::F64Eq>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
862 | { |
863 | if (UNLIKELY(left != F64)) |
864 | return Unexpected<Result::error_type>("validation failed: f64.eq left value type mismatch" ); |
865 | |
866 | if (UNLIKELY(right != F64)) |
867 | return Unexpected<Result::error_type>("validation failed: f64.eq right value type mismatch" ); |
868 | |
869 | result = I32; |
870 | return { }; |
871 | } |
872 | |
873 | template<> auto Validate::addOp<OpType::F32Le>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
874 | { |
875 | if (UNLIKELY(left != F32)) |
876 | return Unexpected<Result::error_type>("validation failed: f32.le left value type mismatch" ); |
877 | |
878 | if (UNLIKELY(right != F32)) |
879 | return Unexpected<Result::error_type>("validation failed: f32.le right value type mismatch" ); |
880 | |
881 | result = I32; |
882 | return { }; |
883 | } |
884 | |
885 | template<> auto Validate::addOp<OpType::F32Ge>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
886 | { |
887 | if (UNLIKELY(left != F32)) |
888 | return Unexpected<Result::error_type>("validation failed: f32.ge left value type mismatch" ); |
889 | |
890 | if (UNLIKELY(right != F32)) |
891 | return Unexpected<Result::error_type>("validation failed: f32.ge right value type mismatch" ); |
892 | |
893 | result = I32; |
894 | return { }; |
895 | } |
896 | |
897 | template<> auto Validate::addOp<OpType::I32ShrU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
898 | { |
899 | if (UNLIKELY(left != I32)) |
900 | return Unexpected<Result::error_type>("validation failed: i32.shr_u left value type mismatch" ); |
901 | |
902 | if (UNLIKELY(right != I32)) |
903 | return Unexpected<Result::error_type>("validation failed: i32.shr_u right value type mismatch" ); |
904 | |
905 | result = I32; |
906 | return { }; |
907 | } |
908 | |
909 | template<> auto Validate::addOp<OpType::I32ShrS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
910 | { |
911 | if (UNLIKELY(left != I32)) |
912 | return Unexpected<Result::error_type>("validation failed: i32.shr_s left value type mismatch" ); |
913 | |
914 | if (UNLIKELY(right != I32)) |
915 | return Unexpected<Result::error_type>("validation failed: i32.shr_s right value type mismatch" ); |
916 | |
917 | result = I32; |
918 | return { }; |
919 | } |
920 | |
921 | template<> auto Validate::addOp<OpType::I32GeU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
922 | { |
923 | if (UNLIKELY(left != I32)) |
924 | return Unexpected<Result::error_type>("validation failed: i32.ge_u left value type mismatch" ); |
925 | |
926 | if (UNLIKELY(right != I32)) |
927 | return Unexpected<Result::error_type>("validation failed: i32.ge_u right value type mismatch" ); |
928 | |
929 | result = I32; |
930 | return { }; |
931 | } |
932 | |
933 | template<> auto Validate::addOp<OpType::I32GeS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
934 | { |
935 | if (UNLIKELY(left != I32)) |
936 | return Unexpected<Result::error_type>("validation failed: i32.ge_s left value type mismatch" ); |
937 | |
938 | if (UNLIKELY(right != I32)) |
939 | return Unexpected<Result::error_type>("validation failed: i32.ge_s right value type mismatch" ); |
940 | |
941 | result = I32; |
942 | return { }; |
943 | } |
944 | |
945 | template<> auto Validate::addOp<OpType::I32Shl>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
946 | { |
947 | if (UNLIKELY(left != I32)) |
948 | return Unexpected<Result::error_type>("validation failed: i32.shl left value type mismatch" ); |
949 | |
950 | if (UNLIKELY(right != I32)) |
951 | return Unexpected<Result::error_type>("validation failed: i32.shl right value type mismatch" ); |
952 | |
953 | result = I32; |
954 | return { }; |
955 | } |
956 | |
957 | template<> auto Validate::addOp<OpType::I32Xor>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
958 | { |
959 | if (UNLIKELY(left != I32)) |
960 | return Unexpected<Result::error_type>("validation failed: i32.xor left value type mismatch" ); |
961 | |
962 | if (UNLIKELY(right != I32)) |
963 | return Unexpected<Result::error_type>("validation failed: i32.xor right value type mismatch" ); |
964 | |
965 | result = I32; |
966 | return { }; |
967 | } |
968 | |
969 | template<> auto Validate::addOp<OpType::I32RemS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
970 | { |
971 | if (UNLIKELY(left != I32)) |
972 | return Unexpected<Result::error_type>("validation failed: i32.rem_s left value type mismatch" ); |
973 | |
974 | if (UNLIKELY(right != I32)) |
975 | return Unexpected<Result::error_type>("validation failed: i32.rem_s right value type mismatch" ); |
976 | |
977 | result = I32; |
978 | return { }; |
979 | } |
980 | |
981 | template<> auto Validate::addOp<OpType::F64Min>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
982 | { |
983 | if (UNLIKELY(left != F64)) |
984 | return Unexpected<Result::error_type>("validation failed: f64.min left value type mismatch" ); |
985 | |
986 | if (UNLIKELY(right != F64)) |
987 | return Unexpected<Result::error_type>("validation failed: f64.min right value type mismatch" ); |
988 | |
989 | result = F64; |
990 | return { }; |
991 | } |
992 | |
993 | template<> auto Validate::addOp<OpType::F32Mul>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
994 | { |
995 | if (UNLIKELY(left != F32)) |
996 | return Unexpected<Result::error_type>("validation failed: f32.mul left value type mismatch" ); |
997 | |
998 | if (UNLIKELY(right != F32)) |
999 | return Unexpected<Result::error_type>("validation failed: f32.mul right value type mismatch" ); |
1000 | |
1001 | result = F32; |
1002 | return { }; |
1003 | } |
1004 | |
1005 | template<> auto Validate::addOp<OpType::I64Sub>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1006 | { |
1007 | if (UNLIKELY(left != I64)) |
1008 | return Unexpected<Result::error_type>("validation failed: i64.sub left value type mismatch" ); |
1009 | |
1010 | if (UNLIKELY(right != I64)) |
1011 | return Unexpected<Result::error_type>("validation failed: i64.sub right value type mismatch" ); |
1012 | |
1013 | result = I64; |
1014 | return { }; |
1015 | } |
1016 | |
1017 | template<> auto Validate::addOp<OpType::I32Add>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1018 | { |
1019 | if (UNLIKELY(left != I32)) |
1020 | return Unexpected<Result::error_type>("validation failed: i32.add left value type mismatch" ); |
1021 | |
1022 | if (UNLIKELY(right != I32)) |
1023 | return Unexpected<Result::error_type>("validation failed: i32.add right value type mismatch" ); |
1024 | |
1025 | result = I32; |
1026 | return { }; |
1027 | } |
1028 | |
1029 | template<> auto Validate::addOp<OpType::F64Sub>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1030 | { |
1031 | if (UNLIKELY(left != F64)) |
1032 | return Unexpected<Result::error_type>("validation failed: f64.sub left value type mismatch" ); |
1033 | |
1034 | if (UNLIKELY(right != F64)) |
1035 | return Unexpected<Result::error_type>("validation failed: f64.sub right value type mismatch" ); |
1036 | |
1037 | result = F64; |
1038 | return { }; |
1039 | } |
1040 | |
1041 | template<> auto Validate::addOp<OpType::I32Or>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1042 | { |
1043 | if (UNLIKELY(left != I32)) |
1044 | return Unexpected<Result::error_type>("validation failed: i32.or left value type mismatch" ); |
1045 | |
1046 | if (UNLIKELY(right != I32)) |
1047 | return Unexpected<Result::error_type>("validation failed: i32.or right value type mismatch" ); |
1048 | |
1049 | result = I32; |
1050 | return { }; |
1051 | } |
1052 | |
1053 | template<> auto Validate::addOp<OpType::I64LtU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1054 | { |
1055 | if (UNLIKELY(left != I64)) |
1056 | return Unexpected<Result::error_type>("validation failed: i64.lt_u left value type mismatch" ); |
1057 | |
1058 | if (UNLIKELY(right != I64)) |
1059 | return Unexpected<Result::error_type>("validation failed: i64.lt_u right value type mismatch" ); |
1060 | |
1061 | result = I32; |
1062 | return { }; |
1063 | } |
1064 | |
1065 | template<> auto Validate::addOp<OpType::I64LtS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1066 | { |
1067 | if (UNLIKELY(left != I64)) |
1068 | return Unexpected<Result::error_type>("validation failed: i64.lt_s left value type mismatch" ); |
1069 | |
1070 | if (UNLIKELY(right != I64)) |
1071 | return Unexpected<Result::error_type>("validation failed: i64.lt_s right value type mismatch" ); |
1072 | |
1073 | result = I32; |
1074 | return { }; |
1075 | } |
1076 | |
1077 | template<> auto Validate::addOp<OpType::I64Xor>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1078 | { |
1079 | if (UNLIKELY(left != I64)) |
1080 | return Unexpected<Result::error_type>("validation failed: i64.xor left value type mismatch" ); |
1081 | |
1082 | if (UNLIKELY(right != I64)) |
1083 | return Unexpected<Result::error_type>("validation failed: i64.xor right value type mismatch" ); |
1084 | |
1085 | result = I64; |
1086 | return { }; |
1087 | } |
1088 | |
1089 | template<> auto Validate::addOp<OpType::I64GeU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1090 | { |
1091 | if (UNLIKELY(left != I64)) |
1092 | return Unexpected<Result::error_type>("validation failed: i64.ge_u left value type mismatch" ); |
1093 | |
1094 | if (UNLIKELY(right != I64)) |
1095 | return Unexpected<Result::error_type>("validation failed: i64.ge_u right value type mismatch" ); |
1096 | |
1097 | result = I32; |
1098 | return { }; |
1099 | } |
1100 | |
1101 | template<> auto Validate::addOp<OpType::F32Min>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1102 | { |
1103 | if (UNLIKELY(left != F32)) |
1104 | return Unexpected<Result::error_type>("validation failed: f32.min left value type mismatch" ); |
1105 | |
1106 | if (UNLIKELY(right != F32)) |
1107 | return Unexpected<Result::error_type>("validation failed: f32.min right value type mismatch" ); |
1108 | |
1109 | result = F32; |
1110 | return { }; |
1111 | } |
1112 | |
1113 | template<> auto Validate::addOp<OpType::I64Mul>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1114 | { |
1115 | if (UNLIKELY(left != I64)) |
1116 | return Unexpected<Result::error_type>("validation failed: i64.mul left value type mismatch" ); |
1117 | |
1118 | if (UNLIKELY(right != I64)) |
1119 | return Unexpected<Result::error_type>("validation failed: i64.mul right value type mismatch" ); |
1120 | |
1121 | result = I64; |
1122 | return { }; |
1123 | } |
1124 | |
1125 | template<> auto Validate::addOp<OpType::F32Sub>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1126 | { |
1127 | if (UNLIKELY(left != F32)) |
1128 | return Unexpected<Result::error_type>("validation failed: f32.sub left value type mismatch" ); |
1129 | |
1130 | if (UNLIKELY(right != F32)) |
1131 | return Unexpected<Result::error_type>("validation failed: f32.sub right value type mismatch" ); |
1132 | |
1133 | result = F32; |
1134 | return { }; |
1135 | } |
1136 | |
1137 | template<> auto Validate::addOp<OpType::F64Add>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1138 | { |
1139 | if (UNLIKELY(left != F64)) |
1140 | return Unexpected<Result::error_type>("validation failed: f64.add left value type mismatch" ); |
1141 | |
1142 | if (UNLIKELY(right != F64)) |
1143 | return Unexpected<Result::error_type>("validation failed: f64.add right value type mismatch" ); |
1144 | |
1145 | result = F64; |
1146 | return { }; |
1147 | } |
1148 | |
1149 | template<> auto Validate::addOp<OpType::I64GeS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1150 | { |
1151 | if (UNLIKELY(left != I64)) |
1152 | return Unexpected<Result::error_type>("validation failed: i64.ge_s left value type mismatch" ); |
1153 | |
1154 | if (UNLIKELY(right != I64)) |
1155 | return Unexpected<Result::error_type>("validation failed: i64.ge_s right value type mismatch" ); |
1156 | |
1157 | result = I32; |
1158 | return { }; |
1159 | } |
1160 | |
1161 | template<> auto Validate::addOp<OpType::I64RemS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1162 | { |
1163 | if (UNLIKELY(left != I64)) |
1164 | return Unexpected<Result::error_type>("validation failed: i64.rem_s left value type mismatch" ); |
1165 | |
1166 | if (UNLIKELY(right != I64)) |
1167 | return Unexpected<Result::error_type>("validation failed: i64.rem_s right value type mismatch" ); |
1168 | |
1169 | result = I64; |
1170 | return { }; |
1171 | } |
1172 | |
1173 | template<> auto Validate::addOp<OpType::I64RemU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1174 | { |
1175 | if (UNLIKELY(left != I64)) |
1176 | return Unexpected<Result::error_type>("validation failed: i64.rem_u left value type mismatch" ); |
1177 | |
1178 | if (UNLIKELY(right != I64)) |
1179 | return Unexpected<Result::error_type>("validation failed: i64.rem_u right value type mismatch" ); |
1180 | |
1181 | result = I64; |
1182 | return { }; |
1183 | } |
1184 | |
1185 | template<> auto Validate::addOp<OpType::I32Ne>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1186 | { |
1187 | if (UNLIKELY(left != I32)) |
1188 | return Unexpected<Result::error_type>("validation failed: i32.ne left value type mismatch" ); |
1189 | |
1190 | if (UNLIKELY(right != I32)) |
1191 | return Unexpected<Result::error_type>("validation failed: i32.ne right value type mismatch" ); |
1192 | |
1193 | result = I32; |
1194 | return { }; |
1195 | } |
1196 | |
1197 | template<> auto Validate::addOp<OpType::F32Eq>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1198 | { |
1199 | if (UNLIKELY(left != F32)) |
1200 | return Unexpected<Result::error_type>("validation failed: f32.eq left value type mismatch" ); |
1201 | |
1202 | if (UNLIKELY(right != F32)) |
1203 | return Unexpected<Result::error_type>("validation failed: f32.eq right value type mismatch" ); |
1204 | |
1205 | result = I32; |
1206 | return { }; |
1207 | } |
1208 | |
1209 | template<> auto Validate::addOp<OpType::I64Eq>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1210 | { |
1211 | if (UNLIKELY(left != I64)) |
1212 | return Unexpected<Result::error_type>("validation failed: i64.eq left value type mismatch" ); |
1213 | |
1214 | if (UNLIKELY(right != I64)) |
1215 | return Unexpected<Result::error_type>("validation failed: i64.eq right value type mismatch" ); |
1216 | |
1217 | result = I32; |
1218 | return { }; |
1219 | } |
1220 | |
1221 | template<> auto Validate::addOp<OpType::I64ShrU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1222 | { |
1223 | if (UNLIKELY(left != I64)) |
1224 | return Unexpected<Result::error_type>("validation failed: i64.shr_u left value type mismatch" ); |
1225 | |
1226 | if (UNLIKELY(right != I64)) |
1227 | return Unexpected<Result::error_type>("validation failed: i64.shr_u right value type mismatch" ); |
1228 | |
1229 | result = I64; |
1230 | return { }; |
1231 | } |
1232 | |
1233 | template<> auto Validate::addOp<OpType::I64Shl>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1234 | { |
1235 | if (UNLIKELY(left != I64)) |
1236 | return Unexpected<Result::error_type>("validation failed: i64.shl left value type mismatch" ); |
1237 | |
1238 | if (UNLIKELY(right != I64)) |
1239 | return Unexpected<Result::error_type>("validation failed: i64.shl right value type mismatch" ); |
1240 | |
1241 | result = I64; |
1242 | return { }; |
1243 | } |
1244 | |
1245 | template<> auto Validate::addOp<OpType::I64DivU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1246 | { |
1247 | if (UNLIKELY(left != I64)) |
1248 | return Unexpected<Result::error_type>("validation failed: i64.div_u left value type mismatch" ); |
1249 | |
1250 | if (UNLIKELY(right != I64)) |
1251 | return Unexpected<Result::error_type>("validation failed: i64.div_u right value type mismatch" ); |
1252 | |
1253 | result = I64; |
1254 | return { }; |
1255 | } |
1256 | |
1257 | template<> auto Validate::addOp<OpType::F32Gt>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1258 | { |
1259 | if (UNLIKELY(left != F32)) |
1260 | return Unexpected<Result::error_type>("validation failed: f32.gt left value type mismatch" ); |
1261 | |
1262 | if (UNLIKELY(right != F32)) |
1263 | return Unexpected<Result::error_type>("validation failed: f32.gt right value type mismatch" ); |
1264 | |
1265 | result = I32; |
1266 | return { }; |
1267 | } |
1268 | |
1269 | template<> auto Validate::addOp<OpType::I32Rotl>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1270 | { |
1271 | if (UNLIKELY(left != I32)) |
1272 | return Unexpected<Result::error_type>("validation failed: i32.rotl left value type mismatch" ); |
1273 | |
1274 | if (UNLIKELY(right != I32)) |
1275 | return Unexpected<Result::error_type>("validation failed: i32.rotl right value type mismatch" ); |
1276 | |
1277 | result = I32; |
1278 | return { }; |
1279 | } |
1280 | |
1281 | template<> auto Validate::addOp<OpType::I32Rotr>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1282 | { |
1283 | if (UNLIKELY(left != I32)) |
1284 | return Unexpected<Result::error_type>("validation failed: i32.rotr left value type mismatch" ); |
1285 | |
1286 | if (UNLIKELY(right != I32)) |
1287 | return Unexpected<Result::error_type>("validation failed: i32.rotr right value type mismatch" ); |
1288 | |
1289 | result = I32; |
1290 | return { }; |
1291 | } |
1292 | |
1293 | template<> auto Validate::addOp<OpType::I32GtU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1294 | { |
1295 | if (UNLIKELY(left != I32)) |
1296 | return Unexpected<Result::error_type>("validation failed: i32.gt_u left value type mismatch" ); |
1297 | |
1298 | if (UNLIKELY(right != I32)) |
1299 | return Unexpected<Result::error_type>("validation failed: i32.gt_u right value type mismatch" ); |
1300 | |
1301 | result = I32; |
1302 | return { }; |
1303 | } |
1304 | |
1305 | template<> auto Validate::addOp<OpType::I64DivS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1306 | { |
1307 | if (UNLIKELY(left != I64)) |
1308 | return Unexpected<Result::error_type>("validation failed: i64.div_s left value type mismatch" ); |
1309 | |
1310 | if (UNLIKELY(right != I64)) |
1311 | return Unexpected<Result::error_type>("validation failed: i64.div_s right value type mismatch" ); |
1312 | |
1313 | result = I64; |
1314 | return { }; |
1315 | } |
1316 | |
1317 | template<> auto Validate::addOp<OpType::I32GtS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1318 | { |
1319 | if (UNLIKELY(left != I32)) |
1320 | return Unexpected<Result::error_type>("validation failed: i32.gt_s left value type mismatch" ); |
1321 | |
1322 | if (UNLIKELY(right != I32)) |
1323 | return Unexpected<Result::error_type>("validation failed: i32.gt_s right value type mismatch" ); |
1324 | |
1325 | result = I32; |
1326 | return { }; |
1327 | } |
1328 | |
1329 | template<> auto Validate::addOp<OpType::F64Max>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1330 | { |
1331 | if (UNLIKELY(left != F64)) |
1332 | return Unexpected<Result::error_type>("validation failed: f64.max left value type mismatch" ); |
1333 | |
1334 | if (UNLIKELY(right != F64)) |
1335 | return Unexpected<Result::error_type>("validation failed: f64.max right value type mismatch" ); |
1336 | |
1337 | result = F64; |
1338 | return { }; |
1339 | } |
1340 | |
1341 | template<> auto Validate::addOp<OpType::I64LeU>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1342 | { |
1343 | if (UNLIKELY(left != I64)) |
1344 | return Unexpected<Result::error_type>("validation failed: i64.le_u left value type mismatch" ); |
1345 | |
1346 | if (UNLIKELY(right != I64)) |
1347 | return Unexpected<Result::error_type>("validation failed: i64.le_u right value type mismatch" ); |
1348 | |
1349 | result = I32; |
1350 | return { }; |
1351 | } |
1352 | |
1353 | template<> auto Validate::addOp<OpType::I64LeS>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1354 | { |
1355 | if (UNLIKELY(left != I64)) |
1356 | return Unexpected<Result::error_type>("validation failed: i64.le_s left value type mismatch" ); |
1357 | |
1358 | if (UNLIKELY(right != I64)) |
1359 | return Unexpected<Result::error_type>("validation failed: i64.le_s right value type mismatch" ); |
1360 | |
1361 | result = I32; |
1362 | return { }; |
1363 | } |
1364 | |
1365 | template<> auto Validate::addOp<OpType::I64Add>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result |
1366 | { |
1367 | if (UNLIKELY(left != I64)) |
1368 | return Unexpected<Result::error_type>("validation failed: i64.add left value type mismatch" ); |
1369 | |
1370 | if (UNLIKELY(right != I64)) |
1371 | return Unexpected<Result::error_type>("validation failed: i64.add right value type mismatch" ); |
1372 | |
1373 | result = I64; |
1374 | return { }; |
1375 | } |
1376 | |
1377 | |
1378 | auto Validate::load(LoadOpType op, ExpressionType pointer, ExpressionType& result, uint32_t) -> Result |
1379 | { |
1380 | if (UNLIKELY(!hasMemory())) |
1381 | return Unexpected<Result::error_type>("validation failed: load instruction without memory" ); |
1382 | |
1383 | switch (op) { |
1384 | |
1385 | case LoadOpType::I64Load32U: { |
1386 | if (UNLIKELY(pointer != I32)) |
1387 | return Unexpected<Result::error_type>("validation failed: i64.load32_u pointer type mismatch" ); |
1388 | |
1389 | result = I64; |
1390 | return { }; |
1391 | } |
1392 | case LoadOpType::I64Load32S: { |
1393 | if (UNLIKELY(pointer != I32)) |
1394 | return Unexpected<Result::error_type>("validation failed: i64.load32_s pointer type mismatch" ); |
1395 | |
1396 | result = I64; |
1397 | return { }; |
1398 | } |
1399 | case LoadOpType::I32Load16S: { |
1400 | if (UNLIKELY(pointer != I32)) |
1401 | return Unexpected<Result::error_type>("validation failed: i32.load16_s pointer type mismatch" ); |
1402 | |
1403 | result = I32; |
1404 | return { }; |
1405 | } |
1406 | case LoadOpType::I32Load16U: { |
1407 | if (UNLIKELY(pointer != I32)) |
1408 | return Unexpected<Result::error_type>("validation failed: i32.load16_u pointer type mismatch" ); |
1409 | |
1410 | result = I32; |
1411 | return { }; |
1412 | } |
1413 | case LoadOpType::I64Load: { |
1414 | if (UNLIKELY(pointer != I32)) |
1415 | return Unexpected<Result::error_type>("validation failed: i64.load pointer type mismatch" ); |
1416 | |
1417 | result = I64; |
1418 | return { }; |
1419 | } |
1420 | case LoadOpType::F64Load: { |
1421 | if (UNLIKELY(pointer != I32)) |
1422 | return Unexpected<Result::error_type>("validation failed: f64.load pointer type mismatch" ); |
1423 | |
1424 | result = F64; |
1425 | return { }; |
1426 | } |
1427 | case LoadOpType::I32Load8S: { |
1428 | if (UNLIKELY(pointer != I32)) |
1429 | return Unexpected<Result::error_type>("validation failed: i32.load8_s pointer type mismatch" ); |
1430 | |
1431 | result = I32; |
1432 | return { }; |
1433 | } |
1434 | case LoadOpType::I32Load8U: { |
1435 | if (UNLIKELY(pointer != I32)) |
1436 | return Unexpected<Result::error_type>("validation failed: i32.load8_u pointer type mismatch" ); |
1437 | |
1438 | result = I32; |
1439 | return { }; |
1440 | } |
1441 | case LoadOpType::I32Load: { |
1442 | if (UNLIKELY(pointer != I32)) |
1443 | return Unexpected<Result::error_type>("validation failed: i32.load pointer type mismatch" ); |
1444 | |
1445 | result = I32; |
1446 | return { }; |
1447 | } |
1448 | case LoadOpType::F32Load: { |
1449 | if (UNLIKELY(pointer != I32)) |
1450 | return Unexpected<Result::error_type>("validation failed: f32.load pointer type mismatch" ); |
1451 | |
1452 | result = F32; |
1453 | return { }; |
1454 | } |
1455 | case LoadOpType::I64Load8U: { |
1456 | if (UNLIKELY(pointer != I32)) |
1457 | return Unexpected<Result::error_type>("validation failed: i64.load8_u pointer type mismatch" ); |
1458 | |
1459 | result = I64; |
1460 | return { }; |
1461 | } |
1462 | case LoadOpType::I64Load8S: { |
1463 | if (UNLIKELY(pointer != I32)) |
1464 | return Unexpected<Result::error_type>("validation failed: i64.load8_s pointer type mismatch" ); |
1465 | |
1466 | result = I64; |
1467 | return { }; |
1468 | } |
1469 | case LoadOpType::I64Load16S: { |
1470 | if (UNLIKELY(pointer != I32)) |
1471 | return Unexpected<Result::error_type>("validation failed: i64.load16_s pointer type mismatch" ); |
1472 | |
1473 | result = I64; |
1474 | return { }; |
1475 | } |
1476 | case LoadOpType::I64Load16U: { |
1477 | if (UNLIKELY(pointer != I32)) |
1478 | return Unexpected<Result::error_type>("validation failed: i64.load16_u pointer type mismatch" ); |
1479 | |
1480 | result = I64; |
1481 | return { }; |
1482 | } |
1483 | } |
1484 | ASSERT_NOT_REACHED(); |
1485 | } |
1486 | |
1487 | auto Validate::store(StoreOpType op, ExpressionType pointer, ExpressionType value, uint32_t) -> Result |
1488 | { |
1489 | if (UNLIKELY(!hasMemory())) |
1490 | return Unexpected<Result::error_type>("validation failed: store instruction without memory" ); |
1491 | |
1492 | switch (op) { |
1493 | |
1494 | case StoreOpType::I64Store16: { |
1495 | if (UNLIKELY(pointer != I32)) |
1496 | return Unexpected<Result::error_type>("validation failed: i64.store16 pointer type mismatch" ); |
1497 | |
1498 | if (UNLIKELY(value != I64)) |
1499 | return Unexpected<Result::error_type>("validation failed: i64.store16 value type mismatch" ); |
1500 | |
1501 | return { }; |
1502 | } |
1503 | case StoreOpType::I64Store8: { |
1504 | if (UNLIKELY(pointer != I32)) |
1505 | return Unexpected<Result::error_type>("validation failed: i64.store8 pointer type mismatch" ); |
1506 | |
1507 | if (UNLIKELY(value != I64)) |
1508 | return Unexpected<Result::error_type>("validation failed: i64.store8 value type mismatch" ); |
1509 | |
1510 | return { }; |
1511 | } |
1512 | case StoreOpType::I32Store: { |
1513 | if (UNLIKELY(pointer != I32)) |
1514 | return Unexpected<Result::error_type>("validation failed: i32.store pointer type mismatch" ); |
1515 | |
1516 | if (UNLIKELY(value != I32)) |
1517 | return Unexpected<Result::error_type>("validation failed: i32.store value type mismatch" ); |
1518 | |
1519 | return { }; |
1520 | } |
1521 | case StoreOpType::I32Store16: { |
1522 | if (UNLIKELY(pointer != I32)) |
1523 | return Unexpected<Result::error_type>("validation failed: i32.store16 pointer type mismatch" ); |
1524 | |
1525 | if (UNLIKELY(value != I32)) |
1526 | return Unexpected<Result::error_type>("validation failed: i32.store16 value type mismatch" ); |
1527 | |
1528 | return { }; |
1529 | } |
1530 | case StoreOpType::F32Store: { |
1531 | if (UNLIKELY(pointer != I32)) |
1532 | return Unexpected<Result::error_type>("validation failed: f32.store pointer type mismatch" ); |
1533 | |
1534 | if (UNLIKELY(value != F32)) |
1535 | return Unexpected<Result::error_type>("validation failed: f32.store value type mismatch" ); |
1536 | |
1537 | return { }; |
1538 | } |
1539 | case StoreOpType::I64Store: { |
1540 | if (UNLIKELY(pointer != I32)) |
1541 | return Unexpected<Result::error_type>("validation failed: i64.store pointer type mismatch" ); |
1542 | |
1543 | if (UNLIKELY(value != I64)) |
1544 | return Unexpected<Result::error_type>("validation failed: i64.store value type mismatch" ); |
1545 | |
1546 | return { }; |
1547 | } |
1548 | case StoreOpType::F64Store: { |
1549 | if (UNLIKELY(pointer != I32)) |
1550 | return Unexpected<Result::error_type>("validation failed: f64.store pointer type mismatch" ); |
1551 | |
1552 | if (UNLIKELY(value != F64)) |
1553 | return Unexpected<Result::error_type>("validation failed: f64.store value type mismatch" ); |
1554 | |
1555 | return { }; |
1556 | } |
1557 | case StoreOpType::I32Store8: { |
1558 | if (UNLIKELY(pointer != I32)) |
1559 | return Unexpected<Result::error_type>("validation failed: i32.store8 pointer type mismatch" ); |
1560 | |
1561 | if (UNLIKELY(value != I32)) |
1562 | return Unexpected<Result::error_type>("validation failed: i32.store8 value type mismatch" ); |
1563 | |
1564 | return { }; |
1565 | } |
1566 | case StoreOpType::I64Store32: { |
1567 | if (UNLIKELY(pointer != I32)) |
1568 | return Unexpected<Result::error_type>("validation failed: i64.store32 pointer type mismatch" ); |
1569 | |
1570 | if (UNLIKELY(value != I64)) |
1571 | return Unexpected<Result::error_type>("validation failed: i64.store32 value type mismatch" ); |
1572 | |
1573 | return { }; |
1574 | } |
1575 | } |
1576 | ASSERT_NOT_REACHED(); |
1577 | } |
1578 | |
1579 | } } // namespace JSC::Wasm |
1580 | |
1581 | #if ASSERT_DISABLED |
1582 | IGNORE_RETURN_TYPE_WARNINGS_END |
1583 | #endif |
1584 | |
1585 | #endif // ENABLE(WEBASSEMBLY) |
1586 | |
1587 | |