binaryen 1.1.6.pre.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +58 -0
  3. data/extconf.rb +75 -0
  4. data/lib/binaryen/command.rb +57 -0
  5. data/lib/binaryen/error.rb +6 -0
  6. data/lib/binaryen/version.rb +6 -0
  7. data/lib/binaryen.rb +38 -0
  8. data/vendor/arm64-darwin/bin/wasm-as +0 -0
  9. data/vendor/arm64-darwin/bin/wasm-ctor-eval +0 -0
  10. data/vendor/arm64-darwin/bin/wasm-dis +0 -0
  11. data/vendor/arm64-darwin/bin/wasm-emscripten-finalize +0 -0
  12. data/vendor/arm64-darwin/bin/wasm-fuzz-lattices +0 -0
  13. data/vendor/arm64-darwin/bin/wasm-fuzz-types +0 -0
  14. data/vendor/arm64-darwin/bin/wasm-merge +0 -0
  15. data/vendor/arm64-darwin/bin/wasm-metadce +0 -0
  16. data/vendor/arm64-darwin/bin/wasm-opt +0 -0
  17. data/vendor/arm64-darwin/bin/wasm-reduce +0 -0
  18. data/vendor/arm64-darwin/bin/wasm-shell +0 -0
  19. data/vendor/arm64-darwin/bin/wasm-split +0 -0
  20. data/vendor/arm64-darwin/bin/wasm2js +0 -0
  21. data/vendor/arm64-darwin/include/binaryen-c.h +3615 -0
  22. data/vendor/arm64-darwin/include/wasm-delegations.def +105 -0
  23. data/vendor/arm64-darwin/lib/libbinaryen.dylib +0 -0
  24. data/vendor/x86_64-darwin/bin/wasm-as +0 -0
  25. data/vendor/x86_64-darwin/bin/wasm-ctor-eval +0 -0
  26. data/vendor/x86_64-darwin/bin/wasm-dis +0 -0
  27. data/vendor/x86_64-darwin/bin/wasm-emscripten-finalize +0 -0
  28. data/vendor/x86_64-darwin/bin/wasm-fuzz-lattices +0 -0
  29. data/vendor/x86_64-darwin/bin/wasm-fuzz-types +0 -0
  30. data/vendor/x86_64-darwin/bin/wasm-merge +0 -0
  31. data/vendor/x86_64-darwin/bin/wasm-metadce +0 -0
  32. data/vendor/x86_64-darwin/bin/wasm-opt +0 -0
  33. data/vendor/x86_64-darwin/bin/wasm-reduce +0 -0
  34. data/vendor/x86_64-darwin/bin/wasm-shell +0 -0
  35. data/vendor/x86_64-darwin/bin/wasm-split +0 -0
  36. data/vendor/x86_64-darwin/bin/wasm2js +0 -0
  37. data/vendor/x86_64-darwin/include/binaryen-c.h +3615 -0
  38. data/vendor/x86_64-darwin/include/wasm-delegations.def +105 -0
  39. data/vendor/x86_64-darwin/lib/libbinaryen.dylib +0 -0
  40. data/vendor/x86_64-linux/bin/wasm-as +0 -0
  41. data/vendor/x86_64-linux/bin/wasm-ctor-eval +0 -0
  42. data/vendor/x86_64-linux/bin/wasm-dis +0 -0
  43. data/vendor/x86_64-linux/bin/wasm-emscripten-finalize +0 -0
  44. data/vendor/x86_64-linux/bin/wasm-fuzz-lattices +0 -0
  45. data/vendor/x86_64-linux/bin/wasm-fuzz-types +0 -0
  46. data/vendor/x86_64-linux/bin/wasm-merge +0 -0
  47. data/vendor/x86_64-linux/bin/wasm-metadce +0 -0
  48. data/vendor/x86_64-linux/bin/wasm-opt +0 -0
  49. data/vendor/x86_64-linux/bin/wasm-reduce +0 -0
  50. data/vendor/x86_64-linux/bin/wasm-shell +0 -0
  51. data/vendor/x86_64-linux/bin/wasm-split +0 -0
  52. data/vendor/x86_64-linux/bin/wasm2js +0 -0
  53. data/vendor/x86_64-linux/include/binaryen-c.h +3615 -0
  54. data/vendor/x86_64-linux/include/wasm-delegations.def +105 -0
  55. data/vendor/x86_64-linux/lib/libbinaryen.a +0 -0
  56. metadata +99 -0
