-
-
Notifications
You must be signed in to change notification settings - Fork 664
/
builtins.ts
11225 lines (10520 loc) · 405 KB
/
builtins.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @fileoverview Built-in elements providing core WebAssembly functionality.
*
* Each builtin is linked to its definition in std/assembly/builtins.ts.
* When its prototype is called, the compiler recognizes the `@builtin`
* decorator, looks up the respective handler in the global builtins map
* and executes it, with the handler directly emitting WebAssembly code
* according to context.
*
* Builtins can be categorized into core builtins that typically are generic
* and emit code directly and aliases calling core builtins with overridden
* contexts. The latter is used by inline assembler aliases of WebAssembly
* instructions, like `i64.load8_u` deferring to `<i64>load<u8>`.
*
* The `contextIsExact` modifier is used to force a specific instruction
* family. A `i32.store8` deferring to `<i32>store<i8>` for example is
* ambiguous in that the input can still be an i32 or an i64, leading to
* either an `i32.store8` or an `i64.store8`, so `i32` is forced there.
* This behavior is indicated by `from i32/i64` in the comments below.
*
* @license Apache-2.0
*/
// TODO: Add builtins for `i32.add` etc. that do not have a core builtin.
import {
Compiler,
Constraints,
RuntimeFeatures,
UncheckedBehavior
} from "./compiler";
import {
DiagnosticCode,
DiagnosticCategory
} from "./diagnostics";
import {
Expression,
LiteralKind,
StringLiteralExpression,
CallExpression,
NodeKind,
LiteralExpression,
ArrayLiteralExpression,
IdentifierExpression
} from "./ast";
import {
Type,
TypeKind,
TypeFlags
} from "./types";
import {
BinaryOp,
UnaryOp,
AtomicRMWOp,
SIMDExtractOp,
SIMDReplaceOp,
SIMDShiftOp,
SIMDTernaryOp,
SIMDLoadOp,
SIMDLoadStoreLaneOp,
TypeRef,
ExpressionRef,
ExpressionId,
getExpressionId,
getExpressionType,
getConstValueI64High,
getConstValueI64Low,
getConstValueI32,
getConstValueF32,
getConstValueF64,
getLocalGetIndex,
createType,
ExpressionRunnerFlags,
mustPreserveSideEffects
} from "./module";
import {
ElementKind,
FunctionPrototype,
Global,
DecoratorFlags,
Class,
PropertyPrototype,
VariableLikeElement
} from "./program";
import {
FlowFlags,
LocalFlags
} from "./flow";
import {
ReportMode
} from "./resolver";
import {
CommonFlags,
Feature,
featureToString,
TypeinfoFlags
} from "./common";
import {
writeI8,
writeI16,
writeI32,
writeF32,
writeF64,
isPowerOf2
} from "./util";
/** Internal names of various compiler built-ins. */
export namespace BuiltinNames {
// compiler-generated
export const start = "~start";
export const started = "~started";
export const argumentsLength = "~argumentsLength";
export const setArgumentsLength = "~setArgumentsLength";
// std/builtins.ts
export const abort = "~lib/builtins/abort";
export const trace = "~lib/builtins/trace";
export const seed = "~lib/builtins/seed";
export const isBoolean = "~lib/builtins/isBoolean";
export const isInteger = "~lib/builtins/isInteger";
export const isSigned = "~lib/builtins/isSigned";
export const isFloat = "~lib/builtins/isFloat";
export const isVector = "~lib/builtins/isVector";
export const isReference = "~lib/builtins/isReference";
export const isString = "~lib/builtins/isString";
export const isArray = "~lib/builtins/isArray";
export const isArrayLike = "~lib/builtins/isArrayLike";
export const isFunction = "~lib/builtins/isFunction";
export const isNullable = "~lib/builtins/isNullable";
export const isDefined = "~lib/builtins/isDefined";
export const isConstant = "~lib/builtins/isConstant";
export const isManaged = "~lib/builtins/isManaged";
export const isVoid = "~lib/builtins/isVoid";
export const add = "~lib/builtins/add";
export const sub = "~lib/builtins/sub";
export const mul = "~lib/builtins/mul";
export const div = "~lib/builtins/div";
export const clz = "~lib/builtins/clz";
export const ctz = "~lib/builtins/ctz";
export const popcnt = "~lib/builtins/popcnt";
export const rotl = "~lib/builtins/rotl";
export const rotr = "~lib/builtins/rotr";
export const abs = "~lib/builtins/abs";
export const max = "~lib/builtins/max";
export const min = "~lib/builtins/min";
export const ceil = "~lib/builtins/ceil";
export const floor = "~lib/builtins/floor";
export const copysign = "~lib/builtins/copysign";
export const nearest = "~lib/builtins/nearest";
export const reinterpret = "~lib/builtins/reinterpret";
export const sqrt = "~lib/builtins/sqrt";
export const trunc = "~lib/builtins/trunc";
export const eq = "~lib/builtins/eq";
export const ne = "~lib/builtins/ne";
export const rem = "~lib/builtins/rem";
export const load = "~lib/builtins/load";
export const store = "~lib/builtins/store";
export const atomic_load = "~lib/builtins/atomic.load";
export const atomic_store = "~lib/builtins/atomic.store";
export const atomic_add = "~lib/builtins/atomic.add";
export const atomic_sub = "~lib/builtins/atomic.sub";
export const atomic_and = "~lib/builtins/atomic.and";
export const atomic_or = "~lib/builtins/atomic.or";
export const atomic_xor = "~lib/builtins/atomic.xor";
export const atomic_xchg = "~lib/builtins/atomic.xchg";
export const atomic_cmpxchg = "~lib/builtins/atomic.cmpxchg";
export const atomic_wait = "~lib/builtins/atomic.wait";
export const atomic_notify = "~lib/builtins/atomic.notify";
export const atomic_fence = "~lib/builtins/atomic.fence";
export const sizeof = "~lib/builtins/sizeof";
export const alignof = "~lib/builtins/alignof";
export const offsetof = "~lib/builtins/offsetof";
export const nameof = "~lib/builtins/nameof";
export const lengthof = "~lib/builtins/lengthof";
export const select = "~lib/builtins/select";
export const unreachable = "~lib/builtins/unreachable";
export const changetype = "~lib/builtins/changetype";
export const assert = "~lib/builtins/assert";
export const call_indirect = "~lib/builtins/call_indirect";
export const unchecked = "~lib/builtins/unchecked";
export const instantiate = "~lib/builtins/instantiate";
export const idof = "~lib/builtins/idof";
export const i8 = "~lib/builtins/i8";
export const i16 = "~lib/builtins/i16";
export const i32 = "~lib/builtins/i32";
export const i64 = "~lib/builtins/i64";
export const isize = "~lib/builtins/isize";
export const u8 = "~lib/builtins/u8";
export const u16 = "~lib/builtins/u16";
export const u32 = "~lib/builtins/u32";
export const u64 = "~lib/builtins/u64";
export const usize = "~lib/builtins/usize";
export const bool = "~lib/builtins/bool";
export const f32 = "~lib/builtins/f32";
export const f64 = "~lib/builtins/f64";
export const v128 = "~lib/builtins/v128";
export const i32_clz = "~lib/builtins/i32.clz";
export const i64_clz = "~lib/builtins/i64.clz";
export const i32_ctz = "~lib/builtins/i32.ctz";
export const i64_ctz = "~lib/builtins/i64.ctz";
export const i32_popcnt = "~lib/builtins/i32.popcnt";
export const i64_popcnt = "~lib/builtins/i64.popcnt";
export const i32_rotl = "~lib/builtins/i32.rotl";
export const i64_rotl = "~lib/builtins/i64.rotl";
export const i32_rotr = "~lib/builtins/i32.rotr";
export const i64_rotr = "~lib/builtins/i64.rotr";
export const f32_abs = "~lib/builtins/f32.abs";
export const f64_abs = "~lib/builtins/f64.abs";
export const f32_max = "~lib/builtins/f32.max";
export const f64_max = "~lib/builtins/f64.max";
export const f32_min = "~lib/builtins/f32.min";
export const f64_min = "~lib/builtins/f64.min";
export const f32_ceil = "~lib/builtins/f32.ceil";
export const f64_ceil = "~lib/builtins/f64.ceil";
export const f32_floor = "~lib/builtins/f32.floor";
export const f64_floor = "~lib/builtins/f64.floor";
export const f32_copysign = "~lib/builtins/f32.copysign";
export const f64_copysign = "~lib/builtins/f64.copysign";
export const f32_nearest = "~lib/builtins/f32.nearest";
export const f64_nearest = "~lib/builtins/f64.nearest";
export const i32_reinterpret_f32 = "~lib/builtins/i32.reinterpret_f32";
export const i64_reinterpret_f64 = "~lib/builtins/i64.reinterpret_f64";
export const f32_reinterpret_i32 = "~lib/builtins/f32.reinterpret_i32";
export const f64_reinterpret_i64 = "~lib/builtins/f64.reinterpret_i64";
export const f32_sqrt = "~lib/builtins/f32.sqrt";
export const f64_sqrt = "~lib/builtins/f64.sqrt";
export const f32_trunc = "~lib/builtins/f32.trunc";
export const f64_trunc = "~lib/builtins/f64.trunc";
export const i32_add = "~lib/builtins/i32.add";
export const i64_add = "~lib/builtins/i64.add";
export const f32_add = "~lib/builtins/f32.add";
export const f64_add = "~lib/builtins/f64.add";
export const i32_sub = "~lib/builtins/i32.sub";
export const i64_sub = "~lib/builtins/i64.sub";
export const f32_sub = "~lib/builtins/f32.sub";
export const f64_sub = "~lib/builtins/f64.sub";
export const i32_mul = "~lib/builtins/i32.mul";
export const i64_mul = "~lib/builtins/i64.mul";
export const f32_mul = "~lib/builtins/f32.mul";
export const f64_mul = "~lib/builtins/f64.mul";
export const i32_div_s = "~lib/builtins/i32.div_s";
export const i32_div_u = "~lib/builtins/i32.div_u";
export const i64_div_s = "~lib/builtins/i64.div_s";
export const i64_div_u = "~lib/builtins/i64.div_u";
export const f32_div = "~lib/builtins/f32.div";
export const f64_div = "~lib/builtins/f64.div";
export const i32_eq = "~lib/builtins/i32.eq";
export const i64_eq = "~lib/builtins/i64.eq";
export const f32_eq = "~lib/builtins/f32.eq";
export const f64_eq = "~lib/builtins/f64.eq";
export const i32_ne = "~lib/builtins/i32.ne";
export const i64_ne = "~lib/builtins/i64.ne";
export const f32_ne = "~lib/builtins/f32.ne";
export const f64_ne = "~lib/builtins/f64.ne";
export const i32_rem_s = "~lib/builtins/i32.rem_s";
export const i32_rem_u = "~lib/builtins/i32.rem_u";
export const i64_rem_s = "~lib/builtins/i64.rem_s";
export const i64_rem_u = "~lib/builtins/i64.rem_u";
export const i32_load8_s = "~lib/builtins/i32.load8_s";
export const i32_load8_u = "~lib/builtins/i32.load8_u";
export const i32_load16_s = "~lib/builtins/i32.load16_s";
export const i32_load16_u = "~lib/builtins/i32.load16_u";
export const i32_load = "~lib/builtins/i32.load";
export const i64_load8_s = "~lib/builtins/i64.load8_s";
export const i64_load8_u = "~lib/builtins/i64.load8_u";
export const i64_load16_s = "~lib/builtins/i64.load16_s";
export const i64_load16_u = "~lib/builtins/i64.load16_u";
export const i64_load32_s = "~lib/builtins/i64.load32_s";
export const i64_load32_u = "~lib/builtins/i64.load32_u";
export const i64_load = "~lib/builtins/i64.load";
export const f32_load = "~lib/builtins/f32.load";
export const f64_load = "~lib/builtins/f64.load";
export const i32_store8 = "~lib/builtins/i32.store8";
export const i32_store16 = "~lib/builtins/i32.store16";
export const i32_store = "~lib/builtins/i32.store";
export const i64_store8 = "~lib/builtins/i64.store8";
export const i64_store16 = "~lib/builtins/i64.store16";
export const i64_store32 = "~lib/builtins/i64.store32";
export const i64_store = "~lib/builtins/i64.store";
export const f32_store = "~lib/builtins/f32.store";
export const f64_store = "~lib/builtins/f64.store";
export const i32_atomic_load8_u = "~lib/builtins/i32.atomic.load8_u";
export const i32_atomic_load16_u = "~lib/builtins/i32.atomic.load16_u";
export const i32_atomic_load = "~lib/builtins/i32.atomic.load";
export const i64_atomic_load8_u = "~lib/builtins/i64.atomic.load8_u";
export const i64_atomic_load16_u = "~lib/builtins/i64.atomic.load16_u";
export const i64_atomic_load32_u = "~lib/builtins/i64.atomic.load32_u";
export const i64_atomic_load = "~lib/builtins/i64.atomic.load";
export const i32_atomic_store8 = "~lib/builtins/i32.atomic.store8";
export const i32_atomic_store16 = "~lib/builtins/i32.atomic.store16";
export const i32_atomic_store = "~lib/builtins/i32.atomic.store";
export const i64_atomic_store8 = "~lib/builtins/i64.atomic.store8";
export const i64_atomic_store16 = "~lib/builtins/i64.atomic.store16";
export const i64_atomic_store32 = "~lib/builtins/i64.atomic.store32";
export const i64_atomic_store = "~lib/builtins/i64.atomic.store";
export const i32_atomic_rmw8_add_u = "~lib/builtins/i32.atomic.rmw8.add_u";
export const i32_atomic_rmw16_add_u = "~lib/builtins/i32.atomic.rmw16.add_u";
export const i32_atomic_rmw_add = "~lib/builtins/i32.atomic.rmw.add";
export const i64_atomic_rmw8_add_u = "~lib/builtins/i64.atomic.rmw8.add_u";
export const i64_atomic_rmw16_add_u = "~lib/builtins/i64.atomic.rmw16.add_u";
export const i64_atomic_rmw32_add_u = "~lib/builtins/i64.atomic.rmw32.add_u";
export const i64_atomic_rmw_add = "~lib/builtins/i64.atomic.rmw.add";
export const i32_atomic_rmw8_sub_u = "~lib/builtins/i32.atomic.rmw8.sub_u";
export const i32_atomic_rmw16_sub_u = "~lib/builtins/i32.atomic.rmw16.sub_u";
export const i32_atomic_rmw_sub = "~lib/builtins/i32.atomic.rmw.sub";
export const i64_atomic_rmw8_sub_u = "~lib/builtins/i64.atomic.rmw8.sub_u";
export const i64_atomic_rmw16_sub_u = "~lib/builtins/i64.atomic.rmw16.sub_u";
export const i64_atomic_rmw32_sub_u = "~lib/builtins/i64.atomic.rmw32.sub_u";
export const i64_atomic_rmw_sub = "~lib/builtins/i64.atomic.rmw.sub";
export const i32_atomic_rmw8_and_u = "~lib/builtins/i32.atomic.rmw8.and_u";
export const i32_atomic_rmw16_and_u = "~lib/builtins/i32.atomic.rmw16.and_u";
export const i32_atomic_rmw_and = "~lib/builtins/i32.atomic.rmw.and";
export const i64_atomic_rmw8_and_u = "~lib/builtins/i64.atomic.rmw8.and_u";
export const i64_atomic_rmw16_and_u = "~lib/builtins/i64.atomic.rmw16.and_u";
export const i64_atomic_rmw32_and_u = "~lib/builtins/i64.atomic.rmw32.and_u";
export const i64_atomic_rmw_and = "~lib/builtins/i64.atomic.rmw.and";
export const i32_atomic_rmw8_or_u = "~lib/builtins/i32.atomic.rmw8.or_u";
export const i32_atomic_rmw16_or_u = "~lib/builtins/i32.atomic.rmw16.or_u";
export const i32_atomic_rmw_or = "~lib/builtins/i32.atomic.rmw.or";
export const i64_atomic_rmw8_or_u = "~lib/builtins/i64.atomic.rmw8.or_u";
export const i64_atomic_rmw16_or_u = "~lib/builtins/i64.atomic.rmw16.or_u";
export const i64_atomic_rmw32_or_u = "~lib/builtins/i64.atomic.rmw32.or_u";
export const i64_atomic_rmw_or = "~lib/builtins/i64.atomic.rmw.or";
export const i32_atomic_rmw8_xor_u = "~lib/builtins/i32.atomic.rmw8.xor_u";
export const i32_atomic_rmw16_xor_u = "~lib/builtins/i32.atomic.rmw16.xor_u";
export const i32_atomic_rmw_xor = "~lib/builtins/i32.atomic.rmw.xor";
export const i64_atomic_rmw8_xor_u = "~lib/builtins/i64.atomic.rmw8.xor_u";
export const i64_atomic_rmw16_xor_u = "~lib/builtins/i64.atomic.rmw16.xor_u";
export const i64_atomic_rmw32_xor_u = "~lib/builtins/i64.atomic.rmw32.xor_u";
export const i64_atomic_rmw_xor = "~lib/builtins/i64.atomic.rmw.xor";
export const i32_atomic_rmw8_xchg_u = "~lib/builtins/i32.atomic.rmw8.xchg_u";
export const i32_atomic_rmw16_xchg_u = "~lib/builtins/i32.atomic.rmw16.xchg_u";
export const i32_atomic_rmw_xchg = "~lib/builtins/i32.atomic.rmw.xchg";
export const i64_atomic_rmw8_xchg_u = "~lib/builtins/i64.atomic.rmw8.xchg_u";
export const i64_atomic_rmw16_xchg_u = "~lib/builtins/i64.atomic.rmw16.xchg_u";
export const i64_atomic_rmw32_xchg_u = "~lib/builtins/i64.atomic.rmw32.xchg_u";
export const i64_atomic_rmw_xchg = "~lib/builtins/i64.atomic.rmw.xchg";
export const i32_atomic_rmw8_cmpxchg_u = "~lib/builtins/i32.atomic.rmw8.cmpxchg_u";
export const i32_atomic_rmw16_cmpxchg_u = "~lib/builtins/i32.atomic.rmw16.cmpxchg_u";
export const i32_atomic_rmw_cmpxchg = "~lib/builtins/i32.atomic.rmw.cmpxchg";
export const i64_atomic_rmw8_cmpxchg_u = "~lib/builtins/i64.atomic.rmw8.cmpxchg_u";
export const i64_atomic_rmw16_cmpxchg_u = "~lib/builtins/i64.atomic.rmw16.cmpxchg_u";
export const i64_atomic_rmw32_cmpxchg_u = "~lib/builtins/i64.atomic.rmw32.cmpxchg_u";
export const i64_atomic_rmw_cmpxchg = "~lib/builtins/i64.atomic.rmw.cmpxchg";
export const memory_atomic_wait32 = "~lib/memory/memory.atomic.wait32";
export const memory_atomic_wait64 = "~lib/memory/memory.atomic.wait64";
export const v128_splat = "~lib/builtins/v128.splat";
export const v128_extract_lane = "~lib/builtins/v128.extract_lane";
export const v128_replace_lane = "~lib/builtins/v128.replace_lane";
export const v128_shuffle = "~lib/builtins/v128.shuffle";
export const v128_swizzle = "~lib/builtins/v128.swizzle";
export const v128_load_splat = "~lib/builtins/v128.load_splat";
export const v128_load_ext = "~lib/builtins/v128.load_ext";
export const v128_load_zero = "~lib/builtins/v128.load_zero";
export const v128_load_lane = "~lib/builtins/v128.load_lane";
export const v128_store_lane = "~lib/builtins/v128.store_lane";
export const v128_load = "~lib/builtins/v128.load";
export const v128_load8x8_s = "~lib/builtins/v128.load8x8_s";
export const v128_load8x8_u = "~lib/builtins/v128.load8x8_u";
export const v128_load16x4_s = "~lib/builtins/v128.load16x4_s";
export const v128_load16x4_u = "~lib/builtins/v128.load16x4_u";
export const v128_load32x2_s = "~lib/builtins/v128.load32x2_s";
export const v128_load32x2_u = "~lib/builtins/v128.load32x2_u";
export const v128_load8_splat = "~lib/builtins/v128.load8_splat";
export const v128_load16_splat = "~lib/builtins/v128.load16_splat";
export const v128_load32_splat = "~lib/builtins/v128.load32_splat";
export const v128_load64_splat = "~lib/builtins/v128.load64_splat";
export const v128_load32_zero = "~lib/builtins/v128.load32_zero";
export const v128_load64_zero = "~lib/builtins/v128.load64_zero";
export const v128_load8_lane = "~lib/builtins/v128.load8_lane";
export const v128_load16_lane = "~lib/builtins/v128.load16_lane";
export const v128_load32_lane = "~lib/builtins/v128.load32_lane";
export const v128_load64_lane = "~lib/builtins/v128.load64_lane";
export const v128_store8_lane = "~lib/builtins/v128.store8_lane";
export const v128_store16_lane = "~lib/builtins/v128.store16_lane";
export const v128_store32_lane = "~lib/builtins/v128.store32_lane";
export const v128_store64_lane = "~lib/builtins/v128.store64_lane";
export const v128_store = "~lib/builtins/v128.store";
export const v128_add = "~lib/builtins/v128.add";
export const v128_sub = "~lib/builtins/v128.sub";
export const v128_mul = "~lib/builtins/v128.mul";
export const v128_div = "~lib/builtins/v128.div";
export const v128_neg = "~lib/builtins/v128.neg";
export const v128_add_sat = "~lib/builtins/v128.add_sat";
export const v128_sub_sat = "~lib/builtins/v128.sub_sat";
export const v128_shl = "~lib/builtins/v128.shl";
export const v128_shr = "~lib/builtins/v128.shr";
export const v128_and = "~lib/builtins/v128.and";
export const v128_or = "~lib/builtins/v128.or";
export const v128_xor = "~lib/builtins/v128.xor";
export const v128_andnot = "~lib/builtins/v128.andnot";
export const v128_not = "~lib/builtins/v128.not";
export const v128_bitselect = "~lib/builtins/v128.bitselect";
export const v128_any_true = "~lib/builtins/v128.any_true";
export const v128_all_true = "~lib/builtins/v128.all_true";
export const v128_bitmask = "~lib/builtins/v128.bitmask";
export const v128_popcnt = "~lib/builtins/v128.popcnt";
export const v128_min = "~lib/builtins/v128.min";
export const v128_max = "~lib/builtins/v128.max";
export const v128_pmin = "~lib/builtins/v128.pmin";
export const v128_pmax = "~lib/builtins/v128.pmax";
export const v128_dot = "~lib/builtins/v128.dot";
export const v128_avgr = "~lib/builtins/v128.avgr";
export const v128_abs = "~lib/builtins/v128.abs";
export const v128_sqrt = "~lib/builtins/v128.sqrt";
export const v128_ceil = "~lib/builtins/v128.ceil";
export const v128_floor = "~lib/builtins/v128.floor";
export const v128_trunc = "~lib/builtins/v128.trunc";
export const v128_nearest = "~lib/builtins/v128.nearest";
export const v128_eq = "~lib/builtins/v128.eq";
export const v128_ne = "~lib/builtins/v128.ne";
export const v128_lt = "~lib/builtins/v128.lt";
export const v128_le = "~lib/builtins/v128.le";
export const v128_gt = "~lib/builtins/v128.gt";
export const v128_ge = "~lib/builtins/v128.ge";
export const v128_convert = "~lib/builtins/v128.convert";
export const v128_convert_low = "~lib/builtins/v128.convert_low";
export const v128_trunc_sat = "~lib/builtins/v128.trunc_sat";
export const v128_trunc_sat_zero = "~lib/builtins/v128.trunc_sat_zero";
export const v128_narrow = "~lib/builtins/v128.narrow";
export const v128_extend_low = "~lib/builtins/v128.extend_low";
export const v128_extend_high = "~lib/builtins/v128.extend_high";
export const v128_extadd_pairwise = "~lib/builtins/v128.extadd_pairwise";
export const v128_demote_zero = "~lib/builtins/v128.demote_zero";
export const v128_promote_low = "~lib/builtins/v128.promote_low";
export const v128_q15mulr_sat = "~lib/builtins/v128.q15mulr_sat";
export const v128_extmul_low = "~lib/builtins/v128.extmul_low";
export const v128_extmul_high = "~lib/builtins/v128.extmul_high";
export const v128_relaxed_swizzle = "~lib/builtins/v128.relaxed_swizzle";
export const v128_relaxed_trunc = "~lib/builtins/v128.relaxed_trunc";
export const v128_relaxed_trunc_zero = "~lib/builtins/v128.relaxed_trunc_zero";
export const v128_relaxed_madd = "~lib/builtins/v128.relaxed_madd";
export const v128_relaxed_nmadd = "~lib/builtins/v128.relaxed_nmadd";
export const v128_relaxed_laneselect = "~lib/builtins/v128.relaxed_laneselect";
export const v128_relaxed_min = "~lib/builtins/v128.relaxed_min";
export const v128_relaxed_max = "~lib/builtins/v128.relaxed_max";
export const v128_relaxed_q15mulr = "~lib/builtins/v128.relaxed_q15mulr";
export const v128_relaxed_dot = "~lib/builtins/v128.relaxed_dot";
export const v128_relaxed_dot_add = "~lib/builtins/v128.relaxed_dot_add";
export const i8x16 = "~lib/builtins/i8x16";
export const i16x8 = "~lib/builtins/i16x8";
export const i32x4 = "~lib/builtins/i32x4";
export const i64x2 = "~lib/builtins/i64x2";
export const f32x4 = "~lib/builtins/f32x4";
export const f64x2 = "~lib/builtins/f64x2";
export const i8x16_splat = "~lib/builtins/i8x16.splat";
export const i8x16_extract_lane_s = "~lib/builtins/i8x16.extract_lane_s";
export const i8x16_extract_lane_u = "~lib/builtins/i8x16.extract_lane_u";
export const i8x16_replace_lane = "~lib/builtins/i8x16.replace_lane";
export const i8x16_add = "~lib/builtins/i8x16.add";
export const i8x16_sub = "~lib/builtins/i8x16.sub";
export const i8x16_mul = "~lib/builtins/i8x16.mul";
export const i8x16_min_s = "~lib/builtins/i8x16.min_s";
export const i8x16_min_u = "~lib/builtins/i8x16.min_u";
export const i8x16_max_s = "~lib/builtins/i8x16.max_s";
export const i8x16_max_u = "~lib/builtins/i8x16.max_u";
export const i8x16_avgr_u = "~lib/builtins/i8x16.avgr_u";
export const i8x16_abs = "~lib/builtins/i8x16.abs";
export const i8x16_neg = "~lib/builtins/i8x16.neg";
export const i8x16_add_sat_s = "~lib/builtins/i8x16.add_sat_s";
export const i8x16_add_sat_u = "~lib/builtins/i8x16.add_sat_u";
export const i8x16_sub_sat_s = "~lib/builtins/i8x16.sub_sat_s";
export const i8x16_sub_sat_u = "~lib/builtins/i8x16.sub_sat_u";
export const i8x16_shl = "~lib/builtins/i8x16.shl";
export const i8x16_shr_s = "~lib/builtins/i8x16.shr_s";
export const i8x16_shr_u = "~lib/builtins/i8x16.shr_u";
export const i8x16_all_true = "~lib/builtins/i8x16.all_true";
export const i8x16_bitmask = "~lib/builtins/i8x16.bitmask";
export const i8x16_popcnt = "~lib/builtins/i8x16.popcnt";
export const i8x16_eq = "~lib/builtins/i8x16.eq";
export const i8x16_ne = "~lib/builtins/i8x16.ne";
export const i8x16_lt_s = "~lib/builtins/i8x16.lt_s";
export const i8x16_lt_u = "~lib/builtins/i8x16.lt_u";
export const i8x16_le_s = "~lib/builtins/i8x16.le_s";
export const i8x16_le_u = "~lib/builtins/i8x16.le_u";
export const i8x16_gt_s = "~lib/builtins/i8x16.gt_s";
export const i8x16_gt_u = "~lib/builtins/i8x16.gt_u";
export const i8x16_ge_s = "~lib/builtins/i8x16.ge_s";
export const i8x16_ge_u = "~lib/builtins/i8x16.ge_u";
export const i8x16_narrow_i16x8_s = "~lib/builtins/i8x16.narrow_i16x8_s";
export const i8x16_narrow_i16x8_u = "~lib/builtins/i8x16.narrow_i16x8_u";
export const i8x16_shuffle = "~lib/builtins/i8x16.shuffle";
export const i8x16_swizzle = "~lib/builtins/i8x16.swizzle";
export const i16x8_splat = "~lib/builtins/i16x8.splat";
export const i16x8_extract_lane_s = "~lib/builtins/i16x8.extract_lane_s";
export const i16x8_extract_lane_u = "~lib/builtins/i16x8.extract_lane_u";
export const i16x8_replace_lane = "~lib/builtins/i16x8.replace_lane";
export const i16x8_add = "~lib/builtins/i16x8.add";
export const i16x8_sub = "~lib/builtins/i16x8.sub";
export const i16x8_mul = "~lib/builtins/i16x8.mul";
export const i16x8_min_s = "~lib/builtins/i16x8.min_s";
export const i16x8_min_u = "~lib/builtins/i16x8.min_u";
export const i16x8_max_s = "~lib/builtins/i16x8.max_s";
export const i16x8_max_u = "~lib/builtins/i16x8.max_u";
export const i16x8_avgr_u = "~lib/builtins/i16x8.avgr_u";
export const i16x8_abs = "~lib/builtins/i16x8.abs";
export const i16x8_neg = "~lib/builtins/i16x8.neg";
export const i16x8_add_sat_s = "~lib/builtins/i16x8.add_sat_s";
export const i16x8_add_sat_u = "~lib/builtins/i16x8.add_sat_u";
export const i16x8_sub_sat_s = "~lib/builtins/i16x8.sub_sat_s";
export const i16x8_sub_sat_u = "~lib/builtins/i16x8.sub_sat_u";
export const i16x8_shl = "~lib/builtins/i16x8.shl";
export const i16x8_shr_s = "~lib/builtins/i16x8.shr_s";
export const i16x8_shr_u = "~lib/builtins/i16x8.shr_u";
export const i16x8_all_true = "~lib/builtins/i16x8.all_true";
export const i16x8_bitmask = "~lib/builtins/i16x8.bitmask";
export const i16x8_eq = "~lib/builtins/i16x8.eq";
export const i16x8_ne = "~lib/builtins/i16x8.ne";
export const i16x8_lt_s = "~lib/builtins/i16x8.lt_s";
export const i16x8_lt_u = "~lib/builtins/i16x8.lt_u";
export const i16x8_le_s = "~lib/builtins/i16x8.le_s";
export const i16x8_le_u = "~lib/builtins/i16x8.le_u";
export const i16x8_gt_s = "~lib/builtins/i16x8.gt_s";
export const i16x8_gt_u = "~lib/builtins/i16x8.gt_u";
export const i16x8_ge_s = "~lib/builtins/i16x8.ge_s";
export const i16x8_ge_u = "~lib/builtins/i16x8.ge_u";
export const i16x8_narrow_i32x4_s = "~lib/builtins/i16x8.narrow_i32x4_s";
export const i16x8_narrow_i32x4_u = "~lib/builtins/i16x8.narrow_i32x4_u";
export const i16x8_extend_low_i8x16_s = "~lib/builtins/i16x8.extend_low_i8x16_s";
export const i16x8_extend_low_i8x16_u = "~lib/builtins/i16x8.extend_low_i8x16_u";
export const i16x8_extend_high_i8x16_s = "~lib/builtins/i16x8.extend_high_i8x16_s";
export const i16x8_extend_high_i8x16_u = "~lib/builtins/i16x8.extend_high_i8x16_u";
export const i16x8_extadd_pairwise_i8x16_s = "~lib/builtins/i16x8.extadd_pairwise_i8x16_s";
export const i16x8_extadd_pairwise_i8x16_u = "~lib/builtins/i16x8.extadd_pairwise_i8x16_u";
export const i16x8_q15mulr_sat_s = "~lib/builtins/i16x8.q15mulr_sat_s";
export const i16x8_extmul_low_i8x16_s = "~lib/builtins/i16x8.extmul_low_i8x16_s";
export const i16x8_extmul_low_i8x16_u = "~lib/builtins/i16x8.extmul_low_i8x16_u";
export const i16x8_extmul_high_i8x16_s = "~lib/builtins/i16x8.extmul_high_i8x16_s";
export const i16x8_extmul_high_i8x16_u = "~lib/builtins/i16x8.extmul_high_i8x16_u";
export const i16x8_shuffle = "~lib/builtins/i16x8.shuffle";
export const i32x4_splat = "~lib/builtins/i32x4.splat";
export const i32x4_extract_lane = "~lib/builtins/i32x4.extract_lane";
export const i32x4_replace_lane = "~lib/builtins/i32x4.replace_lane";
export const i32x4_add = "~lib/builtins/i32x4.add";
export const i32x4_sub = "~lib/builtins/i32x4.sub";
export const i32x4_mul = "~lib/builtins/i32x4.mul";
export const i32x4_min_s = "~lib/builtins/i32x4.min_s";
export const i32x4_min_u = "~lib/builtins/i32x4.min_u";
export const i32x4_max_s = "~lib/builtins/i32x4.max_s";
export const i32x4_max_u = "~lib/builtins/i32x4.max_u";
export const i32x4_dot_i16x8_s = "~lib/builtins/i32x4.dot_i16x8_s";
export const i32x4_abs = "~lib/builtins/i32x4.abs";
export const i32x4_neg = "~lib/builtins/i32x4.neg";
export const i32x4_shl = "~lib/builtins/i32x4.shl";
export const i32x4_shr_s = "~lib/builtins/i32x4.shr_s";
export const i32x4_shr_u = "~lib/builtins/i32x4.shr_u";
export const i32x4_all_true = "~lib/builtins/i32x4.all_true";
export const i32x4_bitmask = "~lib/builtins/i32x4.bitmask";
export const i32x4_eq = "~lib/builtins/i32x4.eq";
export const i32x4_ne = "~lib/builtins/i32x4.ne";
export const i32x4_lt_s = "~lib/builtins/i32x4.lt_s";
export const i32x4_lt_u = "~lib/builtins/i32x4.lt_u";
export const i32x4_le_s = "~lib/builtins/i32x4.le_s";
export const i32x4_le_u = "~lib/builtins/i32x4.le_u";
export const i32x4_gt_s = "~lib/builtins/i32x4.gt_s";
export const i32x4_gt_u = "~lib/builtins/i32x4.gt_u";
export const i32x4_ge_s = "~lib/builtins/i32x4.ge_s";
export const i32x4_ge_u = "~lib/builtins/i32x4.ge_u";
export const i32x4_trunc_sat_f32x4_s = "~lib/builtins/i32x4.trunc_sat_f32x4_s";
export const i32x4_trunc_sat_f32x4_u = "~lib/builtins/i32x4.trunc_sat_f32x4_u";
export const i32x4_trunc_sat_f64x2_s_zero = "~lib/builtins/i32x4.trunc_sat_f64x2_s_zero";
export const i32x4_trunc_sat_f64x2_u_zero = "~lib/builtins/i32x4.trunc_sat_f64x2_u_zero";
export const i32x4_extend_low_i16x8_s = "~lib/builtins/i32x4.extend_low_i16x8_s";
export const i32x4_extend_low_i16x8_u = "~lib/builtins/i32x4.extend_low_i16x8_u";
export const i32x4_extend_high_i16x8_s = "~lib/builtins/i32x4.extend_high_i16x8_s";
export const i32x4_extend_high_i16x8_u = "~lib/builtins/i32x4.extend_high_i16x8_u";
export const i32x4_extadd_pairwise_i16x8_s = "~lib/builtins/i32x4.extadd_pairwise_i16x8_s";
export const i32x4_extadd_pairwise_i16x8_u = "~lib/builtins/i32x4.extadd_pairwise_i16x8_u";
export const i32x4_extmul_low_i16x8_s = "~lib/builtins/i32x4.extmul_low_i16x8_s";
export const i32x4_extmul_low_i16x8_u = "~lib/builtins/i32x4.extmul_low_i16x8_u";
export const i32x4_extmul_high_i16x8_s = "~lib/builtins/i32x4.extmul_high_i16x8_s";
export const i32x4_extmul_high_i16x8_u = "~lib/builtins/i32x4.extmul_high_i16x8_u";
export const i32x4_shuffle = "~lib/builtins/i32x4.shuffle";
export const i64x2_splat = "~lib/builtins/i64x2.splat";
export const i64x2_extract_lane = "~lib/builtins/i64x2.extract_lane";
export const i64x2_replace_lane = "~lib/builtins/i64x2.replace_lane";
export const i64x2_add = "~lib/builtins/i64x2.add";
export const i64x2_sub = "~lib/builtins/i64x2.sub";
export const i64x2_mul = "~lib/builtins/i64x2.mul";
export const i64x2_abs = "~lib/builtins/i64x2.abs";
export const i64x2_neg = "~lib/builtins/i64x2.neg";
export const i64x2_shl = "~lib/builtins/i64x2.shl";
export const i64x2_shr_s = "~lib/builtins/i64x2.shr_s";
export const i64x2_shr_u = "~lib/builtins/i64x2.shr_u";
export const i64x2_all_true = "~lib/builtins/i64x2.all_true";
export const i64x2_bitmask = "~lib/builtins/i64x2.bitmask";
export const i64x2_eq = "~lib/builtins/i64x2.eq";
export const i64x2_ne = "~lib/builtins/i64x2.ne";
export const i64x2_lt_s = "~lib/builtins/i64x2.lt_s";
export const i64x2_lt_u = "~lib/builtins/i64x2.lt_u";
export const i64x2_le_s = "~lib/builtins/i64x2.le_s";
export const i64x2_le_u = "~lib/builtins/i64x2.le_u";
export const i64x2_gt_s = "~lib/builtins/i64x2.gt_s";
export const i64x2_gt_u = "~lib/builtins/i64x2.gt_u";
export const i64x2_ge_s = "~lib/builtins/i64x2.ge_s";
export const i64x2_ge_u = "~lib/builtins/i64x2.ge_u";
export const i64x2_extend_low_i32x4_s = "~lib/builtins/i64x2.extend_low_i32x4_s";
export const i64x2_extend_low_i32x4_u = "~lib/builtins/i64x2.extend_low_i32x4_u";
export const i64x2_extend_high_i32x4_s = "~lib/builtins/i64x2.extend_high_i32x4_s";
export const i64x2_extend_high_i32x4_u = "~lib/builtins/i64x2.extend_high_i32x4_u";
export const i64x2_extmul_low_i32x4_s = "~lib/builtins/i64x2.extmul_low_i32x4_s";
export const i64x2_extmul_low_i32x4_u = "~lib/builtins/i64x2.extmul_low_i32x4_u";
export const i64x2_extmul_high_i32x4_s = "~lib/builtins/i64x2.extmul_high_i32x4_s";
export const i64x2_extmul_high_i32x4_u = "~lib/builtins/i64x2.extmul_high_i32x4_u";
export const i64x2_shuffle = "~lib/builtins/i64x2.shuffle";
export const f32x4_splat = "~lib/builtins/f32x4.splat";
export const f32x4_extract_lane = "~lib/builtins/f32x4.extract_lane";
export const f32x4_replace_lane = "~lib/builtins/f32x4.replace_lane";
export const f32x4_add = "~lib/builtins/f32x4.add";
export const f32x4_sub = "~lib/builtins/f32x4.sub";
export const f32x4_mul = "~lib/builtins/f32x4.mul";
export const f32x4_div = "~lib/builtins/f32x4.div";
export const f32x4_neg = "~lib/builtins/f32x4.neg";
export const f32x4_min = "~lib/builtins/f32x4.min";
export const f32x4_max = "~lib/builtins/f32x4.max";
export const f32x4_pmin = "~lib/builtins/f32x4.pmin";
export const f32x4_pmax = "~lib/builtins/f32x4.pmax";
export const f32x4_abs = "~lib/builtins/f32x4.abs";
export const f32x4_sqrt = "~lib/builtins/f32x4.sqrt";
export const f32x4_ceil = "~lib/builtins/f32x4.ceil";
export const f32x4_floor = "~lib/builtins/f32x4.floor";
export const f32x4_trunc = "~lib/builtins/f32x4.trunc";
export const f32x4_nearest = "~lib/builtins/f32x4.nearest";
export const f32x4_eq = "~lib/builtins/f32x4.eq";
export const f32x4_ne = "~lib/builtins/f32x4.ne";
export const f32x4_lt = "~lib/builtins/f32x4.lt";
export const f32x4_le = "~lib/builtins/f32x4.le";
export const f32x4_gt = "~lib/builtins/f32x4.gt";
export const f32x4_ge = "~lib/builtins/f32x4.ge";
export const f32x4_convert_i32x4_s = "~lib/builtins/f32x4.convert_i32x4_s";
export const f32x4_convert_i32x4_u = "~lib/builtins/f32x4.convert_i32x4_u";
export const f32x4_demote_f64x2_zero = "~lib/builtins/f32x4.demote_f64x2_zero";
export const f32x4_shuffle = "~lib/builtins/f32x4.shuffle";
export const f64x2_splat = "~lib/builtins/f64x2.splat";
export const f64x2_extract_lane = "~lib/builtins/f64x2.extract_lane";
export const f64x2_replace_lane = "~lib/builtins/f64x2.replace_lane";
export const f64x2_add = "~lib/builtins/f64x2.add";
export const f64x2_sub = "~lib/builtins/f64x2.sub";
export const f64x2_mul = "~lib/builtins/f64x2.mul";
export const f64x2_div = "~lib/builtins/f64x2.div";
export const f64x2_neg = "~lib/builtins/f64x2.neg";
export const f64x2_min = "~lib/builtins/f64x2.min";
export const f64x2_max = "~lib/builtins/f64x2.max";
export const f64x2_pmin = "~lib/builtins/f64x2.pmin";
export const f64x2_pmax = "~lib/builtins/f64x2.pmax";
export const f64x2_abs = "~lib/builtins/f64x2.abs";
export const f64x2_sqrt = "~lib/builtins/f64x2.sqrt";
export const f64x2_ceil = "~lib/builtins/f64x2.ceil";
export const f64x2_floor = "~lib/builtins/f64x2.floor";
export const f64x2_trunc = "~lib/builtins/f64x2.trunc";
export const f64x2_nearest = "~lib/builtins/f64x2.nearest";
export const f64x2_eq = "~lib/builtins/f64x2.eq";
export const f64x2_ne = "~lib/builtins/f64x2.ne";
export const f64x2_lt = "~lib/builtins/f64x2.lt";
export const f64x2_le = "~lib/builtins/f64x2.le";
export const f64x2_gt = "~lib/builtins/f64x2.gt";
export const f64x2_ge = "~lib/builtins/f64x2.ge";
export const f64x2_convert_low_i32x4_s = "~lib/builtins/f64x2.convert_low_i32x4_s";
export const f64x2_convert_low_i32x4_u = "~lib/builtins/f64x2.convert_low_i32x4_u";
export const f64x2_promote_low_f32x4 = "~lib/builtins/f64x2.promote_low_f32x4";
export const f64x2_shuffle = "~lib/builtins/f64x2.shuffle";
export const i8x16_relaxed_swizzle = "~lib/builtins/i8x16.relaxed_swizzle";
export const i32x4_relaxed_trunc_f32x4_s = "~lib/builtins/i32x4.relaxed_trunc_f32x4_s";
export const i32x4_relaxed_trunc_f32x4_u = "~lib/builtins/i32x4.relaxed_trunc_f32x4_u";
export const i32x4_relaxed_trunc_f64x2_s_zero = "~lib/builtins/i32x4.relaxed_trunc_f64x2_s_zero";
export const i32x4_relaxed_trunc_f64x2_u_zero = "~lib/builtins/i32x4.relaxed_trunc_f64x2_u_zero";
export const f32x4_relaxed_madd = "~lib/builtins/f32x4.relaxed_madd";
export const f32x4_relaxed_nmadd = "~lib/builtins/f32x4.relaxed_nmadd";
export const f64x2_relaxed_madd = "~lib/builtins/f64x2.relaxed_madd";
export const f64x2_relaxed_nmadd = "~lib/builtins/f64x2.relaxed_nmadd";
export const i8x16_relaxed_laneselect = "~lib/builtins/i8x16.relaxed_laneselect";
export const i16x8_relaxed_laneselect = "~lib/builtins/i16x8.relaxed_laneselect";
export const i32x4_relaxed_laneselect = "~lib/builtins/i32x4.relaxed_laneselect";
export const i64x2_relaxed_laneselect = "~lib/builtins/i64x2.relaxed_laneselect";
export const f32x4_relaxed_min = "~lib/builtins/f32x4.relaxed_min";
export const f32x4_relaxed_max = "~lib/builtins/f32x4.relaxed_max";
export const f64x2_relaxed_min = "~lib/builtins/f64x2.relaxed_min";
export const f64x2_relaxed_max = "~lib/builtins/f64x2.relaxed_max";
export const i16x8_relaxed_q15mulr_s = "~lib/builtins/i16x8.relaxed_q15mulr_s";
export const i16x8_relaxed_dot_i8x16_i7x16_s = "~lib/builtins/i16x8.relaxed_dot_i8x16_i7x16_s";
export const i32x4_relaxed_dot_i8x16_i7x16_add_s = "~lib/builtins/i32x4.relaxed_dot_i8x16_i7x16_add_s";
export const i31_new = "~lib/builtins/i31.new";
export const i31_get = "~lib/builtins/i31.get";
// internals
export const data_end = "~lib/memory/__data_end";
export const stack_pointer = "~lib/memory/__stack_pointer";
export const heap_base = "~lib/memory/__heap_base";
export const rtti_base = "~lib/rt/__rtti_base";
export const visit_globals = "~lib/rt/__visit_globals";
export const visit_members = "~lib/rt/__visit_members";
export const tostack = "~lib/rt/__tostack";
// std/number.ts
export const NaN = "~lib/number/NaN";
export const Infinity = "~lib/number/Infinity";
export const isNaN = "~lib/number/isNaN";
export const isFinite = "~lib/number/isFinite";
// std/diagnostics.ts
export const ERROR = "~lib/diagnostics/ERROR";
export const WARNING = "~lib/diagnostics/WARNING";
export const INFO = "~lib/diagnostics/INFO";
// std/function.ts
export const Function = "~lib/function/Function";
export const Function_call = "~lib/function/Function#call";
// std/memory.ts
export const memory_size = "~lib/memory/memory.size";
export const memory_grow = "~lib/memory/memory.grow";
export const memory_copy = "~lib/memory/memory.copy";
export const memory_fill = "~lib/memory/memory.fill";
export const memory_data = "~lib/memory/memory.data";
// std/typedarray.ts
export const Int8Array = "~lib/typedarray/Int8Array";
export const Uint8Array = "~lib/typedarray/Uint8Array";
export const Uint8ClampedArray = "~lib/typedarray/Uint8ClampedArray";
export const Int16Array = "~lib/typedarray/Int16Array";
export const Uint16Array = "~lib/typedarray/Uint16Array";
export const Int32Array = "~lib/typedarray/Int32Array";
export const Uint32Array = "~lib/typedarray/Uint32Array";
export const Int64Array = "~lib/typedarray/Int64Array";
export const Uint64Array = "~lib/typedarray/Uint64Array";
export const Float32Array = "~lib/typedarray/Float32Array";
export const Float64Array = "~lib/typedarray/Float64Array";
// std/string.ts
export const String_raw = "~lib/string/String.raw";
export const String_eq = "~lib/string/String.__eq";
export const String_ne = "~lib/string/String.__ne";
export const String_not = "~lib/string/String.__not";
// std/object.ts
export const Object = "~lib/object/Object";
}
/** Builtin variable compilation context. */
export class BuiltinVariableContext {
constructor(
/** Compiler reference. */
public compiler: Compiler,
/** Variable being accessed. */
public element: VariableLikeElement,
/** Contextual type. */
public contextualType: Type = element.type,
/** Respective report expression. */
public reportNode: IdentifierExpression = element.identifierNode
) {}
}
/** Builtin function compilation context. */
export class BuiltinFunctionContext {
constructor(
/** Compiler reference. */
public compiler: Compiler,
/** Prototype being called. */
public prototype: FunctionPrototype,
/** Provided type arguments. */
public typeArguments: Type[] | null,
/** Provided operands. */
public operands: Expression[],
/** Provided this operand, if any. */
public thisOperand: Expression | null,
/** Contextual type. */
public contextualType: Type,
/** Respective call expression. */
public reportNode: CallExpression,
/** Whether originating from inline assembly. */
public contextIsExact: bool
) {}
}
/** Builtin functions map. */
export const builtinFunctions = new Map<string, (ctx: BuiltinFunctionContext) => ExpressionRef>();
/** Builtin variables map. */
export const builtinVariables_onCompile = new Map<string, (ctx: BuiltinVariableContext) => void>();
export const builtinVariables_onAccess = new Map<string, (ctx: BuiltinVariableContext) => ExpressionRef>();
// === Static type evaluation =================================================================
// helper global used by checkConstantType
let checkConstantType_expr: ExpressionRef = 0;
// isBoolean<T!>() / isBoolean<T?>(value: T) -> bool
function builtin_isBoolean(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
let type = checkConstantType(ctx);
compiler.currentType = Type.bool;
if (!type) return module.unreachable();
return reifyConstantType(ctx, module.i32(type.isBooleanValue ? 1 : 0));
}
builtinFunctions.set(BuiltinNames.isBoolean, builtin_isBoolean);
// isInteger<T!>() / isInteger<T?>(value: T) -> bool
function builtin_isInteger(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
let type = checkConstantType(ctx);
compiler.currentType = Type.bool;
if (!type) return module.unreachable();
return reifyConstantType(ctx, module.i32(type.isIntegerValue ? 1 : 0));
}
builtinFunctions.set(BuiltinNames.isInteger, builtin_isInteger);
// isSigned<T!>() / isSigned<T?>(value: T) -> bool
function builtin_isSigned(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
let type = checkConstantType(ctx);
compiler.currentType = Type.bool;
if (!type) return module.unreachable();
return reifyConstantType(ctx, module.i32(type.isSignedIntegerValue ? 1 : 0));
}
builtinFunctions.set(BuiltinNames.isSigned, builtin_isSigned);
// isFloat<T!>() / isFloat<T?>(value: T) -> bool
function builtin_isFloat(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
let type = checkConstantType(ctx);
compiler.currentType = Type.bool;
if (!type) return module.unreachable();
return reifyConstantType(ctx, module.i32(type.isFloatValue ? 1 : 0));
}
builtinFunctions.set(BuiltinNames.isFloat, builtin_isFloat);
// isVector<T!>() / isVector<T?>(value: T) -> bool
function builtin_isVector(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
let type = checkConstantType(ctx);
compiler.currentType = Type.bool;
if (!type) return module.unreachable();
return reifyConstantType(ctx, module.i32(type.isVectorValue ? 1 : 0));
}
builtinFunctions.set(BuiltinNames.isVector, builtin_isVector);
// isReference<T!>() / isReference<T?>(value: T) -> bool
function builtin_isReference(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
let type = checkConstantType(ctx);
compiler.currentType = Type.bool;
if (!type) return module.unreachable();
return reifyConstantType(ctx, module.i32(type.isReference ? 1 : 0));
}
builtinFunctions.set(BuiltinNames.isReference, builtin_isReference);
// isString<T!>() / isString<T?>(value: T) -> bool
function builtin_isString(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
let type = checkConstantType(ctx);
compiler.currentType = Type.bool;
if (!type) return module.unreachable();
let classReference = type.getClass();
return reifyConstantType(ctx,
module.i32(
classReference && classReference.isAssignableTo(compiler.program.stringInstance)
? 1
: 0
)
);
}
builtinFunctions.set(BuiltinNames.isString, builtin_isString);
// isArray<T!>() / isArray<T?>(value: T) -> bool
function builtin_isArray(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
let type = checkConstantType(ctx);
compiler.currentType = Type.bool;
if (!type) return module.unreachable();
let classReference = type.getClass();
return reifyConstantType(ctx,
module.i32(
classReference && classReference.extendsPrototype(compiler.program.arrayPrototype)
? 1
: 0
)
);
}
builtinFunctions.set(BuiltinNames.isArray, builtin_isArray);
// isArrayLike<T!>() / isArrayLike<T?>(value: T) -> bool
function builtin_isArrayLike(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
let type = checkConstantType(ctx);
compiler.currentType = Type.bool;
if (!type) return module.unreachable();
let classReference = type.getClass();
return reifyConstantType(ctx,
module.i32(
classReference && classReference.isArrayLike
? 1
: 0
)
);
}
builtinFunctions.set(BuiltinNames.isArrayLike, builtin_isArrayLike);
// isFunction<T!> / isFunction<T?>(value: T) -> bool
function builtin_isFunction(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
let type = checkConstantType(ctx);
compiler.currentType = Type.bool;
if (!type) return module.unreachable();
return reifyConstantType(ctx, module.i32(type.isFunction ? 1 : 0));
}
builtinFunctions.set(BuiltinNames.isFunction, builtin_isFunction);
// isNullable<T!> / isNullable<T?>(value: T) -> bool
function builtin_isNullable(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
let type = checkConstantType(ctx);
compiler.currentType = Type.bool;
if (!type) return module.unreachable();
return reifyConstantType(ctx, module.i32(type.isNullableReference ? 1 : 0));
}
builtinFunctions.set(BuiltinNames.isNullable, builtin_isNullable);
// isDefined(expression) -> bool
function builtin_isDefined(ctx: BuiltinFunctionContext): ExpressionRef {
// Note that `isDefined` neither compiles nor evaluates the given expression
// but exclusively performs a check whether it can be compiled in theory.
// This is not exactly unsafe due to only seemingly having side effects which
// actually never happen, but may confuse tooling unaware of its semantics.
let compiler = ctx.compiler;
let module = compiler.module;
compiler.currentType = Type.bool;
if (
checkTypeAbsent(ctx) |
checkArgsRequired(ctx, 1)
) return module.unreachable();
let element = compiler.resolver.lookupExpression(
ctx.operands[0],
compiler.currentFlow,
Type.auto,
ReportMode.Swallow
);
return module.i32(element ? 1 : 0);
}
builtinFunctions.set(BuiltinNames.isDefined, builtin_isDefined);
// isConstant(expression) -> bool
function builtin_isConstant(ctx: BuiltinFunctionContext): ExpressionRef {
let compiler = ctx.compiler;
let module = compiler.module;
compiler.currentType = Type.bool;
if (
checkTypeAbsent(ctx) |
checkArgsRequired(ctx, 1)
) return module.unreachable();
let expr = compiler.compileExpression(ctx.operands[0], Type.auto);
compiler.currentType = Type.bool;
if (!mustPreserveSideEffects(expr, module.ref)) {
return module.i32(module.isConstExpression(expr) ? 1 : 0);
}
return module.block(null, [
module.maybeDrop(expr),
module.i32(0)
], getExpressionType(expr));