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/tracing 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 <stddef.h> 47 #include <stdint.h> 48 49 #ifdef __GNUC__ 50 #define WASM_DEPRECATED __attribute__((deprecated)) 51 #elif defined(_MSC_VER) 52 #define WASM_DEPRECATED __declspec(deprecated) 53 #else 54 #define WASM_DEPRECATED 55 #endif 56 57 #if defined(__EMSCRIPTEN__) 58 #include <emscripten.h> 59 #define BINARYEN_API EMSCRIPTEN_KEEPALIVE 60 #elif defined(_MSC_VER) && !defined(BUILD_STATIC_LIBRARY) 61 #define BINARYEN_API __declspec(dllexport) 62 #else 63 #define BINARYEN_API 64 #endif 65 66 #ifdef __cplusplus 67 #define BINARYEN_REF(NAME) \ 68 namespace wasm { \ 69 class NAME; \ 70 }; \ 71 typedef class wasm::NAME* Binaryen##NAME##Ref; 72 #else 73 #define BINARYEN_REF(NAME) typedef struct Binaryen##NAME* Binaryen##NAME##Ref; 74 #endif 75 76 #ifdef __cplusplus 77 extern "C" { 78 #endif 79 80 // 81 // ========== Module Creation ========== 82 // 83 84 // BinaryenIndex 85 // 86 // Used for internal indexes and list sizes. 87 88 typedef uint32_t BinaryenIndex; 89 90 // Core types (call to get the value of each; you can cache them, they 91 // never change) 92 93 typedef uintptr_t BinaryenType; 94 95 BINARYEN_API BinaryenType BinaryenTypeNone(void); 96 BINARYEN_API BinaryenType BinaryenTypeInt32(void); 97 BINARYEN_API BinaryenType BinaryenTypeInt64(void); 98 BINARYEN_API BinaryenType BinaryenTypeFloat32(void); 99 BINARYEN_API BinaryenType BinaryenTypeFloat64(void); 100 BINARYEN_API BinaryenType BinaryenTypeVec128(void); 101 BINARYEN_API BinaryenType BinaryenTypeFuncref(void); 102 BINARYEN_API BinaryenType BinaryenTypeExternref(void); 103 BINARYEN_API BinaryenType BinaryenTypeExnref(void); 104 BINARYEN_API BinaryenType BinaryenTypeAnyref(void); 105 BINARYEN_API BinaryenType BinaryenTypeEqref(void); 106 BINARYEN_API BinaryenType BinaryenTypeI31ref(void); 107 BINARYEN_API BinaryenType BinaryenTypeUnreachable(void); 108 // Not a real type. Used as the last parameter to BinaryenBlock to let 109 // the API figure out the type instead of providing one. 110 BINARYEN_API BinaryenType BinaryenTypeAuto(void); 111 BINARYEN_API BinaryenType BinaryenTypeCreate(BinaryenType* valueTypes, 112 uint32_t numTypes); 113 BINARYEN_API uint32_t BinaryenTypeArity(BinaryenType t); 114 BINARYEN_API void BinaryenTypeExpand(BinaryenType t, BinaryenType* buf); 115 116 WASM_DEPRECATED BinaryenType BinaryenNone(void); 117 WASM_DEPRECATED BinaryenType BinaryenInt32(void); 118 WASM_DEPRECATED BinaryenType BinaryenInt64(void); 119 WASM_DEPRECATED BinaryenType BinaryenFloat32(void); 120 WASM_DEPRECATED BinaryenType BinaryenFloat64(void); 121 WASM_DEPRECATED BinaryenType BinaryenUndefined(void); 122 123 // Expression ids (call to get the value of each; you can cache them) 124 125 typedef uint32_t BinaryenExpressionId; 126 127 BINARYEN_API BinaryenExpressionId BinaryenInvalidId(void); 128 BINARYEN_API BinaryenExpressionId BinaryenBlockId(void); 129 BINARYEN_API BinaryenExpressionId BinaryenIfId(void); 130 BINARYEN_API BinaryenExpressionId BinaryenLoopId(void); 131 BINARYEN_API BinaryenExpressionId BinaryenBreakId(void); 132 BINARYEN_API BinaryenExpressionId BinaryenSwitchId(void); 133 BINARYEN_API BinaryenExpressionId BinaryenCallId(void); 134 BINARYEN_API BinaryenExpressionId BinaryenCallIndirectId(void); 135 BINARYEN_API BinaryenExpressionId BinaryenLocalGetId(void); 136 BINARYEN_API BinaryenExpressionId BinaryenLocalSetId(void); 137 BINARYEN_API BinaryenExpressionId BinaryenGlobalGetId(void); 138 BINARYEN_API BinaryenExpressionId BinaryenGlobalSetId(void); 139 BINARYEN_API BinaryenExpressionId BinaryenLoadId(void); 140 BINARYEN_API BinaryenExpressionId BinaryenStoreId(void); 141 BINARYEN_API BinaryenExpressionId BinaryenConstId(void); 142 BINARYEN_API BinaryenExpressionId BinaryenUnaryId(void); 143 BINARYEN_API BinaryenExpressionId BinaryenBinaryId(void); 144 BINARYEN_API BinaryenExpressionId BinaryenSelectId(void); 145 BINARYEN_API BinaryenExpressionId BinaryenDropId(void); 146 BINARYEN_API BinaryenExpressionId BinaryenReturnId(void); 147 BINARYEN_API BinaryenExpressionId BinaryenMemorySizeId(void); 148 BINARYEN_API BinaryenExpressionId BinaryenMemoryGrowId(void); 149 BINARYEN_API BinaryenExpressionId BinaryenNopId(void); 150 BINARYEN_API BinaryenExpressionId BinaryenUnreachableId(void); 151 BINARYEN_API BinaryenExpressionId BinaryenAtomicCmpxchgId(void); 152 BINARYEN_API BinaryenExpressionId BinaryenAtomicRMWId(void); 153 BINARYEN_API BinaryenExpressionId BinaryenAtomicWaitId(void); 154 BINARYEN_API BinaryenExpressionId BinaryenAtomicNotifyId(void); 155 BINARYEN_API BinaryenExpressionId BinaryenAtomicFenceId(void); 156 BINARYEN_API BinaryenExpressionId BinaryenSIMDExtractId(void); 157 BINARYEN_API BinaryenExpressionId BinaryenSIMDReplaceId(void); 158 BINARYEN_API BinaryenExpressionId BinaryenSIMDShuffleId(void); 159 BINARYEN_API BinaryenExpressionId BinaryenSIMDTernaryId(void); 160 BINARYEN_API BinaryenExpressionId BinaryenSIMDShiftId(void); 161 BINARYEN_API BinaryenExpressionId BinaryenSIMDLoadId(void); 162 BINARYEN_API BinaryenExpressionId BinaryenMemoryInitId(void); 163 BINARYEN_API BinaryenExpressionId BinaryenDataDropId(void); 164 BINARYEN_API BinaryenExpressionId BinaryenMemoryCopyId(void); 165 BINARYEN_API BinaryenExpressionId BinaryenMemoryFillId(void); 166 BINARYEN_API BinaryenExpressionId BinaryenRefNullId(void); 167 BINARYEN_API BinaryenExpressionId BinaryenRefIsNullId(void); 168 BINARYEN_API BinaryenExpressionId BinaryenRefFuncId(void); 169 BINARYEN_API BinaryenExpressionId BinaryenRefEqId(void); 170 BINARYEN_API BinaryenExpressionId BinaryenTryId(void); 171 BINARYEN_API BinaryenExpressionId BinaryenThrowId(void); 172 BINARYEN_API BinaryenExpressionId BinaryenRethrowId(void); 173 BINARYEN_API BinaryenExpressionId BinaryenBrOnExnId(void); 174 BINARYEN_API BinaryenExpressionId BinaryenTupleMakeId(void); 175 BINARYEN_API BinaryenExpressionId BinaryenTupleExtractId(void); 176 BINARYEN_API BinaryenExpressionId BinaryenPopId(void); 177 BINARYEN_API BinaryenExpressionId BinaryenI31NewId(void); 178 BINARYEN_API BinaryenExpressionId BinaryenI31GetId(void); 179 BINARYEN_API BinaryenExpressionId BinaryenRefTestId(void); 180 BINARYEN_API BinaryenExpressionId BinaryenRefCastId(void); 181 BINARYEN_API BinaryenExpressionId BinaryenBrOnCastId(void); 182 BINARYEN_API BinaryenExpressionId BinaryenRttCanonId(void); 183 BINARYEN_API BinaryenExpressionId BinaryenRttSubId(void); 184 BINARYEN_API BinaryenExpressionId BinaryenStructNewId(void); 185 BINARYEN_API BinaryenExpressionId BinaryenStructGetId(void); 186 BINARYEN_API BinaryenExpressionId BinaryenStructSetId(void); 187 BINARYEN_API BinaryenExpressionId BinaryenArrayNewId(void); 188 BINARYEN_API BinaryenExpressionId BinaryenArrayGetId(void); 189 BINARYEN_API BinaryenExpressionId BinaryenArraySetId(void); 190 BINARYEN_API BinaryenExpressionId BinaryenArrayLenId(void); 191 192 // External kinds (call to get the value of each; you can cache them) 193 194 typedef uint32_t BinaryenExternalKind; 195 196 BINARYEN_API BinaryenExternalKind BinaryenExternalFunction(void); 197 BINARYEN_API BinaryenExternalKind BinaryenExternalTable(void); 198 BINARYEN_API BinaryenExternalKind BinaryenExternalMemory(void); 199 BINARYEN_API BinaryenExternalKind BinaryenExternalGlobal(void); 200 BINARYEN_API BinaryenExternalKind BinaryenExternalEvent(void); 201 202 // Features. Call to get the value of each; you can cache them. Use bitwise 203 // operators to combine and test particular features. 204 205 typedef uint32_t BinaryenFeatures; 206 207 BINARYEN_API BinaryenFeatures BinaryenFeatureMVP(void); 208 BINARYEN_API BinaryenFeatures BinaryenFeatureAtomics(void); 209 BINARYEN_API BinaryenFeatures BinaryenFeatureBulkMemory(void); 210 BINARYEN_API BinaryenFeatures BinaryenFeatureMutableGlobals(void); 211 BINARYEN_API BinaryenFeatures BinaryenFeatureNontrappingFPToInt(void); 212 BINARYEN_API BinaryenFeatures BinaryenFeatureSignExt(void); 213 BINARYEN_API BinaryenFeatures BinaryenFeatureSIMD128(void); 214 BINARYEN_API BinaryenFeatures BinaryenFeatureExceptionHandling(void); 215 BINARYEN_API BinaryenFeatures BinaryenFeatureTailCall(void); 216 BINARYEN_API BinaryenFeatures BinaryenFeatureReferenceTypes(void); 217 BINARYEN_API BinaryenFeatures BinaryenFeatureMultivalue(void); 218 BINARYEN_API BinaryenFeatures BinaryenFeatureGC(void); 219 BINARYEN_API BinaryenFeatures BinaryenFeatureMemory64(void); 220 BINARYEN_API BinaryenFeatures BinaryenFeatureAll(void); 221 222 // Modules 223 // 224 // Modules contain lists of functions, imports, exports, function types. The 225 // Add* methods create them on a module. The module owns them and will free 226 // their memory when the module is disposed of. 227 // 228 // Expressions are also allocated inside modules, and freed with the module. 229 // They are not created by Add* methods, since they are not added directly on 230 // the module, instead, they are arguments to other expressions (and then they 231 // are the children of that AST node), or to a function (and then they are the 232 // body of that function). 233 // 234 // A module can also contain a function table for indirect calls, a memory, 235 // and a start method. 236 237 BINARYEN_REF(Module); 238 239 BINARYEN_API BinaryenModuleRef BinaryenModuleCreate(void); 240 BINARYEN_API void BinaryenModuleDispose(BinaryenModuleRef module); 241 242 // Literals. These are passed by value. 243 244 struct BinaryenLiteral { 245 uintptr_t type; 246 union { 247 int32_t i32; 248 int64_t i64; 249 float f32; 250 double f64; 251 uint8_t v128[16]; 252 const char* func; 253 // TODO: exn 254 }; 255 }; 256 257 BINARYEN_API struct BinaryenLiteral BinaryenLiteralInt32(int32_t x); 258 BINARYEN_API struct BinaryenLiteral BinaryenLiteralInt64(int64_t x); 259 BINARYEN_API struct BinaryenLiteral BinaryenLiteralFloat32(float x); 260 BINARYEN_API struct BinaryenLiteral BinaryenLiteralFloat64(double x); 261 BINARYEN_API struct BinaryenLiteral BinaryenLiteralVec128(const uint8_t x[16]); 262 BINARYEN_API struct BinaryenLiteral BinaryenLiteralFloat32Bits(int32_t x); 263 BINARYEN_API struct BinaryenLiteral BinaryenLiteralFloat64Bits(int64_t x); 264 265 // Expressions 266 // 267 // Some expressions have a BinaryenOp, which is the more 268 // specific operation/opcode. 269 // 270 // Some expressions have optional parameters, like Return may not 271 // return a value. You can supply a NULL pointer in those cases. 272 // 273 // For more information, see wasm.h 274 275 typedef int32_t BinaryenOp; 276 277 BINARYEN_API BinaryenOp BinaryenClzInt32(void); 278 BINARYEN_API BinaryenOp BinaryenCtzInt32(void); 279 BINARYEN_API BinaryenOp BinaryenPopcntInt32(void); 280 BINARYEN_API BinaryenOp BinaryenNegFloat32(void); 281 BINARYEN_API BinaryenOp BinaryenAbsFloat32(void); 282 BINARYEN_API BinaryenOp BinaryenCeilFloat32(void); 283 BINARYEN_API BinaryenOp BinaryenFloorFloat32(void); 284 BINARYEN_API BinaryenOp BinaryenTruncFloat32(void); 285 BINARYEN_API BinaryenOp BinaryenNearestFloat32(void); 286 BINARYEN_API BinaryenOp BinaryenSqrtFloat32(void); 287 BINARYEN_API BinaryenOp BinaryenEqZInt32(void); 288 BINARYEN_API BinaryenOp BinaryenClzInt64(void); 289 BINARYEN_API BinaryenOp BinaryenCtzInt64(void); 290 BINARYEN_API BinaryenOp BinaryenPopcntInt64(void); 291 BINARYEN_API BinaryenOp BinaryenNegFloat64(void); 292 BINARYEN_API BinaryenOp BinaryenAbsFloat64(void); 293 BINARYEN_API BinaryenOp BinaryenCeilFloat64(void); 294 BINARYEN_API BinaryenOp BinaryenFloorFloat64(void); 295 BINARYEN_API BinaryenOp BinaryenTruncFloat64(void); 296 BINARYEN_API BinaryenOp BinaryenNearestFloat64(void); 297 BINARYEN_API BinaryenOp BinaryenSqrtFloat64(void); 298 BINARYEN_API BinaryenOp BinaryenEqZInt64(void); 299 BINARYEN_API BinaryenOp BinaryenExtendSInt32(void); 300 BINARYEN_API BinaryenOp BinaryenExtendUInt32(void); 301 BINARYEN_API BinaryenOp BinaryenWrapInt64(void); 302 BINARYEN_API BinaryenOp BinaryenTruncSFloat32ToInt32(void); 303 BINARYEN_API BinaryenOp BinaryenTruncSFloat32ToInt64(void); 304 BINARYEN_API BinaryenOp BinaryenTruncUFloat32ToInt32(void); 305 BINARYEN_API BinaryenOp BinaryenTruncUFloat32ToInt64(void); 306 BINARYEN_API BinaryenOp BinaryenTruncSFloat64ToInt32(void); 307 BINARYEN_API BinaryenOp BinaryenTruncSFloat64ToInt64(void); 308 BINARYEN_API BinaryenOp BinaryenTruncUFloat64ToInt32(void); 309 BINARYEN_API BinaryenOp BinaryenTruncUFloat64ToInt64(void); 310 BINARYEN_API BinaryenOp BinaryenReinterpretFloat32(void); 311 BINARYEN_API BinaryenOp BinaryenReinterpretFloat64(void); 312 BINARYEN_API BinaryenOp BinaryenConvertSInt32ToFloat32(void); 313 BINARYEN_API BinaryenOp BinaryenConvertSInt32ToFloat64(void); 314 BINARYEN_API BinaryenOp BinaryenConvertUInt32ToFloat32(void); 315 BINARYEN_API BinaryenOp BinaryenConvertUInt32ToFloat64(void); 316 BINARYEN_API BinaryenOp BinaryenConvertSInt64ToFloat32(void); 317 BINARYEN_API BinaryenOp BinaryenConvertSInt64ToFloat64(void); 318 BINARYEN_API BinaryenOp BinaryenConvertUInt64ToFloat32(void); 319 BINARYEN_API BinaryenOp BinaryenConvertUInt64ToFloat64(void); 320 BINARYEN_API BinaryenOp BinaryenPromoteFloat32(void); 321 BINARYEN_API BinaryenOp BinaryenDemoteFloat64(void); 322 BINARYEN_API BinaryenOp BinaryenReinterpretInt32(void); 323 BINARYEN_API BinaryenOp BinaryenReinterpretInt64(void); 324 BINARYEN_API BinaryenOp BinaryenExtendS8Int32(void); 325 BINARYEN_API BinaryenOp BinaryenExtendS16Int32(void); 326 BINARYEN_API BinaryenOp BinaryenExtendS8Int64(void); 327 BINARYEN_API BinaryenOp BinaryenExtendS16Int64(void); 328 BINARYEN_API BinaryenOp BinaryenExtendS32Int64(void); 329 BINARYEN_API BinaryenOp BinaryenAddInt32(void); 330 BINARYEN_API BinaryenOp BinaryenSubInt32(void); 331 BINARYEN_API BinaryenOp BinaryenMulInt32(void); 332 BINARYEN_API BinaryenOp BinaryenDivSInt32(void); 333 BINARYEN_API BinaryenOp BinaryenDivUInt32(void); 334 BINARYEN_API BinaryenOp BinaryenRemSInt32(void); 335 BINARYEN_API BinaryenOp BinaryenRemUInt32(void); 336 BINARYEN_API BinaryenOp BinaryenAndInt32(void); 337 BINARYEN_API BinaryenOp BinaryenOrInt32(void); 338 BINARYEN_API BinaryenOp BinaryenXorInt32(void); 339 BINARYEN_API BinaryenOp BinaryenShlInt32(void); 340 BINARYEN_API BinaryenOp BinaryenShrUInt32(void); 341 BINARYEN_API BinaryenOp BinaryenShrSInt32(void); 342 BINARYEN_API BinaryenOp BinaryenRotLInt32(void); 343 BINARYEN_API BinaryenOp BinaryenRotRInt32(void); 344 BINARYEN_API BinaryenOp BinaryenEqInt32(void); 345 BINARYEN_API BinaryenOp BinaryenNeInt32(void); 346 BINARYEN_API BinaryenOp BinaryenLtSInt32(void); 347 BINARYEN_API BinaryenOp BinaryenLtUInt32(void); 348 BINARYEN_API BinaryenOp BinaryenLeSInt32(void); 349 BINARYEN_API BinaryenOp BinaryenLeUInt32(void); 350 BINARYEN_API BinaryenOp BinaryenGtSInt32(void); 351 BINARYEN_API BinaryenOp BinaryenGtUInt32(void); 352 BINARYEN_API BinaryenOp BinaryenGeSInt32(void); 353 BINARYEN_API BinaryenOp BinaryenGeUInt32(void); 354 BINARYEN_API BinaryenOp BinaryenAddInt64(void); 355 BINARYEN_API BinaryenOp BinaryenSubInt64(void); 356 BINARYEN_API BinaryenOp BinaryenMulInt64(void); 357 BINARYEN_API BinaryenOp BinaryenDivSInt64(void); 358 BINARYEN_API BinaryenOp BinaryenDivUInt64(void); 359 BINARYEN_API BinaryenOp BinaryenRemSInt64(void); 360 BINARYEN_API BinaryenOp BinaryenRemUInt64(void); 361 BINARYEN_API BinaryenOp BinaryenAndInt64(void); 362 BINARYEN_API BinaryenOp BinaryenOrInt64(void); 363 BINARYEN_API BinaryenOp BinaryenXorInt64(void); 364 BINARYEN_API BinaryenOp BinaryenShlInt64(void); 365 BINARYEN_API BinaryenOp BinaryenShrUInt64(void); 366 BINARYEN_API BinaryenOp BinaryenShrSInt64(void); 367 BINARYEN_API BinaryenOp BinaryenRotLInt64(void); 368 BINARYEN_API BinaryenOp BinaryenRotRInt64(void); 369 BINARYEN_API BinaryenOp BinaryenEqInt64(void); 370 BINARYEN_API BinaryenOp BinaryenNeInt64(void); 371 BINARYEN_API BinaryenOp BinaryenLtSInt64(void); 372 BINARYEN_API BinaryenOp BinaryenLtUInt64(void); 373 BINARYEN_API BinaryenOp BinaryenLeSInt64(void); 374 BINARYEN_API BinaryenOp BinaryenLeUInt64(void); 375 BINARYEN_API BinaryenOp BinaryenGtSInt64(void); 376 BINARYEN_API BinaryenOp BinaryenGtUInt64(void); 377 BINARYEN_API BinaryenOp BinaryenGeSInt64(void); 378 BINARYEN_API BinaryenOp BinaryenGeUInt64(void); 379 BINARYEN_API BinaryenOp BinaryenAddFloat32(void); 380 BINARYEN_API BinaryenOp BinaryenSubFloat32(void); 381 BINARYEN_API BinaryenOp BinaryenMulFloat32(void); 382 BINARYEN_API BinaryenOp BinaryenDivFloat32(void); 383 BINARYEN_API BinaryenOp BinaryenCopySignFloat32(void); 384 BINARYEN_API BinaryenOp BinaryenMinFloat32(void); 385 BINARYEN_API BinaryenOp BinaryenMaxFloat32(void); 386 BINARYEN_API BinaryenOp BinaryenEqFloat32(void); 387 BINARYEN_API BinaryenOp BinaryenNeFloat32(void); 388 BINARYEN_API BinaryenOp BinaryenLtFloat32(void); 389 BINARYEN_API BinaryenOp BinaryenLeFloat32(void); 390 BINARYEN_API BinaryenOp BinaryenGtFloat32(void); 391 BINARYEN_API BinaryenOp BinaryenGeFloat32(void); 392 BINARYEN_API BinaryenOp BinaryenAddFloat64(void); 393 BINARYEN_API BinaryenOp BinaryenSubFloat64(void); 394 BINARYEN_API BinaryenOp BinaryenMulFloat64(void); 395 BINARYEN_API BinaryenOp BinaryenDivFloat64(void); 396 BINARYEN_API BinaryenOp BinaryenCopySignFloat64(void); 397 BINARYEN_API BinaryenOp BinaryenMinFloat64(void); 398 BINARYEN_API BinaryenOp BinaryenMaxFloat64(void); 399 BINARYEN_API BinaryenOp BinaryenEqFloat64(void); 400 BINARYEN_API BinaryenOp BinaryenNeFloat64(void); 401 BINARYEN_API BinaryenOp BinaryenLtFloat64(void); 402 BINARYEN_API BinaryenOp BinaryenLeFloat64(void); 403 BINARYEN_API BinaryenOp BinaryenGtFloat64(void); 404 BINARYEN_API BinaryenOp BinaryenGeFloat64(void); 405 BINARYEN_API BinaryenOp BinaryenAtomicRMWAdd(void); 406 BINARYEN_API BinaryenOp BinaryenAtomicRMWSub(void); 407 BINARYEN_API BinaryenOp BinaryenAtomicRMWAnd(void); 408 BINARYEN_API BinaryenOp BinaryenAtomicRMWOr(void); 409 BINARYEN_API BinaryenOp BinaryenAtomicRMWXor(void); 410 BINARYEN_API BinaryenOp BinaryenAtomicRMWXchg(void); 411 BINARYEN_API BinaryenOp BinaryenTruncSatSFloat32ToInt32(void); 412 BINARYEN_API BinaryenOp BinaryenTruncSatSFloat32ToInt64(void); 413 BINARYEN_API BinaryenOp BinaryenTruncSatUFloat32ToInt32(void); 414 BINARYEN_API BinaryenOp BinaryenTruncSatUFloat32ToInt64(void); 415 BINARYEN_API BinaryenOp BinaryenTruncSatSFloat64ToInt32(void); 416 BINARYEN_API BinaryenOp BinaryenTruncSatSFloat64ToInt64(void); 417 BINARYEN_API BinaryenOp BinaryenTruncSatUFloat64ToInt32(void); 418 BINARYEN_API BinaryenOp BinaryenTruncSatUFloat64ToInt64(void); 419 BINARYEN_API BinaryenOp BinaryenSplatVecI8x16(void); 420 BINARYEN_API BinaryenOp BinaryenExtractLaneSVecI8x16(void); 421 BINARYEN_API BinaryenOp BinaryenExtractLaneUVecI8x16(void); 422 BINARYEN_API BinaryenOp BinaryenReplaceLaneVecI8x16(void); 423 BINARYEN_API BinaryenOp BinaryenSplatVecI16x8(void); 424 BINARYEN_API BinaryenOp BinaryenExtractLaneSVecI16x8(void); 425 BINARYEN_API BinaryenOp BinaryenExtractLaneUVecI16x8(void); 426 BINARYEN_API BinaryenOp BinaryenReplaceLaneVecI16x8(void); 427 BINARYEN_API BinaryenOp BinaryenSplatVecI32x4(void); 428 BINARYEN_API BinaryenOp BinaryenExtractLaneVecI32x4(void); 429 BINARYEN_API BinaryenOp BinaryenReplaceLaneVecI32x4(void); 430 BINARYEN_API BinaryenOp BinaryenSplatVecI64x2(void); 431 BINARYEN_API BinaryenOp BinaryenExtractLaneVecI64x2(void); 432 BINARYEN_API BinaryenOp BinaryenReplaceLaneVecI64x2(void); 433 BINARYEN_API BinaryenOp BinaryenSplatVecF32x4(void); 434 BINARYEN_API BinaryenOp BinaryenExtractLaneVecF32x4(void); 435 BINARYEN_API BinaryenOp BinaryenReplaceLaneVecF32x4(void); 436 BINARYEN_API BinaryenOp BinaryenSplatVecF64x2(void); 437 BINARYEN_API BinaryenOp BinaryenExtractLaneVecF64x2(void); 438 BINARYEN_API BinaryenOp BinaryenReplaceLaneVecF64x2(void); 439 BINARYEN_API BinaryenOp BinaryenEqVecI8x16(void); 440 BINARYEN_API BinaryenOp BinaryenNeVecI8x16(void); 441 BINARYEN_API BinaryenOp BinaryenLtSVecI8x16(void); 442 BINARYEN_API BinaryenOp BinaryenLtUVecI8x16(void); 443 BINARYEN_API BinaryenOp BinaryenGtSVecI8x16(void); 444 BINARYEN_API BinaryenOp BinaryenGtUVecI8x16(void); 445 BINARYEN_API BinaryenOp BinaryenLeSVecI8x16(void); 446 BINARYEN_API BinaryenOp BinaryenLeUVecI8x16(void); 447 BINARYEN_API BinaryenOp BinaryenGeSVecI8x16(void); 448 BINARYEN_API BinaryenOp BinaryenGeUVecI8x16(void); 449 BINARYEN_API BinaryenOp BinaryenEqVecI16x8(void); 450 BINARYEN_API BinaryenOp BinaryenNeVecI16x8(void); 451 BINARYEN_API BinaryenOp BinaryenLtSVecI16x8(void); 452 BINARYEN_API BinaryenOp BinaryenLtUVecI16x8(void); 453 BINARYEN_API BinaryenOp BinaryenGtSVecI16x8(void); 454 BINARYEN_API BinaryenOp BinaryenGtUVecI16x8(void); 455 BINARYEN_API BinaryenOp BinaryenLeSVecI16x8(void); 456 BINARYEN_API BinaryenOp BinaryenLeUVecI16x8(void); 457 BINARYEN_API BinaryenOp BinaryenGeSVecI16x8(void); 458 BINARYEN_API BinaryenOp BinaryenGeUVecI16x8(void); 459 BINARYEN_API BinaryenOp BinaryenEqVecI32x4(void); 460 BINARYEN_API BinaryenOp BinaryenNeVecI32x4(void); 461 BINARYEN_API BinaryenOp BinaryenLtSVecI32x4(void); 462 BINARYEN_API BinaryenOp BinaryenLtUVecI32x4(void); 463 BINARYEN_API BinaryenOp BinaryenGtSVecI32x4(void); 464 BINARYEN_API BinaryenOp BinaryenGtUVecI32x4(void); 465 BINARYEN_API BinaryenOp BinaryenLeSVecI32x4(void); 466 BINARYEN_API BinaryenOp BinaryenLeUVecI32x4(void); 467 BINARYEN_API BinaryenOp BinaryenGeSVecI32x4(void); 468 BINARYEN_API BinaryenOp BinaryenGeUVecI32x4(void); 469 BINARYEN_API BinaryenOp BinaryenEqVecF32x4(void); 470 BINARYEN_API BinaryenOp BinaryenNeVecF32x4(void); 471 BINARYEN_API BinaryenOp BinaryenLtVecF32x4(void); 472 BINARYEN_API BinaryenOp BinaryenGtVecF32x4(void); 473 BINARYEN_API BinaryenOp BinaryenLeVecF32x4(void); 474 BINARYEN_API BinaryenOp BinaryenGeVecF32x4(void); 475 BINARYEN_API BinaryenOp BinaryenEqVecF64x2(void); 476 BINARYEN_API BinaryenOp BinaryenNeVecF64x2(void); 477 BINARYEN_API BinaryenOp BinaryenLtVecF64x2(void); 478 BINARYEN_API BinaryenOp BinaryenGtVecF64x2(void); 479 BINARYEN_API BinaryenOp BinaryenLeVecF64x2(void); 480 BINARYEN_API BinaryenOp BinaryenGeVecF64x2(void); 481 BINARYEN_API BinaryenOp BinaryenNotVec128(void); 482 BINARYEN_API BinaryenOp BinaryenAndVec128(void); 483 BINARYEN_API BinaryenOp BinaryenOrVec128(void); 484 BINARYEN_API BinaryenOp BinaryenXorVec128(void); 485 BINARYEN_API BinaryenOp BinaryenAndNotVec128(void); 486 BINARYEN_API BinaryenOp BinaryenBitselectVec128(void); 487 BINARYEN_API BinaryenOp BinaryenAbsVecI8x16(void); 488 BINARYEN_API BinaryenOp BinaryenNegVecI8x16(void); 489 BINARYEN_API BinaryenOp BinaryenAnyTrueVecI8x16(void); 490 BINARYEN_API BinaryenOp BinaryenAllTrueVecI8x16(void); 491 BINARYEN_API BinaryenOp BinaryenBitmaskVecI8x16(void); 492 BINARYEN_API BinaryenOp BinaryenShlVecI8x16(void); 493 BINARYEN_API BinaryenOp BinaryenShrSVecI8x16(void); 494 BINARYEN_API BinaryenOp BinaryenShrUVecI8x16(void); 495 BINARYEN_API BinaryenOp BinaryenAddVecI8x16(void); 496 BINARYEN_API BinaryenOp BinaryenAddSatSVecI8x16(void); 497 BINARYEN_API BinaryenOp BinaryenAddSatUVecI8x16(void); 498 BINARYEN_API BinaryenOp BinaryenSubVecI8x16(void); 499 BINARYEN_API BinaryenOp BinaryenSubSatSVecI8x16(void); 500 BINARYEN_API BinaryenOp BinaryenSubSatUVecI8x16(void); 501 BINARYEN_API BinaryenOp BinaryenMulVecI8x16(void); 502 BINARYEN_API BinaryenOp BinaryenMinSVecI8x16(void); 503 BINARYEN_API BinaryenOp BinaryenMinUVecI8x16(void); 504 BINARYEN_API BinaryenOp BinaryenMaxSVecI8x16(void); 505 BINARYEN_API BinaryenOp BinaryenMaxUVecI8x16(void); 506 BINARYEN_API BinaryenOp BinaryenAvgrUVecI8x16(void); 507 BINARYEN_API BinaryenOp BinaryenAbsVecI16x8(void); 508 BINARYEN_API BinaryenOp BinaryenNegVecI16x8(void); 509 BINARYEN_API BinaryenOp BinaryenAnyTrueVecI16x8(void); 510 BINARYEN_API BinaryenOp BinaryenAllTrueVecI16x8(void); 511 BINARYEN_API BinaryenOp BinaryenBitmaskVecI16x8(void); 512 BINARYEN_API BinaryenOp BinaryenShlVecI16x8(void); 513 BINARYEN_API BinaryenOp BinaryenShrSVecI16x8(void); 514 BINARYEN_API BinaryenOp BinaryenShrUVecI16x8(void); 515 BINARYEN_API BinaryenOp BinaryenAddVecI16x8(void); 516 BINARYEN_API BinaryenOp BinaryenAddSatSVecI16x8(void); 517 BINARYEN_API BinaryenOp BinaryenAddSatUVecI16x8(void); 518 BINARYEN_API BinaryenOp BinaryenSubVecI16x8(void); 519 BINARYEN_API BinaryenOp BinaryenSubSatSVecI16x8(void); 520 BINARYEN_API BinaryenOp BinaryenSubSatUVecI16x8(void); 521 BINARYEN_API BinaryenOp BinaryenMulVecI16x8(void); 522 BINARYEN_API BinaryenOp BinaryenMinSVecI16x8(void); 523 BINARYEN_API BinaryenOp BinaryenMinUVecI16x8(void); 524 BINARYEN_API BinaryenOp BinaryenMaxSVecI16x8(void); 525 BINARYEN_API BinaryenOp BinaryenMaxUVecI16x8(void); 526 BINARYEN_API BinaryenOp BinaryenAvgrUVecI16x8(void); 527 BINARYEN_API BinaryenOp BinaryenAbsVecI32x4(void); 528 BINARYEN_API BinaryenOp BinaryenNegVecI32x4(void); 529 BINARYEN_API BinaryenOp BinaryenAnyTrueVecI32x4(void); 530 BINARYEN_API BinaryenOp BinaryenAllTrueVecI32x4(void); 531 BINARYEN_API BinaryenOp BinaryenBitmaskVecI32x4(void); 532 BINARYEN_API BinaryenOp BinaryenShlVecI32x4(void); 533 BINARYEN_API BinaryenOp BinaryenShrSVecI32x4(void); 534 BINARYEN_API BinaryenOp BinaryenShrUVecI32x4(void); 535 BINARYEN_API BinaryenOp BinaryenAddVecI32x4(void); 536 BINARYEN_API BinaryenOp BinaryenSubVecI32x4(void); 537 BINARYEN_API BinaryenOp BinaryenMulVecI32x4(void); 538 BINARYEN_API BinaryenOp BinaryenMinSVecI32x4(void); 539 BINARYEN_API BinaryenOp BinaryenMinUVecI32x4(void); 540 BINARYEN_API BinaryenOp BinaryenMaxSVecI32x4(void); 541 BINARYEN_API BinaryenOp BinaryenMaxUVecI32x4(void); 542 BINARYEN_API BinaryenOp BinaryenDotSVecI16x8ToVecI32x4(void); 543 BINARYEN_API BinaryenOp BinaryenNegVecI64x2(void); 544 BINARYEN_API BinaryenOp BinaryenAnyTrueVecI64x2(void); 545 BINARYEN_API BinaryenOp BinaryenAllTrueVecI64x2(void); 546 BINARYEN_API BinaryenOp BinaryenShlVecI64x2(void); 547 BINARYEN_API BinaryenOp BinaryenShrSVecI64x2(void); 548 BINARYEN_API BinaryenOp BinaryenShrUVecI64x2(void); 549 BINARYEN_API BinaryenOp BinaryenAddVecI64x2(void); 550 BINARYEN_API BinaryenOp BinaryenSubVecI64x2(void); 551 BINARYEN_API BinaryenOp BinaryenMulVecI64x2(void); 552 BINARYEN_API BinaryenOp BinaryenAbsVecF32x4(void); 553 BINARYEN_API BinaryenOp BinaryenNegVecF32x4(void); 554 BINARYEN_API BinaryenOp BinaryenSqrtVecF32x4(void); 555 BINARYEN_API BinaryenOp BinaryenQFMAVecF32x4(void); 556 BINARYEN_API BinaryenOp BinaryenQFMSVecF32x4(void); 557 BINARYEN_API BinaryenOp BinaryenAddVecF32x4(void); 558 BINARYEN_API BinaryenOp BinaryenSubVecF32x4(void); 559 BINARYEN_API BinaryenOp BinaryenMulVecF32x4(void); 560 BINARYEN_API BinaryenOp BinaryenDivVecF32x4(void); 561 BINARYEN_API BinaryenOp BinaryenMinVecF32x4(void); 562 BINARYEN_API BinaryenOp BinaryenMaxVecF32x4(void); 563 BINARYEN_API BinaryenOp BinaryenPMinVecF32x4(void); 564 BINARYEN_API BinaryenOp BinaryenPMaxVecF32x4(void); 565 BINARYEN_API BinaryenOp BinaryenCeilVecF32x4(void); 566 BINARYEN_API BinaryenOp BinaryenFloorVecF32x4(void); 567 BINARYEN_API BinaryenOp BinaryenTruncVecF32x4(void); 568 BINARYEN_API BinaryenOp BinaryenNearestVecF32x4(void); 569 BINARYEN_API BinaryenOp BinaryenAbsVecF64x2(void); 570 BINARYEN_API BinaryenOp BinaryenNegVecF64x2(void); 571 BINARYEN_API BinaryenOp BinaryenSqrtVecF64x2(void); 572 BINARYEN_API BinaryenOp BinaryenQFMAVecF64x2(void); 573 BINARYEN_API BinaryenOp BinaryenQFMSVecF64x2(void); 574 BINARYEN_API BinaryenOp BinaryenAddVecF64x2(void); 575 BINARYEN_API BinaryenOp BinaryenSubVecF64x2(void); 576 BINARYEN_API BinaryenOp BinaryenMulVecF64x2(void); 577 BINARYEN_API BinaryenOp BinaryenDivVecF64x2(void); 578 BINARYEN_API BinaryenOp BinaryenMinVecF64x2(void); 579 BINARYEN_API BinaryenOp BinaryenMaxVecF64x2(void); 580 BINARYEN_API BinaryenOp BinaryenPMinVecF64x2(void); 581 BINARYEN_API BinaryenOp BinaryenPMaxVecF64x2(void); 582 BINARYEN_API BinaryenOp BinaryenCeilVecF64x2(void); 583 BINARYEN_API BinaryenOp BinaryenFloorVecF64x2(void); 584 BINARYEN_API BinaryenOp BinaryenTruncVecF64x2(void); 585 BINARYEN_API BinaryenOp BinaryenNearestVecF64x2(void); 586 BINARYEN_API BinaryenOp BinaryenTruncSatSVecF32x4ToVecI32x4(void); 587 BINARYEN_API BinaryenOp BinaryenTruncSatUVecF32x4ToVecI32x4(void); 588 BINARYEN_API BinaryenOp BinaryenTruncSatSVecF64x2ToVecI64x2(void); 589 BINARYEN_API BinaryenOp BinaryenTruncSatUVecF64x2ToVecI64x2(void); 590 BINARYEN_API BinaryenOp BinaryenConvertSVecI32x4ToVecF32x4(void); 591 BINARYEN_API BinaryenOp BinaryenConvertUVecI32x4ToVecF32x4(void); 592 BINARYEN_API BinaryenOp BinaryenConvertSVecI64x2ToVecF64x2(void); 593 BINARYEN_API BinaryenOp BinaryenConvertUVecI64x2ToVecF64x2(void); 594 BINARYEN_API BinaryenOp BinaryenLoadSplatVec8x16(void); 595 BINARYEN_API BinaryenOp BinaryenLoadSplatVec16x8(void); 596 BINARYEN_API BinaryenOp BinaryenLoadSplatVec32x4(void); 597 BINARYEN_API BinaryenOp BinaryenLoadSplatVec64x2(void); 598 BINARYEN_API BinaryenOp BinaryenLoadExtSVec8x8ToVecI16x8(void); 599 BINARYEN_API BinaryenOp BinaryenLoadExtUVec8x8ToVecI16x8(void); 600 BINARYEN_API BinaryenOp BinaryenLoadExtSVec16x4ToVecI32x4(void); 601 BINARYEN_API BinaryenOp BinaryenLoadExtUVec16x4ToVecI32x4(void); 602 BINARYEN_API BinaryenOp BinaryenLoadExtSVec32x2ToVecI64x2(void); 603 BINARYEN_API BinaryenOp BinaryenLoadExtUVec32x2ToVecI64x2(void); 604 // TODO: Add Load{32,64}Zero to C and JS APIs once merged to proposal 605 BINARYEN_API BinaryenOp BinaryenNarrowSVecI16x8ToVecI8x16(void); 606 BINARYEN_API BinaryenOp BinaryenNarrowUVecI16x8ToVecI8x16(void); 607 BINARYEN_API BinaryenOp BinaryenNarrowSVecI32x4ToVecI16x8(void); 608 BINARYEN_API BinaryenOp BinaryenNarrowUVecI32x4ToVecI16x8(void); 609 BINARYEN_API BinaryenOp BinaryenWidenLowSVecI8x16ToVecI16x8(void); 610 BINARYEN_API BinaryenOp BinaryenWidenHighSVecI8x16ToVecI16x8(void); 611 BINARYEN_API BinaryenOp BinaryenWidenLowUVecI8x16ToVecI16x8(void); 612 BINARYEN_API BinaryenOp BinaryenWidenHighUVecI8x16ToVecI16x8(void); 613 BINARYEN_API BinaryenOp BinaryenWidenLowSVecI16x8ToVecI32x4(void); 614 BINARYEN_API BinaryenOp BinaryenWidenHighSVecI16x8ToVecI32x4(void); 615 BINARYEN_API BinaryenOp BinaryenWidenLowUVecI16x8ToVecI32x4(void); 616 BINARYEN_API BinaryenOp BinaryenWidenHighUVecI16x8ToVecI32x4(void); 617 BINARYEN_API BinaryenOp BinaryenSwizzleVec8x16(void); 618 619 BINARYEN_REF(Expression); 620 621 // Block: name can be NULL. Specifying BinaryenUndefined() as the 'type' 622 // parameter indicates that the block's type shall be figured out 623 // automatically instead of explicitly providing it. This conforms 624 // to the behavior before the 'type' parameter has been introduced. 625 BINARYEN_API BinaryenExpressionRef 626 BinaryenBlock(BinaryenModuleRef module, 627 const char* name, 628 BinaryenExpressionRef* children, 629 BinaryenIndex numChildren, 630 BinaryenType type); 631 // If: ifFalse can be NULL 632 BINARYEN_API BinaryenExpressionRef BinaryenIf(BinaryenModuleRef module, 633 BinaryenExpressionRef condition, 634 BinaryenExpressionRef ifTrue, 635 BinaryenExpressionRef ifFalse); 636 BINARYEN_API BinaryenExpressionRef BinaryenLoop(BinaryenModuleRef module, 637 const char* in, 638 BinaryenExpressionRef body); 639 // Break: value and condition can be NULL 640 BINARYEN_API BinaryenExpressionRef 641 BinaryenBreak(BinaryenModuleRef module, 642 const char* name, 643 BinaryenExpressionRef condition, 644 BinaryenExpressionRef value); 645 // Switch: value can be NULL 646 BINARYEN_API BinaryenExpressionRef 647 BinaryenSwitch(BinaryenModuleRef module, 648 const char** names, 649 BinaryenIndex numNames, 650 const char* defaultName, 651 BinaryenExpressionRef condition, 652 BinaryenExpressionRef value); 653 // Call: Note the 'returnType' parameter. You must declare the 654 // type returned by the function being called, as that 655 // function might not have been created yet, so we don't 656 // know what it is. 657 BINARYEN_API BinaryenExpressionRef BinaryenCall(BinaryenModuleRef module, 658 const char* target, 659 BinaryenExpressionRef* operands, 660 BinaryenIndex numOperands, 661 BinaryenType returnType); 662 BINARYEN_API BinaryenExpressionRef 663 BinaryenCallIndirect(BinaryenModuleRef module, 664 BinaryenExpressionRef target, 665 BinaryenExpressionRef* operands, 666 BinaryenIndex numOperands, 667 BinaryenType params, 668 BinaryenType results); 669 BINARYEN_API BinaryenExpressionRef 670 BinaryenReturnCall(BinaryenModuleRef module, 671 const char* target, 672 BinaryenExpressionRef* operands, 673 BinaryenIndex numOperands, 674 BinaryenType returnType); 675 BINARYEN_API BinaryenExpressionRef 676 BinaryenReturnCallIndirect(BinaryenModuleRef module, 677 BinaryenExpressionRef target, 678 BinaryenExpressionRef* operands, 679 BinaryenIndex numOperands, 680 BinaryenType params, 681 BinaryenType results); 682 683 // LocalGet: Note the 'type' parameter. It might seem redundant, since the 684 // local at that index must have a type. However, this API lets you 685 // build code "top-down": create a node, then its parents, and so 686 // on, and finally create the function at the end. (Note that in fact 687 // you do not mention a function when creating ExpressionRefs, only 688 // a module.) And since LocalGet is a leaf node, we need to be told 689 // its type. (Other nodes detect their type either from their 690 // type or their opcode, or failing that, their children. But 691 // LocalGet has no children, it is where a "stream" of type info 692 // begins.) 693 // Note also that the index of a local can refer to a param or 694 // a var, that is, either a parameter to the function or a variable 695 // declared when you call BinaryenAddFunction. See BinaryenAddFunction 696 // for more details. 697 BINARYEN_API BinaryenExpressionRef BinaryenLocalGet(BinaryenModuleRef module, 698 BinaryenIndex index, 699 BinaryenType type); 700 BINARYEN_API BinaryenExpressionRef BinaryenLocalSet( 701 BinaryenModuleRef module, BinaryenIndex index, BinaryenExpressionRef value); 702 BINARYEN_API BinaryenExpressionRef BinaryenLocalTee(BinaryenModuleRef module, 703 BinaryenIndex index, 704 BinaryenExpressionRef value, 705 BinaryenType type); 706 BINARYEN_API BinaryenExpressionRef BinaryenGlobalGet(BinaryenModuleRef module, 707 const char* name, 708 BinaryenType type); 709 BINARYEN_API BinaryenExpressionRef BinaryenGlobalSet( 710 BinaryenModuleRef module, const char* name, BinaryenExpressionRef value); 711 // Load: align can be 0, in which case it will be the natural alignment (equal 712 // to bytes) 713 BINARYEN_API BinaryenExpressionRef BinaryenLoad(BinaryenModuleRef module, 714 uint32_t bytes, 715 int8_t signed_, 716 uint32_t offset, 717 uint32_t align, 718 BinaryenType type, 719 BinaryenExpressionRef ptr); 720 // Store: align can be 0, in which case it will be the natural alignment (equal 721 // to bytes) 722 BINARYEN_API BinaryenExpressionRef BinaryenStore(BinaryenModuleRef module, 723 uint32_t bytes, 724 uint32_t offset, 725 uint32_t align, 726 BinaryenExpressionRef ptr, 727 BinaryenExpressionRef value, 728 BinaryenType type); 729 BINARYEN_API BinaryenExpressionRef BinaryenConst(BinaryenModuleRef module, 730 struct BinaryenLiteral value); 731 BINARYEN_API BinaryenExpressionRef BinaryenUnary(BinaryenModuleRef module, 732 BinaryenOp op, 733 BinaryenExpressionRef value); 734 BINARYEN_API BinaryenExpressionRef BinaryenBinary(BinaryenModuleRef module, 735 BinaryenOp op, 736 BinaryenExpressionRef left, 737 BinaryenExpressionRef right); 738 BINARYEN_API BinaryenExpressionRef 739 BinaryenSelect(BinaryenModuleRef module, 740 BinaryenExpressionRef condition, 741 BinaryenExpressionRef ifTrue, 742 BinaryenExpressionRef ifFalse, 743 BinaryenType type); 744 BINARYEN_API BinaryenExpressionRef BinaryenDrop(BinaryenModuleRef module, 745 BinaryenExpressionRef value); 746 // Return: value can be NULL 747 BINARYEN_API BinaryenExpressionRef BinaryenReturn(BinaryenModuleRef module, 748 BinaryenExpressionRef value); 749 BINARYEN_API BinaryenExpressionRef BinaryenMemorySize(BinaryenModuleRef module); 750 BINARYEN_API BinaryenExpressionRef 751 BinaryenMemoryGrow(BinaryenModuleRef module, BinaryenExpressionRef delta); 752 BINARYEN_API BinaryenExpressionRef BinaryenNop(BinaryenModuleRef module); 753 BINARYEN_API BinaryenExpressionRef 754 BinaryenUnreachable(BinaryenModuleRef module); 755 BINARYEN_API BinaryenExpressionRef 756 BinaryenAtomicLoad(BinaryenModuleRef module, 757 uint32_t bytes, 758 uint32_t offset, 759 BinaryenType type, 760 BinaryenExpressionRef ptr); 761 BINARYEN_API BinaryenExpressionRef 762 BinaryenAtomicStore(BinaryenModuleRef module, 763 uint32_t bytes, 764 uint32_t offset, 765 BinaryenExpressionRef ptr, 766 BinaryenExpressionRef value, 767 BinaryenType type); 768 BINARYEN_API BinaryenExpressionRef 769 BinaryenAtomicRMW(BinaryenModuleRef module, 770 BinaryenOp op, 771 BinaryenIndex bytes, 772 BinaryenIndex offset, 773 BinaryenExpressionRef ptr, 774 BinaryenExpressionRef value, 775 BinaryenType type); 776 BINARYEN_API BinaryenExpressionRef 777 BinaryenAtomicCmpxchg(BinaryenModuleRef module, 778 BinaryenIndex bytes, 779 BinaryenIndex offset, 780 BinaryenExpressionRef ptr, 781 BinaryenExpressionRef expected, 782 BinaryenExpressionRef replacement, 783 BinaryenType type); 784 BINARYEN_API BinaryenExpressionRef 785 BinaryenAtomicWait(BinaryenModuleRef module, 786 BinaryenExpressionRef ptr, 787 BinaryenExpressionRef expected, 788 BinaryenExpressionRef timeout, 789 BinaryenType type); 790 BINARYEN_API BinaryenExpressionRef 791 BinaryenAtomicNotify(BinaryenModuleRef module, 792 BinaryenExpressionRef ptr, 793 BinaryenExpressionRef notifyCount); 794 BINARYEN_API BinaryenExpressionRef 795 BinaryenAtomicFence(BinaryenModuleRef module); 796 BINARYEN_API BinaryenExpressionRef 797 BinaryenSIMDExtract(BinaryenModuleRef module, 798 BinaryenOp op, 799 BinaryenExpressionRef vec, 800 uint8_t index); 801 BINARYEN_API BinaryenExpressionRef 802 BinaryenSIMDReplace(BinaryenModuleRef module, 803 BinaryenOp op, 804 BinaryenExpressionRef vec, 805 uint8_t index, 806 BinaryenExpressionRef value); 807 BINARYEN_API BinaryenExpressionRef 808 BinaryenSIMDShuffle(BinaryenModuleRef module, 809 BinaryenExpressionRef left, 810 BinaryenExpressionRef right, 811 const uint8_t mask[16]); 812 BINARYEN_API BinaryenExpressionRef BinaryenSIMDTernary(BinaryenModuleRef module, 813 BinaryenOp op, 814 BinaryenExpressionRef a, 815 BinaryenExpressionRef b, 816 BinaryenExpressionRef c); 817 BINARYEN_API BinaryenExpressionRef 818 BinaryenSIMDShift(BinaryenModuleRef module, 819 BinaryenOp op, 820 BinaryenExpressionRef vec, 821 BinaryenExpressionRef shift); 822 BINARYEN_API BinaryenExpressionRef BinaryenSIMDLoad(BinaryenModuleRef module, 823 BinaryenOp op, 824 uint32_t offset, 825 uint32_t align, 826 BinaryenExpressionRef ptr); 827 BINARYEN_API BinaryenExpressionRef 828 BinaryenMemoryInit(BinaryenModuleRef module, 829 uint32_t segment, 830 BinaryenExpressionRef dest, 831 BinaryenExpressionRef offset, 832 BinaryenExpressionRef size); 833 BINARYEN_API BinaryenExpressionRef BinaryenDataDrop(BinaryenModuleRef module, 834 uint32_t segment); 835 BINARYEN_API BinaryenExpressionRef 836 BinaryenMemoryCopy(BinaryenModuleRef module, 837 BinaryenExpressionRef dest, 838 BinaryenExpressionRef source, 839 BinaryenExpressionRef size); 840 BINARYEN_API BinaryenExpressionRef 841 BinaryenMemoryFill(BinaryenModuleRef module, 842 BinaryenExpressionRef dest, 843 BinaryenExpressionRef value, 844 BinaryenExpressionRef size); 845 BINARYEN_API BinaryenExpressionRef BinaryenRefNull(BinaryenModuleRef module, 846 BinaryenType type); 847 BINARYEN_API BinaryenExpressionRef 848 BinaryenRefIsNull(BinaryenModuleRef module, BinaryenExpressionRef value); 849 BINARYEN_API BinaryenExpressionRef BinaryenRefFunc(BinaryenModuleRef module, 850 const char* func); 851 BINARYEN_API BinaryenExpressionRef BinaryenRefEq(BinaryenModuleRef module, 852 BinaryenExpressionRef left, 853 BinaryenExpressionRef right); 854 BINARYEN_API BinaryenExpressionRef BinaryenTry(BinaryenModuleRef module, 855 BinaryenExpressionRef body, 856 BinaryenExpressionRef catchBody); 857 BINARYEN_API BinaryenExpressionRef 858 BinaryenThrow(BinaryenModuleRef module, 859 const char* event, 860 BinaryenExpressionRef* operands, 861 BinaryenIndex numOperands); 862 BINARYEN_API BinaryenExpressionRef 863 BinaryenRethrow(BinaryenModuleRef module, BinaryenExpressionRef exnref); 864 BINARYEN_API BinaryenExpressionRef 865 BinaryenBrOnExn(BinaryenModuleRef module, 866 const char* name, 867 const char* eventName, 868 BinaryenExpressionRef exnref); 869 BINARYEN_API BinaryenExpressionRef 870 BinaryenTupleMake(BinaryenModuleRef module, 871 BinaryenExpressionRef* operands, 872 BinaryenIndex numOperands); 873 BINARYEN_API BinaryenExpressionRef BinaryenTupleExtract( 874 BinaryenModuleRef module, BinaryenExpressionRef tuple, BinaryenIndex index); 875 BINARYEN_API BinaryenExpressionRef BinaryenPop(BinaryenModuleRef module, 876 BinaryenType type); 877 BINARYEN_API BinaryenExpressionRef BinaryenI31New(BinaryenModuleRef module, 878 BinaryenExpressionRef value); 879 BINARYEN_API BinaryenExpressionRef BinaryenI31Get(BinaryenModuleRef module, 880 BinaryenExpressionRef i31, 881 int signed_); 882 // TODO (gc): ref.test 883 // TODO (gc): ref.cast 884 // TODO (gc): br_on_cast 885 // TODO (gc): rtt.canon 886 // TODO (gc): rtt.sub 887 // TODO (gc): struct.new 888 // TODO (gc): struct.get 889 // TODO (gc): struct.set 890 // TODO (gc): array.new 891 // TODO (gc): array.get 892 // TODO (gc): array.set 893 // TODO (gc): array.len 894 895 // Expression 896 897 // Gets the id (kind) of the given expression. 898 BINARYEN_API BinaryenExpressionId 899 BinaryenExpressionGetId(BinaryenExpressionRef expr); 900 // Gets the type of the given expression. 901 BINARYEN_API BinaryenType BinaryenExpressionGetType(BinaryenExpressionRef expr); 902 // Sets the type of the given expression. 903 BINARYEN_API void BinaryenExpressionSetType(BinaryenExpressionRef expr, 904 BinaryenType type); 905 // Prints text format of the given expression to stdout. 906 BINARYEN_API void BinaryenExpressionPrint(BinaryenExpressionRef expr); 907 // Re-finalizes an expression after it has been modified. 908 BINARYEN_API void BinaryenExpressionFinalize(BinaryenExpressionRef expr); 909 // Makes a deep copy of the given expression. 910 BINARYEN_API BinaryenExpressionRef 911 BinaryenExpressionCopy(BinaryenExpressionRef expr, BinaryenModuleRef module); 912 913 // Block 914 915 // Gets the name (label) of a `block` expression. 916 BINARYEN_API const char* BinaryenBlockGetName(BinaryenExpressionRef expr); 917 // Sets the name (label) of a `block` expression. 918 BINARYEN_API void BinaryenBlockSetName(BinaryenExpressionRef expr, 919 const char* name); 920 // Gets the number of child expressions of a `block` expression. 921 BINARYEN_API BinaryenIndex 922 BinaryenBlockGetNumChildren(BinaryenExpressionRef expr); 923 // Gets the child expression at the specified index of a `block` expression. 924 BINARYEN_API BinaryenExpressionRef 925 BinaryenBlockGetChildAt(BinaryenExpressionRef expr, BinaryenIndex index); 926 // Sets (replaces) the child expression at the specified index of a `block` 927 // expression. 928 BINARYEN_API void BinaryenBlockSetChildAt(BinaryenExpressionRef expr, 929 BinaryenIndex index, 930 BinaryenExpressionRef childExpr); 931 // Appends a child expression to a `block` expression, returning its insertion 932 // index. 933 BINARYEN_API BinaryenIndex BinaryenBlockAppendChild( 934 BinaryenExpressionRef expr, BinaryenExpressionRef childExpr); 935 // Inserts a child expression at the specified index of a `block` expression, 936 // moving existing children including the one previously at that index one index 937 // up. 938 BINARYEN_API void BinaryenBlockInsertChildAt(BinaryenExpressionRef expr, 939 BinaryenIndex index, 940 BinaryenExpressionRef childExpr); 941 // Removes the child expression at the specified index of a `block` expression, 942 // moving all subsequent children one index down. Returns the child expression. 943 BINARYEN_API BinaryenExpressionRef 944 BinaryenBlockRemoveChildAt(BinaryenExpressionRef expr, BinaryenIndex index); 945 946 // If 947 948 // Gets the condition expression of an `if` expression. 949 BINARYEN_API BinaryenExpressionRef 950 BinaryenIfGetCondition(BinaryenExpressionRef expr); 951 // Sets the condition expression of an `if` expression. 952 BINARYEN_API void BinaryenIfSetCondition(BinaryenExpressionRef expr, 953 BinaryenExpressionRef condExpr); 954 // Gets the ifTrue (then) expression of an `if` expression. 955 BINARYEN_API BinaryenExpressionRef 956 BinaryenIfGetIfTrue(BinaryenExpressionRef expr); 957 // Sets the ifTrue (then) expression of an `if` expression. 958 BINARYEN_API void BinaryenIfSetIfTrue(BinaryenExpressionRef expr, 959 BinaryenExpressionRef ifTrueExpr); 960 // Gets the ifFalse (else) expression, if any, of an `if` expression. 961 BINARYEN_API BinaryenExpressionRef 962 BinaryenIfGetIfFalse(BinaryenExpressionRef expr); 963 // Sets the ifFalse (else) expression, if any, of an `if` expression. 964 BINARYEN_API void BinaryenIfSetIfFalse(BinaryenExpressionRef expr, 965 BinaryenExpressionRef ifFalseExpr); 966 967 // Loop 968 969 // Gets the name (label) of a `loop` expression. 970 BINARYEN_API const char* BinaryenLoopGetName(BinaryenExpressionRef expr); 971 // Sets the name (label) of a `loop` expression. 972 BINARYEN_API void BinaryenLoopSetName(BinaryenExpressionRef expr, 973 const char* name); 974 // Gets the body expression of a `loop` expression. 975 BINARYEN_API BinaryenExpressionRef 976 BinaryenLoopGetBody(BinaryenExpressionRef expr); 977 // Sets the body expression of a `loop` expression. 978 BINARYEN_API void BinaryenLoopSetBody(BinaryenExpressionRef expr, 979 BinaryenExpressionRef bodyExpr); 980 981 // Break 982 983 // Gets the name (target label) of a `br` or `br_if` expression. 984 BINARYEN_API const char* BinaryenBreakGetName(BinaryenExpressionRef expr); 985 // Sets the name (target label) of a `br` or `br_if` expression. 986 BINARYEN_API void BinaryenBreakSetName(BinaryenExpressionRef expr, 987 const char* name); 988 // Gets the condition expression, if any, of a `br_if` expression. No condition 989 // indicates a `br` expression. 990 BINARYEN_API BinaryenExpressionRef 991 BinaryenBreakGetCondition(BinaryenExpressionRef expr); 992 // Sets the condition expression, if any, of a `br_if` expression. No condition 993 // makes it a `br` expression. 994 BINARYEN_API void BinaryenBreakSetCondition(BinaryenExpressionRef expr, 995 BinaryenExpressionRef condExpr); 996 // Gets the value expression, if any, of a `br` or `br_if` expression. 997 BINARYEN_API BinaryenExpressionRef 998 BinaryenBreakGetValue(BinaryenExpressionRef expr); 999 // Sets the value expression, if any, of a `br` or `br_if` expression. 1000 BINARYEN_API void BinaryenBreakSetValue(BinaryenExpressionRef expr, 1001 BinaryenExpressionRef valueExpr); 1002 1003 // Switch 1004 1005 // Gets the number of names (target labels) of a `br_table` expression. 1006 BINARYEN_API BinaryenIndex 1007 BinaryenSwitchGetNumNames(BinaryenExpressionRef expr); 1008 // Gets the name (target label) at the specified index of a `br_table` 1009 // expression. 1010 BINARYEN_API const char* BinaryenSwitchGetNameAt(BinaryenExpressionRef expr, 1011 BinaryenIndex index); 1012 // Sets the name (target label) at the specified index of a `br_table` 1013 // expression. 1014 BINARYEN_API void BinaryenSwitchSetNameAt(BinaryenExpressionRef expr, 1015 BinaryenIndex index, 1016 const char* name); 1017 // Appends a name to a `br_table` expression, returning its insertion index. 1018 BINARYEN_API BinaryenIndex BinaryenSwitchAppendName(BinaryenExpressionRef expr, 1019 const char* name); 1020 // Inserts a name at the specified index of a `br_table` expression, moving 1021 // existing names including the one previously at that index one index up. 1022 BINARYEN_API void BinaryenSwitchInsertNameAt(BinaryenExpressionRef expr, 1023 BinaryenIndex index, 1024 const char* name); 1025 // Removes the name at the specified index of a `br_table` expression, moving 1026 // all subsequent names one index down. Returns the name. 1027 BINARYEN_API const char* BinaryenSwitchRemoveNameAt(BinaryenExpressionRef expr, 1028 BinaryenIndex index); 1029 // Gets the default name (target label), if any, of a `br_table` expression. 1030 BINARYEN_API const char* 1031 BinaryenSwitchGetDefaultName(BinaryenExpressionRef expr); 1032 // Sets the default name (target label), if any, of a `br_table` expression. 1033 BINARYEN_API void BinaryenSwitchSetDefaultName(BinaryenExpressionRef expr, 1034 const char* name); 1035 // Gets the condition expression of a `br_table` expression. 1036 BINARYEN_API BinaryenExpressionRef 1037 BinaryenSwitchGetCondition(BinaryenExpressionRef expr); 1038 // Sets the condition expression of a `br_table` expression. 1039 BINARYEN_API void BinaryenSwitchSetCondition(BinaryenExpressionRef expr, 1040 BinaryenExpressionRef condExpr); 1041 // Gets the value expression, if any, of a `br_table` expression. 1042 BINARYEN_API BinaryenExpressionRef 1043 BinaryenSwitchGetValue(BinaryenExpressionRef expr); 1044 // Sets the value expression, if any, of a `br_table` expression. 1045 BINARYEN_API void BinaryenSwitchSetValue(BinaryenExpressionRef expr, 1046 BinaryenExpressionRef valueExpr); 1047 1048 // Call 1049 1050 // Gets the target function name of a `call` expression. 1051 BINARYEN_API const char* BinaryenCallGetTarget(BinaryenExpressionRef expr); 1052 // Sets the target function name of a `call` expression. 1053 BINARYEN_API void BinaryenCallSetTarget(BinaryenExpressionRef expr, 1054 const char* target); 1055 // Gets the number of operands of a `call` expression. 1056 BINARYEN_API BinaryenIndex 1057 BinaryenCallGetNumOperands(BinaryenExpressionRef expr); 1058 // Gets the operand expression at the specified index of a `call` expression. 1059 BINARYEN_API BinaryenExpressionRef 1060 BinaryenCallGetOperandAt(BinaryenExpressionRef expr, BinaryenIndex index); 1061 // Sets the operand expression at the specified index of a `call` expression. 1062 BINARYEN_API void BinaryenCallSetOperandAt(BinaryenExpressionRef expr, 1063 BinaryenIndex index, 1064 BinaryenExpressionRef operandExpr); 1065 // Appends an operand expression to a `call` expression, returning its insertion 1066 // index. 1067 BINARYEN_API BinaryenIndex BinaryenCallAppendOperand( 1068 BinaryenExpressionRef expr, BinaryenExpressionRef operandExpr); 1069 // Inserts an operand expression at the specified index of a `call` expression, 1070 // moving existing operands including the one previously at that index one index 1071 // up. 1072 BINARYEN_API void 1073 BinaryenCallInsertOperandAt(BinaryenExpressionRef expr, 1074 BinaryenIndex index, 1075 BinaryenExpressionRef operandExpr); 1076 // Removes the operand expression at the specified index of a `call` expression, 1077 // moving all subsequent operands one index down. Returns the operand 1078 // expression. 1079 BINARYEN_API BinaryenExpressionRef 1080 BinaryenCallRemoveOperandAt(BinaryenExpressionRef expr, BinaryenIndex index); 1081 // Gets whether the specified `call` expression is a tail call. 1082 BINARYEN_API int BinaryenCallIsReturn(BinaryenExpressionRef expr); 1083 // Sets whether the specified `call` expression is a tail call. 1084 BINARYEN_API void BinaryenCallSetReturn(BinaryenExpressionRef expr, 1085 int isReturn); 1086 1087 // CallIndirect 1088 1089 // Gets the target expression of a `call_indirect` expression. 1090 BINARYEN_API BinaryenExpressionRef 1091 BinaryenCallIndirectGetTarget(BinaryenExpressionRef expr); 1092 // Sets the target expression of a `call_indirect` expression. 1093 BINARYEN_API void 1094 BinaryenCallIndirectSetTarget(BinaryenExpressionRef expr, 1095 BinaryenExpressionRef targetExpr); 1096 // Gets the number of operands of a `call_indirect` expression. 1097 BINARYEN_API BinaryenIndex 1098 BinaryenCallIndirectGetNumOperands(BinaryenExpressionRef expr); 1099 // Gets the operand expression at the specified index of a `call_indirect` 1100 // expression. 1101 BINARYEN_API BinaryenExpressionRef BinaryenCallIndirectGetOperandAt( 1102 BinaryenExpressionRef expr, BinaryenIndex index); 1103 // Sets the operand expression at the specified index of a `call_indirect` 1104 // expression. 1105 BINARYEN_API void 1106 BinaryenCallIndirectSetOperandAt(BinaryenExpressionRef expr, 1107 BinaryenIndex index, 1108 BinaryenExpressionRef operandExpr); 1109 // Appends an operand expression to a `call_indirect` expression, returning its 1110 // insertion index. 1111 BINARYEN_API BinaryenIndex BinaryenCallIndirectAppendOperand( 1112 BinaryenExpressionRef expr, BinaryenExpressionRef operandExpr); 1113 // Inserts an operand expression at the specified index of a `call_indirect` 1114 // expression, moving existing operands including the one previously at that 1115 // index one index up. 1116 BINARYEN_API void 1117 BinaryenCallIndirectInsertOperandAt(BinaryenExpressionRef expr, 1118 BinaryenIndex index, 1119 BinaryenExpressionRef operandExpr); 1120 // Removes the operand expression at the specified index of a `call_indirect` 1121 // expression, moving all subsequent operands one index down. Returns the 1122 // operand expression. 1123 BINARYEN_API BinaryenExpressionRef BinaryenCallIndirectRemoveOperandAt( 1124 BinaryenExpressionRef expr, BinaryenIndex index); 1125 // Gets whether the specified `call_indirect` expression is a tail call. 1126 BINARYEN_API int BinaryenCallIndirectIsReturn(BinaryenExpressionRef expr); 1127 // Sets whether the specified `call_indirect` expression is a tail call. 1128 BINARYEN_API void BinaryenCallIndirectSetReturn(BinaryenExpressionRef expr, 1129 int isReturn); 1130 // Gets the parameter types of the specified `call_indirect` expression. 1131 BINARYEN_API BinaryenType 1132 BinaryenCallIndirectGetParams(BinaryenExpressionRef expr); 1133 // Sets the parameter types of the specified `call_indirect` expression. 1134 BINARYEN_API void BinaryenCallIndirectSetParams(BinaryenExpressionRef expr, 1135 BinaryenType params); 1136 // Gets the result types of the specified `call_indirect` expression. 1137 BINARYEN_API BinaryenType 1138 BinaryenCallIndirectGetResults(BinaryenExpressionRef expr); 1139 // Sets the result types of the specified `call_indirect` expression. 1140 BINARYEN_API void BinaryenCallIndirectSetResults(BinaryenExpressionRef expr, 1141 BinaryenType params); 1142 1143 // LocalGet 1144 1145 // Gets the local index of a `local.get` expression. 1146 BINARYEN_API BinaryenIndex BinaryenLocalGetGetIndex(BinaryenExpressionRef expr); 1147 // Sets the local index of a `local.get` expression. 1148 BINARYEN_API void BinaryenLocalGetSetIndex(BinaryenExpressionRef expr, 1149 BinaryenIndex index); 1150 1151 // LocalSet 1152 1153 // Gets whether a `local.set` tees its value (is a `local.tee`). True if the 1154 // expression has a type other than `none`. 1155 BINARYEN_API int BinaryenLocalSetIsTee(BinaryenExpressionRef expr); 1156 // Gets the local index of a `local.set` or `local.tee` expression. 1157 BINARYEN_API BinaryenIndex BinaryenLocalSetGetIndex(BinaryenExpressionRef expr); 1158 // Sets the local index of a `local.set` or `local.tee` expression. 1159 BINARYEN_API void BinaryenLocalSetSetIndex(BinaryenExpressionRef expr, 1160 BinaryenIndex index); 1161 // Gets the value expression of a `local.set` or `local.tee` expression. 1162 BINARYEN_API BinaryenExpressionRef 1163 BinaryenLocalSetGetValue(BinaryenExpressionRef expr); 1164 // Sets the value expression of a `local.set` or `local.tee` expression. 1165 BINARYEN_API void BinaryenLocalSetSetValue(BinaryenExpressionRef expr, 1166 BinaryenExpressionRef valueExpr); 1167 1168 // GlobalGet 1169 1170 // Gets the name of the global being accessed by a `global.get` expression. 1171 BINARYEN_API const char* BinaryenGlobalGetGetName(BinaryenExpressionRef expr); 1172 // Sets the name of the global being accessed by a `global.get` expression. 1173 BINARYEN_API void BinaryenGlobalGetSetName(BinaryenExpressionRef expr, 1174 const char* name); 1175 1176 // GlobalSet 1177 1178 // Gets the name of the global being accessed by a `global.set` expression. 1179 BINARYEN_API const char* BinaryenGlobalSetGetName(BinaryenExpressionRef expr); 1180 // Sets the name of the global being accessed by a `global.set` expression. 1181 BINARYEN_API void BinaryenGlobalSetSetName(BinaryenExpressionRef expr, 1182 const char* name); 1183 // Gets the value expression of a `global.set` expression. 1184 BINARYEN_API BinaryenExpressionRef 1185 BinaryenGlobalSetGetValue(BinaryenExpressionRef expr); 1186 // Sets the value expression of a `global.set` expression. 1187 BINARYEN_API void BinaryenGlobalSetSetValue(BinaryenExpressionRef expr, 1188 BinaryenExpressionRef valueExpr); 1189 1190 // MemoryGrow 1191 1192 // Gets the delta of a `memory.grow` expression. 1193 BINARYEN_API BinaryenExpressionRef 1194 BinaryenMemoryGrowGetDelta(BinaryenExpressionRef expr); 1195 // Sets the delta of a `memory.grow` expression. 1196 BINARYEN_API void BinaryenMemoryGrowSetDelta(BinaryenExpressionRef expr, 1197 BinaryenExpressionRef delta); 1198 1199 // Load 1200 1201 // Gets whether a `load` expression is atomic (is an `atomic.load`). 1202 BINARYEN_API int BinaryenLoadIsAtomic(BinaryenExpressionRef expr); 1203 // Sets whether a `load` expression is atomic (is an `atomic.load`). 1204 BINARYEN_API void BinaryenLoadSetAtomic(BinaryenExpressionRef expr, 1205 int isAtomic); 1206 // Gets whether a `load` expression operates on a signed value (`_s`). 1207 BINARYEN_API int BinaryenLoadIsSigned(BinaryenExpressionRef expr); 1208 // Sets whether a `load` expression operates on a signed value (`_s`). 1209 BINARYEN_API void BinaryenLoadSetSigned(BinaryenExpressionRef expr, 1210 int isSigned); 1211 // Gets the constant offset of a `load` expression. 1212 BINARYEN_API uint32_t BinaryenLoadGetOffset(BinaryenExpressionRef expr); 1213 // Sets the constant offset of a `load` expression. 1214 BINARYEN_API void BinaryenLoadSetOffset(BinaryenExpressionRef expr, 1215 uint32_t offset); 1216 // Gets the number of bytes loaded by a `load` expression. 1217 BINARYEN_API uint32_t BinaryenLoadGetBytes(BinaryenExpressionRef expr); 1218 // Sets the number of bytes loaded by a `load` expression. 1219 BINARYEN_API void BinaryenLoadSetBytes(BinaryenExpressionRef expr, 1220 uint32_t bytes); 1221 // Gets the byte alignment of a `load` expression. 1222 BINARYEN_API uint32_t BinaryenLoadGetAlign(BinaryenExpressionRef expr); 1223 // Sets the byte alignment of a `load` expression. 1224 BINARYEN_API void BinaryenLoadSetAlign(BinaryenExpressionRef expr, 1225 uint32_t align); 1226 // Gets the pointer expression of a `load` expression. 1227 BINARYEN_API BinaryenExpressionRef 1228 BinaryenLoadGetPtr(BinaryenExpressionRef expr); 1229 // Sets the pointer expression of a `load` expression. 1230 BINARYEN_API void BinaryenLoadSetPtr(BinaryenExpressionRef expr, 1231 BinaryenExpressionRef ptrExpr); 1232 1233 // Store 1234 1235 // Gets whether a `store` expression is atomic (is an `atomic.store`). 1236 BINARYEN_API int BinaryenStoreIsAtomic(BinaryenExpressionRef expr); 1237 // Sets whether a `store` expression is atomic (is an `atomic.store`). 1238 BINARYEN_API void BinaryenStoreSetAtomic(BinaryenExpressionRef expr, 1239 int isAtomic); 1240 // Gets the number of bytes stored by a `store` expression. 1241 BINARYEN_API uint32_t BinaryenStoreGetBytes(BinaryenExpressionRef expr); 1242 // Sets the number of bytes stored by a `store` expression. 1243 BINARYEN_API void BinaryenStoreSetBytes(BinaryenExpressionRef expr, 1244 uint32_t bytes); 1245 // Gets the constant offset of a `store` expression. 1246 BINARYEN_API uint32_t BinaryenStoreGetOffset(BinaryenExpressionRef expr); 1247 // Sets the constant offset of a `store` expression. 1248 BINARYEN_API void BinaryenStoreSetOffset(BinaryenExpressionRef expr, 1249 uint32_t offset); 1250 // Gets the byte alignment of a `store` expression. 1251 BINARYEN_API uint32_t BinaryenStoreGetAlign(BinaryenExpressionRef expr); 1252 // Sets the byte alignment of a `store` expression. 1253 BINARYEN_API void BinaryenStoreSetAlign(BinaryenExpressionRef expr, 1254 uint32_t align); 1255 // Gets the pointer expression of a `store` expression. 1256 BINARYEN_API BinaryenExpressionRef 1257 BinaryenStoreGetPtr(BinaryenExpressionRef expr); 1258 // Sets the pointer expression of a `store` expression. 1259 BINARYEN_API void BinaryenStoreSetPtr(BinaryenExpressionRef expr, 1260 BinaryenExpressionRef ptrExpr); 1261 // Gets the value expression of a `store` expression. 1262 BINARYEN_API BinaryenExpressionRef 1263 BinaryenStoreGetValue(BinaryenExpressionRef expr); 1264 // Sets the value expression of a `store` expression. 1265 BINARYEN_API void BinaryenStoreSetValue(BinaryenExpressionRef expr, 1266 BinaryenExpressionRef valueExpr); 1267 // Gets the value type of a `store` expression. 1268 BINARYEN_API BinaryenType BinaryenStoreGetValueType(BinaryenExpressionRef expr); 1269 // Sets the value type of a `store` expression. 1270 BINARYEN_API void BinaryenStoreSetValueType(BinaryenExpressionRef expr, 1271 BinaryenType valueType); 1272 1273 // Const 1274 1275 // Gets the 32-bit integer value of an `i32.const` expression. 1276 BINARYEN_API int32_t BinaryenConstGetValueI32(BinaryenExpressionRef expr); 1277 // Sets the 32-bit integer value of an `i32.const` expression. 1278 BINARYEN_API void BinaryenConstSetValueI32(BinaryenExpressionRef expr, 1279 int32_t value); 1280 // Gets the 64-bit integer value of an `i64.const` expression. 1281 BINARYEN_API int64_t BinaryenConstGetValueI64(BinaryenExpressionRef expr); 1282 // Sets the 64-bit integer value of an `i64.const` expression. 1283 BINARYEN_API void BinaryenConstSetValueI64(BinaryenExpressionRef expr, 1284 int64_t value); 1285 // Gets the low 32-bits of the 64-bit integer value of an `i64.const` 1286 // expression. 1287 BINARYEN_API int32_t BinaryenConstGetValueI64Low(BinaryenExpressionRef expr); 1288 // Sets the low 32-bits of the 64-bit integer value of an `i64.const` 1289 // expression. 1290 BINARYEN_API void BinaryenConstSetValueI64Low(BinaryenExpressionRef expr, 1291 int32_t valueLow); 1292 // Gets the high 32-bits of the 64-bit integer value of an `i64.const` 1293 // expression. 1294 BINARYEN_API int32_t BinaryenConstGetValueI64High(BinaryenExpressionRef expr); 1295 // Sets the high 32-bits of the 64-bit integer value of an `i64.const` 1296 // expression. 1297 BINARYEN_API void BinaryenConstSetValueI64High(BinaryenExpressionRef expr, 1298 int32_t valueHigh); 1299 // Gets the 32-bit float value of a `f32.const` expression. 1300 BINARYEN_API float BinaryenConstGetValueF32(BinaryenExpressionRef expr); 1301 // Sets the 32-bit float value of a `f32.const` expression. 1302 BINARYEN_API void BinaryenConstSetValueF32(BinaryenExpressionRef expr, 1303 float value); 1304 // Gets the 64-bit float (double) value of a `f64.const` expression. 1305 BINARYEN_API double BinaryenConstGetValueF64(BinaryenExpressionRef expr); 1306 // Sets the 64-bit float (double) value of a `f64.const` expression. 1307 BINARYEN_API void BinaryenConstSetValueF64(BinaryenExpressionRef expr, 1308 double value); 1309 // Reads the 128-bit vector value of a `v128.const` expression. 1310 BINARYEN_API void BinaryenConstGetValueV128(BinaryenExpressionRef expr, 1311 uint8_t* out); 1312 // Sets the 128-bit vector value of a `v128.const` expression. 1313 BINARYEN_API void BinaryenConstSetValueV128(BinaryenExpressionRef expr, 1314 const uint8_t value[16]); 1315 1316 // Unary 1317 1318 // Gets the operation being performed by a unary expression. 1319 BINARYEN_API BinaryenOp BinaryenUnaryGetOp(BinaryenExpressionRef expr); 1320 // Sets the operation being performed by a unary expression. 1321 BINARYEN_API void BinaryenUnarySetOp(BinaryenExpressionRef expr, BinaryenOp op); 1322 // Gets the value expression of a unary expression. 1323 BINARYEN_API BinaryenExpressionRef 1324 BinaryenUnaryGetValue(BinaryenExpressionRef expr); 1325 // Sets the value expression of a unary expression. 1326 BINARYEN_API void BinaryenUnarySetValue(BinaryenExpressionRef expr, 1327 BinaryenExpressionRef valueExpr); 1328 1329 // Binary 1330 1331 // Gets the operation being performed by a binary expression. 1332 BINARYEN_API BinaryenOp BinaryenBinaryGetOp(BinaryenExpressionRef expr); 1333 // Sets the operation being performed by a binary expression. 1334 BINARYEN_API void BinaryenBinarySetOp(BinaryenExpressionRef expr, 1335 BinaryenOp op); 1336 // Gets the left expression of a binary expression. 1337 BINARYEN_API BinaryenExpressionRef 1338 BinaryenBinaryGetLeft(BinaryenExpressionRef expr); 1339 // Sets the left expression of a binary expression. 1340 BINARYEN_API void BinaryenBinarySetLeft(BinaryenExpressionRef expr, 1341 BinaryenExpressionRef leftExpr); 1342 // Gets the right expression of a binary expression. 1343 BINARYEN_API BinaryenExpressionRef 1344 BinaryenBinaryGetRight(BinaryenExpressionRef expr); 1345 // Sets the right expression of a binary expression. 1346 BINARYEN_API void BinaryenBinarySetRight(BinaryenExpressionRef expr, 1347 BinaryenExpressionRef rightExpr); 1348 1349 // Select 1350 1351 // Gets the expression becoming selected by a `select` expression if the 1352 // condition turns out true. 1353 BINARYEN_API BinaryenExpressionRef 1354 BinaryenSelectGetIfTrue(BinaryenExpressionRef expr); 1355 // Sets the expression becoming selected by a `select` expression if the 1356 // condition turns out true. 1357 BINARYEN_API void BinaryenSelectSetIfTrue(BinaryenExpressionRef expr, 1358 BinaryenExpressionRef ifTrueExpr); 1359 // Gets the expression becoming selected by a `select` expression if the 1360 // condition turns out false. 1361 BINARYEN_API BinaryenExpressionRef 1362 BinaryenSelectGetIfFalse(BinaryenExpressionRef expr); 1363 // Sets the expression becoming selected by a `select` expression if the 1364 // condition turns out false. 1365 BINARYEN_API void BinaryenSelectSetIfFalse(BinaryenExpressionRef expr, 1366 BinaryenExpressionRef ifFalseExpr); 1367 // Gets the condition expression of a `select` expression. 1368 BINARYEN_API BinaryenExpressionRef 1369 BinaryenSelectGetCondition(BinaryenExpressionRef expr); 1370 // Sets the condition expression of a `select` expression. 1371 BINARYEN_API void BinaryenSelectSetCondition(BinaryenExpressionRef expr, 1372 BinaryenExpressionRef condExpr); 1373 1374 // Drop 1375 1376 // Gets the value expression being dropped by a `drop` expression. 1377 BINARYEN_API BinaryenExpressionRef 1378 BinaryenDropGetValue(BinaryenExpressionRef expr); 1379 // Sets the value expression being dropped by a `drop` expression. 1380 BINARYEN_API void BinaryenDropSetValue(BinaryenExpressionRef expr, 1381 BinaryenExpressionRef valueExpr); 1382 1383 // Return 1384 1385 // Gets the value expression, if any, being returned by a `return` expression. 1386 BINARYEN_API BinaryenExpressionRef 1387 BinaryenReturnGetValue(BinaryenExpressionRef expr); 1388 // Sets the value expression, if any, being returned by a `return` expression. 1389 BINARYEN_API void BinaryenReturnSetValue(BinaryenExpressionRef expr, 1390 BinaryenExpressionRef valueExpr); 1391 1392 // AtomicRMW 1393 1394 // Gets the operation being performed by an atomic read-modify-write expression. 1395 BINARYEN_API BinaryenOp BinaryenAtomicRMWGetOp(BinaryenExpressionRef expr); 1396 // Sets the operation being performed by an atomic read-modify-write expression. 1397 BINARYEN_API void BinaryenAtomicRMWSetOp(BinaryenExpressionRef expr, 1398 BinaryenOp op); 1399 // Gets the number of bytes affected by an atomic read-modify-write expression. 1400 BINARYEN_API uint32_t BinaryenAtomicRMWGetBytes(BinaryenExpressionRef expr); 1401 // Sets the number of bytes affected by an atomic read-modify-write expression. 1402 BINARYEN_API void BinaryenAtomicRMWSetBytes(BinaryenExpressionRef expr, 1403 uint32_t bytes); 1404 // Gets the constant offset of an atomic read-modify-write expression. 1405 BINARYEN_API uint32_t BinaryenAtomicRMWGetOffset(BinaryenExpressionRef expr); 1406 // Sets the constant offset of an atomic read-modify-write expression. 1407 BINARYEN_API void BinaryenAtomicRMWSetOffset(BinaryenExpressionRef expr, 1408 uint32_t offset); 1409 // Gets the pointer expression of an atomic read-modify-write expression. 1410 BINARYEN_API BinaryenExpressionRef 1411 BinaryenAtomicRMWGetPtr(BinaryenExpressionRef expr); 1412 // Sets the pointer expression of an atomic read-modify-write expression. 1413 BINARYEN_API void BinaryenAtomicRMWSetPtr(BinaryenExpressionRef expr, 1414 BinaryenExpressionRef ptrExpr); 1415 // Gets the value expression of an atomic read-modify-write expression. 1416 BINARYEN_API BinaryenExpressionRef 1417 BinaryenAtomicRMWGetValue(BinaryenExpressionRef expr); 1418 // Sets the value expression of an atomic read-modify-write expression. 1419 BINARYEN_API void BinaryenAtomicRMWSetValue(BinaryenExpressionRef expr, 1420 BinaryenExpressionRef valueExpr); 1421 1422 // AtomicCmpxchg 1423 1424 // Gets the number of bytes affected by an atomic compare and exchange 1425 // expression. 1426 BINARYEN_API uint32_t BinaryenAtomicCmpxchgGetBytes(BinaryenExpressionRef expr); 1427 // Sets the number of bytes affected by an atomic compare and exchange 1428 // expression. 1429 BINARYEN_API void BinaryenAtomicCmpxchgSetBytes(BinaryenExpressionRef expr, 1430 uint32_t bytes); 1431 // Gets the constant offset of an atomic compare and exchange expression. 1432 BINARYEN_API uint32_t 1433 BinaryenAtomicCmpxchgGetOffset(BinaryenExpressionRef expr); 1434 // Sets the constant offset of an atomic compare and exchange expression. 1435 BINARYEN_API void BinaryenAtomicCmpxchgSetOffset(BinaryenExpressionRef expr, 1436 uint32_t offset); 1437 // Gets the pointer expression of an atomic compare and exchange expression. 1438 BINARYEN_API BinaryenExpressionRef 1439 BinaryenAtomicCmpxchgGetPtr(BinaryenExpressionRef expr); 1440 // Sets the pointer expression of an atomic compare and exchange expression. 1441 BINARYEN_API void BinaryenAtomicCmpxchgSetPtr(BinaryenExpressionRef expr, 1442 BinaryenExpressionRef ptrExpr); 1443 // Gets the expression representing the expected value of an atomic compare and 1444 // exchange expression. 1445 BINARYEN_API BinaryenExpressionRef 1446 BinaryenAtomicCmpxchgGetExpected(BinaryenExpressionRef expr); 1447 // Sets the expression representing the expected value of an atomic compare and 1448 // exchange expression. 1449 BINARYEN_API void 1450 BinaryenAtomicCmpxchgSetExpected(BinaryenExpressionRef expr, 1451 BinaryenExpressionRef expectedExpr); 1452 // Gets the replacement expression of an atomic compare and exchange expression. 1453 BINARYEN_API BinaryenExpressionRef 1454 BinaryenAtomicCmpxchgGetReplacement(BinaryenExpressionRef expr); 1455 // Sets the replacement expression of an atomic compare and exchange expression. 1456 BINARYEN_API void 1457 BinaryenAtomicCmpxchgSetReplacement(BinaryenExpressionRef expr, 1458 BinaryenExpressionRef replacementExpr); 1459 1460 // AtomicWait 1461 1462 // Gets the pointer expression of an `atomic.wait` expression. 1463 BINARYEN_API BinaryenExpressionRef 1464 BinaryenAtomicWaitGetPtr(BinaryenExpressionRef expr); 1465 // Sets the pointer expression of an `atomic.wait` expression. 1466 BINARYEN_API void BinaryenAtomicWaitSetPtr(BinaryenExpressionRef expr, 1467 BinaryenExpressionRef ptrExpr); 1468 // Gets the expression representing the expected value of an `atomic.wait` 1469 // expression. 1470 BINARYEN_API BinaryenExpressionRef 1471 BinaryenAtomicWaitGetExpected(BinaryenExpressionRef expr); 1472 // Sets the expression representing the expected value of an `atomic.wait` 1473 // expression. 1474 BINARYEN_API void 1475 BinaryenAtomicWaitSetExpected(BinaryenExpressionRef expr, 1476 BinaryenExpressionRef expectedExpr); 1477 // Gets the timeout expression of an `atomic.wait` expression. 1478 BINARYEN_API BinaryenExpressionRef 1479 BinaryenAtomicWaitGetTimeout(BinaryenExpressionRef expr); 1480 // Sets the timeout expression of an `atomic.wait` expression. 1481 BINARYEN_API void 1482 BinaryenAtomicWaitSetTimeout(BinaryenExpressionRef expr, 1483 BinaryenExpressionRef timeoutExpr); 1484 // Gets the expected type of an `atomic.wait` expression. 1485 BINARYEN_API BinaryenType 1486 BinaryenAtomicWaitGetExpectedType(BinaryenExpressionRef expr); 1487 // Sets the expected type of an `atomic.wait` expression. 1488 BINARYEN_API void BinaryenAtomicWaitSetExpectedType(BinaryenExpressionRef expr, 1489 BinaryenType expectedType); 1490 1491 // AtomicNotify 1492 1493 // Gets the pointer expression of an `atomic.notify` expression. 1494 BINARYEN_API BinaryenExpressionRef 1495 BinaryenAtomicNotifyGetPtr(BinaryenExpressionRef expr); 1496 // Sets the pointer expression of an `atomic.notify` expression. 1497 BINARYEN_API void BinaryenAtomicNotifySetPtr(BinaryenExpressionRef expr, 1498 BinaryenExpressionRef ptrExpr); 1499 // Gets the notify count expression of an `atomic.notify` expression. 1500 BINARYEN_API BinaryenExpressionRef 1501 BinaryenAtomicNotifyGetNotifyCount(BinaryenExpressionRef expr); 1502 // Sets the notify count expression of an `atomic.notify` expression. 1503 BINARYEN_API void 1504 BinaryenAtomicNotifySetNotifyCount(BinaryenExpressionRef expr, 1505 BinaryenExpressionRef notifyCountExpr); 1506 1507 // AtomicFence 1508 1509 // Gets the order of an `atomic.fence` expression. 1510 BINARYEN_API uint8_t BinaryenAtomicFenceGetOrder(BinaryenExpressionRef expr); 1511 // Sets the order of an `atomic.fence` expression. 1512 BINARYEN_API void BinaryenAtomicFenceSetOrder(BinaryenExpressionRef expr, 1513 uint8_t order); 1514 1515 // SIMDExtract 1516 1517 // Gets the operation being performed by a SIMD extract expression. 1518 BINARYEN_API BinaryenOp BinaryenSIMDExtractGetOp(BinaryenExpressionRef expr); 1519 // Sets the operation being performed by a SIMD extract expression. 1520 BINARYEN_API void BinaryenSIMDExtractSetOp(BinaryenExpressionRef expr, 1521 BinaryenOp op); 1522 // Gets the vector expression a SIMD extract expression extracts from. 1523 BINARYEN_API BinaryenExpressionRef 1524 BinaryenSIMDExtractGetVec(BinaryenExpressionRef expr); 1525 // Sets the vector expression a SIMD extract expression extracts from. 1526 BINARYEN_API void BinaryenSIMDExtractSetVec(BinaryenExpressionRef expr, 1527 BinaryenExpressionRef vecExpr); 1528 // Gets the index of the extracted lane of a SIMD extract expression. 1529 BINARYEN_API uint8_t BinaryenSIMDExtractGetIndex(BinaryenExpressionRef expr); 1530 // Sets the index of the extracted lane of a SIMD extract expression. 1531 BINARYEN_API void BinaryenSIMDExtractSetIndex(BinaryenExpressionRef expr, 1532 uint8_t index); 1533 1534 // SIMDReplace 1535 1536 // Gets the operation being performed by a SIMD replace expression. 1537 BINARYEN_API BinaryenOp BinaryenSIMDReplaceGetOp(BinaryenExpressionRef expr); 1538 // Sets the operation being performed by a SIMD replace expression. 1539 BINARYEN_API void BinaryenSIMDReplaceSetOp(BinaryenExpressionRef expr, 1540 BinaryenOp op); 1541 // Gets the vector expression a SIMD replace expression replaces in. 1542 BINARYEN_API BinaryenExpressionRef 1543 BinaryenSIMDReplaceGetVec(BinaryenExpressionRef expr); 1544 // Sets the vector expression a SIMD replace expression replaces in. 1545 BINARYEN_API void BinaryenSIMDReplaceSetVec(BinaryenExpressionRef expr, 1546 BinaryenExpressionRef vecExpr); 1547 // Gets the index of the replaced lane of a SIMD replace expression. 1548 BINARYEN_API uint8_t BinaryenSIMDReplaceGetIndex(BinaryenExpressionRef expr); 1549 // Sets the index of the replaced lane of a SIMD replace expression. 1550 BINARYEN_API void BinaryenSIMDReplaceSetIndex(BinaryenExpressionRef expr, 1551 uint8_t index); 1552 // Gets the value expression a SIMD replace expression replaces with. 1553 BINARYEN_API BinaryenExpressionRef 1554 BinaryenSIMDReplaceGetValue(BinaryenExpressionRef expr); 1555 // Sets the value expression a SIMD replace expression replaces with. 1556 BINARYEN_API void BinaryenSIMDReplaceSetValue(BinaryenExpressionRef expr, 1557 BinaryenExpressionRef valueExpr); 1558 1559 // SIMDShuffle 1560 1561 // Gets the left expression of a SIMD shuffle expression. 1562 BINARYEN_API BinaryenExpressionRef 1563 BinaryenSIMDShuffleGetLeft(BinaryenExpressionRef expr); 1564 // Sets the left expression of a SIMD shuffle expression. 1565 BINARYEN_API void BinaryenSIMDShuffleSetLeft(BinaryenExpressionRef expr, 1566 BinaryenExpressionRef leftExpr); 1567 // Gets the right expression of a SIMD shuffle expression. 1568 BINARYEN_API BinaryenExpressionRef 1569 BinaryenSIMDShuffleGetRight(BinaryenExpressionRef expr); 1570 // Sets the right expression of a SIMD shuffle expression. 1571 BINARYEN_API void BinaryenSIMDShuffleSetRight(BinaryenExpressionRef expr, 1572 BinaryenExpressionRef rightExpr); 1573 // Gets the 128-bit mask of a SIMD shuffle expression. 1574 BINARYEN_API void BinaryenSIMDShuffleGetMask(BinaryenExpressionRef expr, 1575 uint8_t* mask); 1576 // Sets the 128-bit mask of a SIMD shuffle expression. 1577 BINARYEN_API void BinaryenSIMDShuffleSetMask(BinaryenExpressionRef expr, 1578 const uint8_t mask[16]); 1579 1580 // SIMDTernary 1581 1582 // Gets the operation being performed by a SIMD ternary expression. 1583 BINARYEN_API BinaryenOp BinaryenSIMDTernaryGetOp(BinaryenExpressionRef expr); 1584 // Sets the operation being performed by a SIMD ternary expression. 1585 BINARYEN_API void BinaryenSIMDTernarySetOp(BinaryenExpressionRef expr, 1586 BinaryenOp op); 1587 // Gets the first operand expression of a SIMD ternary expression. 1588 BINARYEN_API BinaryenExpressionRef 1589 BinaryenSIMDTernaryGetA(BinaryenExpressionRef expr); 1590 // Sets the first operand expression of a SIMD ternary expression. 1591 BINARYEN_API void BinaryenSIMDTernarySetA(BinaryenExpressionRef expr, 1592 BinaryenExpressionRef aExpr); 1593 // Gets the second operand expression of a SIMD ternary expression. 1594 BINARYEN_API BinaryenExpressionRef 1595 BinaryenSIMDTernaryGetB(BinaryenExpressionRef expr); 1596 // Sets the second operand expression of a SIMD ternary expression. 1597 BINARYEN_API void BinaryenSIMDTernarySetB(BinaryenExpressionRef expr, 1598 BinaryenExpressionRef bExpr); 1599 // Gets the third operand expression of a SIMD ternary expression. 1600 BINARYEN_API BinaryenExpressionRef 1601 BinaryenSIMDTernaryGetC(BinaryenExpressionRef expr); 1602 // Sets the third operand expression of a SIMD ternary expression. 1603 BINARYEN_API void BinaryenSIMDTernarySetC(BinaryenExpressionRef expr, 1604 BinaryenExpressionRef cExpr); 1605 1606 // SIMDShift 1607 1608 // Gets the operation being performed by a SIMD shift expression. 1609 BINARYEN_API BinaryenOp BinaryenSIMDShiftGetOp(BinaryenExpressionRef expr); 1610 // Sets the operation being performed by a SIMD shift expression. 1611 BINARYEN_API void BinaryenSIMDShiftSetOp(BinaryenExpressionRef expr, 1612 BinaryenOp op); 1613 // Gets the expression being shifted by a SIMD shift expression. 1614 BINARYEN_API BinaryenExpressionRef 1615 BinaryenSIMDShiftGetVec(BinaryenExpressionRef expr); 1616 // Sets the expression being shifted by a SIMD shift expression. 1617 BINARYEN_API void BinaryenSIMDShiftSetVec(BinaryenExpressionRef expr, 1618 BinaryenExpressionRef vecExpr); 1619 // Gets the expression representing the shift of a SIMD shift expression. 1620 BINARYEN_API BinaryenExpressionRef 1621 BinaryenSIMDShiftGetShift(BinaryenExpressionRef expr); 1622 // Sets the expression representing the shift of a SIMD shift expression. 1623 BINARYEN_API void BinaryenSIMDShiftSetShift(BinaryenExpressionRef expr, 1624 BinaryenExpressionRef shiftExpr); 1625 1626 // SIMDLoad 1627 1628 // Gets the operation being performed by a SIMD load expression. 1629 BINARYEN_API BinaryenOp BinaryenSIMDLoadGetOp(BinaryenExpressionRef expr); 1630 // Sets the operation being performed by a SIMD load expression. 1631 BINARYEN_API void BinaryenSIMDLoadSetOp(BinaryenExpressionRef expr, 1632 BinaryenOp op); 1633 // Gets the constant offset of a SIMD load expression. 1634 BINARYEN_API uint32_t BinaryenSIMDLoadGetOffset(BinaryenExpressionRef expr); 1635 // Sets the constant offset of a SIMD load expression. 1636 BINARYEN_API void BinaryenSIMDLoadSetOffset(BinaryenExpressionRef expr, 1637 uint32_t offset); 1638 // Gets the byte alignment of a SIMD load expression. 1639 BINARYEN_API uint32_t BinaryenSIMDLoadGetAlign(BinaryenExpressionRef expr); 1640 // Sets the byte alignment of a SIMD load expression. 1641 BINARYEN_API void BinaryenSIMDLoadSetAlign(BinaryenExpressionRef expr, 1642 uint32_t align); 1643 // Gets the pointer expression of a SIMD load expression. 1644 BINARYEN_API BinaryenExpressionRef 1645 BinaryenSIMDLoadGetPtr(BinaryenExpressionRef expr); 1646 // Sets the pointer expression of a SIMD load expression. 1647 BINARYEN_API void BinaryenSIMDLoadSetPtr(BinaryenExpressionRef expr, 1648 BinaryenExpressionRef ptrExpr); 1649 1650 // MemoryInit 1651 1652 // Gets the index of the segment being initialized by a `memory.init` 1653 // expression. 1654 BINARYEN_API uint32_t BinaryenMemoryInitGetSegment(BinaryenExpressionRef expr); 1655 // Sets the index of the segment being initialized by a `memory.init` 1656 // expression. 1657 BINARYEN_API void BinaryenMemoryInitSetSegment(BinaryenExpressionRef expr, 1658 uint32_t segmentIndex); 1659 // Gets the destination expression of a `memory.init` expression. 1660 BINARYEN_API BinaryenExpressionRef 1661 BinaryenMemoryInitGetDest(BinaryenExpressionRef expr); 1662 // Sets the destination expression of a `memory.init` expression. 1663 BINARYEN_API void BinaryenMemoryInitSetDest(BinaryenExpressionRef expr, 1664 BinaryenExpressionRef destExpr); 1665 // Gets the offset expression of a `memory.init` expression. 1666 BINARYEN_API BinaryenExpressionRef 1667 BinaryenMemoryInitGetOffset(BinaryenExpressionRef expr); 1668 // Sets the offset expression of a `memory.init` expression. 1669 BINARYEN_API void BinaryenMemoryInitSetOffset(BinaryenExpressionRef expr, 1670 BinaryenExpressionRef offsetExpr); 1671 // Gets the size expression of a `memory.init` expression. 1672 BINARYEN_API BinaryenExpressionRef 1673 BinaryenMemoryInitGetSize(BinaryenExpressionRef expr); 1674 // Sets the size expression of a `memory.init` expression. 1675 BINARYEN_API void BinaryenMemoryInitSetSize(BinaryenExpressionRef expr, 1676 BinaryenExpressionRef sizeExpr); 1677 1678 // DataDrop 1679 1680 // Gets the index of the segment being dropped by a `memory.drop` expression. 1681 BINARYEN_API uint32_t BinaryenDataDropGetSegment(BinaryenExpressionRef expr); 1682 // Sets the index of the segment being dropped by a `memory.drop` expression. 1683 BINARYEN_API void BinaryenDataDropSetSegment(BinaryenExpressionRef expr, 1684 uint32_t segmentIndex); 1685 1686 // MemoryCopy 1687 1688 // Gets the destination expression of a `memory.copy` expression. 1689 BINARYEN_API BinaryenExpressionRef 1690 BinaryenMemoryCopyGetDest(BinaryenExpressionRef expr); 1691 // Sets the destination expression of a `memory.copy` expression. 1692 BINARYEN_API void BinaryenMemoryCopySetDest(BinaryenExpressionRef expr, 1693 BinaryenExpressionRef destExpr); 1694 // Gets the source expression of a `memory.copy` expression. 1695 BINARYEN_API BinaryenExpressionRef 1696 BinaryenMemoryCopyGetSource(BinaryenExpressionRef expr); 1697 // Sets the source expression of a `memory.copy` expression. 1698 BINARYEN_API void BinaryenMemoryCopySetSource(BinaryenExpressionRef expr, 1699 BinaryenExpressionRef sourceExpr); 1700 // Gets the size expression (number of bytes copied) of a `memory.copy` 1701 // expression. 1702 BINARYEN_API BinaryenExpressionRef 1703 BinaryenMemoryCopyGetSize(BinaryenExpressionRef expr); 1704 // Sets the size expression (number of bytes copied) of a `memory.copy` 1705 // expression. 1706 BINARYEN_API void BinaryenMemoryCopySetSize(BinaryenExpressionRef expr, 1707 BinaryenExpressionRef sizeExpr); 1708 1709 // MemoryFill 1710 1711 // Gets the destination expression of a `memory.fill` expression. 1712 BINARYEN_API BinaryenExpressionRef 1713 BinaryenMemoryFillGetDest(BinaryenExpressionRef expr); 1714 // Sets the destination expression of a `memory.fill` expression. 1715 BINARYEN_API void BinaryenMemoryFillSetDest(BinaryenExpressionRef expr, 1716 BinaryenExpressionRef destExpr); 1717 // Gets the value expression of a `memory.fill` expression. 1718 BINARYEN_API BinaryenExpressionRef 1719 BinaryenMemoryFillGetValue(BinaryenExpressionRef expr); 1720 // Sets the value expression of a `memory.fill` expression. 1721 BINARYEN_API void BinaryenMemoryFillSetValue(BinaryenExpressionRef expr, 1722 BinaryenExpressionRef valueExpr); 1723 // Gets the size expression (number of bytes filled) of a `memory.fill` 1724 // expression. 1725 BINARYEN_API BinaryenExpressionRef 1726 BinaryenMemoryFillGetSize(BinaryenExpressionRef expr); 1727 // Sets the size expression (number of bytes filled) of a `memory.fill` 1728 // expression. 1729 BINARYEN_API void BinaryenMemoryFillSetSize(BinaryenExpressionRef expr, 1730 BinaryenExpressionRef sizeExpr); 1731 1732 // RefIsNull 1733 1734 // Gets the value expression tested to be null of a `ref.is_null` expression. 1735 BINARYEN_API BinaryenExpressionRef 1736 BinaryenRefIsNullGetValue(BinaryenExpressionRef expr); 1737 // Sets the value expression tested to be null of a `ref.is_null` expression. 1738 BINARYEN_API void BinaryenRefIsNullSetValue(BinaryenExpressionRef expr, 1739 BinaryenExpressionRef valueExpr); 1740 1741 // RefFunc 1742 1743 // Gets the name of the function being wrapped by a `ref.func` expression. 1744 BINARYEN_API const char* BinaryenRefFuncGetFunc(BinaryenExpressionRef expr); 1745 // Sets the name of the function being wrapped by a `ref.func` expression. 1746 BINARYEN_API void BinaryenRefFuncSetFunc(BinaryenExpressionRef expr, 1747 const char* funcName); 1748 1749 // RefEq 1750 1751 // Gets the left expression of a `ref.eq` expression. 1752 BINARYEN_API BinaryenExpressionRef 1753 BinaryenRefEqGetLeft(BinaryenExpressionRef expr); 1754 // Sets the left expression of a `ref.eq` expression. 1755 BINARYEN_API void BinaryenRefEqSetLeft(BinaryenExpressionRef expr, 1756 BinaryenExpressionRef left); 1757 // Gets the right expression of a `ref.eq` expression. 1758 BINARYEN_API BinaryenExpressionRef 1759 BinaryenRefEqGetRight(BinaryenExpressionRef expr); 1760 // Sets the right expression of a `ref.eq` expression. 1761 BINARYEN_API void BinaryenRefEqSetRight(BinaryenExpressionRef expr, 1762 BinaryenExpressionRef right); 1763 1764 // Try 1765 1766 // Gets the body expression of a `try` expression. 1767 BINARYEN_API BinaryenExpressionRef 1768 BinaryenTryGetBody(BinaryenExpressionRef expr); 1769 // Sets the body expression of a `try` expression. 1770 BINARYEN_API void BinaryenTrySetBody(BinaryenExpressionRef expr, 1771 BinaryenExpressionRef bodyExpr); 1772 // Gets the catch body expression of a `try` expression. 1773 BINARYEN_API BinaryenExpressionRef 1774 BinaryenTryGetCatchBody(BinaryenExpressionRef expr); 1775 // Sets the catch body expression of a `try` expression. 1776 BINARYEN_API void BinaryenTrySetCatchBody(BinaryenExpressionRef expr, 1777 BinaryenExpressionRef catchBodyExpr); 1778 1779 // Throw 1780 1781 // Gets the name of the event being thrown by a `throw` expression. 1782 BINARYEN_API const char* BinaryenThrowGetEvent(BinaryenExpressionRef expr); 1783 // Sets the name of the event being thrown by a `throw` expression. 1784 BINARYEN_API void BinaryenThrowSetEvent(BinaryenExpressionRef expr, 1785 const char* eventName); 1786 // Gets the number of operands of a `throw` expression. 1787 BINARYEN_API BinaryenIndex 1788 BinaryenThrowGetNumOperands(BinaryenExpressionRef expr); 1789 // Gets the operand at the specified index of a `throw` expression. 1790 BINARYEN_API BinaryenExpressionRef 1791 BinaryenThrowGetOperandAt(BinaryenExpressionRef expr, BinaryenIndex index); 1792 // Sets the operand at the specified index of a `throw` expression. 1793 BINARYEN_API void BinaryenThrowSetOperandAt(BinaryenExpressionRef expr, 1794 BinaryenIndex index, 1795 BinaryenExpressionRef operandExpr); 1796 // Appends an operand expression to a `throw` expression, returning its 1797 // insertion index. 1798 BINARYEN_API BinaryenIndex BinaryenThrowAppendOperand( 1799 BinaryenExpressionRef expr, BinaryenExpressionRef operandExpr); 1800 // Inserts an operand expression at the specified index of a `throw` expression, 1801 // moving existing operands including the one previously at that index one index 1802 // up. 1803 BINARYEN_API void 1804 BinaryenThrowInsertOperandAt(BinaryenExpressionRef expr, 1805 BinaryenIndex index, 1806 BinaryenExpressionRef operandExpr); 1807 // Removes the operand expression at the specified index of a `throw` 1808 // expression, moving all subsequent operands one index down. Returns the 1809 // operand expression. 1810 BINARYEN_API BinaryenExpressionRef 1811 BinaryenThrowRemoveOperandAt(BinaryenExpressionRef expr, BinaryenIndex index); 1812 1813 // Rethrow 1814 1815 // Gets the exception reference expression of a `rethrow` expression. 1816 BINARYEN_API BinaryenExpressionRef 1817 BinaryenRethrowGetExnref(BinaryenExpressionRef expr); 1818 // Sets the exception reference expression of a `rethrow` expression. 1819 BINARYEN_API void BinaryenRethrowSetExnref(BinaryenExpressionRef expr, 1820 BinaryenExpressionRef exnrefExpr); 1821 1822 // BrOnExn 1823 1824 // Gets the name of the event triggering a `br_on_exn` expression. 1825 BINARYEN_API const char* BinaryenBrOnExnGetEvent(BinaryenExpressionRef expr); 1826 // Sets the name of the event triggering a `br_on_exn` expression. 1827 BINARYEN_API void BinaryenBrOnExnSetEvent(BinaryenExpressionRef expr, 1828 const char* eventName); 1829 // Gets the name (target label) of a `br_on_exn` expression. 1830 BINARYEN_API const char* BinaryenBrOnExnGetName(BinaryenExpressionRef expr); 1831 // Sets the name (target label) of a `br_on_exn` expression. 1832 BINARYEN_API void BinaryenBrOnExnSetName(BinaryenExpressionRef expr, 1833 const char* name); 1834 // Gets the expression reference expression of a `br_on_exn` expression. 1835 BINARYEN_API BinaryenExpressionRef 1836 BinaryenBrOnExnGetExnref(BinaryenExpressionRef expr); 1837 // Sets the expression reference expression of a `br_on_exn` expression. 1838 BINARYEN_API void BinaryenBrOnExnSetExnref(BinaryenExpressionRef expr, 1839 BinaryenExpressionRef exnrefExpr); 1840 1841 // TupleMake 1842 1843 // Gets the number of operands of a `tuple.make` expression. 1844 BINARYEN_API BinaryenIndex 1845 BinaryenTupleMakeGetNumOperands(BinaryenExpressionRef expr); 1846 // Gets the operand at the specified index of a `tuple.make` expression. 1847 BINARYEN_API BinaryenExpressionRef 1848 BinaryenTupleMakeGetOperandAt(BinaryenExpressionRef expr, BinaryenIndex index); 1849 // Sets the operand at the specified index of a `tuple.make` expression. 1850 BINARYEN_API void 1851 BinaryenTupleMakeSetOperandAt(BinaryenExpressionRef expr, 1852 BinaryenIndex index, 1853 BinaryenExpressionRef operandExpr); 1854 // Appends an operand expression to a `tuple.make` expression, returning its 1855 // insertion index. 1856 BINARYEN_API BinaryenIndex BinaryenTupleMakeAppendOperand( 1857 BinaryenExpressionRef expr, BinaryenExpressionRef operandExpr); 1858 // Inserts an operand expression at the specified index of a `tuple.make` 1859 // expression, moving existing operands including the one previously at that 1860 // index one index up. 1861 BINARYEN_API void 1862 BinaryenTupleMakeInsertOperandAt(BinaryenExpressionRef expr, 1863 BinaryenIndex index, 1864 BinaryenExpressionRef operandExpr); 1865 // Removes the operand expression at the specified index of a `tuple.make` 1866 // expression, moving all subsequent operands one index down. Returns the 1867 // operand expression. 1868 BINARYEN_API BinaryenExpressionRef BinaryenTupleMakeRemoveOperandAt( 1869 BinaryenExpressionRef expr, BinaryenIndex index); 1870 1871 // TupleExtract 1872 1873 // Gets the tuple extracted from of a `tuple.extract` expression. 1874 BINARYEN_API BinaryenExpressionRef 1875 BinaryenTupleExtractGetTuple(BinaryenExpressionRef expr); 1876 // Sets the tuple extracted from of a `tuple.extract` expression. 1877 BINARYEN_API void BinaryenTupleExtractSetTuple(BinaryenExpressionRef expr, 1878 BinaryenExpressionRef tupleExpr); 1879 // Gets the index extracted at of a `tuple.extract` expression. 1880 BINARYEN_API BinaryenIndex 1881 BinaryenTupleExtractGetIndex(BinaryenExpressionRef expr); 1882 // Sets the index extracted at of a `tuple.extract` expression. 1883 BINARYEN_API void BinaryenTupleExtractSetIndex(BinaryenExpressionRef expr, 1884 BinaryenIndex index); 1885 1886 // I31New 1887 1888 // Gets the value expression of an `i31.new` expression. 1889 BINARYEN_API BinaryenExpressionRef 1890 BinaryenI31NewGetValue(BinaryenExpressionRef expr); 1891 // Sets the value expression of an `i31.new` expression. 1892 BINARYEN_API void BinaryenI31NewSetValue(BinaryenExpressionRef expr, 1893 BinaryenExpressionRef valueExpr); 1894 1895 // I31Get 1896 1897 // Gets the i31 expression of an `i31.get` expression. 1898 BINARYEN_API BinaryenExpressionRef 1899 BinaryenI31GetGetI31(BinaryenExpressionRef expr); 1900 // Sets the i31 expression of an `i31.get` expression. 1901 BINARYEN_API void BinaryenI31GetSetI31(BinaryenExpressionRef expr, 1902 BinaryenExpressionRef i31Expr); 1903 // Gets whether an `i31.get` expression returns a signed value (`_s`). 1904 BINARYEN_API int BinaryenI31GetIsSigned(BinaryenExpressionRef expr); 1905 // Sets whether an `i31.get` expression returns a signed value (`_s`). 1906 BINARYEN_API void BinaryenI31GetSetSigned(BinaryenExpressionRef expr, 1907 int signed_); 1908 1909 // Functions 1910 1911 BINARYEN_REF(Function); 1912 1913 // Adds a function to the module. This is thread-safe. 1914 // @varTypes: the types of variables. In WebAssembly, vars share 1915 // an index space with params. In other words, params come from 1916 // the function type, and vars are provided in this call, and 1917 // together they are all the locals. The order is first params 1918 // and then vars, so if you have one param it will be at index 1919 // 0 (and written $0), and if you also have 2 vars they will be 1920 // at indexes 1 and 2, etc., that is, they share an index space. 1921 BINARYEN_API BinaryenFunctionRef 1922 BinaryenAddFunction(BinaryenModuleRef module, 1923 const char* name, 1924 BinaryenType params, 1925 BinaryenType results, 1926 BinaryenType* varTypes, 1927 BinaryenIndex numVarTypes, 1928 BinaryenExpressionRef body); 1929 // Gets a function reference by name. 1930 BINARYEN_API BinaryenFunctionRef BinaryenGetFunction(BinaryenModuleRef module, 1931 const char* name); 1932 // Removes a function by name. 1933 BINARYEN_API void BinaryenRemoveFunction(BinaryenModuleRef module, 1934 const char* name); 1935 1936 // Gets the number of functions in the module. 1937 BINARYEN_API uint32_t BinaryenGetNumFunctions(BinaryenModuleRef module); 1938 // Get function pointer from its index. 1939 BINARYEN_API BinaryenFunctionRef 1940 BinaryenGetFunctionByIndex(BinaryenModuleRef module, BinaryenIndex id); 1941 1942 // Imports 1943 1944 BINARYEN_API void BinaryenAddFunctionImport(BinaryenModuleRef module, 1945 const char* internalName, 1946 const char* externalModuleName, 1947 const char* externalBaseName, 1948 BinaryenType params, 1949 BinaryenType results); 1950 BINARYEN_API void BinaryenAddTableImport(BinaryenModuleRef module, 1951 const char* internalName, 1952 const char* externalModuleName, 1953 const char* externalBaseName); 1954 BINARYEN_API void BinaryenAddMemoryImport(BinaryenModuleRef module, 1955 const char* internalName, 1956 const char* externalModuleName, 1957 const char* externalBaseName, 1958 uint8_t shared); 1959 BINARYEN_API void BinaryenAddGlobalImport(BinaryenModuleRef module, 1960 const char* internalName, 1961 const char* externalModuleName, 1962 const char* externalBaseName, 1963 BinaryenType globalType, 1964 int mutable_); 1965 BINARYEN_API void BinaryenAddEventImport(BinaryenModuleRef module, 1966 const char* internalName, 1967 const char* externalModuleName, 1968 const char* externalBaseName, 1969 uint32_t attribute, 1970 BinaryenType params, 1971 BinaryenType results); 1972 1973 // Exports 1974 1975 BINARYEN_REF(Export); 1976 1977 WASM_DEPRECATED BinaryenExportRef BinaryenAddExport(BinaryenModuleRef module, 1978 const char* internalName, 1979 const char* externalName); 1980 BINARYEN_API BinaryenExportRef BinaryenAddFunctionExport( 1981 BinaryenModuleRef module, const char* internalName, const char* externalName); 1982 BINARYEN_API BinaryenExportRef BinaryenAddTableExport(BinaryenModuleRef module, 1983 const char* internalName, 1984 const char* externalName); 1985 BINARYEN_API BinaryenExportRef BinaryenAddMemoryExport( 1986 BinaryenModuleRef module, const char* internalName, const char* externalName); 1987 BINARYEN_API BinaryenExportRef BinaryenAddGlobalExport( 1988 BinaryenModuleRef module, const char* internalName, const char* externalName); 1989 BINARYEN_API BinaryenExportRef BinaryenAddEventExport(BinaryenModuleRef module, 1990 const char* internalName, 1991 const char* externalName); 1992 BINARYEN_API void BinaryenRemoveExport(BinaryenModuleRef module, 1993 const char* externalName); 1994 1995 // Globals 1996 1997 BINARYEN_REF(Global); 1998 1999 BINARYEN_API BinaryenGlobalRef BinaryenAddGlobal(BinaryenModuleRef module, 2000 const char* name, 2001 BinaryenType type, 2002 int8_t mutable_, 2003 BinaryenExpressionRef init); 2004 // Gets a global reference by name. 2005 BINARYEN_API BinaryenGlobalRef BinaryenGetGlobal(BinaryenModuleRef module, 2006 const char* name); 2007 BINARYEN_API void BinaryenRemoveGlobal(BinaryenModuleRef module, 2008 const char* name); 2009 2010 // Events 2011 2012 BINARYEN_REF(Event); 2013 2014 BINARYEN_API BinaryenEventRef BinaryenAddEvent(BinaryenModuleRef module, 2015 const char* name, 2016 uint32_t attribute, 2017 BinaryenType params, 2018 BinaryenType results); 2019 BINARYEN_API BinaryenEventRef BinaryenGetEvent(BinaryenModuleRef module, 2020 const char* name); 2021 BINARYEN_API void BinaryenRemoveEvent(BinaryenModuleRef module, 2022 const char* name); 2023 2024 // Function table. One per module 2025 2026 // TODO: Add support for multiple segments in BinaryenSetFunctionTable. 2027 BINARYEN_API void BinaryenSetFunctionTable(BinaryenModuleRef module, 2028 BinaryenIndex initial, 2029 BinaryenIndex maximum, 2030 const char** funcNames, 2031 BinaryenIndex numFuncNames, 2032 BinaryenExpressionRef offset); 2033 BINARYEN_API int BinaryenIsFunctionTableImported(BinaryenModuleRef module); 2034 BINARYEN_API BinaryenIndex 2035 BinaryenGetNumFunctionTableSegments(BinaryenModuleRef module); 2036 BINARYEN_API BinaryenExpressionRef BinaryenGetFunctionTableSegmentOffset( 2037 BinaryenModuleRef module, BinaryenIndex segmentId); 2038 BINARYEN_API BinaryenIndex BinaryenGetFunctionTableSegmentLength( 2039 BinaryenModuleRef module, BinaryenIndex segmentId); 2040 BINARYEN_API const char* BinaryenGetFunctionTableSegmentData( 2041 BinaryenModuleRef module, BinaryenIndex segmentId, BinaryenIndex dataId); 2042 2043 // Memory. One per module 2044 2045 // Each segment has data in segments, a start offset in segmentOffsets, and a 2046 // size in segmentSizes. exportName can be NULL 2047 BINARYEN_API void BinaryenSetMemory(BinaryenModuleRef module, 2048 BinaryenIndex initial, 2049 BinaryenIndex maximum, 2050 const char* exportName, 2051 const char** segments, 2052 int8_t* segmentPassive, 2053 BinaryenExpressionRef* segmentOffsets, 2054 BinaryenIndex* segmentSizes, 2055 BinaryenIndex numSegments, 2056 uint8_t shared); 2057 2058 // Memory segments. Query utilities. 2059 2060 BINARYEN_API uint32_t BinaryenGetNumMemorySegments(BinaryenModuleRef module); 2061 BINARYEN_API uint32_t 2062 BinaryenGetMemorySegmentByteOffset(BinaryenModuleRef module, BinaryenIndex id); 2063 BINARYEN_API size_t BinaryenGetMemorySegmentByteLength(BinaryenModuleRef module, 2064 BinaryenIndex id); 2065 BINARYEN_API int BinaryenGetMemorySegmentPassive(BinaryenModuleRef module, 2066 BinaryenIndex id); 2067 BINARYEN_API void BinaryenCopyMemorySegmentData(BinaryenModuleRef module, 2068 BinaryenIndex id, 2069 char* buffer); 2070 2071 // Start function. One per module 2072 2073 BINARYEN_API void BinaryenSetStart(BinaryenModuleRef module, 2074 BinaryenFunctionRef start); 2075 2076 // Features 2077 2078 // These control what features are allowed when validation and in passes. 2079 BINARYEN_API BinaryenFeatures 2080 BinaryenModuleGetFeatures(BinaryenModuleRef module); 2081 BINARYEN_API void BinaryenModuleSetFeatures(BinaryenModuleRef module, 2082 BinaryenFeatures features); 2083 2084 // 2085 // ========== Module Operations ========== 2086 // 2087 2088 // Parse a module in s-expression text format 2089 BINARYEN_API BinaryenModuleRef BinaryenModuleParse(const char* text); 2090 2091 // Print a module to stdout in s-expression text format. Useful for debugging. 2092 BINARYEN_API void BinaryenModulePrint(BinaryenModuleRef module); 2093 2094 // Print a module to stdout in asm.js syntax. 2095 BINARYEN_API void BinaryenModulePrintAsmjs(BinaryenModuleRef module); 2096 2097 // Validate a module, showing errors on problems. 2098 // @return 0 if an error occurred, 1 if validated succesfully 2099 BINARYEN_API int BinaryenModuleValidate(BinaryenModuleRef module); 2100 2101 // Runs the standard optimization passes on the module. Uses the currently set 2102 // global optimize and shrink level. 2103 BINARYEN_API void BinaryenModuleOptimize(BinaryenModuleRef module); 2104 2105 // Gets the currently set optimize level. Applies to all modules, globally. 2106 // 0, 1, 2 correspond to -O0, -O1, -O2 (default), etc. 2107 BINARYEN_API int BinaryenGetOptimizeLevel(void); 2108 2109 // Sets the optimization level to use. Applies to all modules, globally. 2110 // 0, 1, 2 correspond to -O0, -O1, -O2 (default), etc. 2111 BINARYEN_API void BinaryenSetOptimizeLevel(int level); 2112 2113 // Gets the currently set shrink level. Applies to all modules, globally. 2114 // 0, 1, 2 correspond to -O0, -Os (default), -Oz. 2115 BINARYEN_API int BinaryenGetShrinkLevel(void); 2116 2117 // Sets the shrink level to use. Applies to all modules, globally. 2118 // 0, 1, 2 correspond to -O0, -Os (default), -Oz. 2119 BINARYEN_API void BinaryenSetShrinkLevel(int level); 2120 2121 // Gets whether generating debug information is currently enabled or not. 2122 // Applies to all modules, globally. 2123 BINARYEN_API int BinaryenGetDebugInfo(void); 2124 2125 // Enables or disables debug information in emitted binaries. 2126 // Applies to all modules, globally. 2127 BINARYEN_API void BinaryenSetDebugInfo(int on); 2128 2129 // Gets whether the low 1K of memory can be considered unused when optimizing. 2130 // Applies to all modules, globally. 2131 BINARYEN_API int BinaryenGetLowMemoryUnused(void); 2132 2133 // Enables or disables whether the low 1K of memory can be considered unused 2134 // when optimizing. Applies to all modules, globally. 2135 BINARYEN_API void BinaryenSetLowMemoryUnused(int on); 2136 2137 // Gets whether fast math optimizations are enabled, ignoring for example 2138 // corner cases of floating-point math like NaN changes. 2139 // Applies to all modules, globally. 2140 BINARYEN_API int BinaryenGetFastMath(void); 2141 2142 // Enables or disables fast math optimizations, ignoring for example 2143 // corner cases of floating-point math like NaN changes. 2144 // Applies to all modules, globally. 2145 BINARYEN_API void BinaryenSetFastMath(int value); 2146 2147 // Gets the value of the specified arbitrary pass argument. 2148 // Applies to all modules, globally. 2149 BINARYEN_API const char* BinaryenGetPassArgument(const char* name); 2150 2151 // Sets the value of the specified arbitrary pass argument. Removes the 2152 // respective argument if `value` is NULL. Applies to all modules, globally. 2153 BINARYEN_API void BinaryenSetPassArgument(const char* name, const char* value); 2154 2155 // Clears all arbitrary pass arguments. 2156 // Applies to all modules, globally. 2157 BINARYEN_API void BinaryenClearPassArguments(); 2158 2159 // Gets the function size at which we always inline. 2160 // Applies to all modules, globally. 2161 BINARYEN_API BinaryenIndex BinaryenGetAlwaysInlineMaxSize(void); 2162 2163 // Sets the function size at which we always inline. 2164 // Applies to all modules, globally. 2165 BINARYEN_API void BinaryenSetAlwaysInlineMaxSize(BinaryenIndex size); 2166 2167 // Gets the function size which we inline when functions are lightweight. 2168 // Applies to all modules, globally. 2169 BINARYEN_API BinaryenIndex BinaryenGetFlexibleInlineMaxSize(void); 2170 2171 // Sets the function size which we inline when functions are lightweight. 2172 // Applies to all modules, globally. 2173 BINARYEN_API void BinaryenSetFlexibleInlineMaxSize(BinaryenIndex size); 2174 2175 // Gets the function size which we inline when there is only one caller. 2176 // Applies to all modules, globally. 2177 BINARYEN_API BinaryenIndex BinaryenGetOneCallerInlineMaxSize(void); 2178 2179 // Sets the function size which we inline when there is only one caller. 2180 // Applies to all modules, globally. 2181 BINARYEN_API void BinaryenSetOneCallerInlineMaxSize(BinaryenIndex size); 2182 2183 // Gets whether functions with loops are allowed to be inlined. 2184 // Applies to all modules, globally. 2185 BINARYEN_API int BinaryenGetAllowInliningFunctionsWithLoops(void); 2186 2187 // Sets whether functions with loops are allowed to be inlined. 2188 // Applies to all modules, globally. 2189 BINARYEN_API void BinaryenSetAllowInliningFunctionsWithLoops(int enabled); 2190 2191 // Runs the specified passes on the module. Uses the currently set global 2192 // optimize and shrink level. 2193 BINARYEN_API void BinaryenModuleRunPasses(BinaryenModuleRef module, 2194 const char** passes, 2195 BinaryenIndex numPasses); 2196 2197 // Auto-generate drop() operations where needed. This lets you generate code 2198 // without worrying about where they are needed. (It is more efficient to do it 2199 // yourself, but simpler to use autodrop). 2200 BINARYEN_API void BinaryenModuleAutoDrop(BinaryenModuleRef module); 2201 2202 // Serialize a module into binary form. Uses the currently set global debugInfo 2203 // option. 2204 // @return how many bytes were written. This will be less than or equal to 2205 // outputSize 2206 size_t BINARYEN_API BinaryenModuleWrite(BinaryenModuleRef module, 2207 char* output, 2208 size_t outputSize); 2209 2210 // Serialize a module in s-expression text format. 2211 // @return how many bytes were written. This will be less than or equal to 2212 // outputSize 2213 BINARYEN_API size_t BinaryenModuleWriteText(BinaryenModuleRef module, 2214 char* output, 2215 size_t outputSize); 2216 2217 typedef struct BinaryenBufferSizes { 2218 size_t outputBytes; 2219 size_t sourceMapBytes; 2220 } BinaryenBufferSizes; 2221 2222 // Serialize a module into binary form including its source map. Uses the 2223 // currently set global debugInfo option. 2224 // @returns how many bytes were written. This will be less than or equal to 2225 // outputSize 2226 BINARYEN_API BinaryenBufferSizes 2227 BinaryenModuleWriteWithSourceMap(BinaryenModuleRef module, 2228 const char* url, 2229 char* output, 2230 size_t outputSize, 2231 char* sourceMap, 2232 size_t sourceMapSize); 2233 2234 // Result structure of BinaryenModuleAllocateAndWrite. Contained buffers have 2235 // been allocated using malloc() and the user is expected to free() them 2236 // manually once not needed anymore. 2237 typedef struct BinaryenModuleAllocateAndWriteResult { 2238 void* binary; 2239 size_t binaryBytes; 2240 char* sourceMap; 2241 } BinaryenModuleAllocateAndWriteResult; 2242 2243 // Serializes a module into binary form, optionally including its source map if 2244 // sourceMapUrl has been specified. Uses the currently set global debugInfo 2245 // option. Differs from BinaryenModuleWrite in that it implicitly allocates 2246 // appropriate buffers using malloc(), and expects the user to free() them 2247 // manually once not needed anymore. 2248 BINARYEN_API BinaryenModuleAllocateAndWriteResult 2249 BinaryenModuleAllocateAndWrite(BinaryenModuleRef module, 2250 const char* sourceMapUrl); 2251 2252 // Serialize a module in s-expression form. Implicity allocates the returned 2253 // char* with malloc(), and expects the user to free() them manually 2254 // once not needed anymore. 2255 BINARYEN_API char* BinaryenModuleAllocateAndWriteText(BinaryenModuleRef module); 2256 2257 // Deserialize a module from binary form. 2258 BINARYEN_API BinaryenModuleRef BinaryenModuleRead(char* input, 2259 size_t inputSize); 2260 2261 // Execute a module in the Binaryen interpreter. This will create an instance of 2262 // the module, run it in the interpreter - which means running the start method 2263 // - and then destroying the instance. 2264 BINARYEN_API void BinaryenModuleInterpret(BinaryenModuleRef module); 2265 2266 // Adds a debug info file name to the module and returns its index. 2267 BINARYEN_API BinaryenIndex BinaryenModuleAddDebugInfoFileName( 2268 BinaryenModuleRef module, const char* filename); 2269 2270 // Gets the name of the debug info file at the specified index. Returns `NULL` 2271 // if it does not exist. 2272 BINARYEN_API const char* 2273 BinaryenModuleGetDebugInfoFileName(BinaryenModuleRef module, 2274 BinaryenIndex index); 2275 2276 // 2277 // ========== Function Operations ========== 2278 // 2279 2280 // Gets the name of the specified `Function`. 2281 BINARYEN_API const char* BinaryenFunctionGetName(BinaryenFunctionRef func); 2282 // Gets the type of the parameter at the specified index of the specified 2283 // `Function`. 2284 BINARYEN_API BinaryenType BinaryenFunctionGetParams(BinaryenFunctionRef func); 2285 // Gets the result type of the specified `Function`. 2286 BINARYEN_API BinaryenType BinaryenFunctionGetResults(BinaryenFunctionRef func); 2287 // Gets the number of additional locals within the specified `Function`. 2288 BINARYEN_API BinaryenIndex BinaryenFunctionGetNumVars(BinaryenFunctionRef func); 2289 // Gets the type of the additional local at the specified index within the 2290 // specified `Function`. 2291 BINARYEN_API BinaryenType BinaryenFunctionGetVar(BinaryenFunctionRef func, 2292 BinaryenIndex index); 2293 // Gets the number of locals within the specified function. Includes parameters. 2294 BINARYEN_API BinaryenIndex 2295 BinaryenFunctionGetNumLocals(BinaryenFunctionRef func); 2296 // Tests if the local at the specified index has a name. 2297 BINARYEN_API int BinaryenFunctionHasLocalName(BinaryenFunctionRef func, 2298 BinaryenIndex index); 2299 // Gets the name of the local at the specified index. 2300 BINARYEN_API const char* BinaryenFunctionGetLocalName(BinaryenFunctionRef func, 2301 BinaryenIndex index); 2302 // Sets the name of the local at the specified index. 2303 BINARYEN_API void BinaryenFunctionSetLocalName(BinaryenFunctionRef func, 2304 BinaryenIndex index, 2305 const char* name); 2306 // Gets the body of the specified `Function`. 2307 BINARYEN_API BinaryenExpressionRef 2308 BinaryenFunctionGetBody(BinaryenFunctionRef func); 2309 // Sets the body of the specified `Function`. 2310 BINARYEN_API void BinaryenFunctionSetBody(BinaryenFunctionRef func, 2311 BinaryenExpressionRef body); 2312 2313 // Runs the standard optimization passes on the function. Uses the currently set 2314 // global optimize and shrink level. 2315 BINARYEN_API void BinaryenFunctionOptimize(BinaryenFunctionRef func, 2316 BinaryenModuleRef module); 2317 2318 // Runs the specified passes on the function. Uses the currently set global 2319 // optimize and shrink level. 2320 BINARYEN_API void BinaryenFunctionRunPasses(BinaryenFunctionRef func, 2321 BinaryenModuleRef module, 2322 const char** passes, 2323 BinaryenIndex numPasses); 2324 2325 // Sets the debug location of the specified `Expression` within the specified 2326 // `Function`. 2327 BINARYEN_API void BinaryenFunctionSetDebugLocation(BinaryenFunctionRef func, 2328 BinaryenExpressionRef expr, 2329 BinaryenIndex fileIndex, 2330 BinaryenIndex lineNumber, 2331 BinaryenIndex columnNumber); 2332 2333 // 2334 // ========== Global Operations ========== 2335 // 2336 2337 // Gets the name of the specified `Global`. 2338 BINARYEN_API const char* BinaryenGlobalGetName(BinaryenGlobalRef global); 2339 // Gets the name of the `GlobalType` associated with the specified `Global`. May 2340 // be `NULL` if the signature is implicit. 2341 BINARYEN_API BinaryenType BinaryenGlobalGetType(BinaryenGlobalRef global); 2342 // Returns true if the specified `Global` is mutable. 2343 BINARYEN_API int BinaryenGlobalIsMutable(BinaryenGlobalRef global); 2344 // Gets the initialization expression of the specified `Global`. 2345 BINARYEN_API BinaryenExpressionRef 2346 BinaryenGlobalGetInitExpr(BinaryenGlobalRef global); 2347 2348 // 2349 // ========== Event Operations ========== 2350 // 2351 2352 // Gets the name of the specified `Event`. 2353 BINARYEN_API const char* BinaryenEventGetName(BinaryenEventRef event); 2354 // Gets the attribute of the specified `Event`. 2355 BINARYEN_API int BinaryenEventGetAttribute(BinaryenEventRef event); 2356 // Gets the parameters type of the specified `Event`. 2357 BINARYEN_API BinaryenType BinaryenEventGetParams(BinaryenEventRef event); 2358 // Gets the results type of the specified `Event`. 2359 BINARYEN_API BinaryenType BinaryenEventGetResults(BinaryenEventRef event); 2360 2361 // 2362 // ========== Import Operations ========== 2363 // 2364 2365 // Gets the external module name of the specified import. 2366 BINARYEN_API const char* 2367 BinaryenFunctionImportGetModule(BinaryenFunctionRef import); 2368 BINARYEN_API const char* 2369 BinaryenGlobalImportGetModule(BinaryenGlobalRef import); 2370 BINARYEN_API const char* BinaryenEventImportGetModule(BinaryenEventRef import); 2371 // Gets the external base name of the specified import. 2372 BINARYEN_API const char* 2373 BinaryenFunctionImportGetBase(BinaryenFunctionRef import); 2374 BINARYEN_API const char* BinaryenGlobalImportGetBase(BinaryenGlobalRef import); 2375 BINARYEN_API const char* BinaryenEventImportGetBase(BinaryenEventRef import); 2376 2377 // 2378 // ========== Export Operations ========== 2379 // 2380 2381 // Gets the external kind of the specified export. 2382 BINARYEN_API BinaryenExternalKind 2383 BinaryenExportGetKind(BinaryenExportRef export_); 2384 // Gets the external name of the specified export. 2385 BINARYEN_API const char* BinaryenExportGetName(BinaryenExportRef export_); 2386 // Gets the internal name of the specified export. 2387 BINARYEN_API const char* BinaryenExportGetValue(BinaryenExportRef export_); 2388 // Gets the number of exports in the module. 2389 BINARYEN_API uint32_t BinaryenGetNumExports(BinaryenModuleRef module); 2390 // Get export pointer from its index. 2391 BINARYEN_API BinaryenExportRef 2392 BinaryenGetExportByIndex(BinaryenModuleRef module, BinaryenIndex id); 2393 2394 // 2395 // ========= Custom sections ========= 2396 // 2397 2398 BINARYEN_API void BinaryenAddCustomSection(BinaryenModuleRef module, 2399 const char* name, 2400 const char* contents, 2401 BinaryenIndex contentsSize); 2402 2403 // 2404 // ========= Effect analyzer ========= 2405 // 2406 2407 typedef uint32_t BinaryenSideEffects; 2408 2409 BINARYEN_API BinaryenSideEffects BinaryenSideEffectNone(void); 2410 BINARYEN_API BinaryenSideEffects BinaryenSideEffectBranches(void); 2411 BINARYEN_API BinaryenSideEffects BinaryenSideEffectCalls(void); 2412 BINARYEN_API BinaryenSideEffects BinaryenSideEffectReadsLocal(void); 2413 BINARYEN_API BinaryenSideEffects BinaryenSideEffectWritesLocal(void); 2414 BINARYEN_API BinaryenSideEffects BinaryenSideEffectReadsGlobal(void); 2415 BINARYEN_API BinaryenSideEffects BinaryenSideEffectWritesGlobal(void); 2416 BINARYEN_API BinaryenSideEffects BinaryenSideEffectReadsMemory(void); 2417 BINARYEN_API BinaryenSideEffects BinaryenSideEffectWritesMemory(void); 2418 BINARYEN_API BinaryenSideEffects BinaryenSideEffectImplicitTrap(void); 2419 BINARYEN_API BinaryenSideEffects BinaryenSideEffectIsAtomic(void); 2420 BINARYEN_API BinaryenSideEffects BinaryenSideEffectThrows(void); 2421 BINARYEN_API BinaryenSideEffects BinaryenSideEffectDanglingPop(void); 2422 BINARYEN_API BinaryenSideEffects BinaryenSideEffectAny(void); 2423 2424 BINARYEN_API BinaryenSideEffects BinaryenExpressionGetSideEffects( 2425 BinaryenExpressionRef expr, BinaryenFeatures features); 2426 2427 // 2428 // ========== CFG / Relooper ========== 2429 // 2430 // General usage is (1) create a relooper, (2) create blocks, (3) add 2431 // branches between them, (4) render the output. 2432 // 2433 // For more details, see src/cfg/Relooper.h and 2434 // https://github.com/WebAssembly/binaryen/wiki/Compiling-to-WebAssembly-with-Binaryen#cfg-api 2435 2436 #ifdef __cplusplus 2437 namespace CFG { 2438 struct Relooper; 2439 struct Block; 2440 } // namespace CFG 2441 typedef struct CFG::Relooper* RelooperRef; 2442 typedef struct CFG::Block* RelooperBlockRef; 2443 #else 2444 typedef struct Relooper* RelooperRef; 2445 typedef struct RelooperBlock* RelooperBlockRef; 2446 #endif 2447 2448 // Create a relooper instance 2449 BINARYEN_API RelooperRef RelooperCreate(BinaryenModuleRef module); 2450 2451 // Create a basic block that ends with nothing, or with some simple branching 2452 BINARYEN_API RelooperBlockRef RelooperAddBlock(RelooperRef relooper, 2453 BinaryenExpressionRef code); 2454 2455 // Create a branch to another basic block 2456 // The branch can have code on it, that is executed as the branch happens. this 2457 // is useful for phis. otherwise, code can be NULL 2458 BINARYEN_API void RelooperAddBranch(RelooperBlockRef from, 2459 RelooperBlockRef to, 2460 BinaryenExpressionRef condition, 2461 BinaryenExpressionRef code); 2462 2463 // Create a basic block that ends a switch on a condition 2464 BINARYEN_API RelooperBlockRef 2465 RelooperAddBlockWithSwitch(RelooperRef relooper, 2466 BinaryenExpressionRef code, 2467 BinaryenExpressionRef condition); 2468 2469 // Create a switch-style branch to another basic block. The block's switch table 2470 // will have these indexes going to that target 2471 BINARYEN_API void RelooperAddBranchForSwitch(RelooperBlockRef from, 2472 RelooperBlockRef to, 2473 BinaryenIndex* indexes, 2474 BinaryenIndex numIndexes, 2475 BinaryenExpressionRef code); 2476 2477 // Generate structed wasm control flow from the CFG of blocks and branches that 2478 // were created on this relooper instance. This returns the rendered output, and 2479 // also disposes of the relooper and its blocks and branches, as they are no 2480 // longer needed. 2481 // @param labelHelper To render irreducible control flow, we may need a helper 2482 // variable to guide us to the right target label. This value should be 2483 // an index of an i32 local variable that is free for us to use. 2484 BINARYEN_API BinaryenExpressionRef RelooperRenderAndDispose( 2485 RelooperRef relooper, RelooperBlockRef entry, BinaryenIndex labelHelper); 2486 2487 // 2488 // ========= ExpressionRunner ========== 2489 // 2490 2491 #ifdef __cplusplus 2492 namespace wasm { 2493 class CExpressionRunner; 2494 } // namespace wasm 2495 typedef class wasm::CExpressionRunner* ExpressionRunnerRef; 2496 #else 2497 typedef struct CExpressionRunner* ExpressionRunnerRef; 2498 #endif 2499 2500 typedef uint32_t ExpressionRunnerFlags; 2501 2502 // By default, just evaluate the expression, i.e. all we want to know is whether 2503 // it computes down to a concrete value, where it is not necessary to preserve 2504 // side effects like those of a `local.tee`. 2505 BINARYEN_API ExpressionRunnerFlags ExpressionRunnerFlagsDefault(); 2506 2507 // Be very careful to preserve any side effects. For example, if we are 2508 // intending to replace the expression with a constant afterwards, even if we 2509 // can technically evaluate down to a constant, we still cannot replace the 2510 // expression if it also sets a local, which must be preserved in this scenario 2511 // so subsequent code keeps functioning. 2512 BINARYEN_API ExpressionRunnerFlags ExpressionRunnerFlagsPreserveSideeffects(); 2513 2514 // Traverse through function calls, attempting to compute their concrete value. 2515 // Must not be used in function-parallel scenarios, where the called function 2516 // might be concurrently modified, leading to undefined behavior. Traversing 2517 // another function reuses all of this runner's flags. 2518 BINARYEN_API ExpressionRunnerFlags ExpressionRunnerFlagsTraverseCalls(); 2519 2520 // Creates an ExpressionRunner instance 2521 BINARYEN_API ExpressionRunnerRef 2522 ExpressionRunnerCreate(BinaryenModuleRef module, 2523 ExpressionRunnerFlags flags, 2524 BinaryenIndex maxDepth, 2525 BinaryenIndex maxLoopIterations); 2526 2527 // Sets a known local value to use. Order matters if expressions have side 2528 // effects. For example, if the expression also sets a local, this side effect 2529 // will also happen (not affected by any flags). Returns `true` if the 2530 // expression actually evaluates to a constant. 2531 BINARYEN_API int ExpressionRunnerSetLocalValue(ExpressionRunnerRef runner, 2532 BinaryenIndex index, 2533 BinaryenExpressionRef value); 2534 2535 // Sets a known global value to use. Order matters if expressions have side 2536 // effects. For example, if the expression also sets a local, this side effect 2537 // will also happen (not affected by any flags). Returns `true` if the 2538 // expression actually evaluates to a constant. 2539 BINARYEN_API int ExpressionRunnerSetGlobalValue(ExpressionRunnerRef runner, 2540 const char* name, 2541 BinaryenExpressionRef value); 2542 2543 // Runs the expression and returns the constant value expression it evaluates 2544 // to, if any. Otherwise returns `NULL`. Also disposes the runner. 2545 BINARYEN_API BinaryenExpressionRef ExpressionRunnerRunAndDispose( 2546 ExpressionRunnerRef runner, BinaryenExpressionRef expr); 2547 2548 // 2549 // ========= Utilities ========= 2550 // 2551 2552 // Enable or disable coloring for the WASM printer 2553 BINARYEN_API void BinaryenSetColorsEnabled(int enabled); 2554 2555 // Query whether color is enable for the WASM printer 2556 BINARYEN_API int BinaryenAreColorsEnabled(); 2557 #ifdef __cplusplus 2558 } // extern "C" 2559 #endif 2560 2561 #endif // wasm_binaryen_c_h 2562