@@ -0,0 +1,3615 @@
1
+ /*
2
+ * Copyright 2016 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
+ //================
18
+ // Binaryen C API
19
+ //
20
+ // The first part of the API lets you create modules and their parts.
21
+ //
22
+ // The second part of the API lets you perform operations on modules.
23
+ //
24
+ // The third part of the API lets you provide a general control-flow
25
+ // graph (CFG) as input.
26
+ //
27
+ // The final part of the API contains miscellaneous utilities like
28
+ // debugging for the API itself.
29
+ //
30
+ // ---------------
31
+ //
32
+ // Thread safety: You can create Expressions in parallel, as they do not
33
+ // refer to global state. BinaryenAddFunction is also
34
+ // thread-safe, which means that you can create functions and
35
+ // their contents in multiple threads. This is important since
36
+ // functions are where the majority of the work is done.
37
+ // Other methods - creating imports, exports, etc. - are
38
+ // not currently thread-safe (as there is typically no need
39
+ // to parallelize them).
40
+ //
41
+ //================
42
+
43
+ #ifndef wasm_binaryen_c_h
44
+ #define wasm_binaryen_c_h
45
+
46
+ #include <stdbool.h>
47
+ #include <stddef.h>
48
+ #include <stdint.h>
49
+
50
+ #ifdef __GNUC__
51
+ #define WASM_DEPRECATED __attribute__((deprecated))
52
+ #elif defined(_MSC_VER)
53
+ #define WASM_DEPRECATED __declspec(deprecated)
54
+ #else
55
+ #define WASM_DEPRECATED
56
+ #endif
57
+
58
+ #if defined(__EMSCRIPTEN__)
59
+ #include <emscripten.h>
60
+ #define BINARYEN_API EMSCRIPTEN_KEEPALIVE
61
+ #elif defined(_MSC_VER) && !defined(BUILD_STATIC_LIBRARY)
62
+ #define BINARYEN_API __declspec(dllexport)
63
+ #else
64
+ #define BINARYEN_API
65
+ #endif
66
+
67
+ #ifdef __cplusplus
68
+ #define BINARYEN_REF(NAME) \
69
+ namespace wasm { \
70
+ class NAME; \
71
+ }; \
72
+ typedef class wasm::NAME* Binaryen##NAME##Ref;
73
+ #else
74
+ #define BINARYEN_REF(NAME) typedef struct Binaryen##NAME* Binaryen##NAME##Ref;
75
+ #endif
76
+
77
+ #ifdef __cplusplus
78
+ extern "C" {
79
+ #endif
80
+
81
+ //
82
+ // ========== Module Creation ==========
83
+ //
84
+
85
+ // BinaryenIndex
86
+ //
87
+ // Used for internal indexes and list sizes.
88
+
89
+ typedef uint32_t BinaryenIndex;
90
+
91
+ // Core types (call to get the value of each; you can cache them, they
92
+ // never change)
93
+
94
+ typedef uintptr_t BinaryenType;
95
+
96
+ BINARYEN_API BinaryenType BinaryenTypeNone(void);
97
+ BINARYEN_API BinaryenType BinaryenTypeInt32(void);
98
+ BINARYEN_API BinaryenType BinaryenTypeInt64(void);
99
+ BINARYEN_API BinaryenType BinaryenTypeFloat32(void);
100
+ BINARYEN_API BinaryenType BinaryenTypeFloat64(void);
101
+ BINARYEN_API BinaryenType BinaryenTypeVec128(void);
102
+ BINARYEN_API BinaryenType BinaryenTypeFuncref(void);
103
+ BINARYEN_API BinaryenType BinaryenTypeExternref(void);
104
+ BINARYEN_API BinaryenType BinaryenTypeAnyref(void);
105
+ BINARYEN_API BinaryenType BinaryenTypeEqref(void);
106
+ BINARYEN_API BinaryenType BinaryenTypeI31ref(void);
107
+ BINARYEN_API BinaryenType BinaryenTypeStructref(void);
108
+ BINARYEN_API BinaryenType BinaryenTypeArrayref(void);
109
+ BINARYEN_API BinaryenType BinaryenTypeStringref(void);
110
+ BINARYEN_API BinaryenType BinaryenTypeStringviewWTF8(void);
111
+ BINARYEN_API BinaryenType BinaryenTypeStringviewWTF16(void);
112
+ BINARYEN_API BinaryenType BinaryenTypeStringviewIter(void);
113
+ BINARYEN_API BinaryenType BinaryenTypeNullref(void);
114
+ BINARYEN_API BinaryenType BinaryenTypeNullExternref(void);
115
+ BINARYEN_API BinaryenType BinaryenTypeNullFuncref(void);
116
+ BINARYEN_API BinaryenType BinaryenTypeUnreachable(void);
117
+ // Not a real type. Used as the last parameter to BinaryenBlock to let
118
+ // the API figure out the type instead of providing one.
119
+ BINARYEN_API BinaryenType BinaryenTypeAuto(void);
120
+ BINARYEN_API BinaryenType BinaryenTypeCreate(BinaryenType* valueTypes,
121
+ BinaryenIndex numTypes);
122
+ BINARYEN_API uint32_t BinaryenTypeArity(BinaryenType t);
123
+ BINARYEN_API void BinaryenTypeExpand(BinaryenType t, BinaryenType* buf);
124
+
125
+ WASM_DEPRECATED BinaryenType BinaryenNone(void);
126
+ WASM_DEPRECATED BinaryenType BinaryenInt32(void);
127
+ WASM_DEPRECATED BinaryenType BinaryenInt64(void);
128
+ WASM_DEPRECATED BinaryenType BinaryenFloat32(void);
129
+ WASM_DEPRECATED BinaryenType BinaryenFloat64(void);
130
+ WASM_DEPRECATED BinaryenType BinaryenUndefined(void);
131
+
132
+ // Packed types (call to get the value of each; you can cache them)
133
+
134
+ typedef uint32_t BinaryenPackedType;
135
+
136
+ BINARYEN_API BinaryenPackedType BinaryenPackedTypeNotPacked(void);
137
+ BINARYEN_API BinaryenPackedType BinaryenPackedTypeInt8(void);
138
+ BINARYEN_API BinaryenPackedType BinaryenPackedTypeInt16(void);
139
+
140
+ // Heap types
141
+
142
+ typedef uintptr_t BinaryenHeapType;
143
+
144
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeExt(void);
145
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeFunc(void);
146
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeAny(void);
147
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeEq(void);
148
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeI31(void);
149
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeStruct(void);
150
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeArray(void);
151
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeString(void);
152
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeStringviewWTF8(void);
153
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeStringviewWTF16(void);
154
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeStringviewIter(void);
155
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeNone(void);
156
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeNoext(void);
157
+ BINARYEN_API BinaryenHeapType BinaryenHeapTypeNofunc(void);
158
+
159
+ BINARYEN_API bool BinaryenHeapTypeIsBasic(BinaryenHeapType heapType);
160
+ BINARYEN_API bool BinaryenHeapTypeIsSignature(BinaryenHeapType heapType);
161
+ BINARYEN_API bool BinaryenHeapTypeIsStruct(BinaryenHeapType heapType);
162
+ BINARYEN_API bool BinaryenHeapTypeIsArray(BinaryenHeapType heapType);
163
+ BINARYEN_API bool BinaryenHeapTypeIsBottom(BinaryenHeapType heapType);
164
+ BINARYEN_API BinaryenHeapType
165
+ BinaryenHeapTypeGetBottom(BinaryenHeapType heapType);
166
+ BINARYEN_API bool BinaryenHeapTypeIsSubType(BinaryenHeapType left,
167
+ BinaryenHeapType right);
168
+ BINARYEN_API BinaryenIndex
169
+ BinaryenStructTypeGetNumFields(BinaryenHeapType heapType);
170
+ BINARYEN_API BinaryenType
171
+ BinaryenStructTypeGetFieldType(BinaryenHeapType heapType, BinaryenIndex index);
172
+ BINARYEN_API BinaryenPackedType BinaryenStructTypeGetFieldPackedType(
173
+ BinaryenHeapType heapType, BinaryenIndex index);
174
+ BINARYEN_API bool BinaryenStructTypeIsFieldMutable(BinaryenHeapType heapType,
175
+ BinaryenIndex index);
176
+ BINARYEN_API BinaryenType
177
+ BinaryenArrayTypeGetElementType(BinaryenHeapType heapType);
178
+ BINARYEN_API BinaryenPackedType
179
+ BinaryenArrayTypeGetElementPackedType(BinaryenHeapType heapType);
180
+ BINARYEN_API bool BinaryenArrayTypeIsElementMutable(BinaryenHeapType heapType);
181
+ BINARYEN_API BinaryenType
182
+ BinaryenSignatureTypeGetParams(BinaryenHeapType heapType);
183
+ BINARYEN_API BinaryenType
184
+ BinaryenSignatureTypeGetResults(BinaryenHeapType heapType);
185
+
186
+ BINARYEN_API BinaryenHeapType BinaryenTypeGetHeapType(BinaryenType type);
187
+ BINARYEN_API bool BinaryenTypeIsNullable(BinaryenType type);
188
+ BINARYEN_API BinaryenType BinaryenTypeFromHeapType(BinaryenHeapType heapType,
189
+ bool nullable);
190
+
191
+ // Expression ids (call to get the value of each; you can cache them)
192
+
193
+ typedef uint32_t BinaryenExpressionId;
194
+
195
+ BINARYEN_API BinaryenExpressionId BinaryenInvalidId(void);
196
+
197
+ #define DELEGATE(CLASS_TO_VISIT) \
198
+ BINARYEN_API BinaryenExpressionId Binaryen##CLASS_TO_VISIT##Id(void);
199
+
200
+ #include "wasm-delegations.def"
201
+
202
+ // External kinds (call to get the value of each; you can cache them)
203
+
204
+ typedef uint32_t BinaryenExternalKind;
205
+
206
+ BINARYEN_API BinaryenExternalKind BinaryenExternalFunction(void);
207
+ BINARYEN_API BinaryenExternalKind BinaryenExternalTable(void);
208
+ BINARYEN_API BinaryenExternalKind BinaryenExternalMemory(void);
209
+ BINARYEN_API BinaryenExternalKind BinaryenExternalGlobal(void);
210
+ BINARYEN_API BinaryenExternalKind BinaryenExternalTag(void);
211
+
212
+ // Features. Call to get the value of each; you can cache them. Use bitwise
213
+ // operators to combine and test particular features.
214
+
215
+ typedef uint32_t BinaryenFeatures;
216
+
217
+ BINARYEN_API BinaryenFeatures BinaryenFeatureMVP(void);
218
+ BINARYEN_API BinaryenFeatures BinaryenFeatureAtomics(void);
219
+ BINARYEN_API BinaryenFeatures BinaryenFeatureBulkMemory(void);
220
+ BINARYEN_API BinaryenFeatures BinaryenFeatureMutableGlobals(void);
221
+ BINARYEN_API BinaryenFeatures BinaryenFeatureNontrappingFPToInt(void);
222
+ BINARYEN_API BinaryenFeatures BinaryenFeatureSignExt(void);
223
+ BINARYEN_API BinaryenFeatures BinaryenFeatureSIMD128(void);
224
+ BINARYEN_API BinaryenFeatures BinaryenFeatureExceptionHandling(void);
225
+ BINARYEN_API BinaryenFeatures BinaryenFeatureTailCall(void);
226
+ BINARYEN_API BinaryenFeatures BinaryenFeatureReferenceTypes(void);
227
+ BINARYEN_API BinaryenFeatures BinaryenFeatureMultivalue(void);
228
+ BINARYEN_API BinaryenFeatures BinaryenFeatureGC(void);
229
+ BINARYEN_API BinaryenFeatures BinaryenFeatureMemory64(void);
230
+ BINARYEN_API BinaryenFeatures BinaryenFeatureRelaxedSIMD(void);
231
+ BINARYEN_API BinaryenFeatures BinaryenFeatureExtendedConst(void);
232
+ BINARYEN_API BinaryenFeatures BinaryenFeatureStrings(void);
233
+ BINARYEN_API BinaryenFeatures BinaryenFeatureMultiMemory(void);
234
+ BINARYEN_API BinaryenFeatures BinaryenFeatureAll(void);
235
+
236
+ // Modules
237
+ //
238
+ // Modules contain lists of functions, imports, exports, function types. The
239
+ // Add* methods create them on a module. The module owns them and will free
240
+ // their memory when the module is disposed of.
241
+ //
242
+ // Expressions are also allocated inside modules, and freed with the module.
243
+ // They are not created by Add* methods, since they are not added directly on
244
+ // the module, instead, they are arguments to other expressions (and then they
245
+ // are the children of that AST node), or to a function (and then they are the
246
+ // body of that function).
247
+ //
248
+ // A module can also contain a function table for indirect calls, a memory,
249
+ // and a start method.
250
+
251
+ BINARYEN_REF(Module);
252
+
253
+ BINARYEN_API BinaryenModuleRef BinaryenModuleCreate(void);
254
+ BINARYEN_API void BinaryenModuleDispose(BinaryenModuleRef module);
255
+
256
+ // Literals. These are passed by value.
257
+
258
+ struct BinaryenLiteral {
259
+ uintptr_t type;
260
+ union {
261
+ int32_t i32;
262
+ int64_t i64;
263
+ float f32;
264
+ double f64;
265
+ uint8_t v128[16];
266
+ const char* func;
267
+ };
268
+ };
269
+
270
+ BINARYEN_API struct BinaryenLiteral BinaryenLiteralInt32(int32_t x);
271
+ BINARYEN_API struct BinaryenLiteral BinaryenLiteralInt64(int64_t x);
272
+ BINARYEN_API struct BinaryenLiteral BinaryenLiteralFloat32(float x);
273
+ BINARYEN_API struct BinaryenLiteral BinaryenLiteralFloat64(double x);
274
+ BINARYEN_API struct BinaryenLiteral BinaryenLiteralVec128(const uint8_t x[16]);
275
+ BINARYEN_API struct BinaryenLiteral BinaryenLiteralFloat32Bits(int32_t x);
276
+ BINARYEN_API struct BinaryenLiteral BinaryenLiteralFloat64Bits(int64_t x);
277
+
278
+ // Expressions
279
+ //
280
+ // Some expressions have a BinaryenOp, which is the more
281
+ // specific operation/opcode.
282
+ //
283
+ // Some expressions have optional parameters, like Return may not
284
+ // return a value. You can supply a NULL pointer in those cases.
285
+ //
286
+ // For more information, see wasm.h
287
+
288
+ typedef int32_t BinaryenOp;
289
+
290
+ BINARYEN_API BinaryenOp BinaryenClzInt32(void);
291
+ BINARYEN_API BinaryenOp BinaryenCtzInt32(void);
292
+ BINARYEN_API BinaryenOp BinaryenPopcntInt32(void);
293
+ BINARYEN_API BinaryenOp BinaryenNegFloat32(void);
294
+ BINARYEN_API BinaryenOp BinaryenAbsFloat32(void);
295
+ BINARYEN_API BinaryenOp BinaryenCeilFloat32(void);
296
+ BINARYEN_API BinaryenOp BinaryenFloorFloat32(void);
297
+ BINARYEN_API BinaryenOp BinaryenTruncFloat32(void);
298
+ BINARYEN_API BinaryenOp BinaryenNearestFloat32(void);
299
+ BINARYEN_API BinaryenOp BinaryenSqrtFloat32(void);
300
+ BINARYEN_API BinaryenOp BinaryenEqZInt32(void);
301
+ BINARYEN_API BinaryenOp BinaryenClzInt64(void);
302
+ BINARYEN_API BinaryenOp BinaryenCtzInt64(void);
303
+ BINARYEN_API BinaryenOp BinaryenPopcntInt64(void);
304
+ BINARYEN_API BinaryenOp BinaryenNegFloat64(void);
305
+ BINARYEN_API BinaryenOp BinaryenAbsFloat64(void);
306
+ BINARYEN_API BinaryenOp BinaryenCeilFloat64(void);
307
+ BINARYEN_API BinaryenOp BinaryenFloorFloat64(void);
308
+ BINARYEN_API BinaryenOp BinaryenTruncFloat64(void);
309
+ BINARYEN_API BinaryenOp BinaryenNearestFloat64(void);
310
+ BINARYEN_API BinaryenOp BinaryenSqrtFloat64(void);
311
+ BINARYEN_API BinaryenOp BinaryenEqZInt64(void);
312
+ BINARYEN_API BinaryenOp BinaryenExtendSInt32(void);
313
+ BINARYEN_API BinaryenOp BinaryenExtendUInt32(void);
314
+ BINARYEN_API BinaryenOp BinaryenWrapInt64(void);
315
+ BINARYEN_API BinaryenOp BinaryenTruncSFloat32ToInt32(void);
316
+ BINARYEN_API BinaryenOp BinaryenTruncSFloat32ToInt64(void);
317
+ BINARYEN_API BinaryenOp BinaryenTruncUFloat32ToInt32(void);
318
+ BINARYEN_API BinaryenOp BinaryenTruncUFloat32ToInt64(void);
319
+ BINARYEN_API BinaryenOp BinaryenTruncSFloat64ToInt32(void);
320
+ BINARYEN_API BinaryenOp BinaryenTruncSFloat64ToInt64(void);
321
+ BINARYEN_API BinaryenOp BinaryenTruncUFloat64ToInt32(void);
322
+ BINARYEN_API BinaryenOp BinaryenTruncUFloat64ToInt64(void);
323
+ BINARYEN_API BinaryenOp BinaryenReinterpretFloat32(void);
324
+ BINARYEN_API BinaryenOp BinaryenReinterpretFloat64(void);
325
+ BINARYEN_API BinaryenOp BinaryenConvertSInt32ToFloat32(void);
326
+ BINARYEN_API BinaryenOp BinaryenConvertSInt32ToFloat64(void);
327
+ BINARYEN_API BinaryenOp BinaryenConvertUInt32ToFloat32(void);
328
+ BINARYEN_API BinaryenOp BinaryenConvertUInt32ToFloat64(void);
329
+ BINARYEN_API BinaryenOp BinaryenConvertSInt64ToFloat32(void);
330
+ BINARYEN_API BinaryenOp BinaryenConvertSInt64ToFloat64(void);
331
+ BINARYEN_API BinaryenOp BinaryenConvertUInt64ToFloat32(void);
332
+ BINARYEN_API BinaryenOp BinaryenConvertUInt64ToFloat64(void);
333
+ BINARYEN_API BinaryenOp BinaryenPromoteFloat32(void);
334
+ BINARYEN_API BinaryenOp BinaryenDemoteFloat64(void);
335
+ BINARYEN_API BinaryenOp BinaryenReinterpretInt32(void);
336
+ BINARYEN_API BinaryenOp BinaryenReinterpretInt64(void);
337
+ BINARYEN_API BinaryenOp BinaryenExtendS8Int32(void);
338
+ BINARYEN_API BinaryenOp BinaryenExtendS16Int32(void);
339
+ BINARYEN_API BinaryenOp BinaryenExtendS8Int64(void);
340
+ BINARYEN_API BinaryenOp BinaryenExtendS16Int64(void);
341
+ BINARYEN_API BinaryenOp BinaryenExtendS32Int64(void);
342
+ BINARYEN_API BinaryenOp BinaryenAddInt32(void);
343
+ BINARYEN_API BinaryenOp BinaryenSubInt32(void);
344
+ BINARYEN_API BinaryenOp BinaryenMulInt32(void);
345
+ BINARYEN_API BinaryenOp BinaryenDivSInt32(void);
346
+ BINARYEN_API BinaryenOp BinaryenDivUInt32(void);
347
+ BINARYEN_API BinaryenOp BinaryenRemSInt32(void);
348
+ BINARYEN_API BinaryenOp BinaryenRemUInt32(void);
349
+ BINARYEN_API BinaryenOp BinaryenAndInt32(void);
350
+ BINARYEN_API BinaryenOp BinaryenOrInt32(void);
351
+ BINARYEN_API BinaryenOp BinaryenXorInt32(void);
352
+ BINARYEN_API BinaryenOp BinaryenShlInt32(void);
353
+ BINARYEN_API BinaryenOp BinaryenShrUInt32(void);
354
+ BINARYEN_API BinaryenOp BinaryenShrSInt32(void);
355
+ BINARYEN_API BinaryenOp BinaryenRotLInt32(void);
356
+ BINARYEN_API BinaryenOp BinaryenRotRInt32(void);
357
+ BINARYEN_API BinaryenOp BinaryenEqInt32(void);
358
+ BINARYEN_API BinaryenOp BinaryenNeInt32(void);
359
+ BINARYEN_API BinaryenOp BinaryenLtSInt32(void);
360
+ BINARYEN_API BinaryenOp BinaryenLtUInt32(void);
361
+ BINARYEN_API BinaryenOp BinaryenLeSInt32(void);
362
+ BINARYEN_API BinaryenOp BinaryenLeUInt32(void);
363
+ BINARYEN_API BinaryenOp BinaryenGtSInt32(void);
364
+ BINARYEN_API BinaryenOp BinaryenGtUInt32(void);
365
+ BINARYEN_API BinaryenOp BinaryenGeSInt32(void);
366
+ BINARYEN_API BinaryenOp BinaryenGeUInt32(void);
367
+ BINARYEN_API BinaryenOp BinaryenAddInt64(void);
368
+ BINARYEN_API BinaryenOp BinaryenSubInt64(void);
369
+ BINARYEN_API BinaryenOp BinaryenMulInt64(void);
370
+ BINARYEN_API BinaryenOp BinaryenDivSInt64(void);
371
+ BINARYEN_API BinaryenOp BinaryenDivUInt64(void);
372
+ BINARYEN_API BinaryenOp BinaryenRemSInt64(void);
373
+ BINARYEN_API BinaryenOp BinaryenRemUInt64(void);
374
+ BINARYEN_API BinaryenOp BinaryenAndInt64(void);
375
+ BINARYEN_API BinaryenOp BinaryenOrInt64(void);
376
+ BINARYEN_API BinaryenOp BinaryenXorInt64(void);
377
+ BINARYEN_API BinaryenOp BinaryenShlInt64(void);
378
+ BINARYEN_API BinaryenOp BinaryenShrUInt64(void);
379
+ BINARYEN_API BinaryenOp BinaryenShrSInt64(void);
380
+ BINARYEN_API BinaryenOp BinaryenRotLInt64(void);
381
+ BINARYEN_API BinaryenOp BinaryenRotRInt64(void);
382
+ BINARYEN_API BinaryenOp BinaryenEqInt64(void);
383
+ BINARYEN_API BinaryenOp BinaryenNeInt64(void);
384
+ BINARYEN_API BinaryenOp BinaryenLtSInt64(void);
385
+ BINARYEN_API BinaryenOp BinaryenLtUInt64(void);
386
+ BINARYEN_API BinaryenOp BinaryenLeSInt64(void);
387
+ BINARYEN_API BinaryenOp BinaryenLeUInt64(void);
388
+ BINARYEN_API BinaryenOp BinaryenGtSInt64(void);
389
+ BINARYEN_API BinaryenOp BinaryenGtUInt64(void);
390
+ BINARYEN_API BinaryenOp BinaryenGeSInt64(void);
391
+ BINARYEN_API BinaryenOp BinaryenGeUInt64(void);
392
+ BINARYEN_API BinaryenOp BinaryenAddFloat32(void);
393
+ BINARYEN_API BinaryenOp BinaryenSubFloat32(void);
394
+ BINARYEN_API BinaryenOp BinaryenMulFloat32(void);
395
+ BINARYEN_API BinaryenOp BinaryenDivFloat32(void);
396
+ BINARYEN_API BinaryenOp BinaryenCopySignFloat32(void);
397
+ BINARYEN_API BinaryenOp BinaryenMinFloat32(void);
398
+ BINARYEN_API BinaryenOp BinaryenMaxFloat32(void);
399
+ BINARYEN_API BinaryenOp BinaryenEqFloat32(void);
400
+ BINARYEN_API BinaryenOp BinaryenNeFloat32(void);
401
+ BINARYEN_API BinaryenOp BinaryenLtFloat32(void);
402
+ BINARYEN_API BinaryenOp BinaryenLeFloat32(void);
403
+ BINARYEN_API BinaryenOp BinaryenGtFloat32(void);
404
+ BINARYEN_API BinaryenOp BinaryenGeFloat32(void);
405
+ BINARYEN_API BinaryenOp BinaryenAddFloat64(void);
406
+ BINARYEN_API BinaryenOp BinaryenSubFloat64(void);
407
+ BINARYEN_API BinaryenOp BinaryenMulFloat64(void);
408
+ BINARYEN_API BinaryenOp BinaryenDivFloat64(void);
409
+ BINARYEN_API BinaryenOp BinaryenCopySignFloat64(void);
410
+ BINARYEN_API BinaryenOp BinaryenMinFloat64(void);
411
+ BINARYEN_API BinaryenOp BinaryenMaxFloat64(void);
412
+ BINARYEN_API BinaryenOp BinaryenEqFloat64(void);
413
+ BINARYEN_API BinaryenOp BinaryenNeFloat64(void);
414
+ BINARYEN_API BinaryenOp BinaryenLtFloat64(void);
415
+ BINARYEN_API BinaryenOp BinaryenLeFloat64(void);
416
+ BINARYEN_API BinaryenOp BinaryenGtFloat64(void);
417
+ BINARYEN_API BinaryenOp BinaryenGeFloat64(void);
418
+ BINARYEN_API BinaryenOp BinaryenAtomicRMWAdd(void);
419
+ BINARYEN_API BinaryenOp BinaryenAtomicRMWSub(void);
420
+ BINARYEN_API BinaryenOp BinaryenAtomicRMWAnd(void);
421
+ BINARYEN_API BinaryenOp BinaryenAtomicRMWOr(void);
422
+ BINARYEN_API BinaryenOp BinaryenAtomicRMWXor(void);
423
+ BINARYEN_API BinaryenOp BinaryenAtomicRMWXchg(void);
424
+ BINARYEN_API BinaryenOp BinaryenTruncSatSFloat32ToInt32(void);
425
+ BINARYEN_API BinaryenOp BinaryenTruncSatSFloat32ToInt64(void);
426
+ BINARYEN_API BinaryenOp BinaryenTruncSatUFloat32ToInt32(void);
427
+ BINARYEN_API BinaryenOp BinaryenTruncSatUFloat32ToInt64(void);
428
+ BINARYEN_API BinaryenOp BinaryenTruncSatSFloat64ToInt32(void);
429
+ BINARYEN_API BinaryenOp BinaryenTruncSatSFloat64ToInt64(void);
430
+ BINARYEN_API BinaryenOp BinaryenTruncSatUFloat64ToInt32(void);
431
+ BINARYEN_API BinaryenOp BinaryenTruncSatUFloat64ToInt64(void);
432
+ BINARYEN_API BinaryenOp BinaryenSplatVecI8x16(void);
433
+ BINARYEN_API BinaryenOp BinaryenExtractLaneSVecI8x16(void);
434
+ BINARYEN_API BinaryenOp BinaryenExtractLaneUVecI8x16(void);
435
+ BINARYEN_API BinaryenOp BinaryenReplaceLaneVecI8x16(void);
436
+ BINARYEN_API BinaryenOp BinaryenSplatVecI16x8(void);
437
+ BINARYEN_API BinaryenOp BinaryenExtractLaneSVecI16x8(void);
438
+ BINARYEN_API BinaryenOp BinaryenExtractLaneUVecI16x8(void);
439
+ BINARYEN_API BinaryenOp BinaryenReplaceLaneVecI16x8(void);
440
+ BINARYEN_API BinaryenOp BinaryenSplatVecI32x4(void);
441
+ BINARYEN_API BinaryenOp BinaryenExtractLaneVecI32x4(void);
442
+ BINARYEN_API BinaryenOp BinaryenReplaceLaneVecI32x4(void);
443
+ BINARYEN_API BinaryenOp BinaryenSplatVecI64x2(void);
444
+ BINARYEN_API BinaryenOp BinaryenExtractLaneVecI64x2(void);
445
+ BINARYEN_API BinaryenOp BinaryenReplaceLaneVecI64x2(void);
446
+ BINARYEN_API BinaryenOp BinaryenSplatVecF32x4(void);
447
+ BINARYEN_API BinaryenOp BinaryenExtractLaneVecF32x4(void);
448
+ BINARYEN_API BinaryenOp BinaryenReplaceLaneVecF32x4(void);
449
+ BINARYEN_API BinaryenOp BinaryenSplatVecF64x2(void);
450
+ BINARYEN_API BinaryenOp BinaryenExtractLaneVecF64x2(void);
451
+ BINARYEN_API BinaryenOp BinaryenReplaceLaneVecF64x2(void);
452
+ BINARYEN_API BinaryenOp BinaryenEqVecI8x16(void);
453
+ BINARYEN_API BinaryenOp BinaryenNeVecI8x16(void);
454
+ BINARYEN_API BinaryenOp BinaryenLtSVecI8x16(void);
455
+ BINARYEN_API BinaryenOp BinaryenLtUVecI8x16(void);
456
+ BINARYEN_API BinaryenOp BinaryenGtSVecI8x16(void);
457
+ BINARYEN_API BinaryenOp BinaryenGtUVecI8x16(void);
458
+ BINARYEN_API BinaryenOp BinaryenLeSVecI8x16(void);
459
+ BINARYEN_API BinaryenOp BinaryenLeUVecI8x16(void);
460
+ BINARYEN_API BinaryenOp BinaryenGeSVecI8x16(void);
461
+ BINARYEN_API BinaryenOp BinaryenGeUVecI8x16(void);
462
+ BINARYEN_API BinaryenOp BinaryenEqVecI16x8(void);
463
+ BINARYEN_API BinaryenOp BinaryenNeVecI16x8(void);
464
+ BINARYEN_API BinaryenOp BinaryenLtSVecI16x8(void);
465
+ BINARYEN_API BinaryenOp BinaryenLtUVecI16x8(void);
466
+ BINARYEN_API BinaryenOp BinaryenGtSVecI16x8(void);
467
+ BINARYEN_API BinaryenOp BinaryenGtUVecI16x8(void);
468
+ BINARYEN_API BinaryenOp BinaryenLeSVecI16x8(void);
469
+ BINARYEN_API BinaryenOp BinaryenLeUVecI16x8(void);
470
+ BINARYEN_API BinaryenOp BinaryenGeSVecI16x8(void);
471
+ BINARYEN_API BinaryenOp BinaryenGeUVecI16x8(void);
472
+ BINARYEN_API BinaryenOp BinaryenEqVecI32x4(void);
473
+ BINARYEN_API BinaryenOp BinaryenNeVecI32x4(void);
474
+ BINARYEN_API BinaryenOp BinaryenLtSVecI32x4(void);
475
+ BINARYEN_API BinaryenOp BinaryenLtUVecI32x4(void);
476
+ BINARYEN_API BinaryenOp BinaryenGtSVecI32x4(void);
477
+ BINARYEN_API BinaryenOp BinaryenGtUVecI32x4(void);
478
+ BINARYEN_API BinaryenOp BinaryenLeSVecI32x4(void);
479
+ BINARYEN_API BinaryenOp BinaryenLeUVecI32x4(void);
480
+ BINARYEN_API BinaryenOp BinaryenGeSVecI32x4(void);
481
+ BINARYEN_API BinaryenOp BinaryenGeUVecI32x4(void);
482
+ BINARYEN_API BinaryenOp BinaryenEqVecI64x2(void);
483
+ BINARYEN_API BinaryenOp BinaryenNeVecI64x2(void);
484
+ BINARYEN_API BinaryenOp BinaryenLtSVecI64x2(void);
485
+ BINARYEN_API BinaryenOp BinaryenGtSVecI64x2(void);
486
+ BINARYEN_API BinaryenOp BinaryenLeSVecI64x2(void);
487
+ BINARYEN_API BinaryenOp BinaryenGeSVecI64x2(void);
488
+ BINARYEN_API BinaryenOp BinaryenEqVecF32x4(void);
489
+ BINARYEN_API BinaryenOp BinaryenNeVecF32x4(void);
490
+ BINARYEN_API BinaryenOp BinaryenLtVecF32x4(void);
491
+ BINARYEN_API BinaryenOp BinaryenGtVecF32x4(void);
492
+ BINARYEN_API BinaryenOp BinaryenLeVecF32x4(void);
493
+ BINARYEN_API BinaryenOp BinaryenGeVecF32x4(void);
494
+ BINARYEN_API BinaryenOp BinaryenEqVecF64x2(void);
495
+ BINARYEN_API BinaryenOp BinaryenNeVecF64x2(void);
496
+ BINARYEN_API BinaryenOp BinaryenLtVecF64x2(void);
497
+ BINARYEN_API BinaryenOp BinaryenGtVecF64x2(void);
498
+ BINARYEN_API BinaryenOp BinaryenLeVecF64x2(void);
499
+ BINARYEN_API BinaryenOp BinaryenGeVecF64x2(void);
500
+ BINARYEN_API BinaryenOp BinaryenNotVec128(void);
501
+ BINARYEN_API BinaryenOp BinaryenAndVec128(void);
502
+ BINARYEN_API BinaryenOp BinaryenOrVec128(void);
503
+ BINARYEN_API BinaryenOp BinaryenXorVec128(void);
504
+ BINARYEN_API BinaryenOp BinaryenAndNotVec128(void);
505
+ BINARYEN_API BinaryenOp BinaryenBitselectVec128(void);
506
+ BINARYEN_API BinaryenOp BinaryenRelaxedFmaVecF32x4(void);
507
+ BINARYEN_API BinaryenOp BinaryenRelaxedFmsVecF32x4(void);
508
+ BINARYEN_API BinaryenOp BinaryenRelaxedFmaVecF64x2(void);
509
+ BINARYEN_API BinaryenOp BinaryenRelaxedFmsVecF64x2(void);
510
+ BINARYEN_API BinaryenOp BinaryenLaneselectI8x16(void);
511
+ BINARYEN_API BinaryenOp BinaryenLaneselectI16x8(void);
512
+ BINARYEN_API BinaryenOp BinaryenLaneselectI32x4(void);
513
+ BINARYEN_API BinaryenOp BinaryenLaneselectI64x2(void);
514
+ BINARYEN_API BinaryenOp BinaryenDotI8x16I7x16AddSToVecI32x4(void);
515
+ BINARYEN_API BinaryenOp BinaryenAnyTrueVec128(void);
516
+ BINARYEN_API BinaryenOp BinaryenPopcntVecI8x16(void);
517
+ BINARYEN_API BinaryenOp BinaryenAbsVecI8x16(void);
518
+ BINARYEN_API BinaryenOp BinaryenNegVecI8x16(void);
519
+ BINARYEN_API BinaryenOp BinaryenAllTrueVecI8x16(void);
520
+ BINARYEN_API BinaryenOp BinaryenBitmaskVecI8x16(void);
521
+ BINARYEN_API BinaryenOp BinaryenShlVecI8x16(void);
522
+ BINARYEN_API BinaryenOp BinaryenShrSVecI8x16(void);
523
+ BINARYEN_API BinaryenOp BinaryenShrUVecI8x16(void);
524
+ BINARYEN_API BinaryenOp BinaryenAddVecI8x16(void);
525
+ BINARYEN_API BinaryenOp BinaryenAddSatSVecI8x16(void);
526
+ BINARYEN_API BinaryenOp BinaryenAddSatUVecI8x16(void);
527
+ BINARYEN_API BinaryenOp BinaryenSubVecI8x16(void);
528
+ BINARYEN_API BinaryenOp BinaryenSubSatSVecI8x16(void);
529
+ BINARYEN_API BinaryenOp BinaryenSubSatUVecI8x16(void);
530
+ BINARYEN_API BinaryenOp BinaryenMinSVecI8x16(void);
531
+ BINARYEN_API BinaryenOp BinaryenMinUVecI8x16(void);
532
+ BINARYEN_API BinaryenOp BinaryenMaxSVecI8x16(void);
533
+ BINARYEN_API BinaryenOp BinaryenMaxUVecI8x16(void);
534
+ BINARYEN_API BinaryenOp BinaryenAvgrUVecI8x16(void);
535
+ BINARYEN_API BinaryenOp BinaryenAbsVecI16x8(void);
536
+ BINARYEN_API BinaryenOp BinaryenNegVecI16x8(void);
537
+ BINARYEN_API BinaryenOp BinaryenAllTrueVecI16x8(void);
538
+ BINARYEN_API BinaryenOp BinaryenBitmaskVecI16x8(void);
539
+ BINARYEN_API BinaryenOp BinaryenShlVecI16x8(void);
540
+ BINARYEN_API BinaryenOp BinaryenShrSVecI16x8(void);
541
+ BINARYEN_API BinaryenOp BinaryenShrUVecI16x8(void);
542
+ BINARYEN_API BinaryenOp BinaryenAddVecI16x8(void);
543
+ BINARYEN_API BinaryenOp BinaryenAddSatSVecI16x8(void);
544
+ BINARYEN_API BinaryenOp BinaryenAddSatUVecI16x8(void);
545
+ BINARYEN_API BinaryenOp BinaryenSubVecI16x8(void);
546
+ BINARYEN_API BinaryenOp BinaryenSubSatSVecI16x8(void);
547
+ BINARYEN_API BinaryenOp BinaryenSubSatUVecI16x8(void);
548
+ BINARYEN_API BinaryenOp BinaryenMulVecI16x8(void);
549
+ BINARYEN_API BinaryenOp BinaryenMinSVecI16x8(void);
550
+ BINARYEN_API BinaryenOp BinaryenMinUVecI16x8(void);
551
+ BINARYEN_API BinaryenOp BinaryenMaxSVecI16x8(void);
552
+ BINARYEN_API BinaryenOp BinaryenMaxUVecI16x8(void);
553
+ BINARYEN_API BinaryenOp BinaryenAvgrUVecI16x8(void);
554
+ BINARYEN_API BinaryenOp BinaryenQ15MulrSatSVecI16x8(void);
555
+ BINARYEN_API BinaryenOp BinaryenExtMulLowSVecI16x8(void);
556
+ BINARYEN_API BinaryenOp BinaryenExtMulHighSVecI16x8(void);
557
+ BINARYEN_API BinaryenOp BinaryenExtMulLowUVecI16x8(void);
558
+ BINARYEN_API BinaryenOp BinaryenExtMulHighUVecI16x8(void);
559
+ BINARYEN_API BinaryenOp BinaryenAbsVecI32x4(void);
560
+ BINARYEN_API BinaryenOp BinaryenNegVecI32x4(void);
561
+ BINARYEN_API BinaryenOp BinaryenAllTrueVecI32x4(void);
562
+ BINARYEN_API BinaryenOp BinaryenBitmaskVecI32x4(void);
563
+ BINARYEN_API BinaryenOp BinaryenShlVecI32x4(void);
564
+ BINARYEN_API BinaryenOp BinaryenShrSVecI32x4(void);
565
+ BINARYEN_API BinaryenOp BinaryenShrUVecI32x4(void);
566
+ BINARYEN_API BinaryenOp BinaryenAddVecI32x4(void);
567
+ BINARYEN_API BinaryenOp BinaryenSubVecI32x4(void);
568
+ BINARYEN_API BinaryenOp BinaryenMulVecI32x4(void);
569
+ BINARYEN_API BinaryenOp BinaryenMinSVecI32x4(void);
570
+ BINARYEN_API BinaryenOp BinaryenMinUVecI32x4(void);
571
+ BINARYEN_API BinaryenOp BinaryenMaxSVecI32x4(void);
572
+ BINARYEN_API BinaryenOp BinaryenMaxUVecI32x4(void);
573
+ BINARYEN_API BinaryenOp BinaryenDotSVecI16x8ToVecI32x4(void);
574
+ BINARYEN_API BinaryenOp BinaryenExtMulLowSVecI32x4(void);
575
+ BINARYEN_API BinaryenOp BinaryenExtMulHighSVecI32x4(void);
576
+ BINARYEN_API BinaryenOp BinaryenExtMulLowUVecI32x4(void);
577
+ BINARYEN_API BinaryenOp BinaryenExtMulHighUVecI32x4(void);
578
+ BINARYEN_API BinaryenOp BinaryenAbsVecI64x2(void);
579
+ BINARYEN_API BinaryenOp BinaryenNegVecI64x2(void);
580
+ BINARYEN_API BinaryenOp BinaryenAllTrueVecI64x2(void);
581
+ BINARYEN_API BinaryenOp BinaryenBitmaskVecI64x2(void);
582
+ BINARYEN_API BinaryenOp BinaryenShlVecI64x2(void);
583
+ BINARYEN_API BinaryenOp BinaryenShrSVecI64x2(void);
584
+ BINARYEN_API BinaryenOp BinaryenShrUVecI64x2(void);
585
+ BINARYEN_API BinaryenOp BinaryenAddVecI64x2(void);
586
+ BINARYEN_API BinaryenOp BinaryenSubVecI64x2(void);
587
+ BINARYEN_API BinaryenOp BinaryenMulVecI64x2(void);
588
+ BINARYEN_API BinaryenOp BinaryenExtMulLowSVecI64x2(void);
589
+ BINARYEN_API BinaryenOp BinaryenExtMulHighSVecI64x2(void);
590
+ BINARYEN_API BinaryenOp BinaryenExtMulLowUVecI64x2(void);
591
+ BINARYEN_API BinaryenOp BinaryenExtMulHighUVecI64x2(void);
592
+ BINARYEN_API BinaryenOp BinaryenAbsVecF32x4(void);
593
+ BINARYEN_API BinaryenOp BinaryenNegVecF32x4(void);
594
+ BINARYEN_API BinaryenOp BinaryenSqrtVecF32x4(void);
595
+ BINARYEN_API BinaryenOp BinaryenAddVecF32x4(void);
596
+ BINARYEN_API BinaryenOp BinaryenSubVecF32x4(void);
597
+ BINARYEN_API BinaryenOp BinaryenMulVecF32x4(void);
598
+ BINARYEN_API BinaryenOp BinaryenDivVecF32x4(void);
599
+ BINARYEN_API BinaryenOp BinaryenMinVecF32x4(void);
600
+ BINARYEN_API BinaryenOp BinaryenMaxVecF32x4(void);
601
+ BINARYEN_API BinaryenOp BinaryenPMinVecF32x4(void);
602
+ BINARYEN_API BinaryenOp BinaryenPMaxVecF32x4(void);
603
+ BINARYEN_API BinaryenOp BinaryenCeilVecF32x4(void);
604
+ BINARYEN_API BinaryenOp BinaryenFloorVecF32x4(void);
605
+ BINARYEN_API BinaryenOp BinaryenTruncVecF32x4(void);
606
+ BINARYEN_API BinaryenOp BinaryenNearestVecF32x4(void);
607
+ BINARYEN_API BinaryenOp BinaryenAbsVecF64x2(void);
608
+ BINARYEN_API BinaryenOp BinaryenNegVecF64x2(void);
609
+ BINARYEN_API BinaryenOp BinaryenSqrtVecF64x2(void);
610
+ BINARYEN_API BinaryenOp BinaryenAddVecF64x2(void);
611
+ BINARYEN_API BinaryenOp BinaryenSubVecF64x2(void);
612
+ BINARYEN_API BinaryenOp BinaryenMulVecF64x2(void);
613
+ BINARYEN_API BinaryenOp BinaryenDivVecF64x2(void);
614
+ BINARYEN_API BinaryenOp BinaryenMinVecF64x2(void);
615
+ BINARYEN_API BinaryenOp BinaryenMaxVecF64x2(void);
616
+ BINARYEN_API BinaryenOp BinaryenPMinVecF64x2(void);
617
+ BINARYEN_API BinaryenOp BinaryenPMaxVecF64x2(void);
618
+ BINARYEN_API BinaryenOp BinaryenCeilVecF64x2(void);
619
+ BINARYEN_API BinaryenOp BinaryenFloorVecF64x2(void);
620
+ BINARYEN_API BinaryenOp BinaryenTruncVecF64x2(void);
621
+ BINARYEN_API BinaryenOp BinaryenNearestVecF64x2(void);
622
+ BINARYEN_API BinaryenOp BinaryenExtAddPairwiseSVecI8x16ToI16x8(void);
623
+ BINARYEN_API BinaryenOp BinaryenExtAddPairwiseUVecI8x16ToI16x8(void);
624
+ BINARYEN_API BinaryenOp BinaryenExtAddPairwiseSVecI16x8ToI32x4(void);
625
+ BINARYEN_API BinaryenOp BinaryenExtAddPairwiseUVecI16x8ToI32x4(void);
626
+ BINARYEN_API BinaryenOp BinaryenTruncSatSVecF32x4ToVecI32x4(void);
627
+ BINARYEN_API BinaryenOp BinaryenTruncSatUVecF32x4ToVecI32x4(void);
628
+ BINARYEN_API BinaryenOp BinaryenConvertSVecI32x4ToVecF32x4(void);
629
+ BINARYEN_API BinaryenOp BinaryenConvertUVecI32x4ToVecF32x4(void);
630
+ BINARYEN_API BinaryenOp BinaryenLoad8SplatVec128(void);
631
+ BINARYEN_API BinaryenOp BinaryenLoad16SplatVec128(void);
632
+ BINARYEN_API BinaryenOp BinaryenLoad32SplatVec128(void);
633
+ BINARYEN_API BinaryenOp BinaryenLoad64SplatVec128(void);
634
+ BINARYEN_API BinaryenOp BinaryenLoad8x8SVec128(void);
635
+ BINARYEN_API BinaryenOp BinaryenLoad8x8UVec128(void);
636
+ BINARYEN_API BinaryenOp BinaryenLoad16x4SVec128(void);
637
+ BINARYEN_API BinaryenOp BinaryenLoad16x4UVec128(void);
638
+ BINARYEN_API BinaryenOp BinaryenLoad32x2SVec128(void);
639
+ BINARYEN_API BinaryenOp BinaryenLoad32x2UVec128(void);
640
+ BINARYEN_API BinaryenOp BinaryenLoad32ZeroVec128(void);
641
+ BINARYEN_API BinaryenOp BinaryenLoad64ZeroVec128(void);
642
+ BINARYEN_API BinaryenOp BinaryenLoad8LaneVec128(void);
643
+ BINARYEN_API BinaryenOp BinaryenLoad16LaneVec128(void);
644
+ BINARYEN_API BinaryenOp BinaryenLoad32LaneVec128(void);
645
+ BINARYEN_API BinaryenOp BinaryenLoad64LaneVec128(void);
646
+ BINARYEN_API BinaryenOp BinaryenStore8LaneVec128(void);
647
+ BINARYEN_API BinaryenOp BinaryenStore16LaneVec128(void);
648
+ BINARYEN_API BinaryenOp BinaryenStore32LaneVec128(void);
649
+ BINARYEN_API BinaryenOp BinaryenStore64LaneVec128(void);
650
+ BINARYEN_API BinaryenOp BinaryenNarrowSVecI16x8ToVecI8x16(void);
651
+ BINARYEN_API BinaryenOp BinaryenNarrowUVecI16x8ToVecI8x16(void);
652
+ BINARYEN_API BinaryenOp BinaryenNarrowSVecI32x4ToVecI16x8(void);
653
+ BINARYEN_API BinaryenOp BinaryenNarrowUVecI32x4ToVecI16x8(void);
654
+ BINARYEN_API BinaryenOp BinaryenExtendLowSVecI8x16ToVecI16x8(void);
655
+ BINARYEN_API BinaryenOp BinaryenExtendHighSVecI8x16ToVecI16x8(void);
656
+ BINARYEN_API BinaryenOp BinaryenExtendLowUVecI8x16ToVecI16x8(void);
657
+ BINARYEN_API BinaryenOp BinaryenExtendHighUVecI8x16ToVecI16x8(void);
658
+ BINARYEN_API BinaryenOp BinaryenExtendLowSVecI16x8ToVecI32x4(void);
659
+ BINARYEN_API BinaryenOp BinaryenExtendHighSVecI16x8ToVecI32x4(void);
660
+ BINARYEN_API BinaryenOp BinaryenExtendLowUVecI16x8ToVecI32x4(void);
661
+ BINARYEN_API BinaryenOp BinaryenExtendHighUVecI16x8ToVecI32x4(void);
662
+ BINARYEN_API BinaryenOp BinaryenExtendLowSVecI32x4ToVecI64x2(void);
663
+ BINARYEN_API BinaryenOp BinaryenExtendHighSVecI32x4ToVecI64x2(void);
664
+ BINARYEN_API BinaryenOp BinaryenExtendLowUVecI32x4ToVecI64x2(void);
665
+ BINARYEN_API BinaryenOp BinaryenExtendHighUVecI32x4ToVecI64x2(void);
666
+ BINARYEN_API BinaryenOp BinaryenConvertLowSVecI32x4ToVecF64x2(void);
667
+ BINARYEN_API BinaryenOp BinaryenConvertLowUVecI32x4ToVecF64x2(void);
668
+ BINARYEN_API BinaryenOp BinaryenTruncSatZeroSVecF64x2ToVecI32x4(void);
669
+ BINARYEN_API BinaryenOp BinaryenTruncSatZeroUVecF64x2ToVecI32x4(void);
670
+ BINARYEN_API BinaryenOp BinaryenDemoteZeroVecF64x2ToVecF32x4(void);
671
+ BINARYEN_API BinaryenOp BinaryenPromoteLowVecF32x4ToVecF64x2(void);
672
+ BINARYEN_API BinaryenOp BinaryenRelaxedTruncSVecF32x4ToVecI32x4(void);
673
+ BINARYEN_API BinaryenOp BinaryenRelaxedTruncUVecF32x4ToVecI32x4(void);
674
+ BINARYEN_API BinaryenOp BinaryenRelaxedTruncZeroSVecF64x2ToVecI32x4(void);
675
+ BINARYEN_API BinaryenOp BinaryenRelaxedTruncZeroUVecF64x2ToVecI32x4(void);
676
+ BINARYEN_API BinaryenOp BinaryenSwizzleVecI8x16(void);
677
+ BINARYEN_API BinaryenOp BinaryenRelaxedSwizzleVecI8x16(void);
678
+ BINARYEN_API BinaryenOp BinaryenRelaxedMinVecF32x4(void);
679
+ BINARYEN_API BinaryenOp BinaryenRelaxedMaxVecF32x4(void);
680
+ BINARYEN_API BinaryenOp BinaryenRelaxedMinVecF64x2(void);
681
+ BINARYEN_API BinaryenOp BinaryenRelaxedMaxVecF64x2(void);
682
+ BINARYEN_API BinaryenOp BinaryenRelaxedQ15MulrSVecI16x8(void);
683
+ BINARYEN_API BinaryenOp BinaryenDotI8x16I7x16SToVecI16x8(void);
684
+ BINARYEN_API BinaryenOp BinaryenRefAsNonNull(void);
685
+ BINARYEN_API BinaryenOp BinaryenRefAsExternInternalize(void);
686
+ BINARYEN_API BinaryenOp BinaryenRefAsExternExternalize(void);
687
+ BINARYEN_API BinaryenOp BinaryenBrOnNull(void);
688
+ BINARYEN_API BinaryenOp BinaryenBrOnNonNull(void);
689
+ BINARYEN_API BinaryenOp BinaryenBrOnCast(void);
690
+ BINARYEN_API BinaryenOp BinaryenBrOnCastFail(void);
691
+ BINARYEN_API BinaryenOp BinaryenStringNewUTF8(void);
692
+ BINARYEN_API BinaryenOp BinaryenStringNewWTF8(void);
693
+ BINARYEN_API BinaryenOp BinaryenStringNewLossyUTF8(void);
694
+ BINARYEN_API BinaryenOp BinaryenStringNewWTF16(void);
695
+ BINARYEN_API BinaryenOp BinaryenStringNewUTF8Array(void);
696
+ BINARYEN_API BinaryenOp BinaryenStringNewWTF8Array(void);
697
+ BINARYEN_API BinaryenOp BinaryenStringNewLossyUTF8Array(void);
698
+ BINARYEN_API BinaryenOp BinaryenStringNewWTF16Array(void);
699
+ BINARYEN_API BinaryenOp BinaryenStringNewFromCodePoint(void);
700
+ BINARYEN_API BinaryenOp BinaryenStringMeasureUTF8(void);
701
+ BINARYEN_API BinaryenOp BinaryenStringMeasureWTF8(void);
702
+ BINARYEN_API BinaryenOp BinaryenStringMeasureWTF16(void);
703
+ BINARYEN_API BinaryenOp BinaryenStringMeasureIsUSV(void);
704
+ BINARYEN_API BinaryenOp BinaryenStringMeasureWTF16View(void);
705
+ BINARYEN_API BinaryenOp BinaryenStringEncodeUTF8(void);
706
+ BINARYEN_API BinaryenOp BinaryenStringEncodeLossyUTF8(void);
707
+ BINARYEN_API BinaryenOp BinaryenStringEncodeWTF8(void);
708
+ BINARYEN_API BinaryenOp BinaryenStringEncodeWTF16(void);
709
+ BINARYEN_API BinaryenOp BinaryenStringEncodeUTF8Array(void);
710
+ BINARYEN_API BinaryenOp BinaryenStringEncodeLossyUTF8Array(void);
711
+ BINARYEN_API BinaryenOp BinaryenStringEncodeWTF8Array(void);
712
+ BINARYEN_API BinaryenOp BinaryenStringEncodeWTF16Array(void);
713
+ BINARYEN_API BinaryenOp BinaryenStringAsWTF8(void);
714
+ BINARYEN_API BinaryenOp BinaryenStringAsWTF16(void);
715
+ BINARYEN_API BinaryenOp BinaryenStringAsIter(void);
716
+ BINARYEN_API BinaryenOp BinaryenStringIterMoveAdvance(void);
717
+ BINARYEN_API BinaryenOp BinaryenStringIterMoveRewind(void);
718
+ BINARYEN_API BinaryenOp BinaryenStringSliceWTF8(void);
719
+ BINARYEN_API BinaryenOp BinaryenStringSliceWTF16(void);
720
+ BINARYEN_API BinaryenOp BinaryenStringEqEqual(void);
721
+ BINARYEN_API BinaryenOp BinaryenStringEqCompare(void);
722
+
723
+ BINARYEN_REF(Expression);
724
+
725
+ // Block: name can be NULL. Specifying BinaryenUndefined() as the 'type'
726
+ // parameter indicates that the block's type shall be figured out
727
+ // automatically instead of explicitly providing it. This conforms
728
+ // to the behavior before the 'type' parameter has been introduced.
729
+ BINARYEN_API BinaryenExpressionRef
730
+ BinaryenBlock(BinaryenModuleRef module,
731
+ const char* name,
732
+ BinaryenExpressionRef* children,
733
+ BinaryenIndex numChildren,
734
+ BinaryenType type);
735
+ // If: ifFalse can be NULL
736
+ BINARYEN_API BinaryenExpressionRef BinaryenIf(BinaryenModuleRef module,
737
+ BinaryenExpressionRef condition,
738
+ BinaryenExpressionRef ifTrue,
739
+ BinaryenExpressionRef ifFalse);
740
+ BINARYEN_API BinaryenExpressionRef BinaryenLoop(BinaryenModuleRef module,
741
+ const char* in,
742
+ BinaryenExpressionRef body);
743
+ // Break: value and condition can be NULL
744
+ BINARYEN_API BinaryenExpressionRef
745
+ BinaryenBreak(BinaryenModuleRef module,
746
+ const char* name,
747
+ BinaryenExpressionRef condition,
748
+ BinaryenExpressionRef value);
749
+ // Switch: value can be NULL
750
+ BINARYEN_API BinaryenExpressionRef
751
+ BinaryenSwitch(BinaryenModuleRef module,
752
+ const char** names,
753
+ BinaryenIndex numNames,
754
+ const char* defaultName,
755
+ BinaryenExpressionRef condition,
756
+ BinaryenExpressionRef value);
757
+ // Call: Note the 'returnType' parameter. You must declare the
758
+ // type returned by the function being called, as that
759
+ // function might not have been created yet, so we don't
760
+ // know what it is.
761
+ BINARYEN_API BinaryenExpressionRef BinaryenCall(BinaryenModuleRef module,
762
+ const char* target,
763
+ BinaryenExpressionRef* operands,
764
+ BinaryenIndex numOperands,
765
+ BinaryenType returnType);
766
+ BINARYEN_API BinaryenExpressionRef
767
+ BinaryenCallIndirect(BinaryenModuleRef module,
768
+ const char* table,
769
+ BinaryenExpressionRef target,
770
+ BinaryenExpressionRef* operands,
771
+ BinaryenIndex numOperands,
772
+ BinaryenType params,
773
+ BinaryenType results);
774
+ BINARYEN_API BinaryenExpressionRef
775
+ BinaryenReturnCall(BinaryenModuleRef module,
776
+ const char* target,
777
+ BinaryenExpressionRef* operands,
778
+ BinaryenIndex numOperands,
779
+ BinaryenType returnType);
780
+ BINARYEN_API BinaryenExpressionRef
781
+ BinaryenReturnCallIndirect(BinaryenModuleRef module,
782
+ const char* table,
783
+ BinaryenExpressionRef target,
784
+ BinaryenExpressionRef* operands,
785
+ BinaryenIndex numOperands,
786
+ BinaryenType params,
787
+ BinaryenType results);
788
+
789
+ // LocalGet: Note the 'type' parameter. It might seem redundant, since the
790
+ // local at that index must have a type. However, this API lets you
791
+ // build code "top-down": create a node, then its parents, and so
792
+ // on, and finally create the function at the end. (Note that in fact
793
+ // you do not mention a function when creating ExpressionRefs, only
794
+ // a module.) And since LocalGet is a leaf node, we need to be told
795
+ // its type. (Other nodes detect their type either from their
796
+ // type or their opcode, or failing that, their children. But
797
+ // LocalGet has no children, it is where a "stream" of type info
798
+ // begins.)
799
+ // Note also that the index of a local can refer to a param or
800
+ // a var, that is, either a parameter to the function or a variable
801
+ // declared when you call BinaryenAddFunction. See BinaryenAddFunction
802
+ // for more details.
803
+ BINARYEN_API BinaryenExpressionRef BinaryenLocalGet(BinaryenModuleRef module,
804
+ BinaryenIndex index,
805
+ BinaryenType type);
806
+ BINARYEN_API BinaryenExpressionRef BinaryenLocalSet(
807
+ BinaryenModuleRef module, BinaryenIndex index, BinaryenExpressionRef value);
808
+ BINARYEN_API BinaryenExpressionRef BinaryenLocalTee(BinaryenModuleRef module,
809
+ BinaryenIndex index,
810
+ BinaryenExpressionRef value,
811
+ BinaryenType type);
812
+ BINARYEN_API BinaryenExpressionRef BinaryenGlobalGet(BinaryenModuleRef module,
813
+ const char* name,
814
+ BinaryenType type);
815
+ BINARYEN_API BinaryenExpressionRef BinaryenGlobalSet(
816
+ BinaryenModuleRef module, const char* name, BinaryenExpressionRef value);
817
+ // Load: align can be 0, in which case it will be the natural alignment (equal
818
+ // to bytes)
819
+ BINARYEN_API BinaryenExpressionRef BinaryenLoad(BinaryenModuleRef module,
820
+ uint32_t bytes,
821
+ bool signed_,
822
+ uint32_t offset,
823
+ uint32_t align,
824
+ BinaryenType type,
825
+ BinaryenExpressionRef ptr,
826
+ const char* memoryName);
827
+ // Store: align can be 0, in which case it will be the natural alignment (equal
828
+ // to bytes)
829
+ BINARYEN_API BinaryenExpressionRef BinaryenStore(BinaryenModuleRef module,
830
+ uint32_t bytes,
831
+ uint32_t offset,
832
+ uint32_t align,
833
+ BinaryenExpressionRef ptr,
834
+ BinaryenExpressionRef value,
835
+ BinaryenType type,
836
+ const char* memoryName);
837
+ BINARYEN_API BinaryenExpressionRef BinaryenConst(BinaryenModuleRef module,
838
+ struct BinaryenLiteral value);
839
+ BINARYEN_API BinaryenExpressionRef BinaryenUnary(BinaryenModuleRef module,
840
+ BinaryenOp op,
841
+ BinaryenExpressionRef value);
842
+ BINARYEN_API BinaryenExpressionRef BinaryenBinary(BinaryenModuleRef module,
843
+ BinaryenOp op,
844
+ BinaryenExpressionRef left,
845
+ BinaryenExpressionRef right);
846
+ BINARYEN_API BinaryenExpressionRef
847
+ BinaryenSelect(BinaryenModuleRef module,
848
+ BinaryenExpressionRef condition,
849
+ BinaryenExpressionRef ifTrue,
850
+ BinaryenExpressionRef ifFalse,
851
+ BinaryenType type);
852
+ BINARYEN_API BinaryenExpressionRef BinaryenDrop(BinaryenModuleRef module,
853
+ BinaryenExpressionRef value);
854
+ // Return: value can be NULL
855
+ BINARYEN_API BinaryenExpressionRef BinaryenReturn(BinaryenModuleRef module,
856
+ BinaryenExpressionRef value);
857
+ BINARYEN_API BinaryenExpressionRef BinaryenMemorySize(BinaryenModuleRef module,
858
+ const char* memoryName,
859
+ bool memoryIs64);
860
+ BINARYEN_API BinaryenExpressionRef
861
+ BinaryenMemoryGrow(BinaryenModuleRef module,
862
+ BinaryenExpressionRef delta,
863
+ const char* memoryName,
864
+ bool memoryIs64);
865
+ BINARYEN_API BinaryenExpressionRef BinaryenNop(BinaryenModuleRef module);
866
+ BINARYEN_API BinaryenExpressionRef
867
+ BinaryenUnreachable(BinaryenModuleRef module);
868
+ BINARYEN_API BinaryenExpressionRef BinaryenAtomicLoad(BinaryenModuleRef module,
869
+ uint32_t bytes,
870
+ uint32_t offset,
871
+ BinaryenType type,
872
+ BinaryenExpressionRef ptr,
873
+ const char* memoryName);
874
+ BINARYEN_API BinaryenExpressionRef
875
+ BinaryenAtomicStore(BinaryenModuleRef module,
876
+ uint32_t bytes,
877
+ uint32_t offset,
878
+ BinaryenExpressionRef ptr,
879
+ BinaryenExpressionRef value,
880
+ BinaryenType type,
881
+ const char* memoryName);
882
+ BINARYEN_API BinaryenExpressionRef
883
+ BinaryenAtomicRMW(BinaryenModuleRef module,
884
+ BinaryenOp op,
885
+ BinaryenIndex bytes,
886
+ BinaryenIndex offset,
887
+ BinaryenExpressionRef ptr,
888
+ BinaryenExpressionRef value,
889
+ BinaryenType type,
890
+ const char* memoryName);
891
+ BINARYEN_API BinaryenExpressionRef
892
+ BinaryenAtomicCmpxchg(BinaryenModuleRef module,
893
+ BinaryenIndex bytes,
894
+ BinaryenIndex offset,
895
+ BinaryenExpressionRef ptr,
896
+ BinaryenExpressionRef expected,
897
+ BinaryenExpressionRef replacement,
898
+ BinaryenType type,
899
+ const char* memoryName);
900
+ BINARYEN_API BinaryenExpressionRef
901
+ BinaryenAtomicWait(BinaryenModuleRef module,
902
+ BinaryenExpressionRef ptr,
903
+ BinaryenExpressionRef expected,
904
+ BinaryenExpressionRef timeout,
905
+ BinaryenType type,
906
+ const char* memoryName);
907
+ BINARYEN_API BinaryenExpressionRef
908
+ BinaryenAtomicNotify(BinaryenModuleRef module,
909
+ BinaryenExpressionRef ptr,
910
+ BinaryenExpressionRef notifyCount,
911
+ const char* memoryName);
912
+ BINARYEN_API BinaryenExpressionRef
913
+ BinaryenAtomicFence(BinaryenModuleRef module);
914
+ BINARYEN_API BinaryenExpressionRef
915
+ BinaryenSIMDExtract(BinaryenModuleRef module,
916
+ BinaryenOp op,
917
+ BinaryenExpressionRef vec,
918
+ uint8_t index);
919
+ BINARYEN_API BinaryenExpressionRef
920
+ BinaryenSIMDReplace(BinaryenModuleRef module,
921
+ BinaryenOp op,
922
+ BinaryenExpressionRef vec,
923
+ uint8_t index,
924
+ BinaryenExpressionRef value);
925
+ BINARYEN_API BinaryenExpressionRef
926
+ BinaryenSIMDShuffle(BinaryenModuleRef module,
927
+ BinaryenExpressionRef left,
928
+ BinaryenExpressionRef right,
929
+ const uint8_t mask[16]);
930
+ BINARYEN_API BinaryenExpressionRef BinaryenSIMDTernary(BinaryenModuleRef module,
931
+ BinaryenOp op,
932
+ BinaryenExpressionRef a,
933
+ BinaryenExpressionRef b,
934
+ BinaryenExpressionRef c);
935
+ BINARYEN_API BinaryenExpressionRef
936
+ BinaryenSIMDShift(BinaryenModuleRef module,
937
+ BinaryenOp op,
938
+ BinaryenExpressionRef vec,
939
+ BinaryenExpressionRef shift);
940
+ BINARYEN_API BinaryenExpressionRef BinaryenSIMDLoad(BinaryenModuleRef module,
941
+ BinaryenOp op,
942
+ uint32_t offset,
943
+ uint32_t align,
944
+ BinaryenExpressionRef ptr,
945
+ const char* name);
946
+ BINARYEN_API BinaryenExpressionRef
947
+ BinaryenSIMDLoadStoreLane(BinaryenModuleRef module,
948
+ BinaryenOp op,
949
+ uint32_t offset,
950
+ uint32_t align,
951
+ uint8_t index,
952
+ BinaryenExpressionRef ptr,
953
+ BinaryenExpressionRef vec,
954
+ const char* memoryName);
955
+ BINARYEN_API BinaryenExpressionRef
956
+ BinaryenMemoryInit(BinaryenModuleRef module,
957
+ const char* segment,
958
+ BinaryenExpressionRef dest,
959
+ BinaryenExpressionRef offset,
960
+ BinaryenExpressionRef size,
961
+ const char* memoryName);
962
+ BINARYEN_API BinaryenExpressionRef BinaryenDataDrop(BinaryenModuleRef module,
963
+ const char* segment);
964
+ BINARYEN_API BinaryenExpressionRef
965
+ BinaryenMemoryCopy(BinaryenModuleRef module,
966
+ BinaryenExpressionRef dest,
967
+ BinaryenExpressionRef source,
968
+ BinaryenExpressionRef size,
969
+ const char* destMemory,
970
+ const char* sourceMemory);
971
+ BINARYEN_API BinaryenExpressionRef
972
+ BinaryenMemoryFill(BinaryenModuleRef module,
973
+ BinaryenExpressionRef dest,
974
+ BinaryenExpressionRef value,
975
+ BinaryenExpressionRef size,
976
+ const char* memoryName);
977
+ BINARYEN_API BinaryenExpressionRef BinaryenRefNull(BinaryenModuleRef module,
978
+ BinaryenType type);
979
+ BINARYEN_API BinaryenExpressionRef
980
+ BinaryenRefIsNull(BinaryenModuleRef module, BinaryenExpressionRef value);
981
+ BINARYEN_API BinaryenExpressionRef BinaryenRefAs(BinaryenModuleRef module,
982
+ BinaryenOp op,
983
+ BinaryenExpressionRef value);
984
+ BINARYEN_API BinaryenExpressionRef BinaryenRefFunc(BinaryenModuleRef module,
985
+ const char* func,
986
+ BinaryenType type);
987
+ BINARYEN_API BinaryenExpressionRef BinaryenRefEq(BinaryenModuleRef module,
988
+ BinaryenExpressionRef left,
989
+ BinaryenExpressionRef right);
990
+ BINARYEN_API BinaryenExpressionRef BinaryenTableGet(BinaryenModuleRef module,
991
+ const char* name,
992
+ BinaryenExpressionRef index,
993
+ BinaryenType type);
994
+ BINARYEN_API BinaryenExpressionRef
995
+ BinaryenTableSet(BinaryenModuleRef module,
996
+ const char* name,
997
+ BinaryenExpressionRef index,
998
+ BinaryenExpressionRef value);
999
+ BINARYEN_API BinaryenExpressionRef BinaryenTableSize(BinaryenModuleRef module,
1000
+ const char* name);
1001
+ BINARYEN_API BinaryenExpressionRef
1002
+ BinaryenTableGrow(BinaryenModuleRef module,
1003
+ const char* name,
1004
+ BinaryenExpressionRef value,
1005
+ BinaryenExpressionRef delta);
1006
+ // Try: name can be NULL. delegateTarget should be NULL in try-catch.
1007
+ BINARYEN_API BinaryenExpressionRef
1008
+ BinaryenTry(BinaryenModuleRef module,
1009
+ const char* name,
1010
+ BinaryenExpressionRef body,
1011
+ const char** catchTags,
1012
+ BinaryenIndex numCatchTags,
1013
+ BinaryenExpressionRef* catchBodies,
1014
+ BinaryenIndex numCatchBodies,
1015
+ const char* delegateTarget);
1016
+ BINARYEN_API BinaryenExpressionRef
1017
+ BinaryenThrow(BinaryenModuleRef module,
1018
+ const char* tag,
1019
+ BinaryenExpressionRef* operands,
1020
+ BinaryenIndex numOperands);
1021
+ BINARYEN_API BinaryenExpressionRef BinaryenRethrow(BinaryenModuleRef module,
1022
+ const char* target);
1023
+ BINARYEN_API BinaryenExpressionRef
1024
+ BinaryenTupleMake(BinaryenModuleRef module,
1025
+ BinaryenExpressionRef* operands,
1026
+ BinaryenIndex numOperands);
1027
+ BINARYEN_API BinaryenExpressionRef BinaryenTupleExtract(
1028
+ BinaryenModuleRef module, BinaryenExpressionRef tuple, BinaryenIndex index);
1029
+ BINARYEN_API BinaryenExpressionRef BinaryenPop(BinaryenModuleRef module,
1030
+ BinaryenType type);
1031
+ BINARYEN_API BinaryenExpressionRef BinaryenRefI31(BinaryenModuleRef module,
1032
+ BinaryenExpressionRef value);
1033
+ BINARYEN_API BinaryenExpressionRef BinaryenI31Get(BinaryenModuleRef module,
1034
+ BinaryenExpressionRef i31,
1035
+ bool signed_);
1036
+ BINARYEN_API BinaryenExpressionRef
1037
+ BinaryenCallRef(BinaryenModuleRef module,
1038
+ BinaryenExpressionRef target,
1039
+ BinaryenExpressionRef* operands,
1040
+ BinaryenIndex numOperands,
1041
+ BinaryenType type,
1042
+ bool isReturn);
1043
+ BINARYEN_API BinaryenExpressionRef BinaryenRefTest(BinaryenModuleRef module,
1044
+ BinaryenExpressionRef ref,
1045
+ BinaryenType castType);
1046
+ BINARYEN_API BinaryenExpressionRef BinaryenRefCast(BinaryenModuleRef module,
1047
+ BinaryenExpressionRef ref,
1048
+ BinaryenType type);
1049
+ BINARYEN_API BinaryenExpressionRef BinaryenBrOn(BinaryenModuleRef module,
1050
+ BinaryenOp op,
1051
+ const char* name,
1052
+ BinaryenExpressionRef ref,
1053
+ BinaryenType castType);
1054
+ BINARYEN_API BinaryenExpressionRef
1055
+ BinaryenStructNew(BinaryenModuleRef module,
1056
+ BinaryenExpressionRef* operands,
1057
+ BinaryenIndex numOperands,
1058
+ BinaryenHeapType type);
1059
+ BINARYEN_API BinaryenExpressionRef BinaryenStructGet(BinaryenModuleRef module,
1060
+ BinaryenIndex index,
1061
+ BinaryenExpressionRef ref,
1062
+ BinaryenType type,
1063
+ bool signed_);
1064
+ BINARYEN_API BinaryenExpressionRef
1065
+ BinaryenStructSet(BinaryenModuleRef module,
1066
+ BinaryenIndex index,
1067
+ BinaryenExpressionRef ref,
1068
+ BinaryenExpressionRef value);
1069
+ BINARYEN_API BinaryenExpressionRef BinaryenArrayNew(BinaryenModuleRef module,
1070
+ BinaryenHeapType type,
1071
+ BinaryenExpressionRef size,
1072
+ BinaryenExpressionRef init);
1073
+
1074
+ // TODO: BinaryenArrayNewSeg
1075
+
1076
+ BINARYEN_API BinaryenExpressionRef
1077
+ BinaryenArrayNewFixed(BinaryenModuleRef module,
1078
+ BinaryenHeapType type,
1079
+ BinaryenExpressionRef* values,
1080
+ BinaryenIndex numValues);
1081
+ BINARYEN_API BinaryenExpressionRef BinaryenArrayGet(BinaryenModuleRef module,
1082
+ BinaryenExpressionRef ref,
1083
+ BinaryenExpressionRef index,
1084
+ BinaryenType type,
1085
+ bool signed_);
1086
+ BINARYEN_API BinaryenExpressionRef
1087
+ BinaryenArraySet(BinaryenModuleRef module,
1088
+ BinaryenExpressionRef ref,
1089
+ BinaryenExpressionRef index,
1090
+ BinaryenExpressionRef value);
1091
+ BINARYEN_API BinaryenExpressionRef BinaryenArrayLen(BinaryenModuleRef module,
1092
+ BinaryenExpressionRef ref);
1093
+ BINARYEN_API BinaryenExpressionRef
1094
+ BinaryenArrayCopy(BinaryenModuleRef module,
1095
+ BinaryenExpressionRef destRef,
1096
+ BinaryenExpressionRef destIndex,
1097
+ BinaryenExpressionRef srcRef,
1098
+ BinaryenExpressionRef srcIndex,
1099
+ BinaryenExpressionRef length);
1100
+ BINARYEN_API BinaryenExpressionRef
1101
+ BinaryenStringNew(BinaryenModuleRef module,
1102
+ BinaryenOp op,
1103
+ BinaryenExpressionRef ptr,
1104
+ BinaryenExpressionRef length,
1105
+ BinaryenExpressionRef start,
1106
+ BinaryenExpressionRef end,
1107
+ bool try_);
1108
+ BINARYEN_API BinaryenExpressionRef BinaryenStringConst(BinaryenModuleRef module,
1109
+ const char* name);
1110
+ BINARYEN_API BinaryenExpressionRef BinaryenStringMeasure(
1111
+ BinaryenModuleRef module, BinaryenOp op, BinaryenExpressionRef ref);
1112
+ BINARYEN_API BinaryenExpressionRef
1113
+ BinaryenStringEncode(BinaryenModuleRef module,
1114
+ BinaryenOp op,
1115
+ BinaryenExpressionRef ref,
1116
+ BinaryenExpressionRef ptr,
1117
+ BinaryenExpressionRef start);
1118
+ BINARYEN_API BinaryenExpressionRef
1119
+ BinaryenStringConcat(BinaryenModuleRef module,
1120
+ BinaryenExpressionRef left,
1121
+ BinaryenExpressionRef right);
1122
+ BINARYEN_API BinaryenExpressionRef
1123
+ BinaryenStringEq(BinaryenModuleRef module,
1124
+ BinaryenOp op,
1125
+ BinaryenExpressionRef left,
1126
+ BinaryenExpressionRef right);
1127
+ BINARYEN_API BinaryenExpressionRef BinaryenStringAs(BinaryenModuleRef module,
1128
+ BinaryenOp op,
1129
+ BinaryenExpressionRef ref);
1130
+ BINARYEN_API BinaryenExpressionRef
1131
+ BinaryenStringWTF8Advance(BinaryenModuleRef module,
1132
+ BinaryenExpressionRef ref,
1133
+ BinaryenExpressionRef pos,
1134
+ BinaryenExpressionRef bytes);
1135
+ BINARYEN_API BinaryenExpressionRef
1136
+ BinaryenStringWTF16Get(BinaryenModuleRef module,
1137
+ BinaryenExpressionRef ref,
1138
+ BinaryenExpressionRef pos);
1139
+ BINARYEN_API BinaryenExpressionRef
1140
+ BinaryenStringIterNext(BinaryenModuleRef module, BinaryenExpressionRef ref);
1141
+ BINARYEN_API BinaryenExpressionRef
1142
+ BinaryenStringIterMove(BinaryenModuleRef module,
1143
+ BinaryenOp op,
1144
+ BinaryenExpressionRef ref,
1145
+ BinaryenExpressionRef num);
1146
+ BINARYEN_API BinaryenExpressionRef
1147
+ BinaryenStringSliceWTF(BinaryenModuleRef module,
1148
+ BinaryenOp op,
1149
+ BinaryenExpressionRef ref,
1150
+ BinaryenExpressionRef start,
1151
+ BinaryenExpressionRef end);
1152
+ BINARYEN_API BinaryenExpressionRef
1153
+ BinaryenStringSliceIter(BinaryenModuleRef module,
1154
+ BinaryenExpressionRef ref,
1155
+ BinaryenExpressionRef num);
1156
+
1157
+ // Expression
1158
+
1159
+ // Gets the id (kind) of the given expression.
1160
+ BINARYEN_API BinaryenExpressionId
1161
+ BinaryenExpressionGetId(BinaryenExpressionRef expr);
1162
+ // Gets the type of the given expression.
1163
+ BINARYEN_API BinaryenType BinaryenExpressionGetType(BinaryenExpressionRef expr);
1164
+ // Sets the type of the given expression.
1165
+ BINARYEN_API void BinaryenExpressionSetType(BinaryenExpressionRef expr,
1166
+ BinaryenType type);
1167
+ // Prints text format of the given expression to stdout.
1168
+ BINARYEN_API void BinaryenExpressionPrint(BinaryenExpressionRef expr);
1169
+ // Re-finalizes an expression after it has been modified.
1170
+ BINARYEN_API void BinaryenExpressionFinalize(BinaryenExpressionRef expr);
1171
+ // Makes a deep copy of the given expression.
1172
+ BINARYEN_API BinaryenExpressionRef
1173
+ BinaryenExpressionCopy(BinaryenExpressionRef expr, BinaryenModuleRef module);
1174
+
1175
+ // Block
1176
+
1177
+ // Gets the name (label) of a `block` expression.
1178
+ BINARYEN_API const char* BinaryenBlockGetName(BinaryenExpressionRef expr);
1179
+ // Sets the name (label) of a `block` expression.
1180
+ BINARYEN_API void BinaryenBlockSetName(BinaryenExpressionRef expr,
1181
+ const char* name);
1182
+ // Gets the number of child expressions of a `block` expression.
1183
+ BINARYEN_API BinaryenIndex
1184
+ BinaryenBlockGetNumChildren(BinaryenExpressionRef expr);
1185
+ // Gets the child expression at the specified index of a `block` expression.
1186
+ BINARYEN_API BinaryenExpressionRef
1187
+ BinaryenBlockGetChildAt(BinaryenExpressionRef expr, BinaryenIndex index);
1188
+ // Sets (replaces) the child expression at the specified index of a `block`
1189
+ // expression.
1190
+ BINARYEN_API void BinaryenBlockSetChildAt(BinaryenExpressionRef expr,
1191
+ BinaryenIndex index,
1192
+ BinaryenExpressionRef childExpr);
1193
+ // Appends a child expression to a `block` expression, returning its insertion
1194
+ // index.
1195
+ BINARYEN_API BinaryenIndex BinaryenBlockAppendChild(
1196
+ BinaryenExpressionRef expr, BinaryenExpressionRef childExpr);
1197
+ // Inserts a child expression at the specified index of a `block` expression,
1198
+ // moving existing children including the one previously at that index one index
1199
+ // up.
1200
+ BINARYEN_API void BinaryenBlockInsertChildAt(BinaryenExpressionRef expr,
1201
+ BinaryenIndex index,
1202
+ BinaryenExpressionRef childExpr);
1203
+ // Removes the child expression at the specified index of a `block` expression,
1204
+ // moving all subsequent children one index down. Returns the child expression.
1205
+ BINARYEN_API BinaryenExpressionRef
1206
+ BinaryenBlockRemoveChildAt(BinaryenExpressionRef expr, BinaryenIndex index);
1207
+
1208
+ // If
1209
+
1210
+ // Gets the condition expression of an `if` expression.
1211
+ BINARYEN_API BinaryenExpressionRef
1212
+ BinaryenIfGetCondition(BinaryenExpressionRef expr);
1213
+ // Sets the condition expression of an `if` expression.
1214
+ BINARYEN_API void BinaryenIfSetCondition(BinaryenExpressionRef expr,
1215
+ BinaryenExpressionRef condExpr);
1216
+ // Gets the ifTrue (then) expression of an `if` expression.
1217
+ BINARYEN_API BinaryenExpressionRef
1218
+ BinaryenIfGetIfTrue(BinaryenExpressionRef expr);
1219
+ // Sets the ifTrue (then) expression of an `if` expression.
1220
+ BINARYEN_API void BinaryenIfSetIfTrue(BinaryenExpressionRef expr,
1221
+ BinaryenExpressionRef ifTrueExpr);
1222
+ // Gets the ifFalse (else) expression, if any, of an `if` expression.
1223
+ BINARYEN_API BinaryenExpressionRef
1224
+ BinaryenIfGetIfFalse(BinaryenExpressionRef expr);
1225
+ // Sets the ifFalse (else) expression, if any, of an `if` expression.
1226
+ BINARYEN_API void BinaryenIfSetIfFalse(BinaryenExpressionRef expr,
1227
+ BinaryenExpressionRef ifFalseExpr);
1228
+
1229
+ // Loop
1230
+
1231
+ // Gets the name (label) of a `loop` expression.
1232
+ BINARYEN_API const char* BinaryenLoopGetName(BinaryenExpressionRef expr);
1233
+ // Sets the name (label) of a `loop` expression.
1234
+ BINARYEN_API void BinaryenLoopSetName(BinaryenExpressionRef expr,
1235
+ const char* name);
1236
+ // Gets the body expression of a `loop` expression.
1237
+ BINARYEN_API BinaryenExpressionRef
1238
+ BinaryenLoopGetBody(BinaryenExpressionRef expr);
1239
+ // Sets the body expression of a `loop` expression.
1240
+ BINARYEN_API void BinaryenLoopSetBody(BinaryenExpressionRef expr,
1241
+ BinaryenExpressionRef bodyExpr);
1242
+
1243
+ // Break
1244
+
1245
+ // Gets the name (target label) of a `br` or `br_if` expression.
1246
+ BINARYEN_API const char* BinaryenBreakGetName(BinaryenExpressionRef expr);
1247
+ // Sets the name (target label) of a `br` or `br_if` expression.
1248
+ BINARYEN_API void BinaryenBreakSetName(BinaryenExpressionRef expr,
1249
+ const char* name);
1250
+ // Gets the condition expression, if any, of a `br_if` expression. No condition
1251
+ // indicates a `br` expression.
1252
+ BINARYEN_API BinaryenExpressionRef
1253
+ BinaryenBreakGetCondition(BinaryenExpressionRef expr);
1254
+ // Sets the condition expression, if any, of a `br_if` expression. No condition
1255
+ // makes it a `br` expression.
1256
+ BINARYEN_API void BinaryenBreakSetCondition(BinaryenExpressionRef expr,
1257
+ BinaryenExpressionRef condExpr);
1258
+ // Gets the value expression, if any, of a `br` or `br_if` expression.
1259
+ BINARYEN_API BinaryenExpressionRef
1260
+ BinaryenBreakGetValue(BinaryenExpressionRef expr);
1261
+ // Sets the value expression, if any, of a `br` or `br_if` expression.
1262
+ BINARYEN_API void BinaryenBreakSetValue(BinaryenExpressionRef expr,
1263
+ BinaryenExpressionRef valueExpr);
1264
+
1265
+ // Switch
1266
+
1267
+ // Gets the number of names (target labels) of a `br_table` expression.
1268
+ BINARYEN_API BinaryenIndex
1269
+ BinaryenSwitchGetNumNames(BinaryenExpressionRef expr);
1270
+ // Gets the name (target label) at the specified index of a `br_table`
1271
+ // expression.
1272
+ BINARYEN_API const char* BinaryenSwitchGetNameAt(BinaryenExpressionRef expr,
1273
+ BinaryenIndex index);
1274
+ // Sets the name (target label) at the specified index of a `br_table`
1275
+ // expression.
1276
+ BINARYEN_API void BinaryenSwitchSetNameAt(BinaryenExpressionRef expr,
1277
+ BinaryenIndex index,
1278
+ const char* name);
1279
+ // Appends a name to a `br_table` expression, returning its insertion index.
1280
+ BINARYEN_API BinaryenIndex BinaryenSwitchAppendName(BinaryenExpressionRef expr,
1281
+ const char* name);
1282
+ // Inserts a name at the specified index of a `br_table` expression, moving
1283
+ // existing names including the one previously at that index one index up.
1284
+ BINARYEN_API void BinaryenSwitchInsertNameAt(BinaryenExpressionRef expr,
1285
+ BinaryenIndex index,
1286
+ const char* name);
1287
+ // Removes the name at the specified index of a `br_table` expression, moving
1288
+ // all subsequent names one index down. Returns the name.
1289
+ BINARYEN_API const char* BinaryenSwitchRemoveNameAt(BinaryenExpressionRef expr,
1290
+ BinaryenIndex index);
1291
+ // Gets the default name (target label), if any, of a `br_table` expression.
1292
+ BINARYEN_API const char*
1293
+ BinaryenSwitchGetDefaultName(BinaryenExpressionRef expr);
1294
+ // Sets the default name (target label), if any, of a `br_table` expression.
1295
+ BINARYEN_API void BinaryenSwitchSetDefaultName(BinaryenExpressionRef expr,
1296
+ const char* name);
1297
+ // Gets the condition expression of a `br_table` expression.
1298
+ BINARYEN_API BinaryenExpressionRef
1299
+ BinaryenSwitchGetCondition(BinaryenExpressionRef expr);
1300
+ // Sets the condition expression of a `br_table` expression.
1301
+ BINARYEN_API void BinaryenSwitchSetCondition(BinaryenExpressionRef expr,
1302
+ BinaryenExpressionRef condExpr);
1303
+ // Gets the value expression, if any, of a `br_table` expression.
1304
+ BINARYEN_API BinaryenExpressionRef
1305
+ BinaryenSwitchGetValue(BinaryenExpressionRef expr);
1306
+ // Sets the value expression, if any, of a `br_table` expression.
1307
+ BINARYEN_API void BinaryenSwitchSetValue(BinaryenExpressionRef expr,
1308
+ BinaryenExpressionRef valueExpr);
1309
+
1310
+ // Call
1311
+
1312
+ // Gets the target function name of a `call` expression.
1313
+ BINARYEN_API const char* BinaryenCallGetTarget(BinaryenExpressionRef expr);
1314
+ // Sets the target function name of a `call` expression.
1315
+ BINARYEN_API void BinaryenCallSetTarget(BinaryenExpressionRef expr,
1316
+ const char* target);
1317
+ // Gets the number of operands of a `call` expression.
1318
+ BINARYEN_API BinaryenIndex
1319
+ BinaryenCallGetNumOperands(BinaryenExpressionRef expr);
1320
+ // Gets the operand expression at the specified index of a `call` expression.
1321
+ BINARYEN_API BinaryenExpressionRef
1322
+ BinaryenCallGetOperandAt(BinaryenExpressionRef expr, BinaryenIndex index);
1323
+ // Sets the operand expression at the specified index of a `call` expression.
1324
+ BINARYEN_API void BinaryenCallSetOperandAt(BinaryenExpressionRef expr,
1325
+ BinaryenIndex index,
1326
+ BinaryenExpressionRef operandExpr);
1327
+ // Appends an operand expression to a `call` expression, returning its insertion
1328
+ // index.
1329
+ BINARYEN_API BinaryenIndex BinaryenCallAppendOperand(
1330
+ BinaryenExpressionRef expr, BinaryenExpressionRef operandExpr);
1331
+ // Inserts an operand expression at the specified index of a `call` expression,
1332
+ // moving existing operands including the one previously at that index one index
1333
+ // up.
1334
+ BINARYEN_API void
1335
+ BinaryenCallInsertOperandAt(BinaryenExpressionRef expr,
1336
+ BinaryenIndex index,
1337
+ BinaryenExpressionRef operandExpr);
1338
+ // Removes the operand expression at the specified index of a `call` expression,
1339
+ // moving all subsequent operands one index down. Returns the operand
1340
+ // expression.
1341
+ BINARYEN_API BinaryenExpressionRef
1342
+ BinaryenCallRemoveOperandAt(BinaryenExpressionRef expr, BinaryenIndex index);
1343
+ // Gets whether the specified `call` expression is a tail call.
1344
+ BINARYEN_API bool BinaryenCallIsReturn(BinaryenExpressionRef expr);
1345
+ // Sets whether the specified `call` expression is a tail call.
1346
+ BINARYEN_API void BinaryenCallSetReturn(BinaryenExpressionRef expr,
1347
+ bool isReturn);
1348
+
1349
+ // CallIndirect
1350
+
1351
+ // Gets the target expression of a `call_indirect` expression.
1352
+ BINARYEN_API BinaryenExpressionRef
1353
+ BinaryenCallIndirectGetTarget(BinaryenExpressionRef expr);
1354
+ // Sets the target expression of a `call_indirect` expression.
1355
+ BINARYEN_API void
1356
+ BinaryenCallIndirectSetTarget(BinaryenExpressionRef expr,
1357
+ BinaryenExpressionRef targetExpr);
1358
+ // Gets the table name of a `call_indirect` expression.
1359
+ BINARYEN_API const char*
1360
+ BinaryenCallIndirectGetTable(BinaryenExpressionRef expr);
1361
+ // Sets the table name of a `call_indirect` expression.
1362
+ BINARYEN_API void BinaryenCallIndirectSetTable(BinaryenExpressionRef expr,
1363
+ const char* table);
1364
+ // Gets the number of operands of a `call_indirect` expression.
1365
+ BINARYEN_API BinaryenIndex
1366
+ BinaryenCallIndirectGetNumOperands(BinaryenExpressionRef expr);
1367
+ // Gets the operand expression at the specified index of a `call_indirect`
1368
+ // expression.
1369
+ BINARYEN_API BinaryenExpressionRef BinaryenCallIndirectGetOperandAt(
1370
+ BinaryenExpressionRef expr, BinaryenIndex index);
1371
+ // Sets the operand expression at the specified index of a `call_indirect`
1372
+ // expression.
1373
+ BINARYEN_API void
1374
+ BinaryenCallIndirectSetOperandAt(BinaryenExpressionRef expr,
1375
+ BinaryenIndex index,
1376
+ BinaryenExpressionRef operandExpr);
1377
+ // Appends an operand expression to a `call_indirect` expression, returning its
1378
+ // insertion index.
1379
+ BINARYEN_API BinaryenIndex BinaryenCallIndirectAppendOperand(
1380
+ BinaryenExpressionRef expr, BinaryenExpressionRef operandExpr);
1381
+ // Inserts an operand expression at the specified index of a `call_indirect`
1382
+ // expression, moving existing operands including the one previously at that
1383
+ // index one index up.
1384
+ BINARYEN_API void
1385
+ BinaryenCallIndirectInsertOperandAt(BinaryenExpressionRef expr,
1386
+ BinaryenIndex index,
1387
+ BinaryenExpressionRef operandExpr);
1388
+ // Removes the operand expression at the specified index of a `call_indirect`
1389
+ // expression, moving all subsequent operands one index down. Returns the
1390
+ // operand expression.
1391
+ BINARYEN_API BinaryenExpressionRef BinaryenCallIndirectRemoveOperandAt(
1392
+ BinaryenExpressionRef expr, BinaryenIndex index);
1393
+ // Gets whether the specified `call_indirect` expression is a tail call.
1394
+ BINARYEN_API bool BinaryenCallIndirectIsReturn(BinaryenExpressionRef expr);
1395
+ // Sets whether the specified `call_indirect` expression is a tail call.
1396
+ BINARYEN_API void BinaryenCallIndirectSetReturn(BinaryenExpressionRef expr,
1397
+ bool isReturn);
1398
+ // Gets the parameter types of the specified `call_indirect` expression.
1399
+ BINARYEN_API BinaryenType
1400
+ BinaryenCallIndirectGetParams(BinaryenExpressionRef expr);
1401
+ // Sets the parameter types of the specified `call_indirect` expression.
1402
+ BINARYEN_API void BinaryenCallIndirectSetParams(BinaryenExpressionRef expr,
1403
+ BinaryenType params);
1404
+ // Gets the result types of the specified `call_indirect` expression.
1405
+ BINARYEN_API BinaryenType
1406
+ BinaryenCallIndirectGetResults(BinaryenExpressionRef expr);
1407
+ // Sets the result types of the specified `call_indirect` expression.
1408
+ BINARYEN_API void BinaryenCallIndirectSetResults(BinaryenExpressionRef expr,
1409
+ BinaryenType params);
1410
+
1411
+ // LocalGet
1412
+
1413
+ // Gets the local index of a `local.get` expression.
1414
+ BINARYEN_API BinaryenIndex BinaryenLocalGetGetIndex(BinaryenExpressionRef expr);
1415
+ // Sets the local index of a `local.get` expression.
1416
+ BINARYEN_API void BinaryenLocalGetSetIndex(BinaryenExpressionRef expr,
1417
+ BinaryenIndex index);
1418
+
1419
+ // LocalSet
1420
+
1421
+ // Gets whether a `local.set` tees its value (is a `local.tee`). True if the
1422
+ // expression has a type other than `none`.
1423
+ BINARYEN_API bool BinaryenLocalSetIsTee(BinaryenExpressionRef expr);
1424
+ // Gets the local index of a `local.set` or `local.tee` expression.
1425
+ BINARYEN_API BinaryenIndex BinaryenLocalSetGetIndex(BinaryenExpressionRef expr);
1426
+ // Sets the local index of a `local.set` or `local.tee` expression.
1427
+ BINARYEN_API void BinaryenLocalSetSetIndex(BinaryenExpressionRef expr,
1428
+ BinaryenIndex index);
1429
+ // Gets the value expression of a `local.set` or `local.tee` expression.
1430
+ BINARYEN_API BinaryenExpressionRef
1431
+ BinaryenLocalSetGetValue(BinaryenExpressionRef expr);
1432
+ // Sets the value expression of a `local.set` or `local.tee` expression.
1433
+ BINARYEN_API void BinaryenLocalSetSetValue(BinaryenExpressionRef expr,
1434
+ BinaryenExpressionRef valueExpr);
1435
+
1436
+ // GlobalGet
1437
+
1438
+ // Gets the name of the global being accessed by a `global.get` expression.
1439
+ BINARYEN_API const char* BinaryenGlobalGetGetName(BinaryenExpressionRef expr);
1440
+ // Sets the name of the global being accessed by a `global.get` expression.
1441
+ BINARYEN_API void BinaryenGlobalGetSetName(BinaryenExpressionRef expr,
1442
+ const char* name);
1443
+
1444
+ // GlobalSet
1445
+
1446
+ // Gets the name of the global being accessed by a `global.set` expression.
1447
+ BINARYEN_API const char* BinaryenGlobalSetGetName(BinaryenExpressionRef expr);
1448
+ // Sets the name of the global being accessed by a `global.set` expression.
1449
+ BINARYEN_API void BinaryenGlobalSetSetName(BinaryenExpressionRef expr,
1450
+ const char* name);
1451
+ // Gets the value expression of a `global.set` expression.
1452
+ BINARYEN_API BinaryenExpressionRef
1453
+ BinaryenGlobalSetGetValue(BinaryenExpressionRef expr);
1454
+ // Sets the value expression of a `global.set` expression.
1455
+ BINARYEN_API void BinaryenGlobalSetSetValue(BinaryenExpressionRef expr,
1456
+ BinaryenExpressionRef valueExpr);
1457
+
1458
+ // TableGet
1459
+
1460
+ // Gets the name of the table being accessed by a `table.get` expression.
1461
+ BINARYEN_API const char* BinaryenTableGetGetTable(BinaryenExpressionRef expr);
1462
+ // Sets the name of the table being accessed by a `table.get` expression.
1463
+ BINARYEN_API void BinaryenTableGetSetTable(BinaryenExpressionRef expr,
1464
+ const char* table);
1465
+ // Gets the index expression of a `table.get` expression.
1466
+ BINARYEN_API BinaryenExpressionRef
1467
+ BinaryenTableGetGetIndex(BinaryenExpressionRef expr);
1468
+ // Sets the index expression of a `table.get` expression.
1469
+ BINARYEN_API void BinaryenTableGetSetIndex(BinaryenExpressionRef expr,
1470
+ BinaryenExpressionRef indexExpr);
1471
+
1472
+ // TableSet
1473
+
1474
+ // Gets the name of the table being accessed by a `table.set` expression.
1475
+ BINARYEN_API const char* BinaryenTableSetGetTable(BinaryenExpressionRef expr);
1476
+ // Sets the name of the table being accessed by a `table.set` expression.
1477
+ BINARYEN_API void BinaryenTableSetSetTable(BinaryenExpressionRef expr,
1478
+ const char* table);
1479
+ // Gets the index expression of a `table.set` expression.
1480
+ BINARYEN_API BinaryenExpressionRef
1481
+ BinaryenTableSetGetIndex(BinaryenExpressionRef expr);
1482
+ // Sets the index expression of a `table.set` expression.
1483
+ BINARYEN_API void BinaryenTableSetSetIndex(BinaryenExpressionRef expr,
1484
+ BinaryenExpressionRef indexExpr);
1485
+ // Gets the value expression of a `table.set` expression.
1486
+ BINARYEN_API BinaryenExpressionRef
1487
+ BinaryenTableSetGetValue(BinaryenExpressionRef expr);
1488
+ // Sets the value expression of a `table.set` expression.
1489
+ BINARYEN_API void BinaryenTableSetSetValue(BinaryenExpressionRef expr,
1490
+ BinaryenExpressionRef valueExpr);
1491
+
1492
+ // TableSize
1493
+
1494
+ // Gets the name of the table being accessed by a `table.size` expression.
1495
+ BINARYEN_API const char* BinaryenTableSizeGetTable(BinaryenExpressionRef expr);
1496
+ // Sets the name of the table being accessed by a `table.size` expression.
1497
+ BINARYEN_API void BinaryenTableSizeSetTable(BinaryenExpressionRef expr,
1498
+ const char* table);
1499
+
1500
+ // TableGrow
1501
+
1502
+ // Gets the name of the table being accessed by a `table.grow` expression.
1503
+ BINARYEN_API const char* BinaryenTableGrowGetTable(BinaryenExpressionRef expr);
1504
+ // Sets the name of the table being accessed by a `table.grow` expression.
1505
+ BINARYEN_API void BinaryenTableGrowSetTable(BinaryenExpressionRef expr,
1506
+ const char* table);
1507
+ // Gets the value expression of a `table.grow` expression.
1508
+ BINARYEN_API BinaryenExpressionRef
1509
+ BinaryenTableGrowGetValue(BinaryenExpressionRef expr);
1510
+ // Sets the value expression of a `table.grow` expression.
1511
+ BINARYEN_API void BinaryenTableGrowSetValue(BinaryenExpressionRef expr,
1512
+ BinaryenExpressionRef valueExpr);
1513
+ // Gets the delta of a `table.grow` expression.
1514
+ BINARYEN_API BinaryenExpressionRef
1515
+ BinaryenTableGrowGetDelta(BinaryenExpressionRef expr);
1516
+ // Sets the delta of a `table.grow` expression.
1517
+ BINARYEN_API void BinaryenTableGrowSetDelta(BinaryenExpressionRef expr,
1518
+ BinaryenExpressionRef deltaExpr);
1519
+ // MemoryGrow
1520
+
1521
+ // Gets the delta of a `memory.grow` expression.
1522
+ BINARYEN_API BinaryenExpressionRef
1523
+ BinaryenMemoryGrowGetDelta(BinaryenExpressionRef expr);
1524
+ // Sets the delta of a `memory.grow` expression.
1525
+ BINARYEN_API void BinaryenMemoryGrowSetDelta(BinaryenExpressionRef expr,
1526
+ BinaryenExpressionRef deltaExpr);
1527
+
1528
+ // Load
1529
+
1530
+ // Gets whether a `load` expression is atomic (is an `atomic.load`).
1531
+ BINARYEN_API bool BinaryenLoadIsAtomic(BinaryenExpressionRef expr);
1532
+ // Sets whether a `load` expression is atomic (is an `atomic.load`).
1533
+ BINARYEN_API void BinaryenLoadSetAtomic(BinaryenExpressionRef expr,
1534
+ bool isAtomic);
1535
+ // Gets whether a `load` expression operates on a signed value (`_s`).
1536
+ BINARYEN_API bool BinaryenLoadIsSigned(BinaryenExpressionRef expr);
1537
+ // Sets whether a `load` expression operates on a signed value (`_s`).
1538
+ BINARYEN_API void BinaryenLoadSetSigned(BinaryenExpressionRef expr,
1539
+ bool isSigned);
1540
+ // Gets the constant offset of a `load` expression.
1541
+ BINARYEN_API uint32_t BinaryenLoadGetOffset(BinaryenExpressionRef expr);
1542
+ // Sets the constant offset of a `load` expression.
1543
+ BINARYEN_API void BinaryenLoadSetOffset(BinaryenExpressionRef expr,
1544
+ uint32_t offset);
1545
+ // Gets the number of bytes loaded by a `load` expression.
1546
+ BINARYEN_API uint32_t BinaryenLoadGetBytes(BinaryenExpressionRef expr);
1547
+ // Sets the number of bytes loaded by a `load` expression.
1548
+ BINARYEN_API void BinaryenLoadSetBytes(BinaryenExpressionRef expr,
1549
+ uint32_t bytes);
1550
+ // Gets the byte alignment of a `load` expression.
1551
+ BINARYEN_API uint32_t BinaryenLoadGetAlign(BinaryenExpressionRef expr);
1552
+ // Sets the byte alignment of a `load` expression.
1553
+ BINARYEN_API void BinaryenLoadSetAlign(BinaryenExpressionRef expr,
1554
+ uint32_t align);
1555
+ // Gets the pointer expression of a `load` expression.
1556
+ BINARYEN_API BinaryenExpressionRef
1557
+ BinaryenLoadGetPtr(BinaryenExpressionRef expr);
1558
+ // Sets the pointer expression of a `load` expression.
1559
+ BINARYEN_API void BinaryenLoadSetPtr(BinaryenExpressionRef expr,
1560
+ BinaryenExpressionRef ptrExpr);
1561
+
1562
+ // Store
1563
+
1564
+ // Gets whether a `store` expression is atomic (is an `atomic.store`).
1565
+ BINARYEN_API bool BinaryenStoreIsAtomic(BinaryenExpressionRef expr);
1566
+ // Sets whether a `store` expression is atomic (is an `atomic.store`).
1567
+ BINARYEN_API void BinaryenStoreSetAtomic(BinaryenExpressionRef expr,
1568
+ bool isAtomic);
1569
+ // Gets the number of bytes stored by a `store` expression.
1570
+ BINARYEN_API uint32_t BinaryenStoreGetBytes(BinaryenExpressionRef expr);
1571
+ // Sets the number of bytes stored by a `store` expression.
1572
+ BINARYEN_API void BinaryenStoreSetBytes(BinaryenExpressionRef expr,
1573
+ uint32_t bytes);
1574
+ // Gets the constant offset of a `store` expression.
1575
+ BINARYEN_API uint32_t BinaryenStoreGetOffset(BinaryenExpressionRef expr);
1576
+ // Sets the constant offset of a `store` expression.
1577
+ BINARYEN_API void BinaryenStoreSetOffset(BinaryenExpressionRef expr,
1578
+ uint32_t offset);
1579
+ // Gets the byte alignment of a `store` expression.
1580
+ BINARYEN_API uint32_t BinaryenStoreGetAlign(BinaryenExpressionRef expr);
1581
+ // Sets the byte alignment of a `store` expression.
1582
+ BINARYEN_API void BinaryenStoreSetAlign(BinaryenExpressionRef expr,
1583
+ uint32_t align);
1584
+ // Gets the pointer expression of a `store` expression.
1585
+ BINARYEN_API BinaryenExpressionRef
1586
+ BinaryenStoreGetPtr(BinaryenExpressionRef expr);
1587
+ // Sets the pointer expression of a `store` expression.
1588
+ BINARYEN_API void BinaryenStoreSetPtr(BinaryenExpressionRef expr,
1589
+ BinaryenExpressionRef ptrExpr);
1590
+ // Gets the value expression of a `store` expression.
1591
+ BINARYEN_API BinaryenExpressionRef
1592
+ BinaryenStoreGetValue(BinaryenExpressionRef expr);
1593
+ // Sets the value expression of a `store` expression.
1594
+ BINARYEN_API void BinaryenStoreSetValue(BinaryenExpressionRef expr,
1595
+ BinaryenExpressionRef valueExpr);
1596
+ // Gets the value type of a `store` expression.
1597
+ BINARYEN_API BinaryenType BinaryenStoreGetValueType(BinaryenExpressionRef expr);
1598
+ // Sets the value type of a `store` expression.
1599
+ BINARYEN_API void BinaryenStoreSetValueType(BinaryenExpressionRef expr,
1600
+ BinaryenType valueType);
1601
+
1602
+ // Const
1603
+
1604
+ // Gets the 32-bit integer value of an `i32.const` expression.
1605
+ BINARYEN_API int32_t BinaryenConstGetValueI32(BinaryenExpressionRef expr);
1606
+ // Sets the 32-bit integer value of an `i32.const` expression.
1607
+ BINARYEN_API void BinaryenConstSetValueI32(BinaryenExpressionRef expr,
1608
+ int32_t value);
1609
+ // Gets the 64-bit integer value of an `i64.const` expression.
1610
+ BINARYEN_API int64_t BinaryenConstGetValueI64(BinaryenExpressionRef expr);
1611
+ // Sets the 64-bit integer value of an `i64.const` expression.
1612
+ BINARYEN_API void BinaryenConstSetValueI64(BinaryenExpressionRef expr,
1613
+ int64_t value);
1614
+ // Gets the low 32-bits of the 64-bit integer value of an `i64.const`
1615
+ // expression.
1616
+ BINARYEN_API int32_t BinaryenConstGetValueI64Low(BinaryenExpressionRef expr);
1617
+ // Sets the low 32-bits of the 64-bit integer value of an `i64.const`
1618
+ // expression.
1619
+ BINARYEN_API void BinaryenConstSetValueI64Low(BinaryenExpressionRef expr,
1620
+ int32_t valueLow);
1621
+ // Gets the high 32-bits of the 64-bit integer value of an `i64.const`
1622
+ // expression.
1623
+ BINARYEN_API int32_t BinaryenConstGetValueI64High(BinaryenExpressionRef expr);
1624
+ // Sets the high 32-bits of the 64-bit integer value of an `i64.const`
1625
+ // expression.
1626
+ BINARYEN_API void BinaryenConstSetValueI64High(BinaryenExpressionRef expr,
1627
+ int32_t valueHigh);
1628
+ // Gets the 32-bit float value of a `f32.const` expression.
1629
+ BINARYEN_API float BinaryenConstGetValueF32(BinaryenExpressionRef expr);
1630
+ // Sets the 32-bit float value of a `f32.const` expression.
1631
+ BINARYEN_API void BinaryenConstSetValueF32(BinaryenExpressionRef expr,
1632
+ float value);
1633
+ // Gets the 64-bit float (double) value of a `f64.const` expression.
1634
+ BINARYEN_API double BinaryenConstGetValueF64(BinaryenExpressionRef expr);
1635
+ // Sets the 64-bit float (double) value of a `f64.const` expression.
1636
+ BINARYEN_API void BinaryenConstSetValueF64(BinaryenExpressionRef expr,
1637
+ double value);
1638
+ // Reads the 128-bit vector value of a `v128.const` expression.
1639
+ BINARYEN_API void BinaryenConstGetValueV128(BinaryenExpressionRef expr,
1640
+ uint8_t* out);
1641
+ // Sets the 128-bit vector value of a `v128.const` expression.
1642
+ BINARYEN_API void BinaryenConstSetValueV128(BinaryenExpressionRef expr,
1643
+ const uint8_t value[16]);
1644
+
1645
+ // Unary
1646
+
1647
+ // Gets the operation being performed by a unary expression.
1648
+ BINARYEN_API BinaryenOp BinaryenUnaryGetOp(BinaryenExpressionRef expr);
1649
+ // Sets the operation being performed by a unary expression.
1650
+ BINARYEN_API void BinaryenUnarySetOp(BinaryenExpressionRef expr, BinaryenOp op);
1651
+ // Gets the value expression of a unary expression.
1652
+ BINARYEN_API BinaryenExpressionRef
1653
+ BinaryenUnaryGetValue(BinaryenExpressionRef expr);
1654
+ // Sets the value expression of a unary expression.
1655
+ BINARYEN_API void BinaryenUnarySetValue(BinaryenExpressionRef expr,
1656
+ BinaryenExpressionRef valueExpr);
1657
+
1658
+ // Binary
1659
+
1660
+ // Gets the operation being performed by a binary expression.
1661
+ BINARYEN_API BinaryenOp BinaryenBinaryGetOp(BinaryenExpressionRef expr);
1662
+ // Sets the operation being performed by a binary expression.
1663
+ BINARYEN_API void BinaryenBinarySetOp(BinaryenExpressionRef expr,
1664
+ BinaryenOp op);
1665
+ // Gets the left expression of a binary expression.
1666
+ BINARYEN_API BinaryenExpressionRef
1667
+ BinaryenBinaryGetLeft(BinaryenExpressionRef expr);
1668
+ // Sets the left expression of a binary expression.
1669
+ BINARYEN_API void BinaryenBinarySetLeft(BinaryenExpressionRef expr,
1670
+ BinaryenExpressionRef leftExpr);
1671
+ // Gets the right expression of a binary expression.
1672
+ BINARYEN_API BinaryenExpressionRef
1673
+ BinaryenBinaryGetRight(BinaryenExpressionRef expr);
1674
+ // Sets the right expression of a binary expression.
1675
+ BINARYEN_API void BinaryenBinarySetRight(BinaryenExpressionRef expr,
1676
+ BinaryenExpressionRef rightExpr);
1677
+
1678
+ // Select
1679
+
1680
+ // Gets the expression becoming selected by a `select` expression if the
1681
+ // condition turns out true.
1682
+ BINARYEN_API BinaryenExpressionRef
1683
+ BinaryenSelectGetIfTrue(BinaryenExpressionRef expr);
1684
+ // Sets the expression becoming selected by a `select` expression if the
1685
+ // condition turns out true.
1686
+ BINARYEN_API void BinaryenSelectSetIfTrue(BinaryenExpressionRef expr,
1687
+ BinaryenExpressionRef ifTrueExpr);
1688
+ // Gets the expression becoming selected by a `select` expression if the
1689
+ // condition turns out false.
1690
+ BINARYEN_API BinaryenExpressionRef
1691
+ BinaryenSelectGetIfFalse(BinaryenExpressionRef expr);
1692
+ // Sets the expression becoming selected by a `select` expression if the
1693
+ // condition turns out false.
1694
+ BINARYEN_API void BinaryenSelectSetIfFalse(BinaryenExpressionRef expr,
1695
+ BinaryenExpressionRef ifFalseExpr);
1696
+ // Gets the condition expression of a `select` expression.
1697
+ BINARYEN_API BinaryenExpressionRef
1698
+ BinaryenSelectGetCondition(BinaryenExpressionRef expr);
1699
+ // Sets the condition expression of a `select` expression.
1700
+ BINARYEN_API void BinaryenSelectSetCondition(BinaryenExpressionRef expr,
1701
+ BinaryenExpressionRef condExpr);
1702
+
1703
+ // Drop
1704
+
1705
+ // Gets the value expression being dropped by a `drop` expression.
1706
+ BINARYEN_API BinaryenExpressionRef
1707
+ BinaryenDropGetValue(BinaryenExpressionRef expr);
1708
+ // Sets the value expression being dropped by a `drop` expression.
1709
+ BINARYEN_API void BinaryenDropSetValue(BinaryenExpressionRef expr,
1710
+ BinaryenExpressionRef valueExpr);
1711
+
1712
+ // Return
1713
+
1714
+ // Gets the value expression, if any, being returned by a `return` expression.
1715
+ BINARYEN_API BinaryenExpressionRef
1716
+ BinaryenReturnGetValue(BinaryenExpressionRef expr);
1717
+ // Sets the value expression, if any, being returned by a `return` expression.
1718
+ BINARYEN_API void BinaryenReturnSetValue(BinaryenExpressionRef expr,
1719
+ BinaryenExpressionRef valueExpr);
1720
+
1721
+ // AtomicRMW
1722
+
1723
+ // Gets the operation being performed by an atomic read-modify-write expression.
1724
+ BINARYEN_API BinaryenOp BinaryenAtomicRMWGetOp(BinaryenExpressionRef expr);
1725
+ // Sets the operation being performed by an atomic read-modify-write expression.
1726
+ BINARYEN_API void BinaryenAtomicRMWSetOp(BinaryenExpressionRef expr,
1727
+ BinaryenOp op);
1728
+ // Gets the number of bytes affected by an atomic read-modify-write expression.
1729
+ BINARYEN_API uint32_t BinaryenAtomicRMWGetBytes(BinaryenExpressionRef expr);
1730
+ // Sets the number of bytes affected by an atomic read-modify-write expression.
1731
+ BINARYEN_API void BinaryenAtomicRMWSetBytes(BinaryenExpressionRef expr,
1732
+ uint32_t bytes);
1733
+ // Gets the constant offset of an atomic read-modify-write expression.
1734
+ BINARYEN_API uint32_t BinaryenAtomicRMWGetOffset(BinaryenExpressionRef expr);
1735
+ // Sets the constant offset of an atomic read-modify-write expression.
1736
+ BINARYEN_API void BinaryenAtomicRMWSetOffset(BinaryenExpressionRef expr,
1737
+ uint32_t offset);
1738
+ // Gets the pointer expression of an atomic read-modify-write expression.
1739
+ BINARYEN_API BinaryenExpressionRef
1740
+ BinaryenAtomicRMWGetPtr(BinaryenExpressionRef expr);
1741
+ // Sets the pointer expression of an atomic read-modify-write expression.
1742
+ BINARYEN_API void BinaryenAtomicRMWSetPtr(BinaryenExpressionRef expr,
1743
+ BinaryenExpressionRef ptrExpr);
1744
+ // Gets the value expression of an atomic read-modify-write expression.
1745
+ BINARYEN_API BinaryenExpressionRef
1746
+ BinaryenAtomicRMWGetValue(BinaryenExpressionRef expr);
1747
+ // Sets the value expression of an atomic read-modify-write expression.
1748
+ BINARYEN_API void BinaryenAtomicRMWSetValue(BinaryenExpressionRef expr,
1749
+ BinaryenExpressionRef valueExpr);
1750
+
1751
+ // AtomicCmpxchg
1752
+
1753
+ // Gets the number of bytes affected by an atomic compare and exchange
1754
+ // expression.
1755
+ BINARYEN_API uint32_t BinaryenAtomicCmpxchgGetBytes(BinaryenExpressionRef expr);
1756
+ // Sets the number of bytes affected by an atomic compare and exchange
1757
+ // expression.
1758
+ BINARYEN_API void BinaryenAtomicCmpxchgSetBytes(BinaryenExpressionRef expr,
1759
+ uint32_t bytes);
1760
+ // Gets the constant offset of an atomic compare and exchange expression.
1761
+ BINARYEN_API uint32_t
1762
+ BinaryenAtomicCmpxchgGetOffset(BinaryenExpressionRef expr);
1763
+ // Sets the constant offset of an atomic compare and exchange expression.
1764
+ BINARYEN_API void BinaryenAtomicCmpxchgSetOffset(BinaryenExpressionRef expr,
1765
+ uint32_t offset);
1766
+ // Gets the pointer expression of an atomic compare and exchange expression.
1767
+ BINARYEN_API BinaryenExpressionRef
1768
+ BinaryenAtomicCmpxchgGetPtr(BinaryenExpressionRef expr);
1769
+ // Sets the pointer expression of an atomic compare and exchange expression.
1770
+ BINARYEN_API void BinaryenAtomicCmpxchgSetPtr(BinaryenExpressionRef expr,
1771
+ BinaryenExpressionRef ptrExpr);
1772
+ // Gets the expression representing the expected value of an atomic compare and
1773
+ // exchange expression.
1774
+ BINARYEN_API BinaryenExpressionRef
1775
+ BinaryenAtomicCmpxchgGetExpected(BinaryenExpressionRef expr);
1776
+ // Sets the expression representing the expected value of an atomic compare and
1777
+ // exchange expression.
1778
+ BINARYEN_API void
1779
+ BinaryenAtomicCmpxchgSetExpected(BinaryenExpressionRef expr,
1780
+ BinaryenExpressionRef expectedExpr);
1781
+ // Gets the replacement expression of an atomic compare and exchange expression.
1782
+ BINARYEN_API BinaryenExpressionRef
1783
+ BinaryenAtomicCmpxchgGetReplacement(BinaryenExpressionRef expr);
1784
+ // Sets the replacement expression of an atomic compare and exchange expression.
1785
+ BINARYEN_API void
1786
+ BinaryenAtomicCmpxchgSetReplacement(BinaryenExpressionRef expr,
1787
+ BinaryenExpressionRef replacementExpr);
1788
+
1789
+ // AtomicWait
1790
+
1791
+ // Gets the pointer expression of an `memory.atomic.wait` expression.
1792
+ BINARYEN_API BinaryenExpressionRef
1793
+ BinaryenAtomicWaitGetPtr(BinaryenExpressionRef expr);
1794
+ // Sets the pointer expression of an `memory.atomic.wait` expression.
1795
+ BINARYEN_API void BinaryenAtomicWaitSetPtr(BinaryenExpressionRef expr,
1796
+ BinaryenExpressionRef ptrExpr);
1797
+ // Gets the expression representing the expected value of an
1798
+ // `memory.atomic.wait` expression.
1799
+ BINARYEN_API BinaryenExpressionRef
1800
+ BinaryenAtomicWaitGetExpected(BinaryenExpressionRef expr);
1801
+ // Sets the expression representing the expected value of an
1802
+ // `memory.atomic.wait` expression.
1803
+ BINARYEN_API void
1804
+ BinaryenAtomicWaitSetExpected(BinaryenExpressionRef expr,
1805
+ BinaryenExpressionRef expectedExpr);
1806
+ // Gets the timeout expression of an `memory.atomic.wait` expression.
1807
+ BINARYEN_API BinaryenExpressionRef
1808
+ BinaryenAtomicWaitGetTimeout(BinaryenExpressionRef expr);
1809
+ // Sets the timeout expression of an `memory.atomic.wait` expression.
1810
+ BINARYEN_API void
1811
+ BinaryenAtomicWaitSetTimeout(BinaryenExpressionRef expr,
1812
+ BinaryenExpressionRef timeoutExpr);
1813
+ // Gets the expected type of an `memory.atomic.wait` expression.
1814
+ BINARYEN_API BinaryenType
1815
+ BinaryenAtomicWaitGetExpectedType(BinaryenExpressionRef expr);
1816
+ // Sets the expected type of an `memory.atomic.wait` expression.
1817
+ BINARYEN_API void BinaryenAtomicWaitSetExpectedType(BinaryenExpressionRef expr,
1818
+ BinaryenType expectedType);
1819
+
1820
+ // AtomicNotify
1821
+
1822
+ // Gets the pointer expression of an `memory.atomic.notify` expression.
1823
+ BINARYEN_API BinaryenExpressionRef
1824
+ BinaryenAtomicNotifyGetPtr(BinaryenExpressionRef expr);
1825
+ // Sets the pointer expression of an `memory.atomic.notify` expression.
1826
+ BINARYEN_API void BinaryenAtomicNotifySetPtr(BinaryenExpressionRef expr,
1827
+ BinaryenExpressionRef ptrExpr);
1828
+ // Gets the notify count expression of an `memory.atomic.notify` expression.
1829
+ BINARYEN_API BinaryenExpressionRef
1830
+ BinaryenAtomicNotifyGetNotifyCount(BinaryenExpressionRef expr);
1831
+ // Sets the notify count expression of an `memory.atomic.notify` expression.
1832
+ BINARYEN_API void
1833
+ BinaryenAtomicNotifySetNotifyCount(BinaryenExpressionRef expr,
1834
+ BinaryenExpressionRef notifyCountExpr);
1835
+
1836
+ // AtomicFence
1837
+
1838
+ // Gets the order of an `atomic.fence` expression.
1839
+ BINARYEN_API uint8_t BinaryenAtomicFenceGetOrder(BinaryenExpressionRef expr);
1840
+ // Sets the order of an `atomic.fence` expression.
1841
+ BINARYEN_API void BinaryenAtomicFenceSetOrder(BinaryenExpressionRef expr,
1842
+ uint8_t order);
1843
+
1844
+ // SIMDExtract
1845
+
1846
+ // Gets the operation being performed by a SIMD extract expression.
1847
+ BINARYEN_API BinaryenOp BinaryenSIMDExtractGetOp(BinaryenExpressionRef expr);
1848
+ // Sets the operation being performed by a SIMD extract expression.
1849
+ BINARYEN_API void BinaryenSIMDExtractSetOp(BinaryenExpressionRef expr,
1850
+ BinaryenOp op);
1851
+ // Gets the vector expression a SIMD extract expression extracts from.
1852
+ BINARYEN_API BinaryenExpressionRef
1853
+ BinaryenSIMDExtractGetVec(BinaryenExpressionRef expr);
1854
+ // Sets the vector expression a SIMD extract expression extracts from.
1855
+ BINARYEN_API void BinaryenSIMDExtractSetVec(BinaryenExpressionRef expr,
1856
+ BinaryenExpressionRef vecExpr);
1857
+ // Gets the index of the extracted lane of a SIMD extract expression.
1858
+ BINARYEN_API uint8_t BinaryenSIMDExtractGetIndex(BinaryenExpressionRef expr);
1859
+ // Sets the index of the extracted lane of a SIMD extract expression.
1860
+ BINARYEN_API void BinaryenSIMDExtractSetIndex(BinaryenExpressionRef expr,
1861
+ uint8_t index);
1862
+
1863
+ // SIMDReplace
1864
+
1865
+ // Gets the operation being performed by a SIMD replace expression.
1866
+ BINARYEN_API BinaryenOp BinaryenSIMDReplaceGetOp(BinaryenExpressionRef expr);
1867
+ // Sets the operation being performed by a SIMD replace expression.
1868
+ BINARYEN_API void BinaryenSIMDReplaceSetOp(BinaryenExpressionRef expr,
1869
+ BinaryenOp op);
1870
+ // Gets the vector expression a SIMD replace expression replaces in.
1871
+ BINARYEN_API BinaryenExpressionRef
1872
+ BinaryenSIMDReplaceGetVec(BinaryenExpressionRef expr);
1873
+ // Sets the vector expression a SIMD replace expression replaces in.
1874
+ BINARYEN_API void BinaryenSIMDReplaceSetVec(BinaryenExpressionRef expr,
1875
+ BinaryenExpressionRef vecExpr);
1876
+ // Gets the index of the replaced lane of a SIMD replace expression.
1877
+ BINARYEN_API uint8_t BinaryenSIMDReplaceGetIndex(BinaryenExpressionRef expr);
1878
+ // Sets the index of the replaced lane of a SIMD replace expression.
1879
+ BINARYEN_API void BinaryenSIMDReplaceSetIndex(BinaryenExpressionRef expr,
1880
+ uint8_t index);
1881
+ // Gets the value expression a SIMD replace expression replaces with.
1882
+ BINARYEN_API BinaryenExpressionRef
1883
+ BinaryenSIMDReplaceGetValue(BinaryenExpressionRef expr);
1884
+ // Sets the value expression a SIMD replace expression replaces with.
1885
+ BINARYEN_API void BinaryenSIMDReplaceSetValue(BinaryenExpressionRef expr,
1886
+ BinaryenExpressionRef valueExpr);
1887
+
1888
+ // SIMDShuffle
1889
+
1890
+ // Gets the left expression of a SIMD shuffle expression.
1891
+ BINARYEN_API BinaryenExpressionRef
1892
+ BinaryenSIMDShuffleGetLeft(BinaryenExpressionRef expr);
1893
+ // Sets the left expression of a SIMD shuffle expression.
1894
+ BINARYEN_API void BinaryenSIMDShuffleSetLeft(BinaryenExpressionRef expr,
1895
+ BinaryenExpressionRef leftExpr);
1896
+ // Gets the right expression of a SIMD shuffle expression.
1897
+ BINARYEN_API BinaryenExpressionRef
1898
+ BinaryenSIMDShuffleGetRight(BinaryenExpressionRef expr);
1899
+ // Sets the right expression of a SIMD shuffle expression.
1900
+ BINARYEN_API void BinaryenSIMDShuffleSetRight(BinaryenExpressionRef expr,
1901
+ BinaryenExpressionRef rightExpr);
1902
+ // Gets the 128-bit mask of a SIMD shuffle expression.
1903
+ BINARYEN_API void BinaryenSIMDShuffleGetMask(BinaryenExpressionRef expr,
1904
+ uint8_t* mask);
1905
+ // Sets the 128-bit mask of a SIMD shuffle expression.
1906
+ BINARYEN_API void BinaryenSIMDShuffleSetMask(BinaryenExpressionRef expr,
1907
+ const uint8_t mask[16]);
1908
+
1909
+ // SIMDTernary
1910
+
1911
+ // Gets the operation being performed by a SIMD ternary expression.
1912
+ BINARYEN_API BinaryenOp BinaryenSIMDTernaryGetOp(BinaryenExpressionRef expr);
1913
+ // Sets the operation being performed by a SIMD ternary expression.
1914
+ BINARYEN_API void BinaryenSIMDTernarySetOp(BinaryenExpressionRef expr,
1915
+ BinaryenOp op);
1916
+ // Gets the first operand expression of a SIMD ternary expression.
1917
+ BINARYEN_API BinaryenExpressionRef
1918
+ BinaryenSIMDTernaryGetA(BinaryenExpressionRef expr);
1919
+ // Sets the first operand expression of a SIMD ternary expression.
1920
+ BINARYEN_API void BinaryenSIMDTernarySetA(BinaryenExpressionRef expr,
1921
+ BinaryenExpressionRef aExpr);
1922
+ // Gets the second operand expression of a SIMD ternary expression.
1923
+ BINARYEN_API BinaryenExpressionRef
1924
+ BinaryenSIMDTernaryGetB(BinaryenExpressionRef expr);
1925
+ // Sets the second operand expression of a SIMD ternary expression.
1926
+ BINARYEN_API void BinaryenSIMDTernarySetB(BinaryenExpressionRef expr,
1927
+ BinaryenExpressionRef bExpr);
1928
+ // Gets the third operand expression of a SIMD ternary expression.
1929
+ BINARYEN_API BinaryenExpressionRef
1930
+ BinaryenSIMDTernaryGetC(BinaryenExpressionRef expr);
1931
+ // Sets the third operand expression of a SIMD ternary expression.
1932
+ BINARYEN_API void BinaryenSIMDTernarySetC(BinaryenExpressionRef expr,
1933
+ BinaryenExpressionRef cExpr);
1934
+
1935
+ // SIMDShift
1936
+
1937
+ // Gets the operation being performed by a SIMD shift expression.
1938
+ BINARYEN_API BinaryenOp BinaryenSIMDShiftGetOp(BinaryenExpressionRef expr);
1939
+ // Sets the operation being performed by a SIMD shift expression.
1940
+ BINARYEN_API void BinaryenSIMDShiftSetOp(BinaryenExpressionRef expr,
1941
+ BinaryenOp op);
1942
+ // Gets the expression being shifted by a SIMD shift expression.
1943
+ BINARYEN_API BinaryenExpressionRef
1944
+ BinaryenSIMDShiftGetVec(BinaryenExpressionRef expr);
1945
+ // Sets the expression being shifted by a SIMD shift expression.
1946
+ BINARYEN_API void BinaryenSIMDShiftSetVec(BinaryenExpressionRef expr,
1947
+ BinaryenExpressionRef vecExpr);
1948
+ // Gets the expression representing the shift of a SIMD shift expression.
1949
+ BINARYEN_API BinaryenExpressionRef
1950
+ BinaryenSIMDShiftGetShift(BinaryenExpressionRef expr);
1951
+ // Sets the expression representing the shift of a SIMD shift expression.
1952
+ BINARYEN_API void BinaryenSIMDShiftSetShift(BinaryenExpressionRef expr,
1953
+ BinaryenExpressionRef shiftExpr);
1954
+
1955
+ // SIMDLoad
1956
+
1957
+ // Gets the operation being performed by a SIMD load expression.
1958
+ BINARYEN_API BinaryenOp BinaryenSIMDLoadGetOp(BinaryenExpressionRef expr);
1959
+ // Sets the operation being performed by a SIMD load expression.
1960
+ BINARYEN_API void BinaryenSIMDLoadSetOp(BinaryenExpressionRef expr,
1961
+ BinaryenOp op);
1962
+ // Gets the constant offset of a SIMD load expression.
1963
+ BINARYEN_API uint32_t BinaryenSIMDLoadGetOffset(BinaryenExpressionRef expr);
1964
+ // Sets the constant offset of a SIMD load expression.
1965
+ BINARYEN_API void BinaryenSIMDLoadSetOffset(BinaryenExpressionRef expr,
1966
+ uint32_t offset);
1967
+ // Gets the byte alignment of a SIMD load expression.
1968
+ BINARYEN_API uint32_t BinaryenSIMDLoadGetAlign(BinaryenExpressionRef expr);
1969
+ // Sets the byte alignment of a SIMD load expression.
1970
+ BINARYEN_API void BinaryenSIMDLoadSetAlign(BinaryenExpressionRef expr,
1971
+ uint32_t align);
1972
+ // Gets the pointer expression of a SIMD load expression.
1973
+ BINARYEN_API BinaryenExpressionRef
1974
+ BinaryenSIMDLoadGetPtr(BinaryenExpressionRef expr);
1975
+ // Sets the pointer expression of a SIMD load expression.
1976
+ BINARYEN_API void BinaryenSIMDLoadSetPtr(BinaryenExpressionRef expr,
1977
+ BinaryenExpressionRef ptrExpr);
1978
+
1979
+ // SIMDLoadStoreLane
1980
+
1981
+ // Gets the operation being performed by a SIMD load/store lane expression.
1982
+ BINARYEN_API BinaryenOp
1983
+ BinaryenSIMDLoadStoreLaneGetOp(BinaryenExpressionRef expr);
1984
+ // Sets the operation being performed by a SIMD load/store lane expression.
1985
+ BINARYEN_API void BinaryenSIMDLoadStoreLaneSetOp(BinaryenExpressionRef expr,
1986
+ BinaryenOp op);
1987
+ // Gets the constant offset of a SIMD load/store lane expression.
1988
+ BINARYEN_API uint32_t
1989
+ BinaryenSIMDLoadStoreLaneGetOffset(BinaryenExpressionRef expr);
1990
+ // Sets the constant offset of a SIMD load/store lane expression.
1991
+ BINARYEN_API void BinaryenSIMDLoadStoreLaneSetOffset(BinaryenExpressionRef expr,
1992
+ uint32_t offset);
1993
+ // Gets the byte alignment of a SIMD load/store lane expression.
1994
+ BINARYEN_API uint32_t
1995
+ BinaryenSIMDLoadStoreLaneGetAlign(BinaryenExpressionRef expr);
1996
+ // Sets the byte alignment of a SIMD load/store lane expression.
1997
+ BINARYEN_API void BinaryenSIMDLoadStoreLaneSetAlign(BinaryenExpressionRef expr,
1998
+ uint32_t align);
1999
+ // Gets the lane index of a SIMD load/store lane expression.
2000
+ BINARYEN_API uint8_t
2001
+ BinaryenSIMDLoadStoreLaneGetIndex(BinaryenExpressionRef expr);
2002
+ // Sets the lane index of a SIMD load/store lane expression.
2003
+ BINARYEN_API void BinaryenSIMDLoadStoreLaneSetIndex(BinaryenExpressionRef expr,
2004
+ uint8_t index);
2005
+ // Gets the pointer expression of a SIMD load/store lane expression.
2006
+ BINARYEN_API BinaryenExpressionRef
2007
+ BinaryenSIMDLoadStoreLaneGetPtr(BinaryenExpressionRef expr);
2008
+ // Sets the pointer expression of a SIMD load/store lane expression.
2009
+ BINARYEN_API void
2010
+ BinaryenSIMDLoadStoreLaneSetPtr(BinaryenExpressionRef expr,
2011
+ BinaryenExpressionRef ptrExpr);
2012
+ // Gets the vector expression of a SIMD load/store lane expression.
2013
+ BINARYEN_API BinaryenExpressionRef
2014
+ BinaryenSIMDLoadStoreLaneGetVec(BinaryenExpressionRef expr);
2015
+ // Sets the vector expression of a SIMD load/store lane expression.
2016
+ BINARYEN_API void
2017
+ BinaryenSIMDLoadStoreLaneSetVec(BinaryenExpressionRef expr,
2018
+ BinaryenExpressionRef vecExpr);
2019
+ // Gets whether a SIMD load/store lane expression performs a store. Otherwise it
2020
+ // performs a load.
2021
+ BINARYEN_API bool BinaryenSIMDLoadStoreLaneIsStore(BinaryenExpressionRef expr);
2022
+
2023
+ // MemoryInit
2024
+
2025
+ // Gets the index of the segment being initialized by a `memory.init`
2026
+ // expression.
2027
+ BINARYEN_API const char*
2028
+ BinaryenMemoryInitGetSegment(BinaryenExpressionRef expr);
2029
+ // Sets the index of the segment being initialized by a `memory.init`
2030
+ // expression.
2031
+ BINARYEN_API void BinaryenMemoryInitSetSegment(BinaryenExpressionRef expr,
2032
+ const char* segment);
2033
+ // Gets the destination expression of a `memory.init` expression.
2034
+ BINARYEN_API BinaryenExpressionRef
2035
+ BinaryenMemoryInitGetDest(BinaryenExpressionRef expr);
2036
+ // Sets the destination expression of a `memory.init` expression.
2037
+ BINARYEN_API void BinaryenMemoryInitSetDest(BinaryenExpressionRef expr,
2038
+ BinaryenExpressionRef destExpr);
2039
+ // Gets the offset expression of a `memory.init` expression.
2040
+ BINARYEN_API BinaryenExpressionRef
2041
+ BinaryenMemoryInitGetOffset(BinaryenExpressionRef expr);
2042
+ // Sets the offset expression of a `memory.init` expression.
2043
+ BINARYEN_API void BinaryenMemoryInitSetOffset(BinaryenExpressionRef expr,
2044
+ BinaryenExpressionRef offsetExpr);
2045
+ // Gets the size expression of a `memory.init` expression.
2046
+ BINARYEN_API BinaryenExpressionRef
2047
+ BinaryenMemoryInitGetSize(BinaryenExpressionRef expr);
2048
+ // Sets the size expression of a `memory.init` expression.
2049
+ BINARYEN_API void BinaryenMemoryInitSetSize(BinaryenExpressionRef expr,
2050
+ BinaryenExpressionRef sizeExpr);
2051
+
2052
+ // DataDrop
2053
+
2054
+ // Gets the index of the segment being dropped by a `data.drop` expression.
2055
+ BINARYEN_API const char* BinaryenDataDropGetSegment(BinaryenExpressionRef expr);
2056
+ // Sets the index of the segment being dropped by a `data.drop` expression.
2057
+ BINARYEN_API void BinaryenDataDropSetSegment(BinaryenExpressionRef expr,
2058
+ const char* segment);
2059
+
2060
+ // MemoryCopy
2061
+
2062
+ // Gets the destination expression of a `memory.copy` expression.
2063
+ BINARYEN_API BinaryenExpressionRef
2064
+ BinaryenMemoryCopyGetDest(BinaryenExpressionRef expr);
2065
+ // Sets the destination expression of a `memory.copy` expression.
2066
+ BINARYEN_API void BinaryenMemoryCopySetDest(BinaryenExpressionRef expr,
2067
+ BinaryenExpressionRef destExpr);
2068
+ // Gets the source expression of a `memory.copy` expression.
2069
+ BINARYEN_API BinaryenExpressionRef
2070
+ BinaryenMemoryCopyGetSource(BinaryenExpressionRef expr);
2071
+ // Sets the source expression of a `memory.copy` expression.
2072
+ BINARYEN_API void BinaryenMemoryCopySetSource(BinaryenExpressionRef expr,
2073
+ BinaryenExpressionRef sourceExpr);
2074
+ // Gets the size expression (number of bytes copied) of a `memory.copy`
2075
+ // expression.
2076
+ BINARYEN_API BinaryenExpressionRef
2077
+ BinaryenMemoryCopyGetSize(BinaryenExpressionRef expr);
2078
+ // Sets the size expression (number of bytes copied) of a `memory.copy`
2079
+ // expression.
2080
+ BINARYEN_API void BinaryenMemoryCopySetSize(BinaryenExpressionRef expr,
2081
+ BinaryenExpressionRef sizeExpr);
2082
+
2083
+ // MemoryFill
2084
+
2085
+ // Gets the destination expression of a `memory.fill` expression.
2086
+ BINARYEN_API BinaryenExpressionRef
2087
+ BinaryenMemoryFillGetDest(BinaryenExpressionRef expr);
2088
+ // Sets the destination expression of a `memory.fill` expression.
2089
+ BINARYEN_API void BinaryenMemoryFillSetDest(BinaryenExpressionRef expr,
2090
+ BinaryenExpressionRef destExpr);
2091
+ // Gets the value expression of a `memory.fill` expression.
2092
+ BINARYEN_API BinaryenExpressionRef
2093
+ BinaryenMemoryFillGetValue(BinaryenExpressionRef expr);
2094
+ // Sets the value expression of a `memory.fill` expression.
2095
+ BINARYEN_API void BinaryenMemoryFillSetValue(BinaryenExpressionRef expr,
2096
+ BinaryenExpressionRef valueExpr);
2097
+ // Gets the size expression (number of bytes filled) of a `memory.fill`
2098
+ // expression.
2099
+ BINARYEN_API BinaryenExpressionRef
2100
+ BinaryenMemoryFillGetSize(BinaryenExpressionRef expr);
2101
+ // Sets the size expression (number of bytes filled) of a `memory.fill`
2102
+ // expression.
2103
+ BINARYEN_API void BinaryenMemoryFillSetSize(BinaryenExpressionRef expr,
2104
+ BinaryenExpressionRef sizeExpr);
2105
+
2106
+ // RefIsNull
2107
+
2108
+ BINARYEN_API BinaryenExpressionRef
2109
+ BinaryenRefIsNullGetValue(BinaryenExpressionRef expr);
2110
+ // Sets the value expression tested by a `ref.is_null` expression.
2111
+ BINARYEN_API void BinaryenRefIsNullSetValue(BinaryenExpressionRef expr,
2112
+ BinaryenExpressionRef valueExpr);
2113
+
2114
+ // RefAs
2115
+
2116
+ // Gets the operation performed by a `ref.as_*` expression.
2117
+ BINARYEN_API BinaryenOp BinaryenRefAsGetOp(BinaryenExpressionRef expr);
2118
+ // Sets the operation performed by a `ref.as_*` expression.
2119
+ BINARYEN_API void BinaryenRefAsSetOp(BinaryenExpressionRef expr, BinaryenOp op);
2120
+ // Gets the value expression tested by a `ref.as_*` expression.
2121
+ BINARYEN_API BinaryenExpressionRef
2122
+ BinaryenRefAsGetValue(BinaryenExpressionRef expr);
2123
+ // Sets the value expression tested by a `ref.as_*` expression.
2124
+ BINARYEN_API void BinaryenRefAsSetValue(BinaryenExpressionRef expr,
2125
+ BinaryenExpressionRef valueExpr);
2126
+
2127
+ // RefFunc
2128
+
2129
+ // Gets the name of the function being wrapped by a `ref.func` expression.
2130
+ BINARYEN_API const char* BinaryenRefFuncGetFunc(BinaryenExpressionRef expr);
2131
+ // Sets the name of the function being wrapped by a `ref.func` expression.
2132
+ BINARYEN_API void BinaryenRefFuncSetFunc(BinaryenExpressionRef expr,
2133
+ const char* funcName);
2134
+
2135
+ // RefEq
2136
+
2137
+ // Gets the left expression of a `ref.eq` expression.
2138
+ BINARYEN_API BinaryenExpressionRef
2139
+ BinaryenRefEqGetLeft(BinaryenExpressionRef expr);
2140
+ // Sets the left expression of a `ref.eq` expression.
2141
+ BINARYEN_API void BinaryenRefEqSetLeft(BinaryenExpressionRef expr,
2142
+ BinaryenExpressionRef left);
2143
+ // Gets the right expression of a `ref.eq` expression.
2144
+ BINARYEN_API BinaryenExpressionRef
2145
+ BinaryenRefEqGetRight(BinaryenExpressionRef expr);
2146
+ // Sets the right expression of a `ref.eq` expression.
2147
+ BINARYEN_API void BinaryenRefEqSetRight(BinaryenExpressionRef expr,
2148
+ BinaryenExpressionRef right);
2149
+
2150
+ // Try
2151
+
2152
+ // Gets the name (label) of a `try` expression.
2153
+ BINARYEN_API const char* BinaryenTryGetName(BinaryenExpressionRef expr);
2154
+ // Sets the name (label) of a `try` expression.
2155
+ BINARYEN_API void BinaryenTrySetName(BinaryenExpressionRef expr,
2156
+ const char* name);
2157
+ // Gets the body expression of a `try` expression.
2158
+ BINARYEN_API BinaryenExpressionRef
2159
+ BinaryenTryGetBody(BinaryenExpressionRef expr);
2160
+ // Sets the body expression of a `try` expression.
2161
+ BINARYEN_API void BinaryenTrySetBody(BinaryenExpressionRef expr,
2162
+ BinaryenExpressionRef bodyExpr);
2163
+ // Gets the number of catch blocks (= the number of catch tags) of a `try`
2164
+ // expression.
2165
+ BINARYEN_API BinaryenIndex
2166
+ BinaryenTryGetNumCatchTags(BinaryenExpressionRef expr);
2167
+ // Gets the number of catch/catch_all blocks of a `try` expression.
2168
+ BINARYEN_API BinaryenIndex
2169
+ BinaryenTryGetNumCatchBodies(BinaryenExpressionRef expr);
2170
+ // Gets the catch tag at the specified index of a `try` expression.
2171
+ BINARYEN_API const char* BinaryenTryGetCatchTagAt(BinaryenExpressionRef expr,
2172
+ BinaryenIndex index);
2173
+ // Sets the catch tag at the specified index of a `try` expression.
2174
+ BINARYEN_API void BinaryenTrySetCatchTagAt(BinaryenExpressionRef expr,
2175
+ BinaryenIndex index,
2176
+ const char* catchTag);
2177
+ // Appends a catch tag to a `try` expression, returning its insertion index.
2178
+ BINARYEN_API BinaryenIndex BinaryenTryAppendCatchTag(BinaryenExpressionRef expr,
2179
+ const char* catchTag);
2180
+ // Inserts a catch tag at the specified index of a `try` expression, moving
2181
+ // existing catch tags including the one previously at that index one index up.
2182
+ BINARYEN_API void BinaryenTryInsertCatchTagAt(BinaryenExpressionRef expr,
2183
+ BinaryenIndex index,
2184
+ const char* catchTag);
2185
+ // Removes the catch tag at the specified index of a `try` expression, moving
2186
+ // all subsequent catch tags one index down. Returns the tag.
2187
+ BINARYEN_API const char* BinaryenTryRemoveCatchTagAt(BinaryenExpressionRef expr,
2188
+ BinaryenIndex index);
2189
+ // Gets the catch body expression at the specified index of a `try` expression.
2190
+ BINARYEN_API BinaryenExpressionRef
2191
+ BinaryenTryGetCatchBodyAt(BinaryenExpressionRef expr, BinaryenIndex index);
2192
+ // Sets the catch body expression at the specified index of a `try` expression.
2193
+ BINARYEN_API void BinaryenTrySetCatchBodyAt(BinaryenExpressionRef expr,
2194
+ BinaryenIndex index,
2195
+ BinaryenExpressionRef catchExpr);
2196
+ // Appends a catch expression to a `try` expression, returning its insertion
2197
+ // index.
2198
+ BINARYEN_API BinaryenIndex BinaryenTryAppendCatchBody(
2199
+ BinaryenExpressionRef expr, BinaryenExpressionRef catchExpr);
2200
+ // Inserts a catch expression at the specified index of a `try` expression,
2201
+ // moving existing catch bodies including the one previously at that index one
2202
+ // index up.
2203
+ BINARYEN_API void BinaryenTryInsertCatchBodyAt(BinaryenExpressionRef expr,
2204
+ BinaryenIndex index,
2205
+ BinaryenExpressionRef catchExpr);
2206
+ // Removes the catch expression at the specified index of a `try` expression,
2207
+ // moving all subsequent catch bodies one index down. Returns the catch
2208
+ // expression.
2209
+ BINARYEN_API BinaryenExpressionRef
2210
+ BinaryenTryRemoveCatchBodyAt(BinaryenExpressionRef expr, BinaryenIndex index);
2211
+ // Gets whether a `try` expression has a catch_all clause.
2212
+ BINARYEN_API bool BinaryenTryHasCatchAll(BinaryenExpressionRef expr);
2213
+ // Gets the target label of a `delegate`.
2214
+ BINARYEN_API const char*
2215
+ BinaryenTryGetDelegateTarget(BinaryenExpressionRef expr);
2216
+ // Sets the target label of a `delegate`.
2217
+ BINARYEN_API void BinaryenTrySetDelegateTarget(BinaryenExpressionRef expr,
2218
+ const char* delegateTarget);
2219
+ // Gets whether a `try` expression is a try-delegate.
2220
+ BINARYEN_API bool BinaryenTryIsDelegate(BinaryenExpressionRef expr);
2221
+
2222
+ // Throw
2223
+
2224
+ // Gets the name of the tag being thrown by a `throw` expression.
2225
+ BINARYEN_API const char* BinaryenThrowGetTag(BinaryenExpressionRef expr);
2226
+ // Sets the name of the tag being thrown by a `throw` expression.
2227
+ BINARYEN_API void BinaryenThrowSetTag(BinaryenExpressionRef expr,
2228
+ const char* tagName);
2229
+ // Gets the number of operands of a `throw` expression.
2230
+ BINARYEN_API BinaryenIndex
2231
+ BinaryenThrowGetNumOperands(BinaryenExpressionRef expr);
2232
+ // Gets the operand at the specified index of a `throw` expression.
2233
+ BINARYEN_API BinaryenExpressionRef
2234
+ BinaryenThrowGetOperandAt(BinaryenExpressionRef expr, BinaryenIndex index);
2235
+ // Sets the operand at the specified index of a `throw` expression.
2236
+ BINARYEN_API void BinaryenThrowSetOperandAt(BinaryenExpressionRef expr,
2237
+ BinaryenIndex index,
2238
+ BinaryenExpressionRef operandExpr);
2239
+ // Appends an operand expression to a `throw` expression, returning its
2240
+ // insertion index.
2241
+ BINARYEN_API BinaryenIndex BinaryenThrowAppendOperand(
2242
+ BinaryenExpressionRef expr, BinaryenExpressionRef operandExpr);
2243
+ // Inserts an operand expression at the specified index of a `throw` expression,
2244
+ // moving existing operands including the one previously at that index one index
2245
+ // up.
2246
+ BINARYEN_API void
2247
+ BinaryenThrowInsertOperandAt(BinaryenExpressionRef expr,
2248
+ BinaryenIndex index,
2249
+ BinaryenExpressionRef operandExpr);
2250
+ // Removes the operand expression at the specified index of a `throw`
2251
+ // expression, moving all subsequent operands one index down. Returns the
2252
+ // operand expression.
2253
+ BINARYEN_API BinaryenExpressionRef
2254
+ BinaryenThrowRemoveOperandAt(BinaryenExpressionRef expr, BinaryenIndex index);
2255
+
2256
+ // Rethrow
2257
+
2258
+ // Gets the target catch's corresponding try label of a `rethrow` expression.
2259
+ BINARYEN_API const char* BinaryenRethrowGetTarget(BinaryenExpressionRef expr);
2260
+ // Sets the target catch's corresponding try label of a `rethrow` expression.
2261
+ BINARYEN_API void BinaryenRethrowSetTarget(BinaryenExpressionRef expr,
2262
+ const char* target);
2263
+
2264
+ // TupleMake
2265
+
2266
+ // Gets the number of operands of a `tuple.make` expression.
2267
+ BINARYEN_API BinaryenIndex
2268
+ BinaryenTupleMakeGetNumOperands(BinaryenExpressionRef expr);
2269
+ // Gets the operand at the specified index of a `tuple.make` expression.
2270
+ BINARYEN_API BinaryenExpressionRef
2271
+ BinaryenTupleMakeGetOperandAt(BinaryenExpressionRef expr, BinaryenIndex index);
2272
+ // Sets the operand at the specified index of a `tuple.make` expression.
2273
+ BINARYEN_API void
2274
+ BinaryenTupleMakeSetOperandAt(BinaryenExpressionRef expr,
2275
+ BinaryenIndex index,
2276
+ BinaryenExpressionRef operandExpr);
2277
+ // Appends an operand expression to a `tuple.make` expression, returning its
2278
+ // insertion index.
2279
+ BINARYEN_API BinaryenIndex BinaryenTupleMakeAppendOperand(
2280
+ BinaryenExpressionRef expr, BinaryenExpressionRef operandExpr);
2281
+ // Inserts an operand expression at the specified index of a `tuple.make`
2282
+ // expression, moving existing operands including the one previously at that
2283
+ // index one index up.
2284
+ BINARYEN_API void
2285
+ BinaryenTupleMakeInsertOperandAt(BinaryenExpressionRef expr,
2286
+ BinaryenIndex index,
2287
+ BinaryenExpressionRef operandExpr);
2288
+ // Removes the operand expression at the specified index of a `tuple.make`
2289
+ // expression, moving all subsequent operands one index down. Returns the
2290
+ // operand expression.
2291
+ BINARYEN_API BinaryenExpressionRef BinaryenTupleMakeRemoveOperandAt(
2292
+ BinaryenExpressionRef expr, BinaryenIndex index);
2293
+
2294
+ // TupleExtract
2295
+
2296
+ // Gets the tuple extracted from of a `tuple.extract` expression.
2297
+ BINARYEN_API BinaryenExpressionRef
2298
+ BinaryenTupleExtractGetTuple(BinaryenExpressionRef expr);
2299
+ // Sets the tuple extracted from of a `tuple.extract` expression.
2300
+ BINARYEN_API void BinaryenTupleExtractSetTuple(BinaryenExpressionRef expr,
2301
+ BinaryenExpressionRef tupleExpr);
2302
+ // Gets the index extracted at of a `tuple.extract` expression.
2303
+ BINARYEN_API BinaryenIndex
2304
+ BinaryenTupleExtractGetIndex(BinaryenExpressionRef expr);
2305
+ // Sets the index extracted at of a `tuple.extract` expression.
2306
+ BINARYEN_API void BinaryenTupleExtractSetIndex(BinaryenExpressionRef expr,
2307
+ BinaryenIndex index);
2308
+
2309
+ // RefI31
2310
+
2311
+ // Gets the value expression of a `ref.i31` expression.
2312
+ BINARYEN_API BinaryenExpressionRef
2313
+ BinaryenRefI31GetValue(BinaryenExpressionRef expr);
2314
+ // Sets the value expression of a `ref.i31` expression.
2315
+ BINARYEN_API void BinaryenRefI31SetValue(BinaryenExpressionRef expr,
2316
+ BinaryenExpressionRef valueExpr);
2317
+
2318
+ // I31Get
2319
+
2320
+ // Gets the i31 expression of an `i31.get` expression.
2321
+ BINARYEN_API BinaryenExpressionRef
2322
+ BinaryenI31GetGetI31(BinaryenExpressionRef expr);
2323
+ // Sets the i31 expression of an `i31.get` expression.
2324
+ BINARYEN_API void BinaryenI31GetSetI31(BinaryenExpressionRef expr,
2325
+ BinaryenExpressionRef i31Expr);
2326
+ // Gets whether an `i31.get` expression returns a signed value (`_s`).
2327
+ BINARYEN_API bool BinaryenI31GetIsSigned(BinaryenExpressionRef expr);
2328
+ // Sets whether an `i31.get` expression returns a signed value (`_s`).
2329
+ BINARYEN_API void BinaryenI31GetSetSigned(BinaryenExpressionRef expr,
2330
+ bool signed_);
2331
+
2332
+ // CallRef
2333
+
2334
+ BINARYEN_API BinaryenIndex
2335
+ BinaryenCallRefGetNumOperands(BinaryenExpressionRef expr);
2336
+ BINARYEN_API BinaryenExpressionRef
2337
+ BinaryenCallRefGetOperandAt(BinaryenExpressionRef expr, BinaryenIndex index);
2338
+ BINARYEN_API void
2339
+ BinaryenCallRefSetOperandAt(BinaryenExpressionRef expr,
2340
+ BinaryenIndex index,
2341
+ BinaryenExpressionRef operandExpr);
2342
+ BINARYEN_API BinaryenIndex BinaryenCallRefAppendOperand(
2343
+ BinaryenExpressionRef expr, BinaryenExpressionRef operandExpr);
2344
+ BINARYEN_API void
2345
+ BinaryenCallRefInsertOperandAt(BinaryenExpressionRef expr,
2346
+ BinaryenIndex index,
2347
+ BinaryenExpressionRef operandExpr);
2348
+ BINARYEN_API BinaryenExpressionRef
2349
+ BinaryenCallRefRemoveOperandAt(BinaryenExpressionRef expr, BinaryenIndex index);
2350
+ BINARYEN_API BinaryenExpressionRef
2351
+ BinaryenCallRefGetTarget(BinaryenExpressionRef expr);
2352
+ BINARYEN_API void BinaryenCallRefSetTarget(BinaryenExpressionRef expr,
2353
+ BinaryenExpressionRef targetExpr);
2354
+ BINARYEN_API bool BinaryenCallRefIsReturn(BinaryenExpressionRef expr);
2355
+ BINARYEN_API void BinaryenCallRefSetReturn(BinaryenExpressionRef expr,
2356
+ bool isReturn);
2357
+
2358
+ // RefTest
2359
+
2360
+ BINARYEN_API BinaryenExpressionRef
2361
+ BinaryenRefTestGetRef(BinaryenExpressionRef expr);
2362
+ BINARYEN_API void BinaryenRefTestSetRef(BinaryenExpressionRef expr,
2363
+ BinaryenExpressionRef refExpr);
2364
+ BINARYEN_API BinaryenType
2365
+ BinaryenRefTestGetCastType(BinaryenExpressionRef expr);
2366
+ BINARYEN_API void BinaryenRefTestSetCastType(BinaryenExpressionRef expr,
2367
+ BinaryenType intendedType);
2368
+
2369
+ // RefCast
2370
+
2371
+ BINARYEN_API BinaryenExpressionRef
2372
+ BinaryenRefCastGetRef(BinaryenExpressionRef expr);
2373
+ BINARYEN_API void BinaryenRefCastSetRef(BinaryenExpressionRef expr,
2374
+ BinaryenExpressionRef refExpr);
2375
+
2376
+ // BrOn
2377
+
2378
+ BINARYEN_API BinaryenOp BinaryenBrOnGetOp(BinaryenExpressionRef expr);
2379
+ BINARYEN_API void BinaryenBrOnSetOp(BinaryenExpressionRef expr, BinaryenOp op);
2380
+ BINARYEN_API const char* BinaryenBrOnGetName(BinaryenExpressionRef expr);
2381
+ BINARYEN_API void BinaryenBrOnSetName(BinaryenExpressionRef expr,
2382
+ const char* nameStr);
2383
+ BINARYEN_API BinaryenExpressionRef
2384
+ BinaryenBrOnGetRef(BinaryenExpressionRef expr);
2385
+ BINARYEN_API void BinaryenBrOnSetRef(BinaryenExpressionRef expr,
2386
+ BinaryenExpressionRef refExpr);
2387
+ BINARYEN_API BinaryenType BinaryenBrOnGetCastType(BinaryenExpressionRef expr);
2388
+ BINARYEN_API void BinaryenBrOnSetCastType(BinaryenExpressionRef expr,
2389
+ BinaryenType castType);
2390
+
2391
+ // StructNew
2392
+
2393
+ BINARYEN_API BinaryenIndex
2394
+ BinaryenStructNewGetNumOperands(BinaryenExpressionRef expr);
2395
+ BINARYEN_API BinaryenExpressionRef
2396
+ BinaryenStructNewGetOperandAt(BinaryenExpressionRef expr, BinaryenIndex index);
2397
+ BINARYEN_API void
2398
+ BinaryenStructNewSetOperandAt(BinaryenExpressionRef expr,
2399
+ BinaryenIndex index,
2400
+ BinaryenExpressionRef operandExpr);
2401
+ BINARYEN_API BinaryenIndex BinaryenStructNewAppendOperand(
2402
+ BinaryenExpressionRef expr, BinaryenExpressionRef operandExpr);
2403
+ BINARYEN_API void
2404
+ BinaryenStructNewInsertOperandAt(BinaryenExpressionRef expr,
2405
+ BinaryenIndex index,
2406
+ BinaryenExpressionRef operandExpr);
2407
+ BINARYEN_API BinaryenExpressionRef BinaryenStructNewRemoveOperandAt(
2408
+ BinaryenExpressionRef expr, BinaryenIndex index);
2409
+
2410
+ // StructGet
2411
+
2412
+ BINARYEN_API BinaryenIndex
2413
+ BinaryenStructGetGetIndex(BinaryenExpressionRef expr);
2414
+ BINARYEN_API void BinaryenStructGetSetIndex(BinaryenExpressionRef expr,
2415
+ BinaryenIndex index);
2416
+ BINARYEN_API BinaryenExpressionRef
2417
+ BinaryenStructGetGetRef(BinaryenExpressionRef expr);
2418
+ BINARYEN_API void BinaryenStructGetSetRef(BinaryenExpressionRef expr,
2419
+ BinaryenExpressionRef refExpr);
2420
+ BINARYEN_API bool BinaryenStructGetIsSigned(BinaryenExpressionRef expr);
2421
+ BINARYEN_API void BinaryenStructGetSetSigned(BinaryenExpressionRef expr,
2422
+ bool signed_);
2423
+
2424
+ // StructSet
2425
+
2426
+ BINARYEN_API BinaryenIndex
2427
+ BinaryenStructSetGetIndex(BinaryenExpressionRef expr);
2428
+ BINARYEN_API void BinaryenStructSetSetIndex(BinaryenExpressionRef expr,
2429
+ BinaryenIndex index);
2430
+ BINARYEN_API BinaryenExpressionRef
2431
+ BinaryenStructSetGetRef(BinaryenExpressionRef expr);
2432
+ BINARYEN_API void BinaryenStructSetSetRef(BinaryenExpressionRef expr,
2433
+ BinaryenExpressionRef refExpr);
2434
+ BINARYEN_API BinaryenExpressionRef
2435
+ BinaryenStructSetGetValue(BinaryenExpressionRef expr);
2436
+ BINARYEN_API void BinaryenStructSetSetValue(BinaryenExpressionRef expr,
2437
+ BinaryenExpressionRef valueExpr);
2438
+
2439
+ // ArrayNew
2440
+
2441
+ BINARYEN_API BinaryenExpressionRef
2442
+ BinaryenArrayNewGetInit(BinaryenExpressionRef expr);
2443
+ BINARYEN_API void BinaryenArrayNewSetInit(BinaryenExpressionRef expr,
2444
+ BinaryenExpressionRef initExpr);
2445
+ BINARYEN_API BinaryenExpressionRef
2446
+ BinaryenArrayNewGetSize(BinaryenExpressionRef expr);
2447
+ BINARYEN_API void BinaryenArrayNewSetSize(BinaryenExpressionRef expr,
2448
+ BinaryenExpressionRef sizeExpr);
2449
+
2450
+ // ArrayNewFixed
2451
+
2452
+ BINARYEN_API BinaryenIndex
2453
+ BinaryenArrayNewFixedGetNumValues(BinaryenExpressionRef expr);
2454
+ BINARYEN_API BinaryenExpressionRef BinaryenArrayNewFixedGetValueAt(
2455
+ BinaryenExpressionRef expr, BinaryenIndex index);
2456
+ BINARYEN_API void
2457
+ BinaryenArrayNewFixedSetValueAt(BinaryenExpressionRef expr,
2458
+ BinaryenIndex index,
2459
+ BinaryenExpressionRef valueExpr);
2460
+ BINARYEN_API BinaryenIndex BinaryenArrayNewFixedAppendValue(
2461
+ BinaryenExpressionRef expr, BinaryenExpressionRef valueExpr);
2462
+ BINARYEN_API void
2463
+ BinaryenArrayNewFixedInsertValueAt(BinaryenExpressionRef expr,
2464
+ BinaryenIndex index,
2465
+ BinaryenExpressionRef valueExpr);
2466
+ BINARYEN_API BinaryenExpressionRef BinaryenArrayNewFixedRemoveValueAt(
2467
+ BinaryenExpressionRef expr, BinaryenIndex index);
2468
+
2469
+ // ArrayGet
2470
+
2471
+ BINARYEN_API BinaryenExpressionRef
2472
+ BinaryenArrayGetGetRef(BinaryenExpressionRef expr);
2473
+ BINARYEN_API void BinaryenArrayGetSetRef(BinaryenExpressionRef expr,
2474
+ BinaryenExpressionRef refExpr);
2475
+ BINARYEN_API BinaryenExpressionRef
2476
+ BinaryenArrayGetGetIndex(BinaryenExpressionRef expr);
2477
+ BINARYEN_API void BinaryenArrayGetSetIndex(BinaryenExpressionRef expr,
2478
+ BinaryenExpressionRef indexExpr);
2479
+ BINARYEN_API bool BinaryenArrayGetIsSigned(BinaryenExpressionRef expr);
2480
+ BINARYEN_API void BinaryenArrayGetSetSigned(BinaryenExpressionRef expr,
2481
+ bool signed_);
2482
+
2483
+ // ArraySet
2484
+
2485
+ BINARYEN_API BinaryenExpressionRef
2486
+ BinaryenArraySetGetRef(BinaryenExpressionRef expr);
2487
+ BINARYEN_API void BinaryenArraySetSetRef(BinaryenExpressionRef expr,
2488
+ BinaryenExpressionRef refExpr);
2489
+ BINARYEN_API BinaryenExpressionRef
2490
+ BinaryenArraySetGetIndex(BinaryenExpressionRef expr);
2491
+ BINARYEN_API void BinaryenArraySetSetIndex(BinaryenExpressionRef expr,
2492
+ BinaryenExpressionRef indexExpr);
2493
+ BINARYEN_API BinaryenExpressionRef
2494
+ BinaryenArraySetGetValue(BinaryenExpressionRef expr);
2495
+ BINARYEN_API void BinaryenArraySetSetValue(BinaryenExpressionRef expr,
2496
+ BinaryenExpressionRef valueExpr);
2497
+
2498
+ // ArrayLen
2499
+
2500
+ BINARYEN_API BinaryenExpressionRef
2501
+ BinaryenArrayLenGetRef(BinaryenExpressionRef expr);
2502
+ BINARYEN_API void BinaryenArrayLenSetRef(BinaryenExpressionRef expr,
2503
+ BinaryenExpressionRef refExpr);
2504
+
2505
+ // ArrayCopy
2506
+
2507
+ BINARYEN_API BinaryenExpressionRef
2508
+ BinaryenArrayCopyGetDestRef(BinaryenExpressionRef expr);
2509
+ BINARYEN_API void
2510
+ BinaryenArrayCopySetDestRef(BinaryenExpressionRef expr,
2511
+ BinaryenExpressionRef destRefExpr);
2512
+ BINARYEN_API BinaryenExpressionRef
2513
+ BinaryenArrayCopyGetDestIndex(BinaryenExpressionRef expr);
2514
+ BINARYEN_API void
2515
+ BinaryenArrayCopySetDestIndex(BinaryenExpressionRef expr,
2516
+ BinaryenExpressionRef destIndexExpr);
2517
+ BINARYEN_API BinaryenExpressionRef
2518
+ BinaryenArrayCopyGetSrcRef(BinaryenExpressionRef expr);
2519
+ BINARYEN_API void BinaryenArrayCopySetSrcRef(BinaryenExpressionRef expr,
2520
+ BinaryenExpressionRef srcRefExpr);
2521
+ BINARYEN_API BinaryenExpressionRef
2522
+ BinaryenArrayCopyGetSrcIndex(BinaryenExpressionRef expr);
2523
+ BINARYEN_API void
2524
+ BinaryenArrayCopySetSrcIndex(BinaryenExpressionRef expr,
2525
+ BinaryenExpressionRef srcIndexExpr);
2526
+ BINARYEN_API BinaryenExpressionRef
2527
+ BinaryenArrayCopyGetLength(BinaryenExpressionRef expr);
2528
+ BINARYEN_API void BinaryenArrayCopySetLength(BinaryenExpressionRef expr,
2529
+ BinaryenExpressionRef lengthExpr);
2530
+
2531
+ // StringNew
2532
+
2533
+ BINARYEN_API BinaryenOp BinaryenStringNewGetOp(BinaryenExpressionRef expr);
2534
+ BINARYEN_API void BinaryenStringNewSetOp(BinaryenExpressionRef expr,
2535
+ BinaryenOp op);
2536
+ BINARYEN_API BinaryenExpressionRef
2537
+ BinaryenStringNewGetPtr(BinaryenExpressionRef expr);
2538
+ BINARYEN_API void BinaryenStringNewSetPtr(BinaryenExpressionRef expr,
2539
+ BinaryenExpressionRef ptrExpr);
2540
+ BINARYEN_API BinaryenExpressionRef
2541
+ BinaryenStringNewGetLength(BinaryenExpressionRef expr);
2542
+ BINARYEN_API void BinaryenStringNewSetLength(BinaryenExpressionRef expr,
2543
+ BinaryenExpressionRef lengthExpr);
2544
+ BINARYEN_API BinaryenExpressionRef
2545
+ BinaryenStringNewGetStart(BinaryenExpressionRef expr);
2546
+ BINARYEN_API void BinaryenStringNewSetStart(BinaryenExpressionRef expr,
2547
+ BinaryenExpressionRef startExpr);
2548
+ BINARYEN_API BinaryenExpressionRef
2549
+ BinaryenStringNewGetEnd(BinaryenExpressionRef expr);
2550
+ BINARYEN_API void BinaryenStringNewSetEnd(BinaryenExpressionRef expr,
2551
+ BinaryenExpressionRef endExpr);
2552
+ BINARYEN_API void BinaryenStringNewSetTry(BinaryenExpressionRef expr,
2553
+ bool try_);
2554
+ BINARYEN_API bool BinaryenStringNewIsTry(BinaryenExpressionRef expr);
2555
+
2556
+ // StringConst
2557
+
2558
+ BINARYEN_API const char*
2559
+ BinaryenStringConstGetString(BinaryenExpressionRef expr);
2560
+ BINARYEN_API void BinaryenStringConstSetString(BinaryenExpressionRef expr,
2561
+ const char* stringStr);
2562
+
2563
+ // StringMeasure
2564
+
2565
+ BINARYEN_API BinaryenOp BinaryenStringMeasureGetOp(BinaryenExpressionRef expr);
2566
+ BINARYEN_API void BinaryenStringMeasureSetOp(BinaryenExpressionRef expr,
2567
+ BinaryenOp op);
2568
+ BINARYEN_API BinaryenExpressionRef
2569
+ BinaryenStringMeasureGetRef(BinaryenExpressionRef expr);
2570
+ BINARYEN_API void BinaryenStringMeasureSetRef(BinaryenExpressionRef expr,
2571
+ BinaryenExpressionRef refExpr);
2572
+
2573
+ // StringEncode
2574
+
2575
+ BINARYEN_API BinaryenOp BinaryenStringEncodeGetOp(BinaryenExpressionRef expr);
2576
+ BINARYEN_API void BinaryenStringEncodeSetOp(BinaryenExpressionRef expr,
2577
+ BinaryenOp op);
2578
+ BINARYEN_API BinaryenExpressionRef
2579
+ BinaryenStringEncodeGetRef(BinaryenExpressionRef expr);
2580
+ BINARYEN_API void BinaryenStringEncodeSetRef(BinaryenExpressionRef expr,
2581
+ BinaryenExpressionRef refExpr);
2582
+ BINARYEN_API BinaryenExpressionRef
2583
+ BinaryenStringEncodeGetPtr(BinaryenExpressionRef expr);
2584
+ BINARYEN_API void BinaryenStringEncodeSetPtr(BinaryenExpressionRef expr,
2585
+ BinaryenExpressionRef ptrExpr);
2586
+ BINARYEN_API BinaryenExpressionRef
2587
+ BinaryenStringEncodeGetStart(BinaryenExpressionRef expr);
2588
+ BINARYEN_API void BinaryenStringEncodeSetStart(BinaryenExpressionRef expr,
2589
+ BinaryenExpressionRef startExpr);
2590
+
2591
+ // StringConcat
2592
+
2593
+ BINARYEN_API BinaryenExpressionRef
2594
+ BinaryenStringConcatGetLeft(BinaryenExpressionRef expr);
2595
+ BINARYEN_API void BinaryenStringConcatSetLeft(BinaryenExpressionRef expr,
2596
+ BinaryenExpressionRef leftExpr);
2597
+ BINARYEN_API BinaryenExpressionRef
2598
+ BinaryenStringConcatGetRight(BinaryenExpressionRef expr);
2599
+ BINARYEN_API void BinaryenStringConcatSetRight(BinaryenExpressionRef expr,
2600
+ BinaryenExpressionRef rightExpr);
2601
+
2602
+ // StringEq
2603
+
2604
+ BINARYEN_API BinaryenOp BinaryenStringEqGetOp(BinaryenExpressionRef expr);
2605
+ BINARYEN_API void BinaryenStringEqSetOp(BinaryenExpressionRef expr,
2606
+ BinaryenOp op);
2607
+ BINARYEN_API BinaryenExpressionRef
2608
+ BinaryenStringEqGetLeft(BinaryenExpressionRef expr);
2609
+ BINARYEN_API void BinaryenStringEqSetLeft(BinaryenExpressionRef expr,
2610
+ BinaryenExpressionRef leftExpr);
2611
+ BINARYEN_API BinaryenExpressionRef
2612
+ BinaryenStringEqGetRight(BinaryenExpressionRef expr);
2613
+ BINARYEN_API void BinaryenStringEqSetRight(BinaryenExpressionRef expr,
2614
+ BinaryenExpressionRef rightExpr);
2615
+
2616
+ // StringAs
2617
+
2618
+ BINARYEN_API BinaryenOp BinaryenStringAsGetOp(BinaryenExpressionRef expr);
2619
+ BINARYEN_API void BinaryenStringAsSetOp(BinaryenExpressionRef expr,
2620
+ BinaryenOp op);
2621
+ BINARYEN_API BinaryenExpressionRef
2622
+ BinaryenStringAsGetRef(BinaryenExpressionRef expr);
2623
+ BINARYEN_API void BinaryenStringAsSetRef(BinaryenExpressionRef expr,
2624
+ BinaryenExpressionRef refExpr);
2625
+
2626
+ // StringWTF8Advance
2627
+
2628
+ BINARYEN_API BinaryenExpressionRef
2629
+ BinaryenStringWTF8AdvanceGetRef(BinaryenExpressionRef expr);
2630
+ BINARYEN_API void
2631
+ BinaryenStringWTF8AdvanceSetRef(BinaryenExpressionRef expr,
2632
+ BinaryenExpressionRef refExpr);
2633
+ BINARYEN_API BinaryenExpressionRef
2634
+ BinaryenStringWTF8AdvanceGetPos(BinaryenExpressionRef expr);
2635
+ BINARYEN_API void
2636
+ BinaryenStringWTF8AdvanceSetPos(BinaryenExpressionRef expr,
2637
+ BinaryenExpressionRef posExpr);
2638
+ BINARYEN_API BinaryenExpressionRef
2639
+ BinaryenStringWTF8AdvanceGetBytes(BinaryenExpressionRef expr);
2640
+ BINARYEN_API void
2641
+ BinaryenStringWTF8AdvanceSetBytes(BinaryenExpressionRef expr,
2642
+ BinaryenExpressionRef bytesExpr);
2643
+
2644
+ // StringWTF16Get
2645
+
2646
+ BINARYEN_API BinaryenExpressionRef
2647
+ BinaryenStringWTF16GetGetRef(BinaryenExpressionRef expr);
2648
+ BINARYEN_API void BinaryenStringWTF16GetSetRef(BinaryenExpressionRef expr,
2649
+ BinaryenExpressionRef refExpr);
2650
+ BINARYEN_API BinaryenExpressionRef
2651
+ BinaryenStringWTF16GetGetPos(BinaryenExpressionRef expr);
2652
+ BINARYEN_API void BinaryenStringWTF16GetSetPos(BinaryenExpressionRef expr,
2653
+ BinaryenExpressionRef posExpr);
2654
+
2655
+ // StringIterNext
2656
+
2657
+ BINARYEN_API BinaryenExpressionRef
2658
+ BinaryenStringIterNextGetRef(BinaryenExpressionRef expr);
2659
+ BINARYEN_API void BinaryenStringIterNextSetRef(BinaryenExpressionRef expr,
2660
+ BinaryenExpressionRef refExpr);
2661
+
2662
+ // StringIterMove
2663
+
2664
+ BINARYEN_API BinaryenOp BinaryenStringIterMoveGetOp(BinaryenExpressionRef expr);
2665
+ BINARYEN_API void BinaryenStringIterMoveSetOp(BinaryenExpressionRef expr,
2666
+ BinaryenOp op);
2667
+ BINARYEN_API BinaryenExpressionRef
2668
+ BinaryenStringIterMoveGetRef(BinaryenExpressionRef expr);
2669
+ BINARYEN_API void BinaryenStringIterMoveSetRef(BinaryenExpressionRef expr,
2670
+ BinaryenExpressionRef refExpr);
2671
+ BINARYEN_API BinaryenExpressionRef
2672
+ BinaryenStringIterMoveGetNum(BinaryenExpressionRef expr);
2673
+ BINARYEN_API void BinaryenStringIterMoveSetNum(BinaryenExpressionRef expr,
2674
+ BinaryenExpressionRef numExpr);
2675
+
2676
+ // StringSliceWTF
2677
+
2678
+ BINARYEN_API BinaryenOp BinaryenStringSliceWTFGetOp(BinaryenExpressionRef expr);
2679
+ BINARYEN_API void BinaryenStringSliceWTFSetOp(BinaryenExpressionRef expr,
2680
+ BinaryenOp op);
2681
+ BINARYEN_API BinaryenExpressionRef
2682
+ BinaryenStringSliceWTFGetRef(BinaryenExpressionRef expr);
2683
+ BINARYEN_API void BinaryenStringSliceWTFSetRef(BinaryenExpressionRef expr,
2684
+ BinaryenExpressionRef refExpr);
2685
+ BINARYEN_API BinaryenExpressionRef
2686
+ BinaryenStringSliceWTFGetStart(BinaryenExpressionRef expr);
2687
+ BINARYEN_API void
2688
+ BinaryenStringSliceWTFSetStart(BinaryenExpressionRef expr,
2689
+ BinaryenExpressionRef startExpr);
2690
+ BINARYEN_API BinaryenExpressionRef
2691
+ BinaryenStringSliceWTFGetEnd(BinaryenExpressionRef expr);
2692
+ BINARYEN_API void BinaryenStringSliceWTFSetEnd(BinaryenExpressionRef expr,
2693
+ BinaryenExpressionRef endExpr);
2694
+
2695
+ // StringSliceIter
2696
+
2697
+ BINARYEN_API BinaryenExpressionRef
2698
+ BinaryenStringSliceIterGetRef(BinaryenExpressionRef expr);
2699
+ BINARYEN_API void BinaryenStringSliceIterSetRef(BinaryenExpressionRef expr,
2700
+ BinaryenExpressionRef refExpr);
2701
+ BINARYEN_API BinaryenExpressionRef
2702
+ BinaryenStringSliceIterGetNum(BinaryenExpressionRef expr);
2703
+ BINARYEN_API void BinaryenStringSliceIterSetNum(BinaryenExpressionRef expr,
2704
+ BinaryenExpressionRef numExpr);
2705
+
2706
+ // Functions
2707
+
2708
+ BINARYEN_REF(Function);
2709
+
2710
+ // Adds a function to the module. This is thread-safe.
2711
+ // @varTypes: the types of variables. In WebAssembly, vars share
2712
+ // an index space with params. In other words, params come from
2713
+ // the function type, and vars are provided in this call, and
2714
+ // together they are all the locals. The order is first params
2715
+ // and then vars, so if you have one param it will be at index
2716
+ // 0 (and written $0), and if you also have 2 vars they will be
2717
+ // at indexes 1 and 2, etc., that is, they share an index space.
2718
+ BINARYEN_API BinaryenFunctionRef
2719
+ BinaryenAddFunction(BinaryenModuleRef module,
2720
+ const char* name,
2721
+ BinaryenType params,
2722
+ BinaryenType results,
2723
+ BinaryenType* varTypes,
2724
+ BinaryenIndex numVarTypes,
2725
+ BinaryenExpressionRef body);
2726
+ // As BinaryenAddFunction, but takes a HeapType rather than params and results.
2727
+ // This lets you set the specific type of the function.
2728
+ BINARYEN_API BinaryenFunctionRef
2729
+ BinaryenAddFunctionWithHeapType(BinaryenModuleRef module,
2730
+ const char* name,
2731
+ BinaryenHeapType type,
2732
+ BinaryenType* varTypes,
2733
+ BinaryenIndex numVarTypes,
2734
+ BinaryenExpressionRef body);
2735
+ // Gets a function reference by name. Returns NULL if the function does not
2736
+ // exist.
2737
+ BINARYEN_API BinaryenFunctionRef BinaryenGetFunction(BinaryenModuleRef module,
2738
+ const char* name);
2739
+ // Removes a function by name.
2740
+ BINARYEN_API void BinaryenRemoveFunction(BinaryenModuleRef module,
2741
+ const char* name);
2742
+
2743
+ // Gets the number of functions in the module.
2744
+ BINARYEN_API BinaryenIndex BinaryenGetNumFunctions(BinaryenModuleRef module);
2745
+ // Gets the function at the specified index.
2746
+ BINARYEN_API BinaryenFunctionRef
2747
+ BinaryenGetFunctionByIndex(BinaryenModuleRef module, BinaryenIndex index);
2748
+
2749
+ // Imports
2750
+
2751
+ // These either create a new entity (function/table/memory/etc.) and
2752
+ // mark it as an import, or, if an entity already exists with internalName then
2753
+ // the existing entity is turned into an import.
2754
+
2755
+ BINARYEN_API void BinaryenAddFunctionImport(BinaryenModuleRef module,
2756
+ const char* internalName,
2757
+ const char* externalModuleName,
2758
+ const char* externalBaseName,
2759
+ BinaryenType params,
2760
+ BinaryenType results);
2761
+ BINARYEN_API void BinaryenAddTableImport(BinaryenModuleRef module,
2762
+ const char* internalName,
2763
+ const char* externalModuleName,
2764
+ const char* externalBaseName);
2765
+ BINARYEN_API void BinaryenAddMemoryImport(BinaryenModuleRef module,
2766
+ const char* internalName,
2767
+ const char* externalModuleName,
2768
+ const char* externalBaseName,
2769
+ uint8_t shared);
2770
+ BINARYEN_API void BinaryenAddGlobalImport(BinaryenModuleRef module,
2771
+ const char* internalName,
2772
+ const char* externalModuleName,
2773
+ const char* externalBaseName,
2774
+ BinaryenType globalType,
2775
+ bool mutable_);
2776
+ BINARYEN_API void BinaryenAddTagImport(BinaryenModuleRef module,
2777
+ const char* internalName,
2778
+ const char* externalModuleName,
2779
+ const char* externalBaseName,
2780
+ BinaryenType params,
2781
+ BinaryenType results);
2782
+
2783
+ // Memory
2784
+ BINARYEN_REF(Memory);
2785
+
2786
+ // Exports
2787
+
2788
+ BINARYEN_REF(Export);
2789
+
2790
+ WASM_DEPRECATED BinaryenExportRef BinaryenAddExport(BinaryenModuleRef module,
2791
+ const char* internalName,
2792
+ const char* externalName);
2793
+ // Adds a function export to the module.
2794
+ BINARYEN_API BinaryenExportRef BinaryenAddFunctionExport(
2795
+ BinaryenModuleRef module, const char* internalName, const char* externalName);
2796
+ // Adds a table export to the module.
2797
+ BINARYEN_API BinaryenExportRef BinaryenAddTableExport(BinaryenModuleRef module,
2798
+ const char* internalName,
2799
+ const char* externalName);
2800
+ // Adds a memory export to the module.
2801
+ BINARYEN_API BinaryenExportRef BinaryenAddMemoryExport(
2802
+ BinaryenModuleRef module, const char* internalName, const char* externalName);
2803
+ // Adds a global export to the module.
2804
+ BINARYEN_API BinaryenExportRef BinaryenAddGlobalExport(
2805
+ BinaryenModuleRef module, const char* internalName, const char* externalName);
2806
+ // Adds a tag export to the module.
2807
+ BINARYEN_API BinaryenExportRef BinaryenAddTagExport(BinaryenModuleRef module,
2808
+ const char* internalName,
2809
+ const char* externalName);
2810
+ // Gets an export reference by external name. Returns NULL if the export does
2811
+ // not exist.
2812
+ BINARYEN_API BinaryenExportRef BinaryenGetExport(BinaryenModuleRef module,
2813
+ const char* externalName);
2814
+ // Removes an export by external name.
2815
+ BINARYEN_API void BinaryenRemoveExport(BinaryenModuleRef module,
2816
+ const char* externalName);
2817
+ // Gets the number of exports in the module.
2818
+ BINARYEN_API BinaryenIndex BinaryenGetNumExports(BinaryenModuleRef module);
2819
+ // Gets the export at the specified index.
2820
+ BINARYEN_API BinaryenExportRef
2821
+ BinaryenGetExportByIndex(BinaryenModuleRef module, BinaryenIndex index);
2822
+
2823
+ // Globals
2824
+
2825
+ BINARYEN_REF(Global);
2826
+
2827
+ // Adds a global to the module.
2828
+ BINARYEN_API BinaryenGlobalRef BinaryenAddGlobal(BinaryenModuleRef module,
2829
+ const char* name,
2830
+ BinaryenType type,
2831
+ bool mutable_,
2832
+ BinaryenExpressionRef init);
2833
+ // Gets a global reference by name. Returns NULL if the global does not exist.
2834
+ BINARYEN_API BinaryenGlobalRef BinaryenGetGlobal(BinaryenModuleRef module,
2835
+ const char* name);
2836
+ // Removes a global by name.
2837
+ BINARYEN_API void BinaryenRemoveGlobal(BinaryenModuleRef module,
2838
+ const char* name);
2839
+ // Gets the number of globals in the module.
2840
+ BINARYEN_API BinaryenIndex BinaryenGetNumGlobals(BinaryenModuleRef module);
2841
+ // Gets the global at the specified index.
2842
+ BINARYEN_API BinaryenGlobalRef
2843
+ BinaryenGetGlobalByIndex(BinaryenModuleRef module, BinaryenIndex index);
2844
+
2845
+ // Tags
2846
+
2847
+ BINARYEN_REF(Tag);
2848
+
2849
+ // Adds a tag to the module.
2850
+ BINARYEN_API BinaryenTagRef BinaryenAddTag(BinaryenModuleRef module,
2851
+ const char* name,
2852
+ BinaryenType params,
2853
+ BinaryenType results);
2854
+ // Gets a tag reference by name. Returns NULL if the tag does not exist.
2855
+ BINARYEN_API BinaryenTagRef BinaryenGetTag(BinaryenModuleRef module,
2856
+ const char* name);
2857
+ // Removes a tag by name.
2858
+ BINARYEN_API void BinaryenRemoveTag(BinaryenModuleRef module, const char* name);
2859
+
2860
+ // Tables
2861
+
2862
+ BINARYEN_REF(Table);
2863
+
2864
+ BINARYEN_API BinaryenTableRef BinaryenAddTable(BinaryenModuleRef module,
2865
+ const char* table,
2866
+ BinaryenIndex initial,
2867
+ BinaryenIndex maximum,
2868
+ BinaryenType tableType);
2869
+ BINARYEN_API void BinaryenRemoveTable(BinaryenModuleRef module,
2870
+ const char* table);
2871
+ BINARYEN_API BinaryenIndex BinaryenGetNumTables(BinaryenModuleRef module);
2872
+ BINARYEN_API BinaryenTableRef BinaryenGetTable(BinaryenModuleRef module,
2873
+ const char* name);
2874
+ BINARYEN_API BinaryenTableRef BinaryenGetTableByIndex(BinaryenModuleRef module,
2875
+ BinaryenIndex index);
2876
+
2877
+ // Elem segments
2878
+
2879
+ BINARYEN_REF(ElementSegment);
2880
+
2881
+ BINARYEN_API BinaryenElementSegmentRef
2882
+ BinaryenAddActiveElementSegment(BinaryenModuleRef module,
2883
+ const char* table,
2884
+ const char* name,
2885
+ const char** funcNames,
2886
+ BinaryenIndex numFuncNames,
2887
+ BinaryenExpressionRef offset);
2888
+ BINARYEN_API BinaryenElementSegmentRef
2889
+ BinaryenAddPassiveElementSegment(BinaryenModuleRef module,
2890
+ const char* name,
2891
+ const char** funcNames,
2892
+ BinaryenIndex numFuncNames);
2893
+ BINARYEN_API void BinaryenRemoveElementSegment(BinaryenModuleRef module,
2894
+ const char* name);
2895
+ BINARYEN_API BinaryenIndex
2896
+ BinaryenGetNumElementSegments(BinaryenModuleRef module);
2897
+ BINARYEN_API BinaryenElementSegmentRef
2898
+ BinaryenGetElementSegment(BinaryenModuleRef module, const char* name);
2899
+ BINARYEN_API BinaryenElementSegmentRef
2900
+ BinaryenGetElementSegmentByIndex(BinaryenModuleRef module, BinaryenIndex index);
2901
+
2902
+ // This will create a memory, overwriting any existing memory
2903
+ // Each memory has data in segments, a start offset in segmentOffsets, and a
2904
+ // size in segmentSizes. exportName can be NULL
2905
+ BINARYEN_API void BinaryenSetMemory(BinaryenModuleRef module,
2906
+ BinaryenIndex initial,
2907
+ BinaryenIndex maximum,
2908
+ const char* exportName,
2909
+ const char** segments,
2910
+ bool* segmentPassive,
2911
+ BinaryenExpressionRef* segmentOffsets,
2912
+ BinaryenIndex* segmentSizes,
2913
+ BinaryenIndex numSegments,
2914
+ bool shared,
2915
+ bool memory64,
2916
+ const char* name);
2917
+
2918
+ BINARYEN_API bool BinaryenHasMemory(BinaryenModuleRef module);
2919
+ BINARYEN_API BinaryenIndex BinaryenMemoryGetInitial(BinaryenModuleRef module,
2920
+ const char* name);
2921
+ BINARYEN_API bool BinaryenMemoryHasMax(BinaryenModuleRef module,
2922
+ const char* name);
2923
+ BINARYEN_API BinaryenIndex BinaryenMemoryGetMax(BinaryenModuleRef module,
2924
+ const char* name);
2925
+ BINARYEN_API const char* BinaryenMemoryImportGetModule(BinaryenModuleRef module,
2926
+ const char* name);
2927
+ BINARYEN_API const char* BinaryenMemoryImportGetBase(BinaryenModuleRef module,
2928
+ const char* name);
2929
+ BINARYEN_API bool BinaryenMemoryIsShared(BinaryenModuleRef module,
2930
+ const char* name);
2931
+ BINARYEN_API bool BinaryenMemoryIs64(BinaryenModuleRef module,
2932
+ const char* name);
2933
+
2934
+ // Memory segments. Query utilities.
2935
+
2936
+ BINARYEN_API uint32_t BinaryenGetNumMemorySegments(BinaryenModuleRef module);
2937
+ BINARYEN_API uint32_t
2938
+ BinaryenGetMemorySegmentByteOffset(BinaryenModuleRef module, BinaryenIndex id);
2939
+ BINARYEN_API size_t BinaryenGetMemorySegmentByteLength(BinaryenModuleRef module,
2940
+ BinaryenIndex id);
2941
+ BINARYEN_API bool BinaryenGetMemorySegmentPassive(BinaryenModuleRef module,
2942
+ BinaryenIndex id);
2943
+ BINARYEN_API void BinaryenCopyMemorySegmentData(BinaryenModuleRef module,
2944
+ BinaryenIndex id,
2945
+ char* buffer);
2946
+
2947
+ // Start function. One per module
2948
+
2949
+ BINARYEN_API void BinaryenSetStart(BinaryenModuleRef module,
2950
+ BinaryenFunctionRef start);
2951
+
2952
+ // Features
2953
+
2954
+ // These control what features are allowed when validation and in passes.
2955
+ BINARYEN_API BinaryenFeatures
2956
+ BinaryenModuleGetFeatures(BinaryenModuleRef module);
2957
+ BINARYEN_API void BinaryenModuleSetFeatures(BinaryenModuleRef module,
2958
+ BinaryenFeatures features);
2959
+
2960
+ //
2961
+ // ========== Module Operations ==========
2962
+ //
2963
+
2964
+ // Parse a module in s-expression text format
2965
+ BINARYEN_API BinaryenModuleRef BinaryenModuleParse(const char* text);
2966
+
2967
+ // Print a module to stdout in s-expression text format. Useful for debugging.
2968
+ BINARYEN_API void BinaryenModulePrint(BinaryenModuleRef module);
2969
+
2970
+ // Print a module to stdout in stack IR text format. Useful for debugging.
2971
+ BINARYEN_API void BinaryenModulePrintStackIR(BinaryenModuleRef module,
2972
+ bool optimize);
2973
+
2974
+ // Print a module to stdout in asm.js syntax.
2975
+ BINARYEN_API void BinaryenModulePrintAsmjs(BinaryenModuleRef module);
2976
+
2977
+ // Validate a module, showing errors on problems.
2978
+ // @return 0 if an error occurred, 1 if validated succesfully
2979
+ BINARYEN_API bool BinaryenModuleValidate(BinaryenModuleRef module);
2980
+
2981
+ // Runs the standard optimization passes on the module. Uses the currently set
2982
+ // global optimize and shrink level.
2983
+ BINARYEN_API void BinaryenModuleOptimize(BinaryenModuleRef module);
2984
+
2985
+ // Updates the internal name mapping logic in a module. This must be called
2986
+ // after renaming module elements.
2987
+ BINARYEN_API void BinaryenModuleUpdateMaps(BinaryenModuleRef module);
2988
+
2989
+ // Gets the currently set optimize level. Applies to all modules, globally.
2990
+ // 0, 1, 2 correspond to -O0, -O1, -O2 (default), etc.
2991
+ BINARYEN_API int BinaryenGetOptimizeLevel(void);
2992
+
2993
+ // Sets the optimization level to use. Applies to all modules, globally.
2994
+ // 0, 1, 2 correspond to -O0, -O1, -O2 (default), etc.
2995
+ BINARYEN_API void BinaryenSetOptimizeLevel(int level);
2996
+
2997
+ // Gets the currently set shrink level. Applies to all modules, globally.
2998
+ // 0, 1, 2 correspond to -O0, -Os (default), -Oz.
2999
+ BINARYEN_API int BinaryenGetShrinkLevel(void);
3000
+
3001
+ // Sets the shrink level to use. Applies to all modules, globally.
3002
+ // 0, 1, 2 correspond to -O0, -Os (default), -Oz.
3003
+ BINARYEN_API void BinaryenSetShrinkLevel(int level);
3004
+
3005
+ // Gets whether generating debug information is currently enabled or not.
3006
+ // Applies to all modules, globally.
3007
+ BINARYEN_API bool BinaryenGetDebugInfo(void);
3008
+
3009
+ // Enables or disables debug information in emitted binaries.
3010
+ // Applies to all modules, globally.
3011
+ BINARYEN_API void BinaryenSetDebugInfo(bool on);
3012
+
3013
+ // Gets whether the low 1K of memory can be considered unused when optimizing.
3014
+ // Applies to all modules, globally.
3015
+ BINARYEN_API bool BinaryenGetLowMemoryUnused(void);
3016
+
3017
+ // Enables or disables whether the low 1K of memory can be considered unused
3018
+ // when optimizing. Applies to all modules, globally.
3019
+ BINARYEN_API void BinaryenSetLowMemoryUnused(bool on);
3020
+
3021
+ // Gets whether to assume that an imported memory is zero-initialized.
3022
+ BINARYEN_API bool BinaryenGetZeroFilledMemory(void);
3023
+
3024
+ // Enables or disables whether to assume that an imported memory is
3025
+ // zero-initialized.
3026
+ BINARYEN_API void BinaryenSetZeroFilledMemory(bool on);
3027
+
3028
+ // Gets whether fast math optimizations are enabled, ignoring for example
3029
+ // corner cases of floating-point math like NaN changes.
3030
+ // Applies to all modules, globally.
3031
+ BINARYEN_API bool BinaryenGetFastMath(void);
3032
+
3033
+ // Enables or disables fast math optimizations, ignoring for example
3034
+ // corner cases of floating-point math like NaN changes.
3035
+ // Applies to all modules, globally.
3036
+ BINARYEN_API void BinaryenSetFastMath(bool value);
3037
+
3038
+ // Gets the value of the specified arbitrary pass argument.
3039
+ // Applies to all modules, globally.
3040
+ BINARYEN_API const char* BinaryenGetPassArgument(const char* name);
3041
+
3042
+ // Sets the value of the specified arbitrary pass argument. Removes the
3043
+ // respective argument if `value` is NULL. Applies to all modules, globally.
3044
+ BINARYEN_API void BinaryenSetPassArgument(const char* name, const char* value);
3045
+
3046
+ // Clears all arbitrary pass arguments.
3047
+ // Applies to all modules, globally.
3048
+ BINARYEN_API void BinaryenClearPassArguments();
3049
+
3050
+ // Gets the function size at which we always inline.
3051
+ // Applies to all modules, globally.
3052
+ BINARYEN_API BinaryenIndex BinaryenGetAlwaysInlineMaxSize(void);
3053
+
3054
+ // Sets the function size at which we always inline.
3055
+ // Applies to all modules, globally.
3056
+ BINARYEN_API void BinaryenSetAlwaysInlineMaxSize(BinaryenIndex size);
3057
+
3058
+ // Gets the function size which we inline when functions are lightweight.
3059
+ // Applies to all modules, globally.
3060
+ BINARYEN_API BinaryenIndex BinaryenGetFlexibleInlineMaxSize(void);
3061
+
3062
+ // Sets the function size which we inline when functions are lightweight.
3063
+ // Applies to all modules, globally.
3064
+ BINARYEN_API void BinaryenSetFlexibleInlineMaxSize(BinaryenIndex size);
3065
+
3066
+ // Gets the function size which we inline when there is only one caller.
3067
+ // Applies to all modules, globally.
3068
+ BINARYEN_API BinaryenIndex BinaryenGetOneCallerInlineMaxSize(void);
3069
+
3070
+ // Sets the function size which we inline when there is only one caller.
3071
+ // Applies to all modules, globally.
3072
+ BINARYEN_API void BinaryenSetOneCallerInlineMaxSize(BinaryenIndex size);
3073
+
3074
+ // Gets whether functions with loops are allowed to be inlined.
3075
+ // Applies to all modules, globally.
3076
+ BINARYEN_API bool BinaryenGetAllowInliningFunctionsWithLoops(void);
3077
+
3078
+ // Sets whether functions with loops are allowed to be inlined.
3079
+ // Applies to all modules, globally.
3080
+ BINARYEN_API void BinaryenSetAllowInliningFunctionsWithLoops(bool enabled);
3081
+
3082
+ // Runs the specified passes on the module. Uses the currently set global
3083
+ // optimize and shrink level.
3084
+ BINARYEN_API void BinaryenModuleRunPasses(BinaryenModuleRef module,
3085
+ const char** passes,
3086
+ BinaryenIndex numPasses);
3087
+
3088
+ // Auto-generate drop() operations where needed. This lets you generate code
3089
+ // without worrying about where they are needed. (It is more efficient to do it
3090
+ // yourself, but simpler to use autodrop).
3091
+ BINARYEN_API void BinaryenModuleAutoDrop(BinaryenModuleRef module);
3092
+
3093
+ // Serialize a module into binary form. Uses the currently set global debugInfo
3094
+ // option.
3095
+ // @return how many bytes were written. This will be less than or equal to
3096
+ // outputSize
3097
+ size_t BINARYEN_API BinaryenModuleWrite(BinaryenModuleRef module,
3098
+ char* output,
3099
+ size_t outputSize);
3100
+
3101
+ // Serialize a module in s-expression text format.
3102
+ // @return how many bytes were written. This will be less than or equal to
3103
+ // outputSize
3104
+ BINARYEN_API size_t BinaryenModuleWriteText(BinaryenModuleRef module,
3105
+ char* output,
3106
+ size_t outputSize);
3107
+
3108
+ // Serialize a module in stack IR text format.
3109
+ // @return how many bytes were written. This will be less than or equal to
3110
+ // outputSize
3111
+ BINARYEN_API size_t BinaryenModuleWriteStackIR(BinaryenModuleRef module,
3112
+ char* output,
3113
+ size_t outputSize,
3114
+ bool optimize);
3115
+
3116
+ typedef struct BinaryenBufferSizes {
3117
+ size_t outputBytes;
3118
+ size_t sourceMapBytes;
3119
+ } BinaryenBufferSizes;
3120
+
3121
+ // Serialize a module into binary form including its source map. Uses the
3122
+ // currently set global debugInfo option.
3123
+ // @returns how many bytes were written. This will be less than or equal to
3124
+ // outputSize
3125
+ BINARYEN_API BinaryenBufferSizes
3126
+ BinaryenModuleWriteWithSourceMap(BinaryenModuleRef module,
3127
+ const char* url,
3128
+ char* output,
3129
+ size_t outputSize,
3130
+ char* sourceMap,
3131
+ size_t sourceMapSize);
3132
+
3133
+ // Result structure of BinaryenModuleAllocateAndWrite. Contained buffers have
3134
+ // been allocated using malloc() and the user is expected to free() them
3135
+ // manually once not needed anymore.
3136
+ typedef struct BinaryenModuleAllocateAndWriteResult {
3137
+ void* binary;
3138
+ size_t binaryBytes;
3139
+ char* sourceMap;
3140
+ } BinaryenModuleAllocateAndWriteResult;
3141
+
3142
+ // Serializes a module into binary form, optionally including its source map if
3143
+ // sourceMapUrl has been specified. Uses the currently set global debugInfo
3144
+ // option. Differs from BinaryenModuleWrite in that it implicitly allocates
3145
+ // appropriate buffers using malloc(), and expects the user to free() them
3146
+ // manually once not needed anymore.
3147
+ BINARYEN_API BinaryenModuleAllocateAndWriteResult
3148
+ BinaryenModuleAllocateAndWrite(BinaryenModuleRef module,
3149
+ const char* sourceMapUrl);
3150
+
3151
+ // Serialize a module in s-expression form. Implicity allocates the returned
3152
+ // char* with malloc(), and expects the user to free() them manually
3153
+ // once not needed anymore.
3154
+ BINARYEN_API char* BinaryenModuleAllocateAndWriteText(BinaryenModuleRef module);
3155
+
3156
+ // Serialize a module in stack IR form. Implicitly allocates the returned
3157
+ // char* with malloc(), and expects the user to free() them manually
3158
+ // once not needed anymore.
3159
+ BINARYEN_API char*
3160
+ BinaryenModuleAllocateAndWriteStackIR(BinaryenModuleRef module, bool optimize);
3161
+
3162
+ // Deserialize a module from binary form.
3163
+ BINARYEN_API BinaryenModuleRef BinaryenModuleRead(char* input,
3164
+ size_t inputSize);
3165
+
3166
+ // Execute a module in the Binaryen interpreter. This will create an instance of
3167
+ // the module, run it in the interpreter - which means running the start method
3168
+ // - and then destroying the instance.
3169
+ BINARYEN_API void BinaryenModuleInterpret(BinaryenModuleRef module);
3170
+
3171
+ // Adds a debug info file name to the module and returns its index.
3172
+ BINARYEN_API BinaryenIndex BinaryenModuleAddDebugInfoFileName(
3173
+ BinaryenModuleRef module, const char* filename);
3174
+
3175
+ // Gets the name of the debug info file at the specified index. Returns `NULL`
3176
+ // if it does not exist.
3177
+ BINARYEN_API const char*
3178
+ BinaryenModuleGetDebugInfoFileName(BinaryenModuleRef module,
3179
+ BinaryenIndex index);
3180
+
3181
+ //
3182
+ // ========== Function Operations ==========
3183
+ //
3184
+
3185
+ // Gets the name of the specified `Function`.
3186
+ BINARYEN_API const char* BinaryenFunctionGetName(BinaryenFunctionRef func);
3187
+ // Gets the type of the parameter at the specified index of the specified
3188
+ // `Function`.
3189
+ BINARYEN_API BinaryenType BinaryenFunctionGetParams(BinaryenFunctionRef func);
3190
+ // Gets the result type of the specified `Function`.
3191
+ BINARYEN_API BinaryenType BinaryenFunctionGetResults(BinaryenFunctionRef func);
3192
+ // Gets the number of additional locals within the specified `Function`.
3193
+ BINARYEN_API BinaryenIndex BinaryenFunctionGetNumVars(BinaryenFunctionRef func);
3194
+ // Gets the type of the additional local at the specified index within the
3195
+ // specified `Function`.
3196
+ BINARYEN_API BinaryenType BinaryenFunctionGetVar(BinaryenFunctionRef func,
3197
+ BinaryenIndex index);
3198
+ // Gets the number of locals within the specified function. Includes parameters.
3199
+ BINARYEN_API BinaryenIndex
3200
+ BinaryenFunctionGetNumLocals(BinaryenFunctionRef func);
3201
+ // Tests if the local at the specified index has a name.
3202
+ BINARYEN_API bool BinaryenFunctionHasLocalName(BinaryenFunctionRef func,
3203
+ BinaryenIndex index);
3204
+ // Gets the name of the local at the specified index.
3205
+ BINARYEN_API const char* BinaryenFunctionGetLocalName(BinaryenFunctionRef func,
3206
+ BinaryenIndex index);
3207
+ // Sets the name of the local at the specified index.
3208
+ BINARYEN_API void BinaryenFunctionSetLocalName(BinaryenFunctionRef func,
3209
+ BinaryenIndex index,
3210
+ const char* name);
3211
+ // Gets the body of the specified `Function`.
3212
+ BINARYEN_API BinaryenExpressionRef
3213
+ BinaryenFunctionGetBody(BinaryenFunctionRef func);
3214
+ // Sets the body of the specified `Function`.
3215
+ BINARYEN_API void BinaryenFunctionSetBody(BinaryenFunctionRef func,
3216
+ BinaryenExpressionRef body);
3217
+
3218
+ // Runs the standard optimization passes on the function. Uses the currently set
3219
+ // global optimize and shrink level.
3220
+ BINARYEN_API void BinaryenFunctionOptimize(BinaryenFunctionRef func,
3221
+ BinaryenModuleRef module);
3222
+
3223
+ // Runs the specified passes on the function. Uses the currently set global
3224
+ // optimize and shrink level.
3225
+ BINARYEN_API void BinaryenFunctionRunPasses(BinaryenFunctionRef func,
3226
+ BinaryenModuleRef module,
3227
+ const char** passes,
3228
+ BinaryenIndex numPasses);
3229
+
3230
+ // Sets the debug location of the specified `Expression` within the specified
3231
+ // `Function`.
3232
+ BINARYEN_API void BinaryenFunctionSetDebugLocation(BinaryenFunctionRef func,
3233
+ BinaryenExpressionRef expr,
3234
+ BinaryenIndex fileIndex,
3235
+ BinaryenIndex lineNumber,
3236
+ BinaryenIndex columnNumber);
3237
+
3238
+ //
3239
+ // ========== Table Operations ==========
3240
+ //
3241
+
3242
+ // Gets the name of the specified `Table`.
3243
+ BINARYEN_API const char* BinaryenTableGetName(BinaryenTableRef table);
3244
+ // Sets the name of the specified `Table`.
3245
+ BINARYEN_API void BinaryenTableSetName(BinaryenTableRef table,
3246
+ const char* name);
3247
+ // Gets the initial number of pages of the specified `Table`.
3248
+ BINARYEN_API BinaryenIndex BinaryenTableGetInitial(BinaryenTableRef table);
3249
+ // Sets the initial number of pages of the specified `Table`.
3250
+ BINARYEN_API void BinaryenTableSetInitial(BinaryenTableRef table,
3251
+ BinaryenIndex initial);
3252
+ // Tests whether the specified `Table` has a maximum number of pages.
3253
+ BINARYEN_API bool BinaryenTableHasMax(BinaryenTableRef table);
3254
+ // Gets the maximum number of pages of the specified `Table`.
3255
+ BINARYEN_API BinaryenIndex BinaryenTableGetMax(BinaryenTableRef table);
3256
+ // Sets the maximum number of pages of the specified `Table`.
3257
+ BINARYEN_API void BinaryenTableSetMax(BinaryenTableRef table,
3258
+ BinaryenIndex max);
3259
+
3260
+ //
3261
+ // ========== Elem Segment Operations ==========
3262
+ //
3263
+
3264
+ // Gets the name of the specified `ElementSegment`.
3265
+ BINARYEN_API const char*
3266
+ BinaryenElementSegmentGetName(BinaryenElementSegmentRef elem);
3267
+ // Sets the name of the specified `ElementSegment`.
3268
+ BINARYEN_API void BinaryenElementSegmentSetName(BinaryenElementSegmentRef elem,
3269
+ const char* name);
3270
+ // Gets the table name of the specified `ElementSegment`.
3271
+ BINARYEN_API const char*
3272
+ BinaryenElementSegmentGetTable(BinaryenElementSegmentRef elem);
3273
+ // Sets the table name of the specified `ElementSegment`.
3274
+ BINARYEN_API void BinaryenElementSegmentSetTable(BinaryenElementSegmentRef elem,
3275
+ const char* table);
3276
+ // Gets the segment offset in case of active segments
3277
+ BINARYEN_API BinaryenExpressionRef
3278
+ BinaryenElementSegmentGetOffset(BinaryenElementSegmentRef elem);
3279
+ // Gets the length of items in the segment
3280
+ BINARYEN_API BinaryenIndex
3281
+ BinaryenElementSegmentGetLength(BinaryenElementSegmentRef elem);
3282
+ // Gets the item at the specified index
3283
+ BINARYEN_API const char*
3284
+ BinaryenElementSegmentGetData(BinaryenElementSegmentRef elem,
3285
+ BinaryenIndex dataId);
3286
+ // Returns true if the specified elem segment is passive
3287
+ BINARYEN_API bool
3288
+ BinaryenElementSegmentIsPassive(BinaryenElementSegmentRef elem);
3289
+
3290
+ //
3291
+ // ========== Global Operations ==========
3292
+ //
3293
+
3294
+ // Gets the name of the specified `Global`.
3295
+ BINARYEN_API const char* BinaryenGlobalGetName(BinaryenGlobalRef global);
3296
+ // Gets the name of the `GlobalType` associated with the specified `Global`. May
3297
+ // be `NULL` if the signature is implicit.
3298
+ BINARYEN_API BinaryenType BinaryenGlobalGetType(BinaryenGlobalRef global);
3299
+ // Returns true if the specified `Global` is mutable.
3300
+ BINARYEN_API bool BinaryenGlobalIsMutable(BinaryenGlobalRef global);
3301
+ // Gets the initialization expression of the specified `Global`.
3302
+ BINARYEN_API BinaryenExpressionRef
3303
+ BinaryenGlobalGetInitExpr(BinaryenGlobalRef global);
3304
+
3305
+ //
3306
+ // ========== Tag Operations ==========
3307
+ //
3308
+
3309
+ // Gets the name of the specified `Tag`.
3310
+ BINARYEN_API const char* BinaryenTagGetName(BinaryenTagRef tag);
3311
+ // Gets the parameters type of the specified `Tag`.
3312
+ BINARYEN_API BinaryenType BinaryenTagGetParams(BinaryenTagRef tag);
3313
+ // Gets the results type of the specified `Tag`.
3314
+ BINARYEN_API BinaryenType BinaryenTagGetResults(BinaryenTagRef tag);
3315
+
3316
+ //
3317
+ // ========== Import Operations ==========
3318
+ //
3319
+
3320
+ // Gets the external module name of the specified import.
3321
+ BINARYEN_API const char*
3322
+ BinaryenFunctionImportGetModule(BinaryenFunctionRef import);
3323
+ BINARYEN_API const char* BinaryenTableImportGetModule(BinaryenTableRef import);
3324
+ BINARYEN_API const char*
3325
+ BinaryenGlobalImportGetModule(BinaryenGlobalRef import);
3326
+ BINARYEN_API const char* BinaryenTagImportGetModule(BinaryenTagRef import);
3327
+ // Gets the external base name of the specified import.
3328
+ BINARYEN_API const char*
3329
+ BinaryenFunctionImportGetBase(BinaryenFunctionRef import);
3330
+ BINARYEN_API const char* BinaryenTableImportGetBase(BinaryenTableRef import);
3331
+ BINARYEN_API const char* BinaryenGlobalImportGetBase(BinaryenGlobalRef import);
3332
+ BINARYEN_API const char* BinaryenTagImportGetBase(BinaryenTagRef import);
3333
+
3334
+ //
3335
+ // ========== Export Operations ==========
3336
+ //
3337
+
3338
+ // Gets the external kind of the specified export.
3339
+ BINARYEN_API BinaryenExternalKind
3340
+ BinaryenExportGetKind(BinaryenExportRef export_);
3341
+ // Gets the external name of the specified export.
3342
+ BINARYEN_API const char* BinaryenExportGetName(BinaryenExportRef export_);
3343
+ // Gets the internal name of the specified export.
3344
+ BINARYEN_API const char* BinaryenExportGetValue(BinaryenExportRef export_);
3345
+
3346
+ //
3347
+ // ========= Custom sections =========
3348
+ //
3349
+
3350
+ BINARYEN_API void BinaryenAddCustomSection(BinaryenModuleRef module,
3351
+ const char* name,
3352
+ const char* contents,
3353
+ BinaryenIndex contentsSize);
3354
+
3355
+ //
3356
+ // ========= Effect analyzer =========
3357
+ //
3358
+
3359
+ typedef uint32_t BinaryenSideEffects;
3360
+
3361
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectNone(void);
3362
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectBranches(void);
3363
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectCalls(void);
3364
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectReadsLocal(void);
3365
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectWritesLocal(void);
3366
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectReadsGlobal(void);
3367
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectWritesGlobal(void);
3368
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectReadsMemory(void);
3369
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectWritesMemory(void);
3370
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectReadsTable(void);
3371
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectWritesTable(void);
3372
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectImplicitTrap(void);
3373
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectTrapsNeverHappen(void);
3374
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectIsAtomic(void);
3375
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectThrows(void);
3376
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectDanglingPop(void);
3377
+ BINARYEN_API BinaryenSideEffects BinaryenSideEffectAny(void);
3378
+
3379
+ BINARYEN_API BinaryenSideEffects BinaryenExpressionGetSideEffects(
3380
+ BinaryenExpressionRef expr, BinaryenModuleRef module);
3381
+
3382
+ //
3383
+ // ========== CFG / Relooper ==========
3384
+ //
3385
+ // General usage is (1) create a relooper, (2) create blocks, (3) add
3386
+ // branches between them, (4) render the output.
3387
+ //
3388
+ // For more details, see src/cfg/Relooper.h and
3389
+ // https://github.com/WebAssembly/binaryen/wiki/Compiling-to-WebAssembly-with-Binaryen#cfg-api
3390
+
3391
+ #ifdef __cplusplus
3392
+ namespace CFG {
3393
+ struct Relooper;
3394
+ struct Block;
3395
+ } // namespace CFG
3396
+ typedef struct CFG::Relooper* RelooperRef;
3397
+ typedef struct CFG::Block* RelooperBlockRef;
3398
+ #else
3399
+ typedef struct Relooper* RelooperRef;
3400
+ typedef struct RelooperBlock* RelooperBlockRef;
3401
+ #endif
3402
+
3403
+ // Create a relooper instance
3404
+ BINARYEN_API RelooperRef RelooperCreate(BinaryenModuleRef module);
3405
+
3406
+ // Create a basic block that ends with nothing, or with some simple branching
3407
+ BINARYEN_API RelooperBlockRef RelooperAddBlock(RelooperRef relooper,
3408
+ BinaryenExpressionRef code);
3409
+
3410
+ // Create a branch to another basic block
3411
+ // The branch can have code on it, that is executed as the branch happens. this
3412
+ // is useful for phis. otherwise, code can be NULL
3413
+ BINARYEN_API void RelooperAddBranch(RelooperBlockRef from,
3414
+ RelooperBlockRef to,
3415
+ BinaryenExpressionRef condition,
3416
+ BinaryenExpressionRef code);
3417
+
3418
+ // Create a basic block that ends a switch on a condition
3419
+ BINARYEN_API RelooperBlockRef
3420
+ RelooperAddBlockWithSwitch(RelooperRef relooper,
3421
+ BinaryenExpressionRef code,
3422
+ BinaryenExpressionRef condition);
3423
+
3424
+ // Create a switch-style branch to another basic block. The block's switch table
3425
+ // will have these indexes going to that target
3426
+ BINARYEN_API void RelooperAddBranchForSwitch(RelooperBlockRef from,
3427
+ RelooperBlockRef to,
3428
+ BinaryenIndex* indexes,
3429
+ BinaryenIndex numIndexes,
3430
+ BinaryenExpressionRef code);
3431
+
3432
+ // Generate structed wasm control flow from the CFG of blocks and branches that
3433
+ // were created on this relooper instance. This returns the rendered output, and
3434
+ // also disposes of the relooper and its blocks and branches, as they are no
3435
+ // longer needed.
3436
+ // @param labelHelper To render irreducible control flow, we may need a helper
3437
+ // variable to guide us to the right target label. This value should be
3438
+ // an index of an i32 local variable that is free for us to use.
3439
+ BINARYEN_API BinaryenExpressionRef RelooperRenderAndDispose(
3440
+ RelooperRef relooper, RelooperBlockRef entry, BinaryenIndex labelHelper);
3441
+
3442
+ //
3443
+ // ========= ExpressionRunner ==========
3444
+ //
3445
+
3446
+ #ifdef __cplusplus
3447
+ namespace wasm {
3448
+ class CExpressionRunner;
3449
+ } // namespace wasm
3450
+ typedef class wasm::CExpressionRunner* ExpressionRunnerRef;
3451
+ #else
3452
+ typedef struct CExpressionRunner* ExpressionRunnerRef;
3453
+ #endif
3454
+
3455
+ typedef uint32_t ExpressionRunnerFlags;
3456
+
3457
+ // By default, just evaluate the expression, i.e. all we want to know is whether
3458
+ // it computes down to a concrete value, where it is not necessary to preserve
3459
+ // side effects like those of a `local.tee`.
3460
+ BINARYEN_API ExpressionRunnerFlags ExpressionRunnerFlagsDefault();
3461
+
3462
+ // Be very careful to preserve any side effects. For example, if we are
3463
+ // intending to replace the expression with a constant afterwards, even if we
3464
+ // can technically evaluate down to a constant, we still cannot replace the
3465
+ // expression if it also sets a local, which must be preserved in this scenario
3466
+ // so subsequent code keeps functioning.
3467
+ BINARYEN_API ExpressionRunnerFlags ExpressionRunnerFlagsPreserveSideeffects();
3468
+
3469
+ // Traverse through function calls, attempting to compute their concrete value.
3470
+ // Must not be used in function-parallel scenarios, where the called function
3471
+ // might be concurrently modified, leading to undefined behavior. Traversing
3472
+ // another function reuses all of this runner's flags.
3473
+ BINARYEN_API ExpressionRunnerFlags ExpressionRunnerFlagsTraverseCalls();
3474
+
3475
+ // Creates an ExpressionRunner instance
3476
+ BINARYEN_API ExpressionRunnerRef
3477
+ ExpressionRunnerCreate(BinaryenModuleRef module,
3478
+ ExpressionRunnerFlags flags,
3479
+ BinaryenIndex maxDepth,
3480
+ BinaryenIndex maxLoopIterations);
3481
+
3482
+ // Sets a known local value to use. Order matters if expressions have side
3483
+ // effects. For example, if the expression also sets a local, this side effect
3484
+ // will also happen (not affected by any flags). Returns `true` if the
3485
+ // expression actually evaluates to a constant.
3486
+ BINARYEN_API bool ExpressionRunnerSetLocalValue(ExpressionRunnerRef runner,
3487
+ BinaryenIndex index,
3488
+ BinaryenExpressionRef value);
3489
+
3490
+ // Sets a known global value to use. Order matters if expressions have side
3491
+ // effects. For example, if the expression also sets a local, this side effect
3492
+ // will also happen (not affected by any flags). Returns `true` if the
3493
+ // expression actually evaluates to a constant.
3494
+ BINARYEN_API bool ExpressionRunnerSetGlobalValue(ExpressionRunnerRef runner,
3495
+ const char* name,
3496
+ BinaryenExpressionRef value);
3497
+
3498
+ // Runs the expression and returns the constant value expression it evaluates
3499
+ // to, if any. Otherwise returns `NULL`. Also disposes the runner.
3500
+ BINARYEN_API BinaryenExpressionRef ExpressionRunnerRunAndDispose(
3501
+ ExpressionRunnerRef runner, BinaryenExpressionRef expr);
3502
+
3503
+ //
3504
+ // ========= TypeBuilder =========
3505
+ //
3506
+
3507
+ #ifdef __cplusplus
3508
+ namespace wasm {
3509
+ struct TypeBuilder;
3510
+ } // namespace wasm
3511
+ typedef struct wasm::TypeBuilder* TypeBuilderRef;
3512
+ #else
3513
+ typedef struct TypeBuilder* TypeBuilderRef;
3514
+ #endif
3515
+
3516
+ typedef uint32_t TypeBuilderErrorReason;
3517
+
3518
+ // Indicates a cycle in the supertype relation.
3519
+ BINARYEN_API TypeBuilderErrorReason TypeBuilderErrorReasonSelfSupertype(void);
3520
+ // Indicates that the declared supertype of a type is invalid.
3521
+ BINARYEN_API TypeBuilderErrorReason
3522
+ TypeBuilderErrorReasonInvalidSupertype(void);
3523
+ // Indicates that the declared supertype is an invalid forward reference.
3524
+ BINARYEN_API TypeBuilderErrorReason
3525
+ TypeBuilderErrorReasonForwardSupertypeReference(void);
3526
+ // Indicates that a child of a type is an invalid forward reference.
3527
+ BINARYEN_API TypeBuilderErrorReason
3528
+ TypeBuilderErrorReasonForwardChildReference(void);
3529
+
3530
+ typedef uint32_t BinaryenBasicHeapType;
3531
+
3532
+ // Constructs a new type builder that allows for the construction of recursive
3533
+ // types. Contains a table of `size` mutable heap types.
3534
+ BINARYEN_API TypeBuilderRef TypeBuilderCreate(BinaryenIndex size);
3535
+ // Grows the backing table of the type builder by `count` slots.
3536
+ BINARYEN_API void TypeBuilderGrow(TypeBuilderRef builder, BinaryenIndex count);
3537
+ // Gets the size of the backing table of the type builder.
3538
+ BINARYEN_API BinaryenIndex TypeBuilderGetSize(TypeBuilderRef builder);
3539
+ // Sets the heap type at index `index` to a concrete signature type. Expects
3540
+ // temporary tuple types if multiple parameter and/or result types include
3541
+ // temporary types.
3542
+ BINARYEN_API void TypeBuilderSetSignatureType(TypeBuilderRef builder,
3543
+ BinaryenIndex index,
3544
+ BinaryenType paramTypes,
3545
+ BinaryenType resultTypes);
3546
+ // Sets the heap type at index `index` to a concrete struct type.
3547
+ BINARYEN_API void TypeBuilderSetStructType(TypeBuilderRef builder,
3548
+ BinaryenIndex index,
3549
+ BinaryenType* fieldTypes,
3550
+ BinaryenPackedType* fieldPackedTypes,
3551
+ bool* fieldMutables,
3552
+ int numFields);
3553
+ // Sets the heap type at index `index` to a concrete array type.
3554
+ BINARYEN_API void TypeBuilderSetArrayType(TypeBuilderRef builder,
3555
+ BinaryenIndex index,
3556
+ BinaryenType elementType,
3557
+ BinaryenPackedType elementPackedType,
3558
+ int elementMutable);
3559
+ // Gets the temporary heap type to use at index `index`. Temporary heap types
3560
+ // may only be used to construct temporary types using the type builder.
3561
+ BINARYEN_API BinaryenHeapType TypeBuilderGetTempHeapType(TypeBuilderRef builder,
3562
+ BinaryenIndex index);
3563
+ // Gets a temporary tuple type for use with and owned by the type builder.
3564
+ BINARYEN_API BinaryenType TypeBuilderGetTempTupleType(TypeBuilderRef builder,
3565
+ BinaryenType* types,
3566
+ BinaryenIndex numTypes);
3567
+ // Gets a temporary reference type for use with and owned by the type builder.
3568
+ BINARYEN_API BinaryenType TypeBuilderGetTempRefType(TypeBuilderRef builder,
3569
+ BinaryenHeapType heapType,
3570
+ int nullable);
3571
+ // Sets the type at `index` to be a subtype of the given super type.
3572
+ BINARYEN_API void TypeBuilderSetSubType(TypeBuilderRef builder,
3573
+ BinaryenIndex index,
3574
+ BinaryenHeapType superType);
3575
+ // Sets the type at `index` to be open (i.e. non-final).
3576
+ BINARYEN_API void TypeBuilderSetOpen(TypeBuilderRef builder,
3577
+ BinaryenIndex index);
3578
+ // Creates a new recursion group in the range `index` inclusive to `index +
3579
+ // length` exclusive. Recursion groups must not overlap.
3580
+ BINARYEN_API void TypeBuilderCreateRecGroup(TypeBuilderRef builder,
3581
+ BinaryenIndex index,
3582
+ BinaryenIndex length);
3583
+ // Builds the heap type hierarchy and disposes the builder. Returns `false` and
3584
+ // populates `errorIndex` and `errorReason` on failure.
3585
+ BINARYEN_API bool
3586
+ TypeBuilderBuildAndDispose(TypeBuilderRef builder,
3587
+ BinaryenHeapType* heapTypes,
3588
+ BinaryenIndex* errorIndex,
3589
+ TypeBuilderErrorReason* errorReason);
3590
+
3591
+ // Sets the textual name of a compound `heapType`. Has no effect if the type
3592
+ // already has a canonical name.
3593
+ BINARYEN_API void BinaryenModuleSetTypeName(BinaryenModuleRef module,
3594
+ BinaryenHeapType heapType,
3595
+ const char* name);
3596
+ // Sets the field name of a struct `heapType` at index `index`.
3597
+ BINARYEN_API void BinaryenModuleSetFieldName(BinaryenModuleRef module,
3598
+ BinaryenHeapType heapType,
3599
+ BinaryenIndex index,
3600
+ const char* name);
3601
+
3602
+ //
3603
+ // ========= Utilities =========
3604
+ //
3605
+
3606
+ // Enable or disable coloring for the Wasm printer
3607
+ BINARYEN_API void BinaryenSetColorsEnabled(bool enabled);
3608
+
3609
+ // Query whether color is enable for the Wasm printer
3610
+ BINARYEN_API bool BinaryenAreColorsEnabled();
3611
+ #ifdef __cplusplus
3612
+ } // extern "C"
3613
+ #endif
3614
+
3615
+ #endif // wasm_binaryen_c_h