1/*
2 * Copyright 2020 WebAssembly Community Group participants
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// Implements a switch on an expression class ID, and has a case for each id
18// in which it runs delegates on the fields and immediates. You should include
19// this file after defining the relevant DELEGATE_* macros.
20//
21// All defines used here are undefed automatically at the end for you.
22//
23// Most of the defines are necessary, and you will get an error if you forget
24// them, but some are optional and some imply others, see below.
25//
26// The defines are as follows:
27//
28// DELEGATE_START(id) - called at the start of a case for an expression class.
29//
30// DELEGATE_END(id) - called at the end of a case.
31//
32// DELEGATE_GET_FIELD(id, field) - called to get a field by its name. This must
33// know the object on which to get it, so it is just useful for the case
34// where you operate on a single such object, but in that case it is nice
35// because then other things can be defined automatically for you, see later.
36//
37// DELEGATE_FIELD_CHILD(id, field) - called for each child field (note: children
38// are visited in reverse order, which is convenient for walking by pushing
39// them to a stack first).
40//
41// DELEGATE_FIELD_OPTIONAL_CHILD(id, field) - called for a child that may not be
42// present (like a Return's value). If you do not define this then
43// DELEGATE_FIELD_CHILD is called.
44//
45// DELEGATE_FIELD_CHILD_VECTOR(id, field) - called for a variable-sized vector
46// of child pointers. If this is not defined, and DELEGATE_GET_FIELD is, then
47// DELEGATE_FIELD_CHILD is called on them.
48//
49// DELEGATE_FIELD_INT(id, field) - called for an integer field (bool, enum,
50// Index, int32, or int64).
51//
52// DELEGATE_FIELD_INT_ARRAY(id, field) - called for a std::array of fixed size
53// of integer values (like a SIMD mask). If this is not defined, and
54// DELEGATE_GET_FIELD is, then DELEGATE_FIELD_INT is called on them.
55//
56// DELEGATE_FIELD_LITERAL(id, field) - called for a Literal.
57//
58// DELEGATE_FIELD_NAME(id, field) - called for a Name.
59//
60// DELEGATE_FIELD_NAME_VECTOR(id, field) - called for a variable-sized vector of
61// names (like try's catch tag names). If this is not defined, and
62// DELEGATE_GET_FIELD is, then DELEGATE_FIELD_CHILD is called on them.
63//
64// DELEGATE_FIELD_SCOPE_NAME_DEF(id, field) - called for a scope name definition
65// (like a block's name).
66//
67// DELEGATE_FIELD_SCOPE_NAME_USE(id, field) - called for a scope name use (like
68// a break's target).
69//
70// DELEGATE_FIELD_SCOPE_NAME_USE_VECTOR(id, field) - called for a variable-sized
71// vector of scope names (like a switch's targets). If this is not defined,
72// and DELEGATE_GET_FIELD is, then DELEGATE_FIELD_SCOPE_NAME_USE is called on
73// them.
74//
75// DELEGATE_FIELD_NAME_KIND(id, field, kind) - called for a field that contains
76// the name of a ModuleItemKind (i.e., a top-level module entity like a table
77// or a function). If this is not defined then DELEGATE_FIELD_NAME is called
78// instead.
79//
80// DELEGATE_FIELD_NAME_KIND_VECTOR(id, field, kind) - called for a variable-
81// sized vector of DELEGATE_FIELD_NAME_KIND. If this is not defined, and
82// DELEGATE_GET_FIELD is, then DELEGATE_FIELD_NAME_KIND is called on them.
83// Or, if this is not defined by DELEGATE_FIELD_NAME_VECTOR is, then that is
84// called.
85//
86// DELEGATE_FIELD_TYPE(id, field) - called for a Type.
87//
88// DELEGATE_FIELD_HEAPTYPE(id, field) - called for a HeapType.
89//
90// DELEGATE_FIELD_ADDRESS(id, field) - called for an Address.
91
92#ifndef DELEGATE_START
93#define DELEGATE_START(id)
94#endif
95
96#ifndef DELEGATE_END
97#define DELEGATE_END(id)
98#endif
99
100#ifndef DELEGATE_FIELD_CHILD
101#error please define DELEGATE_FIELD_CHILD(id, field)
102#endif
103
104#ifndef DELEGATE_FIELD_OPTIONAL_CHILD
105#define DELEGATE_FIELD_OPTIONAL_CHILD(id, field) DELEGATE_FIELD_CHILD(id, field)
106#endif
107
108#ifndef DELEGATE_FIELD_CHILD_VECTOR
109#ifdef DELEGATE_GET_FIELD
110#define DELEGATE_FIELD_CHILD_VECTOR(id, field) \
111 for (int i = int((DELEGATE_GET_FIELD(id, field)).size()) - 1; i >= 0; i--) { \
112 DELEGATE_FIELD_CHILD(id, field[i]); \
113 }
114#else
115#error please define DELEGATE_FIELD_CHILD_VECTOR(id, field)
116#endif
117#endif
118
119#ifndef DELEGATE_FIELD_INT
120#error please define DELEGATE_FIELD_INT(id, field)
121#endif
122
123#ifndef DELEGATE_FIELD_INT_ARRAY
124#ifdef DELEGATE_GET_FIELD
125#define DELEGATE_FIELD_INT_ARRAY(id, field) \
126 for (Index i = 0; i < (DELEGATE_GET_FIELD(id, field)).size(); i++) { \
127 DELEGATE_FIELD_INT(id, field[i]); \
128 }
129#else
130#error please define DELEGATE_FIELD_INT_ARRAY(id, field)
131#endif
132#endif
133
134#ifndef DELEGATE_FIELD_LITERAL
135#error please define DELEGATE_FIELD_LITERAL(id, field)
136#endif
137
138#ifndef DELEGATE_FIELD_NAME
139#error please define DELEGATE_FIELD_NAME(id, field)
140#endif
141
142#ifndef DELEGATE_FIELD_NAME_VECTOR
143#ifdef DELEGATE_GET_FIELD
144#define DELEGATE_FIELD_NAME_VECTOR(id, field) \
145 for (Index i = 0; i < (DELEGATE_GET_FIELD(id, field)).size(); i++) { \
146 DELEGATE_FIELD_NAME(id, field[i]); \
147 }
148#else
149#error please define DELEGATE_FIELD_NAME_VECTOR(id, field)
150#endif
151#endif
152
153#ifndef DELEGATE_FIELD_SCOPE_NAME_DEF
154#error please define DELEGATE_FIELD_SCOPE_NAME_DEF(id, field)
155#endif
156
157#ifndef DELEGATE_FIELD_SCOPE_NAME_USE
158#error please define DELEGATE_FIELD_SCOPE_NAME_USE(id, field)
159#endif
160
161#ifndef DELEGATE_FIELD_SCOPE_NAME_USE_VECTOR
162#ifdef DELEGATE_GET_FIELD
163#define DELEGATE_FIELD_SCOPE_NAME_USE_VECTOR(id, field) \
164 for (Index i = 0; i < (DELEGATE_GET_FIELD(id, field)).size(); i++) { \
165 DELEGATE_FIELD_SCOPE_NAME_USE(id, field[i]); \
166 }
167#else
168#error please define DELEGATE_FIELD_SCOPE_NAME_USE_VECTOR(id, field)
169#endif
170#endif
171
172#ifndef DELEGATE_FIELD_NAME_KIND
173#define DELEGATE_FIELD_NAME_KIND(id, field, kind) \
174 DELEGATE_FIELD_NAME(id, field);
175#endif
176
177#ifndef DELEGATE_FIELD_NAME_KIND_VECTOR
178#ifdef DELEGATE_GET_FIELD
179#define DELEGATE_FIELD_NAME_KIND_VECTOR(id, field, kind) \
180 for (Index i = 0; i < (DELEGATE_GET_FIELD(id, field)).size(); i++) { \
181 DELEGATE_FIELD_NAME_KIND(id, field[i], kind); \
182 }
183#else
184#define DELEGATE_FIELD_NAME_KIND_VECTOR(id, field, kind) \
185 DELEGATE_FIELD_NAME_VECTOR(id, field)
186#endif
187#endif
188
189#ifndef DELEGATE_FIELD_TYPE
190#error please define DELEGATE_FIELD_TYPE(id, field)
191#endif
192
193#ifndef DELEGATE_FIELD_HEAPTYPE
194#error please define DELEGATE_FIELD_HEAPTYPE(id, field)
195#endif
196
197#ifndef DELEGATE_FIELD_ADDRESS
198#error please define DELEGATE_FIELD_ADDRESS(id, field)
199#endif
200
201switch (DELEGATE_ID) {
202 case Expression::Id::InvalidId:
203 case Expression::Id::NumExpressionIds: {
204 WASM_UNREACHABLE("unexpected expression type");
205 }
206 case Expression::Id::BlockId: {
207 DELEGATE_START(Block);
208 DELEGATE_FIELD_CHILD_VECTOR(Block, list);
209 DELEGATE_FIELD_SCOPE_NAME_DEF(Block, name);
210 DELEGATE_END(Block);
211 break;
212 }
213 case Expression::Id::IfId: {
214 DELEGATE_START(If);
215 DELEGATE_FIELD_OPTIONAL_CHILD(If, ifFalse);
216 DELEGATE_FIELD_CHILD(If, ifTrue);
217 DELEGATE_FIELD_CHILD(If, condition);
218 DELEGATE_END(If);
219 break;
220 }
221 case Expression::Id::LoopId: {
222 DELEGATE_START(Loop);
223 DELEGATE_FIELD_CHILD(Loop, body);
224 DELEGATE_FIELD_SCOPE_NAME_DEF(Loop, name);
225 DELEGATE_END(Loop);
226 break;
227 }
228 case Expression::Id::BreakId: {
229 DELEGATE_START(Break);
230 DELEGATE_FIELD_OPTIONAL_CHILD(Break, condition);
231 DELEGATE_FIELD_OPTIONAL_CHILD(Break, value);
232 DELEGATE_FIELD_SCOPE_NAME_USE(Break, name);
233 DELEGATE_END(Break);
234 break;
235 }
236 case Expression::Id::SwitchId: {
237 DELEGATE_START(Switch);
238 DELEGATE_FIELD_CHILD(Switch, condition);
239 DELEGATE_FIELD_OPTIONAL_CHILD(Switch, value);
240 DELEGATE_FIELD_SCOPE_NAME_USE(Switch, default_);
241 DELEGATE_FIELD_SCOPE_NAME_USE_VECTOR(Switch, targets);
242 DELEGATE_END(Switch);
243 break;
244 }
245 case Expression::Id::CallId: {
246 DELEGATE_START(Call);
247 DELEGATE_FIELD_CHILD_VECTOR(Call, operands);
248 DELEGATE_FIELD_NAME_KIND(Call, target, ModuleItemKind::Function);
249 DELEGATE_FIELD_INT(Call, isReturn);
250 DELEGATE_END(Call);
251 break;
252 }
253 case Expression::Id::CallIndirectId: {
254 DELEGATE_START(CallIndirect);
255 DELEGATE_FIELD_CHILD(CallIndirect, target);
256 DELEGATE_FIELD_NAME_KIND(CallIndirect, table, ModuleItemKind::Table);
257 DELEGATE_FIELD_CHILD_VECTOR(CallIndirect, operands);
258 DELEGATE_FIELD_HEAPTYPE(CallIndirect, heapType);
259 DELEGATE_FIELD_INT(CallIndirect, isReturn);
260 DELEGATE_END(CallIndirect);
261 break;
262 }
263 case Expression::Id::LocalGetId: {
264 DELEGATE_START(LocalGet);
265 DELEGATE_FIELD_INT(LocalGet, index);
266 DELEGATE_END(LocalGet);
267 break;
268 }
269 case Expression::Id::LocalSetId: {
270 DELEGATE_START(LocalSet);
271 DELEGATE_FIELD_CHILD(LocalSet, value);
272 DELEGATE_FIELD_INT(LocalSet, index);
273 DELEGATE_END(LocalSet);
274 break;
275 }
276 case Expression::Id::GlobalGetId: {
277 DELEGATE_START(GlobalGet);
278 DELEGATE_FIELD_NAME_KIND(GlobalGet, name, ModuleItemKind::Global);
279 DELEGATE_END(GlobalGet);
280 break;
281 }
282 case Expression::Id::GlobalSetId: {
283 DELEGATE_START(GlobalSet);
284 DELEGATE_FIELD_CHILD(GlobalSet, value);
285 DELEGATE_FIELD_NAME_KIND(GlobalSet, name, ModuleItemKind::Global);
286 DELEGATE_END(GlobalSet);
287 break;
288 }
289 case Expression::Id::LoadId: {
290 DELEGATE_START(Load);
291 DELEGATE_FIELD_CHILD(Load, ptr);
292 DELEGATE_FIELD_INT(Load, bytes);
293 DELEGATE_FIELD_INT(Load, signed_);
294 DELEGATE_FIELD_ADDRESS(Load, offset);
295 DELEGATE_FIELD_ADDRESS(Load, align);
296 DELEGATE_FIELD_INT(Load, isAtomic);
297 DELEGATE_FIELD_NAME_KIND(Load, memory, ModuleItemKind::Memory);
298 DELEGATE_END(Load);
299 break;
300 }
301 case Expression::Id::StoreId: {
302 DELEGATE_START(Store);
303 DELEGATE_FIELD_CHILD(Store, value);
304 DELEGATE_FIELD_CHILD(Store, ptr);
305 DELEGATE_FIELD_INT(Store, bytes);
306 DELEGATE_FIELD_ADDRESS(Store, offset);
307 DELEGATE_FIELD_ADDRESS(Store, align);
308 DELEGATE_FIELD_INT(Store, isAtomic);
309 DELEGATE_FIELD_TYPE(Store, valueType);
310 DELEGATE_FIELD_NAME_KIND(Store, memory, ModuleItemKind::Memory);
311 DELEGATE_END(Store);
312 break;
313 }
314 case Expression::Id::AtomicRMWId: {
315 DELEGATE_START(AtomicRMW);
316 DELEGATE_FIELD_CHILD(AtomicRMW, value);
317 DELEGATE_FIELD_CHILD(AtomicRMW, ptr);
318 DELEGATE_FIELD_INT(AtomicRMW, op);
319 DELEGATE_FIELD_INT(AtomicRMW, bytes);
320 DELEGATE_FIELD_ADDRESS(AtomicRMW, offset);
321 DELEGATE_FIELD_NAME_KIND(AtomicRMW, memory, ModuleItemKind::Memory);
322 DELEGATE_END(AtomicRMW);
323 break;
324 }
325 case Expression::Id::AtomicCmpxchgId: {
326 DELEGATE_START(AtomicCmpxchg);
327 DELEGATE_FIELD_CHILD(AtomicCmpxchg, replacement);
328 DELEGATE_FIELD_CHILD(AtomicCmpxchg, expected);
329 DELEGATE_FIELD_CHILD(AtomicCmpxchg, ptr);
330 DELEGATE_FIELD_INT(AtomicCmpxchg, bytes);
331 DELEGATE_FIELD_ADDRESS(AtomicCmpxchg, offset);
332 DELEGATE_FIELD_NAME_KIND(AtomicCmpxchg, memory, ModuleItemKind::Memory);
333 DELEGATE_END(AtomicCmpxchg);
334 break;
335 }
336 case Expression::Id::AtomicWaitId: {
337 DELEGATE_START(AtomicWait);
338 DELEGATE_FIELD_CHILD(AtomicWait, timeout);
339 DELEGATE_FIELD_CHILD(AtomicWait, expected);
340 DELEGATE_FIELD_CHILD(AtomicWait, ptr);
341 DELEGATE_FIELD_ADDRESS(AtomicWait, offset);
342 DELEGATE_FIELD_TYPE(AtomicWait, expectedType);
343 DELEGATE_FIELD_NAME_KIND(AtomicWait, memory, ModuleItemKind::Memory);
344 DELEGATE_END(AtomicWait);
345 break;
346 }
347 case Expression::Id::AtomicNotifyId: {
348 DELEGATE_START(AtomicNotify);
349 DELEGATE_FIELD_CHILD(AtomicNotify, notifyCount);
350 DELEGATE_FIELD_CHILD(AtomicNotify, ptr);
351 DELEGATE_FIELD_ADDRESS(AtomicNotify, offset);
352 DELEGATE_FIELD_NAME_KIND(AtomicNotify, memory, ModuleItemKind::Memory);
353 DELEGATE_END(AtomicNotify);
354 break;
355 }
356 case Expression::Id::AtomicFenceId: {
357 DELEGATE_START(AtomicFence);
358 DELEGATE_FIELD_INT(AtomicFence, order);
359 DELEGATE_END(AtomicFence);
360 break;
361 }
362 case Expression::Id::SIMDExtractId: {
363 DELEGATE_START(SIMDExtract);
364 DELEGATE_FIELD_CHILD(SIMDExtract, vec);
365 DELEGATE_FIELD_INT(SIMDExtract, op);
366 DELEGATE_FIELD_INT(SIMDExtract, index);
367 DELEGATE_END(SIMDExtract);
368 break;
369 }
370 case Expression::Id::SIMDReplaceId: {
371 DELEGATE_START(SIMDReplace);
372 DELEGATE_FIELD_CHILD(SIMDReplace, value);
373 DELEGATE_FIELD_CHILD(SIMDReplace, vec);
374 DELEGATE_FIELD_INT(SIMDReplace, op);
375 DELEGATE_FIELD_INT(SIMDReplace, index);
376 DELEGATE_END(SIMDReplace);
377 break;
378 }
379 case Expression::Id::SIMDShuffleId: {
380 DELEGATE_START(SIMDShuffle);
381 DELEGATE_FIELD_CHILD(SIMDShuffle, right);
382 DELEGATE_FIELD_CHILD(SIMDShuffle, left);
383 DELEGATE_FIELD_INT_ARRAY(SIMDShuffle, mask);
384 DELEGATE_END(SIMDShuffle);
385 break;
386 }
387 case Expression::Id::SIMDTernaryId: {
388 DELEGATE_START(SIMDTernary);
389 DELEGATE_FIELD_CHILD(SIMDTernary, c);
390 DELEGATE_FIELD_CHILD(SIMDTernary, b);
391 DELEGATE_FIELD_CHILD(SIMDTernary, a);
392 DELEGATE_FIELD_INT(SIMDTernary, op);
393 DELEGATE_END(SIMDTernary);
394 break;
395 }
396 case Expression::Id::SIMDShiftId: {
397 DELEGATE_START(SIMDShift);
398 DELEGATE_FIELD_CHILD(SIMDShift, shift);
399 DELEGATE_FIELD_CHILD(SIMDShift, vec);
400 DELEGATE_FIELD_INT(SIMDShift, op);
401 DELEGATE_END(SIMDShift);
402 break;
403 }
404 case Expression::Id::SIMDLoadId: {
405 DELEGATE_START(SIMDLoad);
406 DELEGATE_FIELD_CHILD(SIMDLoad, ptr);
407 DELEGATE_FIELD_INT(SIMDLoad, op);
408 DELEGATE_FIELD_ADDRESS(SIMDLoad, offset);
409 DELEGATE_FIELD_ADDRESS(SIMDLoad, align);
410 DELEGATE_FIELD_NAME_KIND(SIMDLoad, memory, ModuleItemKind::Memory);
411 DELEGATE_END(SIMDLoad);
412 break;
413 }
414 case Expression::Id::SIMDLoadStoreLaneId: {
415 DELEGATE_START(SIMDLoadStoreLane);
416 DELEGATE_FIELD_CHILD(SIMDLoadStoreLane, vec);
417 DELEGATE_FIELD_CHILD(SIMDLoadStoreLane, ptr);
418 DELEGATE_FIELD_INT(SIMDLoadStoreLane, op);
419 DELEGATE_FIELD_ADDRESS(SIMDLoadStoreLane, offset);
420 DELEGATE_FIELD_ADDRESS(SIMDLoadStoreLane, align);
421 DELEGATE_FIELD_INT(SIMDLoadStoreLane, index);
422 DELEGATE_FIELD_NAME_KIND(SIMDLoadStoreLane, memory, ModuleItemKind::Memory);
423 DELEGATE_END(SIMDLoadStoreLane);
424 break;
425 }
426 case Expression::Id::MemoryInitId: {
427 DELEGATE_START(MemoryInit);
428 DELEGATE_FIELD_CHILD(MemoryInit, size);
429 DELEGATE_FIELD_CHILD(MemoryInit, offset);
430 DELEGATE_FIELD_CHILD(MemoryInit, dest);
431 DELEGATE_FIELD_NAME_KIND(MemoryInit, segment, ModuleItemKind::DataSegment);
432 DELEGATE_FIELD_NAME_KIND(MemoryInit, memory, ModuleItemKind::Memory);
433 DELEGATE_END(MemoryInit);
434 break;
435 }
436 case Expression::Id::DataDropId: {
437 DELEGATE_START(DataDrop);
438 DELEGATE_FIELD_NAME_KIND(DataDrop, segment, ModuleItemKind::DataSegment);
439 DELEGATE_END(DataDrop);
440 break;
441 }
442 case Expression::Id::MemoryCopyId: {
443 DELEGATE_START(MemoryCopy);
444 DELEGATE_FIELD_CHILD(MemoryCopy, size);
445 DELEGATE_FIELD_CHILD(MemoryCopy, source);
446 DELEGATE_FIELD_CHILD(MemoryCopy, dest);
447 DELEGATE_FIELD_NAME_KIND(MemoryCopy, sourceMemory, ModuleItemKind::Memory);
448 DELEGATE_FIELD_NAME_KIND(MemoryCopy, destMemory, ModuleItemKind::Memory);
449 DELEGATE_END(MemoryCopy);
450 break;
451 }
452 case Expression::Id::MemoryFillId: {
453 DELEGATE_START(MemoryFill);
454 DELEGATE_FIELD_CHILD(MemoryFill, size);
455 DELEGATE_FIELD_CHILD(MemoryFill, value);
456 DELEGATE_FIELD_CHILD(MemoryFill, dest);
457 DELEGATE_FIELD_NAME_KIND(MemoryFill, memory, ModuleItemKind::Memory);
458 DELEGATE_END(MemoryFill);
459 break;
460 }
461 case Expression::Id::ConstId: {
462 DELEGATE_START(Const);
463 DELEGATE_FIELD_LITERAL(Const, value);
464 DELEGATE_END(Const);
465 break;
466 }
467 case Expression::Id::UnaryId: {
468 DELEGATE_START(Unary);
469 DELEGATE_FIELD_CHILD(Unary, value);
470 DELEGATE_FIELD_INT(Unary, op);
471 DELEGATE_END(Unary);
472 break;
473 }
474 case Expression::Id::BinaryId: {
475 DELEGATE_START(Binary);
476 DELEGATE_FIELD_CHILD(Binary, right);
477 DELEGATE_FIELD_CHILD(Binary, left);
478 DELEGATE_FIELD_INT(Binary, op);
479 DELEGATE_END(Binary);
480 break;
481 }
482 case Expression::Id::SelectId: {
483 DELEGATE_START(Select);
484 DELEGATE_FIELD_CHILD(Select, condition);
485 DELEGATE_FIELD_CHILD(Select, ifFalse);
486 DELEGATE_FIELD_CHILD(Select, ifTrue);
487 DELEGATE_END(Select);
488 break;
489 }
490 case Expression::Id::DropId: {
491 DELEGATE_START(Drop);
492 DELEGATE_FIELD_CHILD(Drop, value);
493 DELEGATE_END(Drop);
494 break;
495 }
496 case Expression::Id::ReturnId: {
497 DELEGATE_START(Return);
498 DELEGATE_FIELD_OPTIONAL_CHILD(Return, value);
499 DELEGATE_END(Return);
500 break;
501 }
502 case Expression::Id::MemorySizeId: {
503 DELEGATE_START(MemorySize);
504 DELEGATE_FIELD_TYPE(MemorySize, ptrType);
505 DELEGATE_FIELD_NAME_KIND(MemorySize, memory, ModuleItemKind::Memory);
506 DELEGATE_END(MemorySize);
507 break;
508 }
509 case Expression::Id::MemoryGrowId: {
510 DELEGATE_START(MemoryGrow);
511 DELEGATE_FIELD_TYPE(MemoryGrow, ptrType);
512 DELEGATE_FIELD_CHILD(MemoryGrow, delta);
513 DELEGATE_FIELD_NAME_KIND(MemoryGrow, memory, ModuleItemKind::Memory);
514 DELEGATE_END(MemoryGrow);
515 break;
516 }
517 case Expression::Id::RefNullId: {
518 DELEGATE_START(RefNull);
519 DELEGATE_END(RefNull);
520 break;
521 }
522 case Expression::Id::RefIsNullId: {
523 DELEGATE_START(RefIsNull);
524 DELEGATE_FIELD_CHILD(RefIsNull, value);
525 DELEGATE_END(RefIsNull);
526 break;
527 }
528 case Expression::Id::RefFuncId: {
529 DELEGATE_START(RefFunc);
530 DELEGATE_FIELD_NAME_KIND(RefFunc, func, ModuleItemKind::Function);
531 DELEGATE_END(RefFunc);
532 break;
533 }
534 case Expression::Id::RefEqId: {
535 DELEGATE_START(RefEq);
536 DELEGATE_FIELD_CHILD(RefEq, right);
537 DELEGATE_FIELD_CHILD(RefEq, left);
538 DELEGATE_END(RefEq);
539 break;
540 }
541 case Expression::Id::TableGetId: {
542 DELEGATE_START(TableGet);
543 DELEGATE_FIELD_CHILD(TableGet, index);
544 DELEGATE_FIELD_NAME_KIND(TableGet, table, ModuleItemKind::Table);
545 DELEGATE_END(TableGet);
546 break;
547 }
548 case Expression::Id::TableSetId: {
549 DELEGATE_START(TableSet);
550 DELEGATE_FIELD_CHILD(TableSet, value);
551 DELEGATE_FIELD_CHILD(TableSet, index);
552 DELEGATE_FIELD_NAME_KIND(TableSet, table, ModuleItemKind::Table);
553 DELEGATE_END(TableSet);
554 break;
555 }
556 case Expression::Id::TableSizeId: {
557 DELEGATE_START(TableSize);
558 DELEGATE_FIELD_NAME_KIND(TableSize, table, ModuleItemKind::Table);
559 DELEGATE_END(TableSize);
560 break;
561 }
562 case Expression::Id::TableGrowId: {
563 DELEGATE_START(TableGrow);
564 DELEGATE_FIELD_CHILD(TableGrow, delta);
565 DELEGATE_FIELD_CHILD(TableGrow, value);
566 DELEGATE_FIELD_NAME_KIND(TableGrow, table, ModuleItemKind::Table);
567 DELEGATE_END(TableGrow);
568 break;
569 }
570 case Expression::Id::TryId: {
571 DELEGATE_START(Try);
572 DELEGATE_FIELD_SCOPE_NAME_USE(Try, delegateTarget);
573 DELEGATE_FIELD_CHILD_VECTOR(Try, catchBodies);
574 DELEGATE_FIELD_NAME_KIND_VECTOR(Try, catchTags, ModuleItemKind::Tag);
575 DELEGATE_FIELD_SCOPE_NAME_DEF(Try, name);
576 DELEGATE_FIELD_CHILD(Try, body);
577 DELEGATE_END(Try);
578 break;
579 }
580 case Expression::Id::ThrowId: {
581 DELEGATE_START(Throw);
582 DELEGATE_FIELD_CHILD_VECTOR(Throw, operands);
583 DELEGATE_FIELD_NAME_KIND(Throw, tag, ModuleItemKind::Tag);
584 DELEGATE_END(Throw);
585 break;
586 }
587 case Expression::Id::RethrowId: {
588 DELEGATE_START(Rethrow);
589 DELEGATE_FIELD_SCOPE_NAME_USE(Rethrow, target);
590 DELEGATE_END(Rethrow);
591 break;
592 }
593 case Expression::Id::NopId: {
594 DELEGATE_START(Nop);
595 DELEGATE_END(Nop);
596 break;
597 }
598 case Expression::Id::UnreachableId: {
599 DELEGATE_START(Unreachable);
600 DELEGATE_END(Unreachable);
601 break;
602 }
603 case Expression::Id::PopId: {
604 DELEGATE_START(Pop);
605 DELEGATE_END(Pop);
606 break;
607 }
608 case Expression::Id::TupleMakeId: {
609 DELEGATE_START(TupleMake);
610 DELEGATE_FIELD_CHILD_VECTOR(Tuple, operands);
611 DELEGATE_END(TupleMake);
612 break;
613 }
614 case Expression::Id::TupleExtractId: {
615 DELEGATE_START(TupleExtract);
616 DELEGATE_FIELD_CHILD(TupleExtract, tuple);
617 DELEGATE_FIELD_INT(TupleExtract, index);
618 DELEGATE_END(TupleExtract);
619 break;
620 }
621 case Expression::Id::I31NewId: {
622 DELEGATE_START(I31New);
623 DELEGATE_FIELD_CHILD(I31New, value);
624 DELEGATE_END(I31New);
625 break;
626 }
627 case Expression::Id::I31GetId: {
628 DELEGATE_START(I31Get);
629 DELEGATE_FIELD_CHILD(I31Get, i31);
630 DELEGATE_FIELD_INT(I31Get, signed_);
631 DELEGATE_END(I31Get);
632 break;
633 }
634 case Expression::Id::CallRefId: {
635 DELEGATE_START(CallRef);
636 DELEGATE_FIELD_CHILD(CallRef, target);
637 DELEGATE_FIELD_CHILD_VECTOR(CallRef, operands);
638 DELEGATE_FIELD_INT(CallRef, isReturn);
639 DELEGATE_END(CallRef);
640 break;
641 }
642 case Expression::Id::RefTestId: {
643 DELEGATE_START(RefTest);
644 DELEGATE_FIELD_TYPE(RefTest, castType);
645 DELEGATE_FIELD_CHILD(RefTest, ref);
646 DELEGATE_END(RefTest);
647 break;
648 }
649 case Expression::Id::RefCastId: {
650 DELEGATE_START(RefCast);
651 DELEGATE_FIELD_INT(RefCast, safety);
652 DELEGATE_FIELD_CHILD(RefCast, ref);
653 DELEGATE_END(RefCast);
654 break;
655 }
656 case Expression::Id::BrOnId: {
657 DELEGATE_START(BrOn);
658 DELEGATE_FIELD_INT(BrOn, op);
659 DELEGATE_FIELD_SCOPE_NAME_USE(BrOn, name);
660 DELEGATE_FIELD_TYPE(BrOn, castType);
661 DELEGATE_FIELD_CHILD(BrOn, ref);
662 DELEGATE_END(BrOn);
663 break;
664 }
665 case Expression::Id::StructNewId: {
666 DELEGATE_START(StructNew);
667 DELEGATE_FIELD_CHILD_VECTOR(StructNew, operands);
668 DELEGATE_END(StructNew);
669 break;
670 }
671 case Expression::Id::StructGetId: {
672 DELEGATE_START(StructGet);
673 DELEGATE_FIELD_INT(StructGet, index);
674 DELEGATE_FIELD_CHILD(StructGet, ref);
675 DELEGATE_FIELD_INT(StructGet, signed_);
676 DELEGATE_END(StructGet);
677 break;
678 }
679 case Expression::Id::StructSetId: {
680 DELEGATE_START(StructSet);
681 DELEGATE_FIELD_INT(StructSet, index);
682 DELEGATE_FIELD_CHILD(StructSet, value);
683 DELEGATE_FIELD_CHILD(StructSet, ref);
684 DELEGATE_END(StructSet);
685 break;
686 }
687 case Expression::Id::ArrayNewId: {
688 DELEGATE_START(ArrayNew);
689 DELEGATE_FIELD_CHILD(ArrayNew, size);
690 DELEGATE_FIELD_OPTIONAL_CHILD(ArrayNew, init);
691 DELEGATE_END(ArrayNew);
692 break;
693 }
694 case Expression::Id::ArrayNewDataId: {
695 DELEGATE_START(ArrayNewData);
696 DELEGATE_FIELD_NAME_KIND(ArrayNewData, segment, ModuleItemKind::DataSegment);
697 DELEGATE_FIELD_CHILD(ArrayNewData, size);
698 DELEGATE_FIELD_CHILD(ArrayNewData, offset);
699 DELEGATE_END(ArrayNewData);
700 break;
701 }
702 case Expression::Id::ArrayNewElemId: {
703 DELEGATE_START(ArrayNewElem);
704 DELEGATE_FIELD_NAME_KIND(ArrayNewElem, segment, ModuleItemKind::ElementSegment);
705 DELEGATE_FIELD_CHILD(ArrayNewElem, size);
706 DELEGATE_FIELD_CHILD(ArrayNewElem, offset);
707 DELEGATE_END(ArrayNewElem);
708 break;
709 }
710 case Expression::Id::ArrayNewFixedId: {
711 DELEGATE_START(ArrayNewFixed);
712 DELEGATE_FIELD_CHILD_VECTOR(ArrayNewFixed, values);
713 DELEGATE_END(ArrayNewFixed);
714 break;
715 }
716 case Expression::Id::ArrayGetId: {
717 DELEGATE_START(ArrayGet);
718 DELEGATE_FIELD_CHILD(ArrayGet, index);
719 DELEGATE_FIELD_CHILD(ArrayGet, ref);
720 DELEGATE_FIELD_INT(ArrayGet, signed_);
721 DELEGATE_END(ArrayGet);
722 break;
723 }
724 case Expression::Id::ArraySetId: {
725 DELEGATE_START(ArraySet);
726 DELEGATE_FIELD_CHILD(ArrayGet, value);
727 DELEGATE_FIELD_CHILD(ArrayGet, index);
728 DELEGATE_FIELD_CHILD(ArrayGet, ref);
729 DELEGATE_END(ArraySet);
730 break;
731 }
732 case Expression::Id::ArrayLenId: {
733 DELEGATE_START(ArrayLen);
734 DELEGATE_FIELD_CHILD(ArrayLen, ref);
735 DELEGATE_END(ArrayLen);
736 break;
737 }
738 case Expression::Id::ArrayCopyId: {
739 DELEGATE_START(ArrayCopy);
740 DELEGATE_FIELD_CHILD(ArrayCopy, length);
741 DELEGATE_FIELD_CHILD(ArrayCopy, srcIndex);
742 DELEGATE_FIELD_CHILD(ArrayCopy, srcRef);
743 DELEGATE_FIELD_CHILD(ArrayCopy, destIndex);
744 DELEGATE_FIELD_CHILD(ArrayCopy, destRef);
745 DELEGATE_END(ArrayCopy);
746 break;
747 }
748 case Expression::Id::ArrayFillId: {
749 DELEGATE_START(ArrayFill);
750 DELEGATE_FIELD_CHILD(ArrayFill, size);
751 DELEGATE_FIELD_CHILD(ArrayFill, value);
752 DELEGATE_FIELD_CHILD(ArrayFill, index);
753 DELEGATE_FIELD_CHILD(ArrayFill, ref);
754 DELEGATE_END(ArrayFill);
755 break;
756 }
757 case Expression::Id::ArrayInitDataId: {
758 DELEGATE_START(ArrayInitData);
759 DELEGATE_FIELD_NAME_KIND(ArrayInitData, segment, ModuleItemKind::DataSegment);
760 DELEGATE_FIELD_CHILD(ArrayInitData, size);
761 DELEGATE_FIELD_CHILD(ArrayInitData, offset);
762 DELEGATE_FIELD_CHILD(ArrayInitData, index);
763 DELEGATE_FIELD_CHILD(ArrayInitData, ref);
764 DELEGATE_END(ArrayInitData);
765 break;
766 }
767 case Expression::Id::ArrayInitElemId: {
768 DELEGATE_START(ArrayInitElem);
769 DELEGATE_FIELD_NAME_KIND(ArrayInitElem, segment, ModuleItemKind::ElementSegment);
770 DELEGATE_FIELD_CHILD(ArrayInitElem, size);
771 DELEGATE_FIELD_CHILD(ArrayInitElem, offset);
772 DELEGATE_FIELD_CHILD(ArrayInitElem, index);
773 DELEGATE_FIELD_CHILD(ArrayInitElem, ref);
774 DELEGATE_END(ArrayInitElem);
775 break;
776 }
777 case Expression::Id::RefAsId: {
778 DELEGATE_START(RefAs);
779 DELEGATE_FIELD_INT(RefAs, op);
780 DELEGATE_FIELD_CHILD(RefAs, value);
781 DELEGATE_END(RefAs);
782 break;
783 }
784 case Expression::Id::StringNewId: {
785 DELEGATE_START(StringNew);
786 DELEGATE_FIELD_INT(StringNew, op);
787 DELEGATE_FIELD_INT(StringNew, try_);
788 DELEGATE_FIELD_OPTIONAL_CHILD(StringNew, end);
789 DELEGATE_FIELD_OPTIONAL_CHILD(StringNew, start);
790 DELEGATE_FIELD_OPTIONAL_CHILD(StringNew, length);
791 DELEGATE_FIELD_CHILD(StringNew, ptr);
792 DELEGATE_END(StringNew);
793 break;
794 }
795 case Expression::Id::StringConstId: {
796 DELEGATE_START(StringConst);
797 DELEGATE_FIELD_NAME(StringConst, string);
798 DELEGATE_END(StringConst);
799 break;
800 }
801 case Expression::Id::StringMeasureId: {
802 DELEGATE_START(StringMeasure);
803 DELEGATE_FIELD_INT(StringMeasure, op);
804 DELEGATE_FIELD_CHILD(StringMeasure, ref);
805 DELEGATE_END(StringMeasure);
806 break;
807 }
808 case Expression::Id::StringEncodeId: {
809 DELEGATE_START(StringEncode);
810 DELEGATE_FIELD_INT(StringEncode, op);
811 DELEGATE_FIELD_OPTIONAL_CHILD(StringEncode, start);
812 DELEGATE_FIELD_CHILD(StringEncode, ptr);
813 DELEGATE_FIELD_CHILD(StringEncode, ref);
814 DELEGATE_END(StringEncode);
815 break;
816 }
817 case Expression::Id::StringConcatId: {
818 DELEGATE_START(StringConcat);
819 DELEGATE_FIELD_CHILD(StringConcat, right);
820 DELEGATE_FIELD_CHILD(StringConcat, left);
821 DELEGATE_END(StringConcat);
822 break;
823 }
824 case Expression::Id::StringEqId: {
825 DELEGATE_START(StringEq);
826 DELEGATE_FIELD_INT(StringEq, op);
827 DELEGATE_FIELD_CHILD(StringEq, right);
828 DELEGATE_FIELD_CHILD(StringEq, left);
829 DELEGATE_END(StringEq);
830 break;
831 }
832 case Expression::Id::StringAsId: {
833 DELEGATE_START(StringAs);
834 DELEGATE_FIELD_INT(StringAs, op);
835 DELEGATE_FIELD_CHILD(StringAs, ref);
836 DELEGATE_END(StringAs);
837 break;
838 }
839 case Expression::Id::StringWTF8AdvanceId: {
840 DELEGATE_START(StringWTF8Advance);
841 DELEGATE_FIELD_CHILD(StringWTF8Advance, bytes);
842 DELEGATE_FIELD_CHILD(StringWTF8Advance, pos);
843 DELEGATE_FIELD_CHILD(StringWTF8Advance, ref);
844 DELEGATE_END(StringWTF8Advance);
845 break;
846 }
847 case Expression::Id::StringWTF16GetId: {
848 DELEGATE_START(StringWTF16Get);
849 DELEGATE_FIELD_CHILD(StringWTF16Get, pos);
850 DELEGATE_FIELD_CHILD(StringWTF16Get, ref);
851 DELEGATE_END(StringWTF16Get);
852 break;
853 }
854 case Expression::Id::StringIterNextId: {
855 DELEGATE_START(StringIterNext);
856 DELEGATE_FIELD_CHILD(StringIterNext, ref);
857 DELEGATE_END(StringIterNext);
858 break;
859 }
860 case Expression::Id::StringIterMoveId: {
861 DELEGATE_START(StringIterMove);
862 DELEGATE_FIELD_INT(StringIterMove, op);
863 DELEGATE_FIELD_CHILD(StringIterMove, num);
864 DELEGATE_FIELD_CHILD(StringIterMove, ref);
865 DELEGATE_END(StringIterMove);
866 break;
867 }
868 case Expression::Id::StringSliceWTFId: {
869 DELEGATE_START(StringSliceWTF);
870 DELEGATE_FIELD_INT(StringSliceWTF, op);
871 DELEGATE_FIELD_CHILD(StringSliceWTF, end);
872 DELEGATE_FIELD_CHILD(StringSliceWTF, start);
873 DELEGATE_FIELD_CHILD(StringSliceWTF, ref);
874 DELEGATE_END(StringSliceWTF);
875 break;
876 }
877 case Expression::Id::StringSliceIterId: {
878 DELEGATE_START(StringSliceIter);
879 DELEGATE_FIELD_CHILD(StringSliceIter, num);
880 DELEGATE_FIELD_CHILD(StringSliceIter, ref);
881 DELEGATE_END(StringSliceIter);
882 break;
883 }
884}
885
886#undef DELEGATE_ID
887#undef DELEGATE_START
888#undef DELEGATE_END
889#undef DELEGATE_FIELD_CHILD
890#undef DELEGATE_FIELD_OPTIONAL_CHILD
891#undef DELEGATE_FIELD_CHILD_VECTOR
892#undef DELEGATE_FIELD_INT
893#undef DELEGATE_FIELD_INT_ARRAY
894#undef DELEGATE_FIELD_LITERAL
895#undef DELEGATE_FIELD_NAME
896#undef DELEGATE_FIELD_NAME_VECTOR
897#undef DELEGATE_FIELD_SCOPE_NAME_DEF
898#undef DELEGATE_FIELD_SCOPE_NAME_USE
899#undef DELEGATE_FIELD_SCOPE_NAME_USE_VECTOR
900#undef DELEGATE_FIELD_NAME_KIND
901#undef DELEGATE_FIELD_NAME_KIND_VECTOR
902#undef DELEGATE_FIELD_TYPE
903#undef DELEGATE_FIELD_HEAPTYPE
904#undef DELEGATE_FIELD_ADDRESS
905#undef DELEGATE_GET_FIELD
906

source code of dart_sdk/third_party/binaryen/src/src/wasm-delegations-fields.def