diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2018-12-04 10:30:35 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-04 10:30:35 -0800 |
commit | bebbeb54f177bdc2cfdff71d6a256a35f2f2057b (patch) | |
tree | 80609eb177ddab4edae30323d42152e9ab59ba9b | |
parent | b4badb815ec844e438a05d501eafb6bb99383bc6 (diff) | |
download | binaryen-bebbeb54f177bdc2cfdff71d6a256a35f2f2057b.tar.gz binaryen-bebbeb54f177bdc2cfdff71d6a256a35f2f2057b.tar.bz2 binaryen-bebbeb54f177bdc2cfdff71d6a256a35f2f2057b.zip |
Implement nontrapping float-to-int instructions (#1780)
29 files changed, 1965 insertions, 1543 deletions
diff --git a/build-js.sh b/build-js.sh index 9aa4105f6..808329386 100755 --- a/build-js.sh +++ b/build-js.sh @@ -263,6 +263,14 @@ export_function "_BinaryenTruncSFloat64ToInt32" export_function "_BinaryenTruncSFloat64ToInt64" export_function "_BinaryenTruncUFloat64ToInt32" export_function "_BinaryenTruncUFloat64ToInt64" +export_function "_BinaryenTruncSatSFloat32ToInt32" +export_function "_BinaryenTruncSatSFloat32ToInt64" +export_function "_BinaryenTruncSatUFloat32ToInt32" +export_function "_BinaryenTruncSatUFloat32ToInt64" +export_function "_BinaryenTruncSatSFloat64ToInt32" +export_function "_BinaryenTruncSatSFloat64ToInt64" +export_function "_BinaryenTruncSatUFloat64ToInt32" +export_function "_BinaryenTruncSatUFloat64ToInt64" export_function "_BinaryenReinterpretFloat32" export_function "_BinaryenReinterpretFloat64" export_function "_BinaryenConvertSInt32ToFloat32" diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py index 5f37fd9d5..f33107ea6 100755 --- a/scripts/gen-s-parser.py +++ b/scripts/gen-s-parser.py @@ -258,7 +258,16 @@ instructions = [ ("i64.atomic.rmw8_u.cmpxchg", "makeAtomicRMWOrCmpxchg(s, i64)"), ("i64.atomic.rmw16_u.cmpxchg", "makeAtomicRMWOrCmpxchg(s, i64)"), ("i64.atomic.rmw32_u.cmpxchg", "makeAtomicRMWOrCmpxchg(s, i64)"), - ("i64.atomic.rmw.cmpxchg", "makeAtomicRMWOrCmpxchg(s, i64)") + ("i64.atomic.rmw.cmpxchg", "makeAtomicRMWOrCmpxchg(s, i64)"), + # nontrapping float-to-int instructions + ("i32.trunc_s:sat/f32", "makeUnary(s, UnaryOp::TruncSatSFloat32ToInt32)"), + ("i32.trunc_u:sat/f32", "makeUnary(s, UnaryOp::TruncSatUFloat32ToInt32)"), + ("i32.trunc_s:sat/f64", "makeUnary(s, UnaryOp::TruncSatSFloat64ToInt32)"), + ("i32.trunc_u:sat/f64", "makeUnary(s, UnaryOp::TruncSatUFloat64ToInt32)"), + ("i64.trunc_s:sat/f32", "makeUnary(s, UnaryOp::TruncSatSFloat32ToInt64)"), + ("i64.trunc_u:sat/f32", "makeUnary(s, UnaryOp::TruncSatUFloat32ToInt64)"), + ("i64.trunc_s:sat/f64", "makeUnary(s, UnaryOp::TruncSatSFloat64ToInt64)"), + ("i64.trunc_u:sat/f64", "makeUnary(s, UnaryOp::TruncSatUFloat64ToInt64)"), ] diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index d098810e2..6248f8d91 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -394,6 +394,14 @@ BinaryenOp BinaryenAtomicRMWAnd(void) { return AtomicRMWOp::And; } BinaryenOp BinaryenAtomicRMWOr(void) { return AtomicRMWOp::Or; } BinaryenOp BinaryenAtomicRMWXor(void) { return AtomicRMWOp::Xor; } BinaryenOp BinaryenAtomicRMWXchg(void) { return AtomicRMWOp::Xchg; } +BinaryenOp BinaryenTruncSatSFloat32ToInt32(void) { return TruncSatSFloat32ToInt32; } +BinaryenOp BinaryenTruncSatSFloat32ToInt64(void) { return TruncSatSFloat32ToInt64; } +BinaryenOp BinaryenTruncSatUFloat32ToInt32(void) { return TruncSatUFloat32ToInt32; } +BinaryenOp BinaryenTruncSatUFloat32ToInt64(void) { return TruncSatUFloat32ToInt64; } +BinaryenOp BinaryenTruncSatSFloat64ToInt32(void) { return TruncSatSFloat64ToInt32; } +BinaryenOp BinaryenTruncSatSFloat64ToInt64(void) { return TruncSatSFloat64ToInt64; } +BinaryenOp BinaryenTruncSatUFloat64ToInt32(void) { return TruncSatUFloat64ToInt32; } +BinaryenOp BinaryenTruncSatUFloat64ToInt64(void) { return TruncSatUFloat64ToInt64; } BinaryenExpressionRef BinaryenBlock(BinaryenModuleRef module, const char* name, BinaryenExpressionRef* children, BinaryenIndex numChildren, BinaryenType type) { auto* ret = ((Module*)module)->allocator.alloc<Block>(); diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 14fc38de3..dc47b379f 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -324,6 +324,14 @@ BinaryenOp BinaryenAtomicRMWAnd(void); BinaryenOp BinaryenAtomicRMWOr(void); BinaryenOp BinaryenAtomicRMWXor(void); BinaryenOp BinaryenAtomicRMWXchg(void); +BinaryenOp BinaryenTruncSatSFloat32ToInt32(void); +BinaryenOp BinaryenTruncSatSFloat32ToInt64(void); +BinaryenOp BinaryenTruncSatUFloat32ToInt32(void); +BinaryenOp BinaryenTruncSatUFloat32ToInt64(void); +BinaryenOp BinaryenTruncSatSFloat64ToInt32(void); +BinaryenOp BinaryenTruncSatSFloat64ToInt64(void); +BinaryenOp BinaryenTruncSatUFloat64ToInt32(void); +BinaryenOp BinaryenTruncSatUFloat64ToInt64(void); typedef void* BinaryenExpressionRef; diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc index 6cf004167..16399bfba 100644 --- a/src/gen-s-parser.inc +++ b/src/gen-s-parser.inc @@ -778,24 +778,56 @@ switch (op[0]) { case 't': { switch (op[10]) { case 's': { - switch (op[13]) { - case '3': - if (strcmp(op, "i32.trunc_s/f32") == 0) return makeUnary(s, UnaryOp::TruncSFloat32ToInt32); - goto parse_error; - case '6': - if (strcmp(op, "i32.trunc_s/f64") == 0) return makeUnary(s, UnaryOp::TruncSFloat64ToInt32); - goto parse_error; + switch (op[11]) { + case '/': { + switch (op[13]) { + case '3': + if (strcmp(op, "i32.trunc_s/f32") == 0) return makeUnary(s, UnaryOp::TruncSFloat32ToInt32); + goto parse_error; + case '6': + if (strcmp(op, "i32.trunc_s/f64") == 0) return makeUnary(s, UnaryOp::TruncSFloat64ToInt32); + goto parse_error; + default: goto parse_error; + } + } + case ':': { + switch (op[17]) { + case '3': + if (strcmp(op, "i32.trunc_s:sat/f32") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat32ToInt32); + goto parse_error; + case '6': + if (strcmp(op, "i32.trunc_s:sat/f64") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat64ToInt32); + goto parse_error; + default: goto parse_error; + } + } default: goto parse_error; } } case 'u': { - switch (op[13]) { - case '3': - if (strcmp(op, "i32.trunc_u/f32") == 0) return makeUnary(s, UnaryOp::TruncUFloat32ToInt32); - goto parse_error; - case '6': - if (strcmp(op, "i32.trunc_u/f64") == 0) return makeUnary(s, UnaryOp::TruncUFloat64ToInt32); - goto parse_error; + switch (op[11]) { + case '/': { + switch (op[13]) { + case '3': + if (strcmp(op, "i32.trunc_u/f32") == 0) return makeUnary(s, UnaryOp::TruncUFloat32ToInt32); + goto parse_error; + case '6': + if (strcmp(op, "i32.trunc_u/f64") == 0) return makeUnary(s, UnaryOp::TruncUFloat64ToInt32); + goto parse_error; + default: goto parse_error; + } + } + case ':': { + switch (op[17]) { + case '3': + if (strcmp(op, "i32.trunc_u:sat/f32") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat32ToInt32); + goto parse_error; + case '6': + if (strcmp(op, "i32.trunc_u:sat/f64") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat64ToInt32); + goto parse_error; + default: goto parse_error; + } + } default: goto parse_error; } } @@ -1275,24 +1307,56 @@ switch (op[0]) { case 't': { switch (op[10]) { case 's': { - switch (op[13]) { - case '3': - if (strcmp(op, "i64.trunc_s/f32") == 0) return makeUnary(s, UnaryOp::TruncSFloat32ToInt64); - goto parse_error; - case '6': - if (strcmp(op, "i64.trunc_s/f64") == 0) return makeUnary(s, UnaryOp::TruncSFloat64ToInt64); - goto parse_error; + switch (op[11]) { + case '/': { + switch (op[13]) { + case '3': + if (strcmp(op, "i64.trunc_s/f32") == 0) return makeUnary(s, UnaryOp::TruncSFloat32ToInt64); + goto parse_error; + case '6': + if (strcmp(op, "i64.trunc_s/f64") == 0) return makeUnary(s, UnaryOp::TruncSFloat64ToInt64); + goto parse_error; + default: goto parse_error; + } + } + case ':': { + switch (op[17]) { + case '3': + if (strcmp(op, "i64.trunc_s:sat/f32") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat32ToInt64); + goto parse_error; + case '6': + if (strcmp(op, "i64.trunc_s:sat/f64") == 0) return makeUnary(s, UnaryOp::TruncSatSFloat64ToInt64); + goto parse_error; + default: goto parse_error; + } + } default: goto parse_error; } } case 'u': { - switch (op[13]) { - case '3': - if (strcmp(op, "i64.trunc_u/f32") == 0) return makeUnary(s, UnaryOp::TruncUFloat32ToInt64); - goto parse_error; - case '6': - if (strcmp(op, "i64.trunc_u/f64") == 0) return makeUnary(s, UnaryOp::TruncUFloat64ToInt64); - goto parse_error; + switch (op[11]) { + case '/': { + switch (op[13]) { + case '3': + if (strcmp(op, "i64.trunc_u/f32") == 0) return makeUnary(s, UnaryOp::TruncUFloat32ToInt64); + goto parse_error; + case '6': + if (strcmp(op, "i64.trunc_u/f64") == 0) return makeUnary(s, UnaryOp::TruncUFloat64ToInt64); + goto parse_error; + default: goto parse_error; + } + } + case ':': { + switch (op[17]) { + case '3': + if (strcmp(op, "i64.trunc_u:sat/f32") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat32ToInt64); + goto parse_error; + case '6': + if (strcmp(op, "i64.trunc_u:sat/f64") == 0) return makeUnary(s, UnaryOp::TruncSatUFloat64ToInt64); + goto parse_error; + default: goto parse_error; + } + } default: goto parse_error; } } diff --git a/src/ir/cost.h b/src/ir/cost.h index 6dabf2fcb..e28f535e7 100644 --- a/src/ir/cost.h +++ b/src/ir/cost.h @@ -141,7 +141,15 @@ struct CostAnalyzer : public Visitor<CostAnalyzer, Index> { case ExtendS16Int32: case ExtendS8Int64: case ExtendS16Int64: - case ExtendS32Int64: ret = 1; break; + case ExtendS32Int64: + case TruncSatSFloat32ToInt32: + case TruncSatUFloat32ToInt32: + case TruncSatSFloat64ToInt32: + case TruncSatUFloat64ToInt32: + case TruncSatSFloat32ToInt64: + case TruncSatUFloat32ToInt64: + case TruncSatSFloat64ToInt64: + case TruncSatUFloat64ToInt64: ret = 1; break; case SqrtFloat32: case SqrtFloat64: ret = 2; break; case InvalidUnary: WASM_UNREACHABLE(); diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 06688d706..b63427935 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -101,6 +101,14 @@ Module['TruncSFloat64ToInt32'] = Module['_BinaryenTruncSFloat64ToInt32'](); Module['TruncSFloat64ToInt64'] = Module['_BinaryenTruncSFloat64ToInt64'](); Module['TruncUFloat64ToInt32'] = Module['_BinaryenTruncUFloat64ToInt32'](); Module['TruncUFloat64ToInt64'] = Module['_BinaryenTruncUFloat64ToInt64'](); +Module['TruncSatSFloat32ToInt32'] = Module['_BinaryenTruncSatSFloat32ToInt32'](); +Module['TruncSatSFloat32ToInt64'] = Module['_BinaryenTruncSatSFloat32ToInt64'](); +Module['TruncSatUFloat32ToInt32'] = Module['_BinaryenTruncSatUFloat32ToInt32'](); +Module['TruncSatUFloat32ToInt64'] = Module['_BinaryenTruncSatUFloat32ToInt64'](); +Module['TruncSatSFloat64ToInt32'] = Module['_BinaryenTruncSatSFloat64ToInt32'](); +Module['TruncSatSFloat64ToInt64'] = Module['_BinaryenTruncSatSFloat64ToInt64'](); +Module['TruncSatUFloat64ToInt32'] = Module['_BinaryenTruncSatUFloat64ToInt32'](); +Module['TruncSatUFloat64ToInt64'] = Module['_BinaryenTruncSatUFloat64ToInt64'](); Module['ReinterpretFloat32'] = Module['_BinaryenReinterpretFloat32'](); Module['ReinterpretFloat64'] = Module['_BinaryenReinterpretFloat64'](); Module['ConvertSInt32ToFloat32'] = Module['_BinaryenConvertSInt32ToFloat32'](); @@ -354,6 +362,22 @@ function wrapModule(module, self) { return Module['_BinaryenUnary'](module, Module['TruncUFloat64ToInt32'], value); }, }, + 'trunc_s_sat': { + 'f32': function(value) { + return Module['_BinaryenUnary'](module, Module['TruncSatSFloat32ToInt32'], value); + }, + 'f64': function(value) { + return Module['_BinaryenUnary'](module, Module['TruncSatSFloat64ToInt32'], value); + }, + }, + 'trunc_u_sat': { + 'f32': function(value) { + return Module['_BinaryenUnary'](module, Module['TruncSatUFloat32ToInt32'], value); + }, + 'f64': function(value) { + return Module['_BinaryenUnary'](module, Module['TruncSatUFloat64ToInt32'], value); + }, + }, 'reinterpret': function(value) { return Module['_BinaryenUnary'](module, Module['ReinterpretFloat32'], value); }, @@ -601,6 +625,22 @@ function wrapModule(module, self) { return Module['_BinaryenUnary'](module, Module['TruncUFloat64ToInt64'], value); }, }, + 'trunc_s_sat': { + 'f32': function(value) { + return Module['_BinaryenUnary'](module, Module['TruncSatSFloat32ToInt64'], value); + }, + 'f64': function(value) { + return Module['_BinaryenUnary'](module, Module['TruncSatSFloat64ToInt64'], value); + }, + }, + 'trunc_u_sat': { + 'f32': function(value) { + return Module['_BinaryenUnary'](module, Module['TruncSatUFloat32ToInt64'], value); + }, + 'f64': function(value) { + return Module['_BinaryenUnary'](module, Module['TruncSatUFloat64ToInt64'], value); + }, + }, 'reinterpret': function(value) { return Module['_BinaryenUnary'](module, Module['ReinterpretFloat64'], value); }, diff --git a/src/literal.h b/src/literal.h index aa9fd9705..1bc09c360 100644 --- a/src/literal.h +++ b/src/literal.h @@ -100,10 +100,15 @@ public: Literal truncateToI32() const; Literal truncateToF32() const; - Literal convertSToF32() const; - Literal convertUToF32() const; - Literal convertSToF64() const; - Literal convertUToF64() const; + Literal truncSIToF32() const; + Literal truncUIToF32() const; + Literal truncSIToF64() const; + Literal truncUIToF64() const; + + Literal truncSatToSI32() const; + Literal truncSatToSI64() const; + Literal truncSatToUI32() const; + Literal truncSatToUI64() const; Literal eqz() const; Literal neg() const; diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index e874321cd..51c7e9f97 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -292,6 +292,14 @@ struct PrintExpressionContents : public Visitor<PrintExpressionContents> { case ExtendS8Int64: o << "i64.extend8_s"; break; case ExtendS16Int64: o << "i64.extend16_s"; break; case ExtendS32Int64: o << "i64.extend32_s"; break; + case TruncSatSFloat32ToInt32: o << "i32.trunc_s:sat/f32"; break; + case TruncSatUFloat32ToInt32: o << "i32.trunc_u:sat/f32"; break; + case TruncSatSFloat64ToInt32: o << "i32.trunc_s:sat/f64"; break; + case TruncSatUFloat64ToInt32: o << "i32.trunc_u:sat/f64"; break; + case TruncSatSFloat32ToInt64: o << "i64.trunc_s:sat/f32"; break; + case TruncSatUFloat32ToInt64: o << "i64.trunc_u:sat/f32"; break; + case TruncSatSFloat64ToInt64: o << "i64.trunc_s:sat/f64"; break; + case TruncSatUFloat64ToInt64: o << "i64.trunc_u:sat/f64"; break; case InvalidUnary: WASM_UNREACHABLE(); } } diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index 8f7123a78..243616c8a 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -1322,8 +1322,22 @@ private: break; } case 1: return makeUnary({ pick(EqZInt64, WrapInt64), make(i64) }); - case 2: return makeUnary({ pick(TruncSFloat32ToInt32, TruncUFloat32ToInt32, ReinterpretFloat32), make(f32) }); - case 3: return makeUnary({ pick(TruncSFloat64ToInt32, TruncUFloat64ToInt32), make(f64) }); + case 2: { + if (features.hasTruncSat()) { + return makeUnary({ pick(TruncSFloat32ToInt32, TruncUFloat32ToInt32, ReinterpretFloat32, TruncSatSFloat32ToInt32, TruncSatUFloat32ToInt32), make(f32) }); + } else { + return makeUnary({ pick(TruncSFloat32ToInt32, TruncUFloat32ToInt32, ReinterpretFloat32), make(f32) }); + } + break; + } + case 3: { + if (features.hasTruncSat()) { + return makeUnary({ pick(TruncSFloat64ToInt32, TruncUFloat64ToInt32, TruncSatSFloat64ToInt32, TruncSatUFloat64ToInt32), make(f64) }); + } else { + return makeUnary({ pick(TruncSFloat64ToInt32, TruncUFloat64ToInt32), make(f64) }); + } + break; + } } WASM_UNREACHABLE(); } @@ -1338,8 +1352,22 @@ private: break; } case 1: return makeUnary({ pick(ExtendSInt32, ExtendUInt32), make(i32) }); - case 2: return makeUnary({ pick(TruncSFloat32ToInt64, TruncUFloat32ToInt64), make(f32) }); - case 3: return makeUnary({ pick(TruncSFloat64ToInt64, TruncUFloat64ToInt64, ReinterpretFloat64), make(f64) }); + case 2: { + if (features.hasTruncSat()) { + return makeUnary({ pick(TruncSFloat32ToInt64, TruncUFloat32ToInt64, TruncSatSFloat32ToInt64, TruncSatUFloat32ToInt64), make(f32) }); + } else { + return makeUnary({ pick(TruncSFloat32ToInt64, TruncUFloat32ToInt64), make(f32) }); + } + break; + } + case 3: { + if (features.hasTruncSat()) { + return makeUnary({ pick(TruncSFloat64ToInt64, TruncUFloat64ToInt64, ReinterpretFloat64, TruncSatSFloat64ToInt64, TruncSatUFloat64ToInt64), make(f64) }); + } else { + return makeUnary({ pick(TruncSFloat64ToInt64, TruncUFloat64ToInt64, ReinterpretFloat64), make(f64) }); + } + break; + } } WASM_UNREACHABLE(); } diff --git a/src/wasm-binary.h b/src/wasm-binary.h index c767cf5eb..eeeba98db 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -548,6 +548,7 @@ enum ASTNodes { I64ExtendS16 = 0xc3, I64ExtendS32 = 0xc4, + TruncSatPrefix = 0xfc, AtomicPrefix = 0xfe }; @@ -627,6 +628,16 @@ enum AtomicOpcodes { AtomicCmpxchgOps_End = 0x4e }; +enum TruncSatOpcodes { + I32STruncSatF32 = 0x00, + I32UTruncSatF32 = 0x01, + I32STruncSatF64 = 0x02, + I32UTruncSatF64 = 0x03, + I64STruncSatF32 = 0x04, + I64UTruncSatF32 = 0x05, + I64STruncSatF64 = 0x06, + I64UTruncSatF64 = 0x07, +}; enum MemoryAccess { Offset = 0x10, // bit 4 @@ -944,6 +955,7 @@ public: bool maybeVisitConst(Expression*& out, uint8_t code); bool maybeVisitUnary(Expression*& out, uint8_t code); bool maybeVisitBinary(Expression*& out, uint8_t code); + bool maybeVisitTruncSat(Expression*& out, uint32_t code); void visitSelect(Select* curr); void visitReturn(Return* curr); bool maybeVisitHost(Expression*& out, uint8_t code); diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 39ea488ef..fed74282d 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -256,13 +256,13 @@ public: case ExtendUInt32: return value.extendToUI64(); case WrapInt64: return value.truncateToI32(); case ConvertUInt32ToFloat32: - case ConvertUInt64ToFloat32: return value.convertUToF32(); + case ConvertUInt64ToFloat32: return value.truncUIToF32(); case ConvertUInt32ToFloat64: - case ConvertUInt64ToFloat64: return value.convertUToF64(); + case ConvertUInt64ToFloat64: return value.truncUIToF64(); case ConvertSInt32ToFloat32: - case ConvertSInt64ToFloat32: return value.convertSToF32(); + case ConvertSInt64ToFloat32: return value.truncSIToF32(); case ConvertSInt32ToFloat64: - case ConvertSInt64ToFloat64: return value.convertSToF64(); + case ConvertSInt64ToFloat64: return value.truncSIToF64(); case ExtendS8Int32: case ExtendS8Int64: return value.extendS8(); case ExtendS16Int32: @@ -291,6 +291,14 @@ public: case TruncUFloat64ToInt32: case TruncUFloat32ToInt64: case TruncUFloat64ToInt64: return truncUFloat(curr, value); + case TruncSatSFloat32ToInt32: + case TruncSatSFloat64ToInt32: return value.truncSatToSI32(); + case TruncSatSFloat32ToInt64: + case TruncSatSFloat64ToInt64: return value.truncSatToSI64(); + case TruncSatUFloat32ToInt32: + case TruncSatUFloat64ToInt32: return value.truncSatToUI32(); + case TruncSatUFloat32ToInt64: + case TruncSatUFloat64ToInt64: return value.truncSatToUI64(); case ReinterpretFloat32: return value.castToI32(); case PromoteFloat32: return value.extendToF64(); case ReinterpretFloat64: return value.castToI64(); diff --git a/src/wasm-stack.h b/src/wasm-stack.h index 1a937f81d..6e1150981 100644 --- a/src/wasm-stack.h +++ b/src/wasm-stack.h @@ -961,6 +961,14 @@ void StackWriter<Mode, Parent>::visitUnary(Unary* curr) { case ExtendS8Int64: o << int8_t(BinaryConsts::I64ExtendS8); break; case ExtendS16Int64: o << int8_t(BinaryConsts::I64ExtendS16); break; case ExtendS32Int64: o << int8_t(BinaryConsts::I64ExtendS32); break; + case TruncSatSFloat32ToInt32: o << int8_t(BinaryConsts::TruncSatPrefix) << U32LEB(BinaryConsts::I32STruncSatF32); break; + case TruncSatUFloat32ToInt32: o << int8_t(BinaryConsts::TruncSatPrefix) << U32LEB(BinaryConsts::I32UTruncSatF32); break; + case TruncSatSFloat64ToInt32: o << int8_t(BinaryConsts::TruncSatPrefix) << U32LEB(BinaryConsts::I32STruncSatF64); break; + case TruncSatUFloat64ToInt32: o << int8_t(BinaryConsts::TruncSatPrefix) << U32LEB(BinaryConsts::I32UTruncSatF64); break; + case TruncSatSFloat32ToInt64: o << int8_t(BinaryConsts::TruncSatPrefix) << U32LEB(BinaryConsts::I64STruncSatF32); break; + case TruncSatUFloat32ToInt64: o << int8_t(BinaryConsts::TruncSatPrefix) << U32LEB(BinaryConsts::I64UTruncSatF32); break; + case TruncSatSFloat64ToInt64: o << int8_t(BinaryConsts::TruncSatPrefix) << U32LEB(BinaryConsts::I64STruncSatF64); break; + case TruncSatUFloat64ToInt64: o << int8_t(BinaryConsts::TruncSatPrefix) << U32LEB(BinaryConsts::I64UTruncSatF64); break; case InvalidUnary: WASM_UNREACHABLE(); } } diff --git a/src/wasm.h b/src/wasm.h index 1d5677134..b7b835ebe 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -119,6 +119,9 @@ enum UnaryOp { // Extend signed subword-sized integer. This differs from e.g. ExtendSInt32 // because the input integer is in an i64 value insetad of an i32 value. ExtendS8Int32, ExtendS16Int32, ExtendS8Int64, ExtendS16Int64, ExtendS32Int64, + // Saturating float-to-int + TruncSatSFloat32ToInt32, TruncSatUFloat32ToInt32, TruncSatSFloat64ToInt32, TruncSatUFloat64ToInt32, + TruncSatSFloat32ToInt64, TruncSatUFloat32ToInt64, TruncSatSFloat64ToInt64, TruncSatUFloat64ToInt64, InvalidUnary }; diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 7b248010e..ece92c6ee 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -22,6 +22,7 @@ #include "emscripten-optimizer/simple_ast.h" #include "pretty_printing.h" #include "support/bits.h" +#include "support/utilities.h" #include "ir/bits.h" @@ -232,30 +233,108 @@ Literal Literal::truncateToF32() const { return Literal(float(getf64())); } -Literal Literal::convertSToF32() const { +Literal Literal::truncSIToF32() const { if (type == Type::i32) return Literal(float(i32)); if (type == Type::i64) return Literal(float(i64)); WASM_UNREACHABLE(); } -Literal Literal::convertUToF32() const { +Literal Literal::truncUIToF32() const { if (type == Type::i32) return Literal(float(uint32_t(i32))); if (type == Type::i64) return Literal(float(uint64_t(i64))); WASM_UNREACHABLE(); } -Literal Literal::convertSToF64() const { +Literal Literal::truncSIToF64() const { if (type == Type::i32) return Literal(double(i32)); if (type == Type::i64) return Literal(double(i64)); WASM_UNREACHABLE(); } -Literal Literal::convertUToF64() const { +Literal Literal::truncUIToF64() const { if (type == Type::i32) return Literal(double(uint32_t(i32))); if (type == Type::i64) return Literal(double(uint64_t(i64))); WASM_UNREACHABLE(); } +template<typename F> +struct AsInt { + using type = void; +}; +template<> struct AsInt<float> { using type = int32_t; }; +template<> struct AsInt<double> { using type = int64_t; }; + +template<typename F, typename I, bool (*RangeCheck)(typename AsInt<F>::type)> +static Literal saturating_trunc(typename AsInt<F>::type val) { + if (std::isnan(bit_cast<F>(val))) { + return Literal(I(0)); + } + if (!RangeCheck(val)) { + if (std::signbit(bit_cast<F>(val))) { + return Literal(std::numeric_limits<I>::min()); + } else { + return Literal(std::numeric_limits<I>::max()); + } + } + return Literal(I(std::trunc(bit_cast<F>(val)))); +} + +Literal Literal::truncSatToSI32() const { + if (type == Type::f32) { + return saturating_trunc<float, int32_t, isInRangeI32TruncS>( + Literal(*this).castToI32().geti32() + ); + } + if (type == Type::f64) { + return saturating_trunc<double, int32_t, isInRangeI32TruncS>( + Literal(*this).castToI64().geti64() + ); + } + WASM_UNREACHABLE(); +} + +Literal Literal::truncSatToSI64() const { + if (type == Type::f32) { + return saturating_trunc<float, int64_t, isInRangeI64TruncS>( + Literal(*this).castToI32().geti32() + ); + } + if (type == Type::f64) { + return saturating_trunc<double, int64_t, isInRangeI64TruncS>( + Literal(*this).castToI64().geti64() + ); + } + WASM_UNREACHABLE(); +} + +Literal Literal::truncSatToUI32() const { + if (type == Type::f32) { + return saturating_trunc<float, uint32_t, isInRangeI32TruncU>( + Literal(*this).castToI32().geti32() + ); + } + if (type == Type::f64) { + return saturating_trunc<double, uint32_t, isInRangeI32TruncU>( + Literal(*this).castToI64().geti64() + ); + } + WASM_UNREACHABLE(); +} + +Literal Literal::truncSatToUI64() const { + if (type == Type::f32) { + return saturating_trunc<float, uint64_t, isInRangeI64TruncU>( + Literal(*this).castToI32().geti32() + ); + } + if (type == Type::f64) { + return saturating_trunc<double, uint64_t, isInRangeI64TruncU>( + Literal(*this).castToI64().geti64() + ); + } + WASM_UNREACHABLE(); +} + Literal Literal::eqz() const { switch (type) { case Type::i32: return eq(Literal(int32_t(0))); diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index eebf0bd63..b36e629b0 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1692,6 +1692,12 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { throwError("invalid code after atomic prefix: " + std::to_string(code)); break; } + case BinaryConsts::TruncSatPrefix: { + uint32_t code = getU32LEB(); + if (maybeVisitTruncSat(curr, code)) break; + throwError("invalid code after nontrapping float-to-int prefix: " + std::to_string(code)); + break; + } default: { // otherwise, the code is a subcode TODO: optimize if (maybeVisitBinary(curr, code)) break; @@ -2276,6 +2282,26 @@ bool WasmBinaryBuilder::maybeVisitUnary(Expression*& out, uint8_t code) { return true; } +bool WasmBinaryBuilder::maybeVisitTruncSat(Expression*& out, uint32_t code) { + Unary* curr; + switch (code) { + case BinaryConsts::I32STruncSatF32: curr = allocator.alloc<Unary>(); curr->op = TruncSatSFloat32ToInt32; break; + case BinaryConsts::I32UTruncSatF32: curr = allocator.alloc<Unary>(); curr->op = TruncSatUFloat32ToInt32; break; + case BinaryConsts::I32STruncSatF64: curr = allocator.alloc<Unary>(); curr->op = TruncSatSFloat64ToInt32; break; + case BinaryConsts::I32UTruncSatF64: curr = allocator.alloc<Unary>(); curr->op = TruncSatUFloat64ToInt32; break; + case BinaryConsts::I64STruncSatF32: curr = allocator.alloc<Unary>(); curr->op = TruncSatSFloat32ToInt64; break; + case BinaryConsts::I64UTruncSatF32: curr = allocator.alloc<Unary>(); curr->op = TruncSatUFloat32ToInt64; break; + case BinaryConsts::I64STruncSatF64: curr = allocator.alloc<Unary>(); curr->op = TruncSatSFloat64ToInt64; break; + case BinaryConsts::I64UTruncSatF64: curr = allocator.alloc<Unary>(); curr->op = TruncSatUFloat64ToInt64; break; + default: return false; + } + if (debug) std::cerr << "zz node: Unary (nontrapping float-to-int)" << std::endl; + curr->value = popNonVoidExpression(); + curr->finalize(); + out = curr; + return true; +} + bool WasmBinaryBuilder::maybeVisitBinary(Expression*& out, uint8_t code) { Binary* curr; #define INT_TYPED_CODE(code) { \ diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index fa239688f..3f65c9f7a 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -723,36 +723,87 @@ void FunctionValidator::visitUnary(Unary* curr) { case ExtendUInt32: case ExtendS8Int32: case ExtendS16Int32: { - shouldBeEqual(curr->value->type, i32, curr, "extend type must be correct"); break; + shouldBeEqual(curr->value->type, i32, curr, "extend type must be correct"); + break; } case ExtendS8Int64: case ExtendS16Int64: case ExtendS32Int64: { - shouldBeEqual(curr->value->type, i64, curr, "extend type must be correct"); break; + shouldBeEqual(curr->value->type, i64, curr, "extend type must be correct"); + break; + } + case WrapInt64: { + shouldBeEqual(curr->value->type, i64, curr, "wrap type must be correct"); + break; + } + case TruncSFloat32ToInt32: + case TruncSFloat32ToInt64: + case TruncUFloat32ToInt32: + case TruncUFloat32ToInt64: { + shouldBeEqual(curr->value->type, f32, curr, "trunc type must be correct"); + break; + } + case TruncSatSFloat32ToInt32: + case TruncSatSFloat32ToInt64: + case TruncSatUFloat32ToInt32: + case TruncSatUFloat32ToInt64: { + shouldBeTrue(info.features.hasTruncSat(), curr, "nontrapping float-to-int conversions are disabled"); + shouldBeEqual(curr->value->type, f32, curr, "trunc type must be correct"); + break; + } + case TruncSFloat64ToInt32: + case TruncSFloat64ToInt64: + case TruncUFloat64ToInt32: + case TruncUFloat64ToInt64: { + shouldBeEqual(curr->value->type, f64, curr, "trunc type must be correct"); + break; + } + case TruncSatSFloat64ToInt32: + case TruncSatSFloat64ToInt64: + case TruncSatUFloat64ToInt32: + case TruncSatUFloat64ToInt64: { + shouldBeTrue(info.features.hasTruncSat(), curr, "nontrapping float-to-int conversions are disabled"); + shouldBeEqual(curr->value->type, f64, curr, "trunc type must be correct"); + break; + } + case ReinterpretFloat32: { + shouldBeEqual(curr->value->type, f32, curr, "reinterpret/f32 type must be correct"); + break; + } + case ReinterpretFloat64: { + shouldBeEqual(curr->value->type, f64, curr, "reinterpret/f64 type must be correct"); + break; + } + case ConvertUInt32ToFloat32: + case ConvertUInt32ToFloat64: + case ConvertSInt32ToFloat32: + case ConvertSInt32ToFloat64: { + shouldBeEqual(curr->value->type, i32, curr, "convert type must be correct"); + break; + } + case ConvertUInt64ToFloat32: + case ConvertUInt64ToFloat64: + case ConvertSInt64ToFloat32: + case ConvertSInt64ToFloat64: { + shouldBeEqual(curr->value->type, i64, curr, "convert type must be correct"); + break; + } + case PromoteFloat32: { + shouldBeEqual(curr->value->type, f32, curr, "promote type must be correct"); + break; + } + case DemoteFloat64: { + shouldBeEqual(curr->value->type, f64, curr, "demote type must be correct"); + break; + } + case ReinterpretInt32: { + shouldBeEqual(curr->value->type, i32, curr, "reinterpret/i32 type must be correct"); + break; + } + case ReinterpretInt64: { + shouldBeEqual(curr->value->type, i64, curr, "reinterpret/i64 type must be correct"); + break; } - case WrapInt64: shouldBeEqual(curr->value->type, i64, curr, "wrap type must be correct"); break; - case TruncSFloat32ToInt32: shouldBeEqual(curr->value->type, f32, curr, "trunc type must be correct"); break; - case TruncSFloat32ToInt64: shouldBeEqual(curr->value->type, f32, curr, "trunc type must be correct"); break; - case TruncUFloat32ToInt32: shouldBeEqual(curr->value->type, f32, curr, "trunc type must be correct"); break; - case TruncUFloat32ToInt64: shouldBeEqual(curr->value->type, f32, curr, "trunc type must be correct"); break; - case TruncSFloat64ToInt32: shouldBeEqual(curr->value->type, f64, curr, "trunc type must be correct"); break; - case TruncSFloat64ToInt64: shouldBeEqual(curr->value->type, f64, curr, "trunc type must be correct"); break; - case TruncUFloat64ToInt32: shouldBeEqual(curr->value->type, f64, curr, "trunc type must be correct"); break; - case TruncUFloat64ToInt64: shouldBeEqual(curr->value->type, f64, curr, "trunc type must be correct"); break; - case ReinterpretFloat32: shouldBeEqual(curr->value->type, f32, curr, "reinterpret/f32 type must be correct"); break; - case ReinterpretFloat64: shouldBeEqual(curr->value->type, f64, curr, "reinterpret/f64 type must be correct"); break; - case ConvertUInt32ToFloat32: shouldBeEqual(curr->value->type, i32, curr, "convert type must be correct"); break; - case ConvertUInt32ToFloat64: shouldBeEqual(curr->value->type, i32, curr, "convert type must be correct"); break; - case ConvertSInt32ToFloat32: shouldBeEqual(curr->value->type, i32, curr, "convert type must be correct"); break; - case ConvertSInt32ToFloat64: shouldBeEqual(curr->value->type, i32, curr, "convert type must be correct"); break; - case ConvertUInt64ToFloat32: shouldBeEqual(curr->value->type, i64, curr, "convert type must be correct"); break; - case ConvertUInt64ToFloat64: shouldBeEqual(curr->value->type, i64, curr, "convert type must be correct"); break; - case ConvertSInt64ToFloat32: shouldBeEqual(curr->value->type, i64, curr, "convert type must be correct"); break; - case ConvertSInt64ToFloat64: shouldBeEqual(curr->value->type, i64, curr, "convert type must be correct"); break; - case PromoteFloat32: shouldBeEqual(curr->value->type, f32, curr, "promote type must be correct"); break; - case DemoteFloat64: shouldBeEqual(curr->value->type, f64, curr, "demote type must be correct"); break; - case ReinterpretInt32: shouldBeEqual(curr->value->type, i32, curr, "reinterpret/i32 type must be correct"); break; - case ReinterpretInt64: shouldBeEqual(curr->value->type, i64, curr, "reinterpret/i64 type must be correct"); break; case InvalidUnary: WASM_UNREACHABLE(); } } diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index e0a9cff93..a1d7666ca 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -467,11 +467,19 @@ void Unary::finalize() { case TruncUFloat32ToInt32: case TruncSFloat64ToInt32: case TruncUFloat64ToInt32: + case TruncSatSFloat32ToInt32: + case TruncSatUFloat32ToInt32: + case TruncSatSFloat64ToInt32: + case TruncSatUFloat64ToInt32: case ReinterpretFloat32: type = i32; break; case TruncSFloat32ToInt64: case TruncUFloat32ToInt64: case TruncSFloat64ToInt64: case TruncUFloat64ToInt64: + case TruncSatSFloat32ToInt64: + case TruncSatUFloat32ToInt64: + case TruncSatSFloat64ToInt64: + case TruncSatUFloat64ToInt64: case ReinterpretFloat64: type = i64; break; case ReinterpretInt32: case ConvertSInt32ToFloat32: diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 4b78894d8..9fdaa0ad2 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -134,6 +134,14 @@ function test_core() { module.i64.trunc_s.f64(module.f64.const(-9005.841)), module.i32.trunc_u.f64(module.f64.const(-9005.841)), module.i64.trunc_u.f64(module.f64.const(-9005.841)), + module.i32.trunc_s_sat.f32(module.f32.const(-33.612)), + module.i64.trunc_s_sat.f32(module.f32.const(-33.612)), + module.i32.trunc_u_sat.f32(module.f32.const(-33.612)), + module.i64.trunc_u_sat.f32(module.f32.const(-33.612)), + module.i32.trunc_s_sat.f64(module.f64.const(-9005.841)), + module.i64.trunc_s_sat.f64(module.f64.const(-9005.841)), + module.i32.trunc_u_sat.f64(module.f64.const(-9005.841)), + module.i64.trunc_u_sat.f64(module.f64.const(-9005.841)), module.i32.reinterpret(module.f32.const(-33.612)), module.i64.reinterpret(module.f64.const(-9005.841)), module.f32.convert_s.i32(module.i32.const(-10)), diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index dc0961a8f..4a320bccc 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -172,6 +172,46 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} ) ) (drop + (i32.trunc_s:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i64.trunc_s:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i32.trunc_u:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i64.trunc_u:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i32.trunc_s:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i64.trunc_s:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i32.trunc_u:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i64.trunc_u:sat/f64 + (f64.const -9005.841) + ) + ) + (drop (i32.reinterpret/f32 (f32.const -33.61199951171875) ) @@ -1168,203 +1208,219 @@ int main() { expressions[65] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); expressions[66] = BinaryenUnary(the_module, 32, expressions[65]); expressions[67] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[68] = BinaryenUnary(the_module, 33, expressions[67]); - expressions[69] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[70] = BinaryenUnary(the_module, 34, expressions[69]); - expressions[71] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[72] = BinaryenUnary(the_module, 35, expressions[71]); - expressions[73] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[74] = BinaryenUnary(the_module, 36, expressions[73]); - expressions[75] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[76] = BinaryenUnary(the_module, 37, expressions[75]); - expressions[77] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[78] = BinaryenUnary(the_module, 38, expressions[77]); - expressions[79] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[80] = BinaryenUnary(the_module, 39, expressions[79]); - expressions[81] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[82] = BinaryenUnary(the_module, 40, expressions[81]); - expressions[83] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[84] = BinaryenUnary(the_module, 41, expressions[83]); - expressions[85] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[86] = BinaryenUnary(the_module, 42, expressions[85]); - expressions[87] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[88] = BinaryenUnary(the_module, 43, expressions[87]); - expressions[89] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[90] = BinaryenUnary(the_module, 44, expressions[89]); + expressions[68] = BinaryenUnary(the_module, 52, expressions[67]); + expressions[69] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[70] = BinaryenUnary(the_module, 56, expressions[69]); + expressions[71] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[72] = BinaryenUnary(the_module, 53, expressions[71]); + expressions[73] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[74] = BinaryenUnary(the_module, 57, expressions[73]); + expressions[75] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[76] = BinaryenUnary(the_module, 54, expressions[75]); + expressions[77] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[78] = BinaryenUnary(the_module, 58, expressions[77]); + expressions[79] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[80] = BinaryenUnary(the_module, 55, expressions[79]); + expressions[81] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[82] = BinaryenUnary(the_module, 59, expressions[81]); + expressions[83] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[84] = BinaryenUnary(the_module, 33, expressions[83]); + expressions[85] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[86] = BinaryenUnary(the_module, 34, expressions[85]); + expressions[87] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[88] = BinaryenUnary(the_module, 35, expressions[87]); + expressions[89] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[90] = BinaryenUnary(the_module, 36, expressions[89]); expressions[91] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[92] = BinaryenUnary(the_module, 45, expressions[91]); - expressions[93] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[94] = BinaryenUnary(the_module, 46, expressions[93]); - expressions[95] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[96] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[97] = BinaryenBinary(the_module, 0, expressions[95], expressions[96]); - expressions[98] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[99] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); - expressions[100] = BinaryenBinary(the_module, 64, expressions[98], expressions[99]); - expressions[101] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[102] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[103] = BinaryenBinary(the_module, 3, expressions[101], expressions[102]); - expressions[104] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); - expressions[105] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); - expressions[106] = BinaryenBinary(the_module, 29, expressions[104], expressions[105]); - expressions[107] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); - expressions[108] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); - expressions[109] = BinaryenBinary(the_module, 30, expressions[107], expressions[108]); - expressions[110] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[111] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[112] = BinaryenBinary(the_module, 6, expressions[110], expressions[111]); - expressions[113] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[114] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[115] = BinaryenBinary(the_module, 7, expressions[113], expressions[114]); - expressions[116] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); - expressions[117] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); - expressions[118] = BinaryenBinary(the_module, 33, expressions[116], expressions[117]); - expressions[119] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[120] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[121] = BinaryenBinary(the_module, 9, expressions[119], expressions[120]); - expressions[122] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); - expressions[123] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); - expressions[124] = BinaryenBinary(the_module, 35, expressions[122], expressions[123]); - expressions[125] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); - expressions[126] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); - expressions[127] = BinaryenBinary(the_module, 36, expressions[125], expressions[126]); - expressions[128] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[129] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[130] = BinaryenBinary(the_module, 12, expressions[128], expressions[129]); - expressions[131] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[132] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[133] = BinaryenBinary(the_module, 13, expressions[131], expressions[132]); - expressions[134] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); - expressions[135] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); - expressions[136] = BinaryenBinary(the_module, 39, expressions[134], expressions[135]); - expressions[137] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[138] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); - expressions[139] = BinaryenBinary(the_module, 53, expressions[137], expressions[138]); - expressions[140] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[141] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); - expressions[142] = BinaryenBinary(the_module, 67, expressions[140], expressions[141]); - expressions[143] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[144] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); - expressions[145] = BinaryenBinary(the_module, 55, expressions[143], expressions[144]); - expressions[146] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[147] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); - expressions[148] = BinaryenBinary(the_module, 69, expressions[146], expressions[147]); - expressions[149] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[150] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[151] = BinaryenBinary(the_module, 15, expressions[149], expressions[150]); - expressions[152] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[153] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); - expressions[154] = BinaryenBinary(the_module, 58, expressions[152], expressions[153]); - expressions[155] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[156] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[157] = BinaryenBinary(the_module, 17, expressions[155], expressions[156]); - expressions[158] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); - expressions[159] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); - expressions[160] = BinaryenBinary(the_module, 43, expressions[158], expressions[159]); - expressions[161] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); - expressions[162] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); - expressions[163] = BinaryenBinary(the_module, 44, expressions[161], expressions[162]); - expressions[164] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[165] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[166] = BinaryenBinary(the_module, 20, expressions[164], expressions[165]); - expressions[167] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); - expressions[168] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); - expressions[169] = BinaryenBinary(the_module, 46, expressions[167], expressions[168]); - expressions[170] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[171] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[172] = BinaryenBinary(the_module, 22, expressions[170], expressions[171]); - expressions[173] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[174] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[175] = BinaryenBinary(the_module, 23, expressions[173], expressions[174]); - expressions[176] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); - expressions[177] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); - expressions[178] = BinaryenBinary(the_module, 49, expressions[176], expressions[177]); - expressions[179] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[180] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); - expressions[181] = BinaryenBinary(the_module, 59, expressions[179], expressions[180]); - expressions[182] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[183] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); - expressions[184] = BinaryenBinary(the_module, 73, expressions[182], expressions[183]); - expressions[185] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[186] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); - expressions[187] = BinaryenBinary(the_module, 74, expressions[185], expressions[186]); - expressions[188] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[189] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); - expressions[190] = BinaryenBinary(the_module, 62, expressions[188], expressions[189]); + expressions[92] = BinaryenUnary(the_module, 37, expressions[91]); + expressions[93] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[94] = BinaryenUnary(the_module, 38, expressions[93]); + expressions[95] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[96] = BinaryenUnary(the_module, 39, expressions[95]); + expressions[97] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[98] = BinaryenUnary(the_module, 40, expressions[97]); + expressions[99] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[100] = BinaryenUnary(the_module, 41, expressions[99]); + expressions[101] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[102] = BinaryenUnary(the_module, 42, expressions[101]); + expressions[103] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[104] = BinaryenUnary(the_module, 43, expressions[103]); + expressions[105] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[106] = BinaryenUnary(the_module, 44, expressions[105]); + expressions[107] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[108] = BinaryenUnary(the_module, 45, expressions[107]); + expressions[109] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[110] = BinaryenUnary(the_module, 46, expressions[109]); + expressions[111] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[112] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[113] = BinaryenBinary(the_module, 0, expressions[111], expressions[112]); + expressions[114] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[115] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); + expressions[116] = BinaryenBinary(the_module, 64, expressions[114], expressions[115]); + expressions[117] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[118] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[119] = BinaryenBinary(the_module, 3, expressions[117], expressions[118]); + expressions[120] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); + expressions[121] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); + expressions[122] = BinaryenBinary(the_module, 29, expressions[120], expressions[121]); + expressions[123] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); + expressions[124] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); + expressions[125] = BinaryenBinary(the_module, 30, expressions[123], expressions[124]); + expressions[126] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[127] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[128] = BinaryenBinary(the_module, 6, expressions[126], expressions[127]); + expressions[129] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[130] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[131] = BinaryenBinary(the_module, 7, expressions[129], expressions[130]); + expressions[132] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); + expressions[133] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); + expressions[134] = BinaryenBinary(the_module, 33, expressions[132], expressions[133]); + expressions[135] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[136] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[137] = BinaryenBinary(the_module, 9, expressions[135], expressions[136]); + expressions[138] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); + expressions[139] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); + expressions[140] = BinaryenBinary(the_module, 35, expressions[138], expressions[139]); + expressions[141] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); + expressions[142] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); + expressions[143] = BinaryenBinary(the_module, 36, expressions[141], expressions[142]); + expressions[144] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[145] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[146] = BinaryenBinary(the_module, 12, expressions[144], expressions[145]); + expressions[147] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[148] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[149] = BinaryenBinary(the_module, 13, expressions[147], expressions[148]); + expressions[150] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); + expressions[151] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); + expressions[152] = BinaryenBinary(the_module, 39, expressions[150], expressions[151]); + expressions[153] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[154] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); + expressions[155] = BinaryenBinary(the_module, 53, expressions[153], expressions[154]); + expressions[156] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[157] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); + expressions[158] = BinaryenBinary(the_module, 67, expressions[156], expressions[157]); + expressions[159] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[160] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); + expressions[161] = BinaryenBinary(the_module, 55, expressions[159], expressions[160]); + expressions[162] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[163] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); + expressions[164] = BinaryenBinary(the_module, 69, expressions[162], expressions[163]); + expressions[165] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[166] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[167] = BinaryenBinary(the_module, 15, expressions[165], expressions[166]); + expressions[168] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[169] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); + expressions[170] = BinaryenBinary(the_module, 58, expressions[168], expressions[169]); + expressions[171] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[172] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[173] = BinaryenBinary(the_module, 17, expressions[171], expressions[172]); + expressions[174] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); + expressions[175] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); + expressions[176] = BinaryenBinary(the_module, 43, expressions[174], expressions[175]); + expressions[177] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); + expressions[178] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); + expressions[179] = BinaryenBinary(the_module, 44, expressions[177], expressions[178]); + expressions[180] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[181] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[182] = BinaryenBinary(the_module, 20, expressions[180], expressions[181]); + expressions[183] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); + expressions[184] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); + expressions[185] = BinaryenBinary(the_module, 46, expressions[183], expressions[184]); + expressions[186] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[187] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[188] = BinaryenBinary(the_module, 22, expressions[186], expressions[187]); + expressions[189] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[190] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[191] = BinaryenBinary(the_module, 23, expressions[189], expressions[190]); + expressions[192] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967274)); + expressions[193] = BinaryenConst(the_module, BinaryenLiteralInt64(4294967273)); + expressions[194] = BinaryenBinary(the_module, 49, expressions[192], expressions[193]); + expressions[195] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[196] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); + expressions[197] = BinaryenBinary(the_module, 59, expressions[195], expressions[196]); + expressions[198] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[199] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); + expressions[200] = BinaryenBinary(the_module, 73, expressions[198], expressions[199]); + expressions[201] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[202] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); + expressions[203] = BinaryenBinary(the_module, 74, expressions[201], expressions[202]); + expressions[204] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[205] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); + expressions[206] = BinaryenBinary(the_module, 62, expressions[204], expressions[205]); { BinaryenExpressionRef children[] = { 0 }; - expressions[191] = BinaryenBlock(the_module, NULL, children, 0, 0); - } - expressions[192] = BinaryenIf(the_module, expressions[7], expressions[8], expressions[9]); - expressions[193] = BinaryenIf(the_module, expressions[10], expressions[11], expressions[0]); - expressions[194] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[195] = BinaryenLoop(the_module, "in", expressions[194]); - expressions[196] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[197] = BinaryenLoop(the_module, NULL, expressions[196]); - expressions[198] = BinaryenBreak(the_module, "the-value", expressions[12], expressions[13]); - expressions[199] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - expressions[200] = BinaryenBreak(the_module, "the-nothing", expressions[199], expressions[0]); - expressions[201] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); - expressions[202] = BinaryenBreak(the_module, "the-value", expressions[0], expressions[201]); - expressions[203] = BinaryenBreak(the_module, "the-nothing", expressions[0], expressions[0]); + expressions[207] = BinaryenBlock(the_module, NULL, children, 0, 0); + } + expressions[208] = BinaryenIf(the_module, expressions[7], expressions[8], expressions[9]); + expressions[209] = BinaryenIf(the_module, expressions[10], expressions[11], expressions[0]); + expressions[210] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[211] = BinaryenLoop(the_module, "in", expressions[210]); + expressions[212] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[213] = BinaryenLoop(the_module, NULL, expressions[212]); + expressions[214] = BinaryenBreak(the_module, "the-value", expressions[12], expressions[13]); + expressions[215] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[216] = BinaryenBreak(the_module, "the-nothing", expressions[215], expressions[0]); + expressions[217] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); + expressions[218] = BinaryenBreak(the_module, "the-value", expressions[0], expressions[217]); + expressions[219] = BinaryenBreak(the_module, "the-nothing", expressions[0], expressions[0]); { const char* names[] = { "the-value" }; - expressions[204] = BinaryenSwitch(the_module, names, 1, "the-value", expressions[14], expressions[15]); + expressions[220] = BinaryenSwitch(the_module, names, 1, "the-value", expressions[14], expressions[15]); } - expressions[205] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[221] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); { const char* names[] = { "the-nothing" }; - expressions[206] = BinaryenSwitch(the_module, names, 1, "the-nothing", expressions[205], expressions[0]); - } - expressions[207] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); - expressions[208] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); - expressions[209] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); - expressions[210] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); - { - BinaryenExpressionRef operands[] = { expressions[207], expressions[208], expressions[209], expressions[210] }; - expressions[211] = BinaryenCall(the_module, "kitchen()sinker", operands, 4, 1); - } - expressions[212] = BinaryenUnary(the_module, 20, expressions[211]); - expressions[213] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); - expressions[214] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); - { - BinaryenExpressionRef operands[] = { expressions[213], expressions[214] }; - expressions[215] = BinaryenCall(the_module, "an-imported", operands, 2, 3); - } - expressions[216] = BinaryenUnary(the_module, 25, expressions[215]); - expressions[217] = BinaryenUnary(the_module, 20, expressions[216]); - expressions[218] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); - expressions[219] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); - expressions[220] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); - expressions[221] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); - expressions[222] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); - { - BinaryenExpressionRef operands[] = { expressions[219], expressions[220], expressions[221], expressions[222] }; - expressions[223] = BinaryenCallIndirect(the_module, expressions[218], operands, 4, "iiIfF"); - } - expressions[224] = BinaryenUnary(the_module, 20, expressions[223]); - expressions[225] = BinaryenGetLocal(the_module, 0, 1); - expressions[226] = BinaryenDrop(the_module, expressions[225]); - expressions[227] = BinaryenConst(the_module, BinaryenLiteralInt32(101)); - expressions[228] = BinaryenSetLocal(the_module, 0, expressions[227]); - expressions[229] = BinaryenConst(the_module, BinaryenLiteralInt32(102)); - expressions[230] = BinaryenTeeLocal(the_module, 0, expressions[229]); - expressions[231] = BinaryenDrop(the_module, expressions[230]); - expressions[232] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - expressions[233] = BinaryenLoad(the_module, 4, 1, 0, 0, 1, expressions[232]); - expressions[234] = BinaryenConst(the_module, BinaryenLiteralInt32(8)); - expressions[235] = BinaryenLoad(the_module, 2, 1, 2, 1, 2, expressions[234]); - expressions[236] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - expressions[237] = BinaryenLoad(the_module, 4, 1, 0, 0, 3, expressions[236]); - expressions[238] = BinaryenConst(the_module, BinaryenLiteralInt32(9)); - expressions[239] = BinaryenLoad(the_module, 8, 1, 2, 8, 4, expressions[238]); - expressions[240] = BinaryenStore(the_module, 4, 0, 0, expressions[19], expressions[20], 1); - expressions[241] = BinaryenStore(the_module, 8, 2, 4, expressions[21], expressions[22], 2); - expressions[242] = BinaryenSelect(the_module, expressions[16], expressions[17], expressions[18]); - expressions[243] = BinaryenConst(the_module, BinaryenLiteralInt32(1337)); - expressions[244] = BinaryenReturn(the_module, expressions[243]); - expressions[245] = BinaryenNop(the_module); - expressions[246] = BinaryenUnreachable(the_module); + expressions[222] = BinaryenSwitch(the_module, names, 1, "the-nothing", expressions[221], expressions[0]); + } + expressions[223] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); + expressions[224] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); + expressions[225] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); + expressions[226] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); + { + BinaryenExpressionRef operands[] = { expressions[223], expressions[224], expressions[225], expressions[226] }; + expressions[227] = BinaryenCall(the_module, "kitchen()sinker", operands, 4, 1); + } + expressions[228] = BinaryenUnary(the_module, 20, expressions[227]); + expressions[229] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); + expressions[230] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); + { + BinaryenExpressionRef operands[] = { expressions[229], expressions[230] }; + expressions[231] = BinaryenCall(the_module, "an-imported", operands, 2, 3); + } + expressions[232] = BinaryenUnary(the_module, 25, expressions[231]); + expressions[233] = BinaryenUnary(the_module, 20, expressions[232]); + expressions[234] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); + expressions[235] = BinaryenConst(the_module, BinaryenLiteralInt32(13)); + expressions[236] = BinaryenConst(the_module, BinaryenLiteralInt64(37)); + expressions[237] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); + expressions[238] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); + { + BinaryenExpressionRef operands[] = { expressions[235], expressions[236], expressions[237], expressions[238] }; + expressions[239] = BinaryenCallIndirect(the_module, expressions[234], operands, 4, "iiIfF"); + } + expressions[240] = BinaryenUnary(the_module, 20, expressions[239]); + expressions[241] = BinaryenGetLocal(the_module, 0, 1); + expressions[242] = BinaryenDrop(the_module, expressions[241]); + expressions[243] = BinaryenConst(the_module, BinaryenLiteralInt32(101)); + expressions[244] = BinaryenSetLocal(the_module, 0, expressions[243]); + expressions[245] = BinaryenConst(the_module, BinaryenLiteralInt32(102)); + expressions[246] = BinaryenTeeLocal(the_module, 0, expressions[245]); + expressions[247] = BinaryenDrop(the_module, expressions[246]); + expressions[248] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + expressions[249] = BinaryenLoad(the_module, 4, 1, 0, 0, 1, expressions[248]); + expressions[250] = BinaryenConst(the_module, BinaryenLiteralInt32(8)); + expressions[251] = BinaryenLoad(the_module, 2, 1, 2, 1, 2, expressions[250]); + expressions[252] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[253] = BinaryenLoad(the_module, 4, 1, 0, 0, 3, expressions[252]); + expressions[254] = BinaryenConst(the_module, BinaryenLiteralInt32(9)); + expressions[255] = BinaryenLoad(the_module, 8, 1, 2, 8, 4, expressions[254]); + expressions[256] = BinaryenStore(the_module, 4, 0, 0, expressions[19], expressions[20], 1); + expressions[257] = BinaryenStore(the_module, 8, 2, 4, expressions[21], expressions[22], 2); + expressions[258] = BinaryenSelect(the_module, expressions[16], expressions[17], expressions[18]); + expressions[259] = BinaryenConst(the_module, BinaryenLiteralInt32(1337)); + expressions[260] = BinaryenReturn(the_module, expressions[259]); + expressions[261] = BinaryenNop(the_module); + expressions[262] = BinaryenUnreachable(the_module); BinaryenExpressionGetId(expressions[30]); BinaryenExpressionGetType(expressions[30]); BinaryenUnaryGetOp(expressions[30]); @@ -1375,26 +1431,26 @@ getExpressionInfo={"id":15,"type":3,"op":6} (f32.const -33.61199951171875) ) - expressions[247] = BinaryenConst(the_module, BinaryenLiteralInt32(5)); - BinaryenExpressionGetId(expressions[247]); - BinaryenExpressionGetType(expressions[247]); - BinaryenConstGetValueI32(expressions[247]); + expressions[263] = BinaryenConst(the_module, BinaryenLiteralInt32(5)); + BinaryenExpressionGetId(expressions[263]); + BinaryenExpressionGetType(expressions[263]); + BinaryenConstGetValueI32(expressions[263]); getExpressionInfo(i32.const)={"id":14,"type":1,"value":5} - expressions[248] = BinaryenConst(the_module, BinaryenLiteralInt64(30064771078)); - BinaryenExpressionGetId(expressions[248]); - BinaryenExpressionGetType(expressions[248]); - BinaryenConstGetValueI64Low(expressions[248]); - BinaryenConstGetValueI64High(expressions[248]); + expressions[264] = BinaryenConst(the_module, BinaryenLiteralInt64(30064771078)); + BinaryenExpressionGetId(expressions[264]); + BinaryenExpressionGetType(expressions[264]); + BinaryenConstGetValueI64Low(expressions[264]); + BinaryenConstGetValueI64High(expressions[264]); getExpressionInfo(i64.const)={"id":14,"type":2,"value":{"low":6,"high":7}} - expressions[249] = BinaryenConst(the_module, BinaryenLiteralFloat32(8.5)); - BinaryenExpressionGetId(expressions[249]); - BinaryenExpressionGetType(expressions[249]); - BinaryenConstGetValueF32(expressions[249]); + expressions[265] = BinaryenConst(the_module, BinaryenLiteralFloat32(8.5)); + BinaryenExpressionGetId(expressions[265]); + BinaryenExpressionGetType(expressions[265]); + BinaryenConstGetValueF32(expressions[265]); getExpressionInfo(f32.const)={"id":14,"type":3,"value":8.5} - expressions[250] = BinaryenConst(the_module, BinaryenLiteralFloat64(9.5)); - BinaryenExpressionGetId(expressions[250]); - BinaryenExpressionGetType(expressions[250]); - BinaryenConstGetValueF64(expressions[250]); + expressions[266] = BinaryenConst(the_module, BinaryenLiteralFloat64(9.5)); + BinaryenExpressionGetId(expressions[266]); + BinaryenExpressionGetType(expressions[266]); + BinaryenConstGetValueF64(expressions[266]); getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} { BinaryenExpressionRef children[] = { expressions[24], expressions[26], expressions[28], expressions[30], expressions[32], @@ -1403,31 +1459,33 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} expressions[58], expressions[60], expressions[62], expressions[64], expressions[66], expressions[68], expressions[70], expressions[72], expressions[74], expressions[76], expressions[78], expressions[80], expressions[82], expressions[84], expressions[86], expressions[88], expressions[90], expressions[92], - expressions[94], expressions[97], expressions[100], expressions[103], expressions[106], expressions[109], - expressions[112], expressions[115], expressions[118], expressions[121], expressions[124], expressions[127], - expressions[130], expressions[133], expressions[136], expressions[139], expressions[142], expressions[145], - expressions[148], expressions[151], expressions[154], expressions[157], expressions[160], expressions[163], - expressions[166], expressions[169], expressions[172], expressions[175], expressions[178], expressions[181], - expressions[184], expressions[187], expressions[190], expressions[191], expressions[192], expressions[193], - expressions[195], expressions[197], expressions[198], expressions[200], expressions[202], expressions[203], - expressions[204], expressions[206], expressions[212], expressions[217], expressions[224], expressions[226], - expressions[228], expressions[231], expressions[233], expressions[235], expressions[237], expressions[239], - expressions[240], expressions[241], expressions[242], expressions[244], expressions[245], expressions[246] }; - expressions[251] = BinaryenBlock(the_module, "the-value", children, 95, 0); + expressions[94], expressions[96], expressions[98], expressions[100], expressions[102], expressions[104], + expressions[106], expressions[108], expressions[110], expressions[113], expressions[116], expressions[119], + expressions[122], expressions[125], expressions[128], expressions[131], expressions[134], expressions[137], + expressions[140], expressions[143], expressions[146], expressions[149], expressions[152], expressions[155], + expressions[158], expressions[161], expressions[164], expressions[167], expressions[170], expressions[173], + expressions[176], expressions[179], expressions[182], expressions[185], expressions[188], expressions[191], + expressions[194], expressions[197], expressions[200], expressions[203], expressions[206], expressions[207], + expressions[208], expressions[209], expressions[211], expressions[213], expressions[214], expressions[216], + expressions[218], expressions[219], expressions[220], expressions[222], expressions[228], expressions[233], + expressions[240], expressions[242], expressions[244], expressions[247], expressions[249], expressions[251], + expressions[253], expressions[255], expressions[256], expressions[257], expressions[258], expressions[260], + expressions[261], expressions[262] }; + expressions[267] = BinaryenBlock(the_module, "the-value", children, 103, 0); } - expressions[252] = BinaryenDrop(the_module, expressions[251]); + expressions[268] = BinaryenDrop(the_module, expressions[267]); { - BinaryenExpressionRef children[] = { expressions[252] }; - expressions[253] = BinaryenBlock(the_module, "the-nothing", children, 1, 0); + BinaryenExpressionRef children[] = { expressions[268] }; + expressions[269] = BinaryenBlock(the_module, "the-nothing", children, 1, 0); } - expressions[254] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); + expressions[270] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); { - BinaryenExpressionRef children[] = { expressions[253], expressions[254] }; - expressions[255] = BinaryenBlock(the_module, "the-body", children, 2, 0); + BinaryenExpressionRef children[] = { expressions[269], expressions[270] }; + expressions[271] = BinaryenBlock(the_module, "the-body", children, 2, 0); } { BinaryenType varTypes[] = { 1 }; - functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 1, expressions[255]); + functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 1, expressions[271]); } { BinaryenType paramTypes[] = { 1, 4 }; @@ -1452,11 +1510,11 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} const char* funcNames[] = { "kitchen()sinker" }; BinaryenSetFunctionTable(the_module, 1, 4294967295, funcNames, 1); } - expressions[256] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); + expressions[272] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); { const char segment0[] = { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100 }; const char* segments[] = { segment0 }; - BinaryenExpressionRef segmentOffsets[] = { expressions[256] }; + BinaryenExpressionRef segmentOffsets[] = { expressions[272] }; BinaryenIndex segmentSizes[] = { 12 }; BinaryenSetMemory(the_module, 1, 256, "mem", segments, segmentOffsets, segmentSizes, 1, 0); } @@ -1464,10 +1522,10 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} BinaryenType paramTypes[] = { 0 }; functionTypes[2] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0); } - expressions[257] = BinaryenNop(the_module); + expressions[273] = BinaryenNop(the_module); { BinaryenType varTypes[] = { 0 }; - functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[2], varTypes, 0, expressions[257]); + functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[2], varTypes, 0, expressions[273]); } BinaryenSetStart(the_module, functions[1]); { @@ -1607,6 +1665,46 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} ) ) (drop + (i32.trunc_s:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i64.trunc_s:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i32.trunc_u:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i64.trunc_u:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i32.trunc_s:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i64.trunc_s:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i32.trunc_u:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i64.trunc_u:sat/f64 + (f64.const -9005.841) + ) + ) + (drop (i32.reinterpret/f32 (f32.const -33.61199951171875) ) diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 9271e3371..d056d0e75 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -138,6 +138,14 @@ void test_core() { makeUnary(module, BinaryenTruncSFloat64ToInt64(), 4), makeUnary(module, BinaryenTruncUFloat64ToInt32(), 4), makeUnary(module, BinaryenTruncUFloat64ToInt64(), 4), + makeUnary(module, BinaryenTruncSatSFloat32ToInt32(), 3), + makeUnary(module, BinaryenTruncSatSFloat32ToInt64(), 3), + makeUnary(module, BinaryenTruncSatUFloat32ToInt32(), 3), + makeUnary(module, BinaryenTruncSatUFloat32ToInt64(), 3), + makeUnary(module, BinaryenTruncSatSFloat64ToInt32(), 4), + makeUnary(module, BinaryenTruncSatSFloat64ToInt64(), 4), + makeUnary(module, BinaryenTruncSatUFloat64ToInt32(), 4), + makeUnary(module, BinaryenTruncSatUFloat64ToInt64(), 4), makeUnary(module, BinaryenReinterpretFloat32(), 3), makeUnary(module, BinaryenReinterpretFloat64(), 4), makeUnary(module, BinaryenConvertSInt32ToFloat32(), 1), diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index faf3c336b..786cf5243 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -141,6 +141,46 @@ BinaryenTypeAuto: -1 ) ) (drop + (i32.trunc_s:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i64.trunc_s:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i32.trunc_u:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i64.trunc_u:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i32.trunc_s:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i64.trunc_s:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i32.trunc_u:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i64.trunc_u:sat/f64 + (f64.const -9005.841) + ) + ) + (drop (i32.reinterpret/f32 (f32.const -33.61199951171875) ) @@ -1146,193 +1186,209 @@ int main() { expressions[75] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); expressions[76] = BinaryenUnary(the_module, 32, expressions[75]); expressions[77] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[78] = BinaryenUnary(the_module, 33, expressions[77]); - expressions[79] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[80] = BinaryenUnary(the_module, 34, expressions[79]); - expressions[81] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[82] = BinaryenUnary(the_module, 35, expressions[81]); - expressions[83] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[84] = BinaryenUnary(the_module, 36, expressions[83]); - expressions[85] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[86] = BinaryenUnary(the_module, 37, expressions[85]); - expressions[87] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[88] = BinaryenUnary(the_module, 38, expressions[87]); - expressions[89] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[90] = BinaryenUnary(the_module, 39, expressions[89]); - expressions[91] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[92] = BinaryenUnary(the_module, 40, expressions[91]); - expressions[93] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[94] = BinaryenUnary(the_module, 41, expressions[93]); - expressions[95] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[96] = BinaryenUnary(the_module, 42, expressions[95]); - expressions[97] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[98] = BinaryenUnary(the_module, 43, expressions[97]); - expressions[99] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[100] = BinaryenUnary(the_module, 44, expressions[99]); + expressions[78] = BinaryenUnary(the_module, 52, expressions[77]); + expressions[79] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[80] = BinaryenUnary(the_module, 56, expressions[79]); + expressions[81] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[82] = BinaryenUnary(the_module, 53, expressions[81]); + expressions[83] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[84] = BinaryenUnary(the_module, 57, expressions[83]); + expressions[85] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[86] = BinaryenUnary(the_module, 54, expressions[85]); + expressions[87] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[88] = BinaryenUnary(the_module, 58, expressions[87]); + expressions[89] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[90] = BinaryenUnary(the_module, 55, expressions[89]); + expressions[91] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[92] = BinaryenUnary(the_module, 59, expressions[91]); + expressions[93] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[94] = BinaryenUnary(the_module, 33, expressions[93]); + expressions[95] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[96] = BinaryenUnary(the_module, 34, expressions[95]); + expressions[97] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[98] = BinaryenUnary(the_module, 35, expressions[97]); + expressions[99] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[100] = BinaryenUnary(the_module, 36, expressions[99]); expressions[101] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[102] = BinaryenUnary(the_module, 45, expressions[101]); - expressions[103] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[104] = BinaryenUnary(the_module, 46, expressions[103]); - expressions[105] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[106] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[107] = BinaryenBinary(the_module, 0, expressions[106], expressions[105]); - expressions[108] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); - expressions[109] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[110] = BinaryenBinary(the_module, 64, expressions[109], expressions[108]); - expressions[111] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[112] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[113] = BinaryenBinary(the_module, 3, expressions[112], expressions[111]); - expressions[114] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); - expressions[115] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[116] = BinaryenBinary(the_module, 29, expressions[115], expressions[114]); - expressions[117] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); - expressions[118] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[119] = BinaryenBinary(the_module, 30, expressions[118], expressions[117]); - expressions[120] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[121] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[122] = BinaryenBinary(the_module, 6, expressions[121], expressions[120]); - expressions[123] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[124] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[125] = BinaryenBinary(the_module, 7, expressions[124], expressions[123]); - expressions[126] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); - expressions[127] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[128] = BinaryenBinary(the_module, 33, expressions[127], expressions[126]); - expressions[129] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[130] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[131] = BinaryenBinary(the_module, 9, expressions[130], expressions[129]); - expressions[132] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); - expressions[133] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[134] = BinaryenBinary(the_module, 35, expressions[133], expressions[132]); - expressions[135] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); - expressions[136] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[137] = BinaryenBinary(the_module, 36, expressions[136], expressions[135]); - expressions[138] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[139] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[140] = BinaryenBinary(the_module, 12, expressions[139], expressions[138]); - expressions[141] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[142] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[143] = BinaryenBinary(the_module, 13, expressions[142], expressions[141]); - expressions[144] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); - expressions[145] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[146] = BinaryenBinary(the_module, 39, expressions[145], expressions[144]); - expressions[147] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); - expressions[148] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[149] = BinaryenBinary(the_module, 53, expressions[148], expressions[147]); - expressions[150] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); - expressions[151] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[152] = BinaryenBinary(the_module, 67, expressions[151], expressions[150]); - expressions[153] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); - expressions[154] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[155] = BinaryenBinary(the_module, 55, expressions[154], expressions[153]); - expressions[156] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); - expressions[157] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[158] = BinaryenBinary(the_module, 69, expressions[157], expressions[156]); - expressions[159] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[160] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[161] = BinaryenBinary(the_module, 15, expressions[160], expressions[159]); - expressions[162] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); - expressions[163] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[164] = BinaryenBinary(the_module, 58, expressions[163], expressions[162]); - expressions[165] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[166] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[167] = BinaryenBinary(the_module, 17, expressions[166], expressions[165]); - expressions[168] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); - expressions[169] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[170] = BinaryenBinary(the_module, 43, expressions[169], expressions[168]); - expressions[171] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); - expressions[172] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[173] = BinaryenBinary(the_module, 44, expressions[172], expressions[171]); - expressions[174] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[175] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[176] = BinaryenBinary(the_module, 20, expressions[175], expressions[174]); - expressions[177] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); - expressions[178] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[179] = BinaryenBinary(the_module, 46, expressions[178], expressions[177]); - expressions[180] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[181] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[182] = BinaryenBinary(the_module, 22, expressions[181], expressions[180]); - expressions[183] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); - expressions[184] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - expressions[185] = BinaryenBinary(the_module, 23, expressions[184], expressions[183]); - expressions[186] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); - expressions[187] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); - expressions[188] = BinaryenBinary(the_module, 49, expressions[187], expressions[186]); - expressions[189] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); - expressions[190] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[191] = BinaryenBinary(the_module, 59, expressions[190], expressions[189]); - expressions[192] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); - expressions[193] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[194] = BinaryenBinary(the_module, 73, expressions[193], expressions[192]); - expressions[195] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); - expressions[196] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); - expressions[197] = BinaryenBinary(the_module, 74, expressions[196], expressions[195]); - expressions[198] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); - expressions[199] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); - expressions[200] = BinaryenBinary(the_module, 62, expressions[199], expressions[198]); + expressions[102] = BinaryenUnary(the_module, 37, expressions[101]); + expressions[103] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[104] = BinaryenUnary(the_module, 38, expressions[103]); + expressions[105] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[106] = BinaryenUnary(the_module, 39, expressions[105]); + expressions[107] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[108] = BinaryenUnary(the_module, 40, expressions[107]); + expressions[109] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[110] = BinaryenUnary(the_module, 41, expressions[109]); + expressions[111] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[112] = BinaryenUnary(the_module, 42, expressions[111]); + expressions[113] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[114] = BinaryenUnary(the_module, 43, expressions[113]); + expressions[115] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[116] = BinaryenUnary(the_module, 44, expressions[115]); + expressions[117] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[118] = BinaryenUnary(the_module, 45, expressions[117]); + expressions[119] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[120] = BinaryenUnary(the_module, 46, expressions[119]); + expressions[121] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[122] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[123] = BinaryenBinary(the_module, 0, expressions[122], expressions[121]); + expressions[124] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); + expressions[125] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[126] = BinaryenBinary(the_module, 64, expressions[125], expressions[124]); + expressions[127] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[128] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[129] = BinaryenBinary(the_module, 3, expressions[128], expressions[127]); + expressions[130] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); + expressions[131] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[132] = BinaryenBinary(the_module, 29, expressions[131], expressions[130]); + expressions[133] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); + expressions[134] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[135] = BinaryenBinary(the_module, 30, expressions[134], expressions[133]); + expressions[136] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[137] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[138] = BinaryenBinary(the_module, 6, expressions[137], expressions[136]); + expressions[139] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[140] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[141] = BinaryenBinary(the_module, 7, expressions[140], expressions[139]); + expressions[142] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); + expressions[143] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[144] = BinaryenBinary(the_module, 33, expressions[143], expressions[142]); + expressions[145] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[146] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[147] = BinaryenBinary(the_module, 9, expressions[146], expressions[145]); + expressions[148] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); + expressions[149] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[150] = BinaryenBinary(the_module, 35, expressions[149], expressions[148]); + expressions[151] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); + expressions[152] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[153] = BinaryenBinary(the_module, 36, expressions[152], expressions[151]); + expressions[154] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[155] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[156] = BinaryenBinary(the_module, 12, expressions[155], expressions[154]); + expressions[157] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[158] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[159] = BinaryenBinary(the_module, 13, expressions[158], expressions[157]); + expressions[160] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); + expressions[161] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[162] = BinaryenBinary(the_module, 39, expressions[161], expressions[160]); + expressions[163] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); + expressions[164] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[165] = BinaryenBinary(the_module, 53, expressions[164], expressions[163]); + expressions[166] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); + expressions[167] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[168] = BinaryenBinary(the_module, 67, expressions[167], expressions[166]); + expressions[169] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); + expressions[170] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[171] = BinaryenBinary(the_module, 55, expressions[170], expressions[169]); + expressions[172] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); + expressions[173] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[174] = BinaryenBinary(the_module, 69, expressions[173], expressions[172]); + expressions[175] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[176] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[177] = BinaryenBinary(the_module, 15, expressions[176], expressions[175]); + expressions[178] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); + expressions[179] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[180] = BinaryenBinary(the_module, 58, expressions[179], expressions[178]); + expressions[181] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[182] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[183] = BinaryenBinary(the_module, 17, expressions[182], expressions[181]); + expressions[184] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); + expressions[185] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[186] = BinaryenBinary(the_module, 43, expressions[185], expressions[184]); + expressions[187] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); + expressions[188] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[189] = BinaryenBinary(the_module, 44, expressions[188], expressions[187]); + expressions[190] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[191] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[192] = BinaryenBinary(the_module, 20, expressions[191], expressions[190]); + expressions[193] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); + expressions[194] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[195] = BinaryenBinary(the_module, 46, expressions[194], expressions[193]); + expressions[196] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[197] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[198] = BinaryenBinary(the_module, 22, expressions[197], expressions[196]); + expressions[199] = BinaryenConst(the_module, BinaryenLiteralInt32(-11)); + expressions[200] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + expressions[201] = BinaryenBinary(the_module, 23, expressions[200], expressions[199]); + expressions[202] = BinaryenConst(the_module, BinaryenLiteralInt64(-23)); + expressions[203] = BinaryenConst(the_module, BinaryenLiteralInt64(-22)); + expressions[204] = BinaryenBinary(the_module, 49, expressions[203], expressions[202]); + expressions[205] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); + expressions[206] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[207] = BinaryenBinary(the_module, 59, expressions[206], expressions[205]); + expressions[208] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); + expressions[209] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[210] = BinaryenBinary(the_module, 73, expressions[209], expressions[208]); + expressions[211] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9007.33)); + expressions[212] = BinaryenConst(the_module, BinaryenLiteralFloat64(-9005.84)); + expressions[213] = BinaryenBinary(the_module, 74, expressions[212], expressions[211]); + expressions[214] = BinaryenConst(the_module, BinaryenLiteralFloat32(-62.5)); + expressions[215] = BinaryenConst(the_module, BinaryenLiteralFloat32(-33.612)); + expressions[216] = BinaryenBinary(the_module, 62, expressions[215], expressions[214]); { BinaryenExpressionRef children[] = { 0 }; - expressions[201] = BinaryenBlock(the_module, NULL, children, 0, BinaryenTypeAuto()); - } - expressions[202] = BinaryenIf(the_module, expressions[17], expressions[18], expressions[19]); - expressions[203] = BinaryenIf(the_module, expressions[20], expressions[21], expressions[0]); - expressions[204] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[205] = BinaryenLoop(the_module, "in", expressions[204]); - expressions[206] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - expressions[207] = BinaryenLoop(the_module, NULL, expressions[206]); - expressions[208] = BinaryenBreak(the_module, "the-value", expressions[22], expressions[23]); - expressions[209] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - expressions[210] = BinaryenBreak(the_module, "the-nothing", expressions[209], expressions[0]); - expressions[211] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); - expressions[212] = BinaryenBreak(the_module, "the-value", expressions[0], expressions[211]); - expressions[213] = BinaryenBreak(the_module, "the-nothing", expressions[0], expressions[0]); + expressions[217] = BinaryenBlock(the_module, NULL, children, 0, BinaryenTypeAuto()); + } + expressions[218] = BinaryenIf(the_module, expressions[17], expressions[18], expressions[19]); + expressions[219] = BinaryenIf(the_module, expressions[20], expressions[21], expressions[0]); + expressions[220] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[221] = BinaryenLoop(the_module, "in", expressions[220]); + expressions[222] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[223] = BinaryenLoop(the_module, NULL, expressions[222]); + expressions[224] = BinaryenBreak(the_module, "the-value", expressions[22], expressions[23]); + expressions[225] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[226] = BinaryenBreak(the_module, "the-nothing", expressions[225], expressions[0]); + expressions[227] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); + expressions[228] = BinaryenBreak(the_module, "the-value", expressions[0], expressions[227]); + expressions[229] = BinaryenBreak(the_module, "the-nothing", expressions[0], expressions[0]); { const char* names[] = { "the-value" }; - expressions[214] = BinaryenSwitch(the_module, names, 1, "the-value", expressions[24], expressions[25]); + expressions[230] = BinaryenSwitch(the_module, names, 1, "the-value", expressions[24], expressions[25]); } - expressions[215] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[231] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); { const char* names[] = { "the-nothing" }; - expressions[216] = BinaryenSwitch(the_module, names, 1, "the-nothing", expressions[215], expressions[0]); + expressions[232] = BinaryenSwitch(the_module, names, 1, "the-nothing", expressions[231], expressions[0]); } { BinaryenExpressionRef operands[] = { expressions[9], expressions[10], expressions[11], expressions[12] }; - expressions[217] = BinaryenCall(the_module, "kitchen()sinker", operands, 4, 1); + expressions[233] = BinaryenCall(the_module, "kitchen()sinker", operands, 4, 1); } - expressions[218] = BinaryenUnary(the_module, 20, expressions[217]); + expressions[234] = BinaryenUnary(the_module, 20, expressions[233]); { BinaryenExpressionRef operands[] = { expressions[7], expressions[8] }; - expressions[219] = BinaryenCall(the_module, "an-imported", operands, 2, 3); + expressions[235] = BinaryenCall(the_module, "an-imported", operands, 2, 3); } - expressions[220] = BinaryenUnary(the_module, 25, expressions[219]); - expressions[221] = BinaryenUnary(the_module, 20, expressions[220]); - expressions[222] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); + expressions[236] = BinaryenUnary(the_module, 25, expressions[235]); + expressions[237] = BinaryenUnary(the_module, 20, expressions[236]); + expressions[238] = BinaryenConst(the_module, BinaryenLiteralInt32(2449)); { BinaryenExpressionRef operands[] = { expressions[13], expressions[14], expressions[15], expressions[16] }; - expressions[223] = BinaryenCallIndirect(the_module, expressions[222], operands, 4, "iiIfF"); - } - expressions[224] = BinaryenUnary(the_module, 20, expressions[223]); - expressions[225] = BinaryenGetLocal(the_module, 0, 1); - expressions[226] = BinaryenDrop(the_module, expressions[225]); - expressions[227] = BinaryenConst(the_module, BinaryenLiteralInt32(101)); - expressions[228] = BinaryenSetLocal(the_module, 0, expressions[227]); - expressions[229] = BinaryenConst(the_module, BinaryenLiteralInt32(102)); - expressions[230] = BinaryenTeeLocal(the_module, 0, expressions[229]); - expressions[231] = BinaryenDrop(the_module, expressions[230]); - expressions[232] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - expressions[233] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[232]); - expressions[234] = BinaryenConst(the_module, BinaryenLiteralInt32(8)); - expressions[235] = BinaryenLoad(the_module, 2, 1, 2, 1, 2, expressions[234]); - expressions[236] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - expressions[237] = BinaryenLoad(the_module, 4, 0, 0, 0, 3, expressions[236]); - expressions[238] = BinaryenConst(the_module, BinaryenLiteralInt32(9)); - expressions[239] = BinaryenLoad(the_module, 8, 0, 2, 8, 4, expressions[238]); - expressions[240] = BinaryenStore(the_module, 4, 0, 0, expressions[29], expressions[30], 1); - expressions[241] = BinaryenStore(the_module, 8, 2, 4, expressions[31], expressions[32], 2); - expressions[242] = BinaryenSelect(the_module, expressions[26], expressions[27], expressions[28]); - expressions[243] = BinaryenConst(the_module, BinaryenLiteralInt32(1337)); - expressions[244] = BinaryenReturn(the_module, expressions[243]); - expressions[245] = BinaryenNop(the_module); - expressions[246] = BinaryenUnreachable(the_module); + expressions[239] = BinaryenCallIndirect(the_module, expressions[238], operands, 4, "iiIfF"); + } + expressions[240] = BinaryenUnary(the_module, 20, expressions[239]); + expressions[241] = BinaryenGetLocal(the_module, 0, 1); + expressions[242] = BinaryenDrop(the_module, expressions[241]); + expressions[243] = BinaryenConst(the_module, BinaryenLiteralInt32(101)); + expressions[244] = BinaryenSetLocal(the_module, 0, expressions[243]); + expressions[245] = BinaryenConst(the_module, BinaryenLiteralInt32(102)); + expressions[246] = BinaryenTeeLocal(the_module, 0, expressions[245]); + expressions[247] = BinaryenDrop(the_module, expressions[246]); + expressions[248] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + expressions[249] = BinaryenLoad(the_module, 4, 0, 0, 0, 1, expressions[248]); + expressions[250] = BinaryenConst(the_module, BinaryenLiteralInt32(8)); + expressions[251] = BinaryenLoad(the_module, 2, 1, 2, 1, 2, expressions[250]); + expressions[252] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + expressions[253] = BinaryenLoad(the_module, 4, 0, 0, 0, 3, expressions[252]); + expressions[254] = BinaryenConst(the_module, BinaryenLiteralInt32(9)); + expressions[255] = BinaryenLoad(the_module, 8, 0, 2, 8, 4, expressions[254]); + expressions[256] = BinaryenStore(the_module, 4, 0, 0, expressions[29], expressions[30], 1); + expressions[257] = BinaryenStore(the_module, 8, 2, 4, expressions[31], expressions[32], 2); + expressions[258] = BinaryenSelect(the_module, expressions[26], expressions[27], expressions[28]); + expressions[259] = BinaryenConst(the_module, BinaryenLiteralInt32(1337)); + expressions[260] = BinaryenReturn(the_module, expressions[259]); + expressions[261] = BinaryenNop(the_module); + expressions[262] = BinaryenUnreachable(the_module); BinaryenExpressionPrint(expressions[40]); (f32.neg (f32.const -33.61199951171875) @@ -1344,36 +1400,38 @@ int main() { expressions[68], expressions[70], expressions[72], expressions[74], expressions[76], expressions[78], expressions[80], expressions[82], expressions[84], expressions[86], expressions[88], expressions[90], expressions[92], expressions[94], expressions[96], expressions[98], expressions[100], expressions[102], - expressions[104], expressions[107], expressions[110], expressions[113], expressions[116], expressions[119], - expressions[122], expressions[125], expressions[128], expressions[131], expressions[134], expressions[137], - expressions[140], expressions[143], expressions[146], expressions[149], expressions[152], expressions[155], - expressions[158], expressions[161], expressions[164], expressions[167], expressions[170], expressions[173], - expressions[176], expressions[179], expressions[182], expressions[185], expressions[188], expressions[191], - expressions[194], expressions[197], expressions[200], expressions[201], expressions[202], expressions[203], - expressions[205], expressions[207], expressions[208], expressions[210], expressions[212], expressions[213], - expressions[214], expressions[216], expressions[218], expressions[221], expressions[224], expressions[226], - expressions[228], expressions[231], expressions[233], expressions[235], expressions[237], expressions[239], - expressions[240], expressions[241], expressions[242], expressions[244], expressions[245], expressions[246] }; - expressions[247] = BinaryenBlock(the_module, "the-value", children, 95, BinaryenTypeAuto()); + expressions[104], expressions[106], expressions[108], expressions[110], expressions[112], expressions[114], + expressions[116], expressions[118], expressions[120], expressions[123], expressions[126], expressions[129], + expressions[132], expressions[135], expressions[138], expressions[141], expressions[144], expressions[147], + expressions[150], expressions[153], expressions[156], expressions[159], expressions[162], expressions[165], + expressions[168], expressions[171], expressions[174], expressions[177], expressions[180], expressions[183], + expressions[186], expressions[189], expressions[192], expressions[195], expressions[198], expressions[201], + expressions[204], expressions[207], expressions[210], expressions[213], expressions[216], expressions[217], + expressions[218], expressions[219], expressions[221], expressions[223], expressions[224], expressions[226], + expressions[228], expressions[229], expressions[230], expressions[232], expressions[234], expressions[237], + expressions[240], expressions[242], expressions[244], expressions[247], expressions[249], expressions[251], + expressions[253], expressions[255], expressions[256], expressions[257], expressions[258], expressions[260], + expressions[261], expressions[262] }; + expressions[263] = BinaryenBlock(the_module, "the-value", children, 103, BinaryenTypeAuto()); } - expressions[248] = BinaryenDrop(the_module, expressions[247]); + expressions[264] = BinaryenDrop(the_module, expressions[263]); { - BinaryenExpressionRef children[] = { expressions[248] }; - expressions[249] = BinaryenBlock(the_module, "the-nothing", children, 1, BinaryenTypeAuto()); + BinaryenExpressionRef children[] = { expressions[264] }; + expressions[265] = BinaryenBlock(the_module, "the-nothing", children, 1, BinaryenTypeAuto()); } - expressions[250] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); + expressions[266] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); { - BinaryenExpressionRef children[] = { expressions[249], expressions[250] }; - expressions[251] = BinaryenBlock(the_module, "the-body", children, 2, BinaryenTypeAuto()); + BinaryenExpressionRef children[] = { expressions[265], expressions[266] }; + expressions[267] = BinaryenBlock(the_module, "the-body", children, 2, BinaryenTypeAuto()); } { BinaryenType varTypes[] = { 1 }; - functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 1, expressions[251]); + functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 1, expressions[267]); } - expressions[252] = BinaryenConst(the_module, BinaryenLiteralInt32(7)); - BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[252]); - expressions[253] = BinaryenConst(the_module, BinaryenLiteralFloat32(7.5)); - BinaryenAddGlobal(the_module, "a-mutable-global", 3, 1, expressions[253]); + expressions[268] = BinaryenConst(the_module, BinaryenLiteralInt32(7)); + BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[268]); + expressions[269] = BinaryenConst(the_module, BinaryenLiteralFloat32(7.5)); + BinaryenAddGlobal(the_module, "a-mutable-global", 3, 1, expressions[269]); { BinaryenType paramTypes[] = { 1, 4 }; functionTypes[1] = BinaryenAddFunctionType(the_module, "fiF", 3, paramTypes, 2); @@ -1385,11 +1443,11 @@ int main() { const char* funcNames[] = { "kitchen()sinker" }; BinaryenSetFunctionTable(the_module, 1, 1, funcNames, 1); } - expressions[254] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); + expressions[270] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); { const char segment0[] = { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100 }; const char* segments[] = { segment0 }; - BinaryenExpressionRef segmentOffsets[] = { expressions[254] }; + BinaryenExpressionRef segmentOffsets[] = { expressions[270] }; BinaryenIndex segmentSizes[] = { 12 }; BinaryenSetMemory(the_module, 1, 256, "mem", segments, segmentOffsets, segmentSizes, 1, 0); } @@ -1397,10 +1455,10 @@ int main() { BinaryenType paramTypes[] = { 0 }; functionTypes[2] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0); } - expressions[255] = BinaryenNop(the_module); + expressions[271] = BinaryenNop(the_module); { BinaryenType varTypes[] = { 0 }; - functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[2], varTypes, 0, expressions[255]); + functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[2], varTypes, 0, expressions[271]); } BinaryenSetStart(the_module, functions[1]); { @@ -1542,6 +1600,46 @@ int main() { ) ) (drop + (i32.trunc_s:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i64.trunc_s:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i32.trunc_u:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i64.trunc_u:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i32.trunc_s:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i64.trunc_s:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i32.trunc_u:sat/f64 + (f64.const -9005.841) + ) + ) + (drop + (i64.trunc_u:sat/f64 + (f64.const -9005.841) + ) + ) + (drop (i32.reinterpret/f32 (f32.const -33.61199951171875) ) diff --git a/test/example/c-api-kitchen-sink.txt.txt b/test/example/c-api-kitchen-sink.txt.txt index d23e109b5..4cf98c329 100644 --- a/test/example/c-api-kitchen-sink.txt.txt +++ b/test/example/c-api-kitchen-sink.txt.txt @@ -133,6 +133,46 @@ ) ) (drop + (i32.trunc_s:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i64.trunc_s:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i32.trunc_u:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i64.trunc_u:sat/f32 + (f32.const -33.61199951171875) + ) + ) + (drop + (i32.trunc_s:sat/f64 + (f64.const -9005.84) + ) + ) + (drop + (i64.trunc_s:sat/f64 + (f64.const -9005.84) + ) + ) + (drop + (i32.trunc_u:sat/f64 + (f64.const -9005.84) + ) + ) + (drop + (i64.trunc_u:sat/f64 + (f64.const -9005.84) + ) + ) + (drop (i32.reinterpret/f32 (f32.const -33.61199951171875) ) diff --git a/test/kitchen_sink.wast b/test/kitchen_sink.wast index dc1583811..19c1aec12 100644 --- a/test/kitchen_sink.wast +++ b/test/kitchen_sink.wast @@ -557,6 +557,26 @@ ) ) (drop + (i32.trunc_s:sat/f32 + (f32.const 10) + ) + ) + (drop + (i32.trunc_u:sat/f32 + (f32.const 10) + ) + ) + (drop + (i32.trunc_s:sat/f64 + (f64.const 10) + ) + ) + (drop + (i32.trunc_u:sat/f64 + (f64.const 10) + ) + ) + (drop (i32.wrap/i64 (i64.const 100) ) @@ -582,6 +602,26 @@ ) ) (drop + (i64.trunc_s:sat/f32 + (f32.const 10) + ) + ) + (drop + (i64.trunc_u:sat/f32 + (f32.const 10) + ) + ) + (drop + (i64.trunc_s:sat/f64 + (f64.const 10) + ) + ) + (drop + (i64.trunc_u:sat/f64 + (f64.const 10) + ) + ) + (drop (i64.extend_s/i32 (i32.const 10) ) diff --git a/test/kitchen_sink.wast.from-wast b/test/kitchen_sink.wast.from-wast index 621b02a56..e8376a9c2 100644 --- a/test/kitchen_sink.wast.from-wast +++ b/test/kitchen_sink.wast.from-wast @@ -557,6 +557,26 @@ ) ) (drop + (i32.trunc_s:sat/f32 + (f32.const 10) + ) + ) + (drop + (i32.trunc_u:sat/f32 + (f32.const 10) + ) + ) + (drop + (i32.trunc_s:sat/f64 + (f64.const 10) + ) + ) + (drop + (i32.trunc_u:sat/f64 + (f64.const 10) + ) + ) + (drop (i32.wrap/i64 (i64.const 100) ) @@ -582,6 +602,26 @@ ) ) (drop + (i64.trunc_s:sat/f32 + (f32.const 10) + ) + ) + (drop + (i64.trunc_u:sat/f32 + (f32.const 10) + ) + ) + (drop + (i64.trunc_s:sat/f64 + (f64.const 10) + ) + ) + (drop + (i64.trunc_u:sat/f64 + (f64.const 10) + ) + ) + (drop (i64.extend_s/i32 (i32.const 10) ) diff --git a/test/kitchen_sink.wast.fromBinary b/test/kitchen_sink.wast.fromBinary index dee6984f8..ee22ef0d5 100644 --- a/test/kitchen_sink.wast.fromBinary +++ b/test/kitchen_sink.wast.fromBinary @@ -556,6 +556,26 @@ ) ) (drop + (i32.trunc_s:sat/f32 + (f32.const 10) + ) + ) + (drop + (i32.trunc_u:sat/f32 + (f32.const 10) + ) + ) + (drop + (i32.trunc_s:sat/f64 + (f64.const 10) + ) + ) + (drop + (i32.trunc_u:sat/f64 + (f64.const 10) + ) + ) + (drop (i32.wrap/i64 (i64.const 100) ) @@ -581,6 +601,26 @@ ) ) (drop + (i64.trunc_s:sat/f32 + (f32.const 10) + ) + ) + (drop + (i64.trunc_u:sat/f32 + (f32.const 10) + ) + ) + (drop + (i64.trunc_s:sat/f64 + (f64.const 10) + ) + ) + (drop + (i64.trunc_u:sat/f64 + (f64.const 10) + ) + ) + (drop (i64.extend_s/i32 (i32.const 10) ) diff --git a/test/kitchen_sink.wast.fromBinary.noDebugInfo b/test/kitchen_sink.wast.fromBinary.noDebugInfo index 162c1fa96..9578cc41b 100644 --- a/test/kitchen_sink.wast.fromBinary.noDebugInfo +++ b/test/kitchen_sink.wast.fromBinary.noDebugInfo @@ -556,6 +556,26 @@ ) ) (drop + (i32.trunc_s:sat/f32 + (f32.const 10) + ) + ) + (drop + (i32.trunc_u:sat/f32 + (f32.const 10) + ) + ) + (drop + (i32.trunc_s:sat/f64 + (f64.const 10) + ) + ) + (drop + (i32.trunc_u:sat/f64 + (f64.const 10) + ) + ) + (drop (i32.wrap/i64 (i64.const 100) ) @@ -581,6 +601,26 @@ ) ) (drop + (i64.trunc_s:sat/f32 + (f32.const 10) + ) + ) + (drop + (i64.trunc_u:sat/f32 + (f32.const 10) + ) + ) + (drop + (i64.trunc_s:sat/f64 + (f64.const 10) + ) + ) + (drop + (i64.trunc_u:sat/f64 + (f64.const 10) + ) + ) + (drop (i64.extend_s/i32 (i32.const 10) ) diff --git a/test/passes/translate-to-fuzz.txt b/test/passes/translate-to-fuzz.txt index 3bd65e51d..50f5486cf 100644 --- a/test/passes/translate-to-fuzz.txt +++ b/test/passes/translate-to-fuzz.txt @@ -1,15 +1,13 @@ (module (type $FUNCSIG$v (func)) - (type $FUNCSIG$ijdfd (func (param i64 f64 f32 f64) (result i32))) - (type $FUNCSIG$j (func (result i64))) (import "fuzzing-support" "log-i32" (func $log-i32 (param i32))) (import "fuzzing-support" "log-i64" (func $log-i64 (param i64))) (import "fuzzing-support" "log-f32" (func $log-f32 (param f32))) (import "fuzzing-support" "log-f64" (func $log-f64 (param f64))) (memory $0 (shared 1 1)) (data (i32.const 0) "n\00\05E\00\00\00\00") - (table $0 4 anyfunc) - (elem (i32.const 0) $func_7 $func_14 $func_14 $func_14) + (table $0 2 2 anyfunc) + (elem (i32.const 0) $func_7 $func_11) (global $global$0 (mut f32) (f32.const 536870912)) (global $global$1 (mut f32) (f32.const 2147483648)) (global $global$2 (mut f64) (f64.const -1048576)) @@ -17,9 +15,6 @@ (global $hangLimit (mut i32) (i32.const 10)) (export "func_5_invoker" (func $func_5_invoker)) (export "func_9_invoker" (func $func_9_invoker)) - (export "func_11" (func $func_11)) - (export "func_12" (func $func_12)) - (export "func_12_invoker" (func $func_12_invoker)) (export "hangLimitInitializer" (func $hangLimitInitializer)) (func $func_4 (; 4 ;) (param $0 f32) (param $1 i64) (param $2 i32) (param $3 f32) (param $4 f64) (result f32) (local $5 f32) @@ -154,7 +149,7 @@ ) ) ) - (func $func_11 (; 11 ;) (type $FUNCSIG$ijdfd) (param $0 i64) (param $1 f64) (param $2 f32) (param $3 f64) (result i32) + (func $func_11 (; 11 ;) (param $0 i64) (param $1 f64) (param $2 f32) (param $3 f64) (result i32) (local $4 f32) (local $5 i64) (local $6 f32) @@ -167,7 +162,7 @@ (get_global $hangLimit) ) (return - (get_local $9) + (i32.const -72) ) ) (set_global $hangLimit @@ -184,7 +179,7 @@ (get_global $hangLimit) ) (return - (i32.const -4) + (get_local $9) ) ) (set_global $hangLimit @@ -196,64 +191,109 @@ ) (block $label$1 (result i32) (if - (i32.eqz - (loop $label$2 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const -536870912) - ) + (loop $label$2 (result i32) + (block + (if + (i32.eqz + (get_global $hangLimit) ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) + (return + (i32.const 1499158319) ) ) - (block (result i32) - (block $label$3 - (set_local $4 - (if (result f32) - (loop $label$4 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $8) - ) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) + ) + ) + ) + (block (result i32) + (block $label$3 + (set_local $6 + (if (result f32) + (loop $label$4 (result i32) + (block + (if + (i32.eqz + (get_global $hangLimit) ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) + (return + (get_local $9) + ) + ) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) ) ) - (get_local $9) ) - (block $label$11 (result f32) - (block $label$20 - (nop) - (if - (i32.const 69016851) - (set_local $0 - (get_local $5) + (block (result i32) + (block $label$5 + (set_local $3 + (get_local $1) + ) + (set_local $6 + (get_local $2) + ) + ) + (br_if $label$4 + (tee_local $8 + (tee_local $9 + (tee_local $8 + (tee_local $8 + (tee_local $9 + (get_local $9) + ) + ) + ) ) - (set_local $7 - (loop $label$21 (result i64) + ) + ) + (loop $label$9 (result i32) + (block + (if + (i32.eqz + (get_global $hangLimit) + ) + (return + (i32.const -42) + ) + ) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) + ) + ) + ) + (i32.trunc_u:sat/f64 + (loop $label$10 (result f64) + (block + (if + (i32.eqz + (get_global $hangLimit) + ) + (return + (i32.const -127) + ) + ) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) + ) + ) + ) + (loop $label$11 (result f64) (block (if (i32.eqz (get_global $hangLimit) ) (return - (i32.const 128) + (get_local $8) ) ) (set_global $hangLimit @@ -263,384 +303,179 @@ ) ) ) - (block (result i64) - (set_local $6 - (block $label$22 (result f32) - (set_local $0 - (i64.const 32768) - ) - (f32.const 512) + (block (result f64) + (set_local $5 + (tee_local $0 + (i64.const 281474976710656) ) ) - (br_if $label$21 - (block $label$23 (result i32) - (nop) - (get_local $9) + (br_if $label$11 + (i32.const 16) + ) + (loop $label$12 (result f64) + (block + (if + (i32.eqz + (get_global $hangLimit) + ) + (return + (i32.const -65536) + ) + ) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) + ) + ) ) + (get_local $1) ) - (i64.const 35325213) ) ) ) ) ) - (f32.const -4294967296) - ) - (block $label$12 - (set_local $1 - (tee_local $3 - (tee_local $1 - (tee_local $3 - (tee_local $3 - (get_local $3) - ) - ) - ) - ) - ) - (br $label$3) ) ) - ) - (set_local $6 - (f32.const -4294967296) - ) - ) - (br_if $label$2 - (i32.eqz - (i32.const -2147483648) - ) - ) - (get_local $9) - ) - ) - ) - (block $label$13 - (set_local $4 - (tee_local $2 - (if (result f32) - (tee_local $8 - (tee_local $9 - (i32.const 487671376) - ) - ) - (loop $label$14 (result f32) - (block - (if + (tee_local $2 + (if (result f32) (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const 374370334) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (tee_local $4 - (tee_local $4 - (tee_local $4 - (tee_local $2 - (tee_local $6 - (f32.const 125437032) - ) - ) - ) - ) - ) - ) - (block $label$24 - (set_local $4 - (get_local $2) - ) - (br $label$13) - ) - ) - ) - ) - (set_local $7 - (i64.const -2147483646) - ) - ) - (block $label$25 - (loop $label$26 - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const 21) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block $label$27 - (set_local $1 - (tee_local $1 - (tee_local $1 - (tee_local $3 - (tee_local $3 - (tee_local $1 - (tee_local $3 - (tee_local $3 - (get_local $3) + (loop $label$13 (result i32) + (block + (if + (i32.eqz + (get_global $hangLimit) + ) + (return + (i32.const -65536) + ) + ) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) + ) ) ) - ) - ) - ) - ) - ) - ) - (loop $label$28 - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const -32768) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block - (set_local $8 - (get_local $9) - ) - (br_if $label$28 - (get_local $8) - ) - (call $log-i32 - (loop $label$29 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const 1048576) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block (result i32) - (tee_local $0 - (if - (i32.eqz - (loop $label$30 - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $9) - ) + (block (result i32) + (block $label$14 + (if + (i32.const 0) + (block $label$15 + (call $log-f64 + (f64.const -2) ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) + (set_local $4 + (get_local $2) ) ) - (block $label$31 - (set_local $4 - (tee_local $2 - (tee_local $2 - (tee_local $4 - (tee_local $4 - (tee_local $2 - (tee_local $6 - (f32.const 125437032) - ) - ) - ) - ) + (set_local $0 + (i64.const 65510) + ) + ) + (call $log-i32 + (loop $label$16 (result i32) + (block + (if + (i32.eqz + (get_global $hangLimit) + ) + (return + (get_local $9) + ) + ) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) ) ) ) - (br $label$27) + (block (result i32) + (nop) + (br_if $label$16 + (i32.eqz + (get_local $8) + ) + ) + (i32.const -71) + ) ) ) ) - (block $label$33 - (set_local $7 - (tee_local $0 - (tee_local $7 - (get_local $5) + (br_if $label$13 + (get_local $9) + ) + (br_if $label$1 + (if (result i32) + (i32.eqz + (tee_local $8 + (i32.const -65536) ) ) - ) - (br $label$27) - ) - (block $label$34 - (block $label$18 - (set_local $2 - (tee_local $4 - (get_local $4) + (block $label$24 (result i32) + (set_local $0 + (i64.const -127) + ) + (call $func_11 + (get_local $7) + (f64.const 3402823466385288598117041e14) + (f32.const 2305843009213693952) + (get_local $3) ) ) - (set_local $9 - (tee_local $9 - (get_local $9) + (tee_local $9 + (i32.const 1162292275) + ) + ) + (i32.eqz + (if (result i32) + (get_local $8) + (i32.const 1024) + (block $label$22 (result i32) + (set_local $0 + (i64.const 36028797018963968) + ) + (loop $label$23 (result i32) + (block + (if + (i32.eqz + (get_global $hangLimit) + ) + (return + (i32.const -65536) + ) + ) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) + ) + ) + ) + (get_local $8) + ) ) ) ) - (br $label$28) - ) - ) - ) - (br_if $label$29 - (i32.const -83) - ) - (br_if $label$1 - (i32.const -65535) - (i32.eqz - (tee_local $9 - (i32.const 512) ) ) ) ) + (get_local $4) + (get_local $2) ) ) - ) - ) - ) - ) - (br_if $label$25 - (i32.eqz - (br_if $label$1 - (i32.const -8388608) - (i32.eqz - (i32.const 1798) - ) - ) - ) - ) - ) - ) - (br $label$0) - ) - ) - ) - (func $func_12 (; 12 ;) (type $FUNCSIG$j) (result i64) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i64.const 6779903213212753417) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block $label$0 (result i64) - (nop) - (i64.const -81) - ) - ) - (func $func_12_invoker (; 13 ;) (type $FUNCSIG$v) - (drop - (call $func_12) - ) - (drop - (call $func_12) - ) - (drop - (call $func_12) - ) - (drop - (call $func_12) - ) - (drop - (call $func_12) - ) - ) - (func $func_14 (; 14 ;) (param $0 f64) (param $1 f32) (param $2 f32) (param $3 i64) (param $4 i32) (result i32) - (local $5 i64) - (local $6 i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $6) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block $label$0 (result i32) - (set_local $6 - (loop $label$1 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const -78) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block (result i32) - (block $label$2 - (set_local $3 - (i64.const 22) - ) - (set_local $2 - (tee_local $1 - (tee_local $1 - (if (result f32) - (get_local $6) - (loop $label$3 (result f32) + (block $label$25 (result f32) + (loop $label$26 (block (if (i32.eqz (get_global $hangLimit) ) (return - (get_local $6) + (i32.const 1465597219) ) ) (set_global $hangLimit @@ -650,492 +485,237 @@ ) ) ) - (block $label$4 (result f32) + (block + (set_local $5 + (i64.const 1877285765241048336) + ) + (br_if $label$26 + (i32.const -127) + ) (set_local $6 - (tee_local $6 - (loop $label$5 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const -32767) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block (result i32) - (block $label$6 - (set_local $0 - (f64.const 18446744073709551615) - ) - (set_local $2 - (f32.const 1.2250390128955172e-22) - ) - ) - (br_if $label$5 - (i32.eqz - (tee_local $4 - (i32.const 656421170) - ) - ) - ) - (i32.const 1598490719) - ) - ) - ) + (get_local $2) ) - (f32.const -144115188075855872) ) ) - (block $label$7 (result f32) - (drop - (get_local $3) - ) - (loop $label$8 (result f32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $6) + (br_if $label$25 + (br_if $label$25 + (tee_local $4 + (f32.const 4294967296) + ) + (loop $label$29 (result i32) + (block + (if + (i32.eqz + (get_global $hangLimit) + ) + (return + (i32.const -88) + ) ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) + ) ) ) - ) - (block (result f32) - (tee_local $6 - (block $label$9 - (set_local $4 - (tee_local $4 - (loop $label$10 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $6) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block (result i32) - (set_local $6 - (get_local $6) - ) - (br_if $label$10 - (get_local $4) - ) - (get_local $6) + (block (result i32) + (block $label$30 + (set_local $3 + (if (result f64) + (i32.const 32767) + (block $label$31 + (set_local $9 + (get_local $8) ) + (br $label$29) ) + (f64.const 4) ) ) - (return - (get_local $4) + (set_local $3 + (get_local $1) ) ) - ) - (br_if $label$8 - (br_if $label$0 - (br_if $label$0 - (i32.const -2147483648) - (i32.eqz - (get_local $4) + (br_if $label$29 + (tee_local $9 + (tee_local $9 + (tee_local $8 + (get_local $8) + ) ) ) - (i32.eqz - (br_if $label$0 - (if (result i32) - (block $label$11 (result i32) - (nop) - (i32.const 67108864) - ) - (block $label$12 - (set_local $5 - (i64.const 86) + ) + (if (result i32) + (block $label$32 (result i32) + (call $log-f32 + (get_local $2) + ) + (i32.const -32768) + ) + (block $label$33 (result i32) + (loop $label$34 + (block + (if + (i32.eqz + (get_global $hangLimit) ) (return - (i32.const 319952130) + (get_local $8) ) ) - (block $label$13 (result i32) - (set_local $1 - (tee_local $1 - (get_local $1) - ) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) ) - (loop $label$14 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $4) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) + ) + ) + (block + (block $label$35 + (nop) + (if + (tee_local $9 + (i32.const -32768) + ) + (nop) + (set_local $9 + (get_local $8) ) - (get_local $4) ) ) - ) - (i32.eqz - (br_if $label$0 - (i32.const 0) + (br_if $label$34 (i32.eqz - (br_if $label$0 - (i32.const 0) - (i32.eqz - (i32.const -131072) - ) - ) + (i32.const -69) ) ) + (call $log-i32 + (i32.const 5) + ) + ) + ) + (tee_local $8 + (tee_local $9 + (i32.const -128) ) ) ) + (get_local $9) ) ) - (get_local $2) ) ) + (i32.eqz + (get_local $8) + ) + ) + ) + ) + ) + (nop) + ) + (br_if $label$2 + (tee_local $9 + (tee_local $9 + (tee_local $9 + (tee_local $9 + (get_local $9) ) ) ) ) ) + (i32.const 7) ) - (br_if $label$1 - (i32.eqz - (if (result i32) - (i32.eqz - (get_local $6) + ) + (block $label$45 + (set_local $5 + (get_local $5) + ) + ) + (block $label$46 + (nop) + (if + (loop $label$47 (result i32) + (block + (if + (i32.eqz + (get_global $hangLimit) + ) + (return + (i32.const -32768) + ) ) - (loop $label$15 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $6) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) ) - (block (result i32) - (block $label$16 - (loop $label$17 - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $6) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (call $log-i64 - (loop $label$18 (result i64) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const 5379960) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block (result i64) - (block $label$19 - (if - (i32.const -65535) - (block $label$20 - (set_local $6 - (loop $label$21 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const 8388608) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block (result i32) - (call $log-f64 - (get_local $0) - ) - (br_if $label$21 - (loop $label$22 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const -18) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (i32.const -536870912) - ) - ) - (tee_local $6 - (tee_local $6 - (i32.const 7937) - ) - ) - ) - ) - ) - (call $log-f64 - (block $label$23 (result f64) - (set_local $3 - (get_local $5) - ) - (br_if $label$23 - (get_local $0) - (i32.eqz - (i32.load offset=4 align=1 - (i32.and - (i32.const 2071622516) - (i32.const 15) - ) - ) - ) - ) - ) - ) - ) - (set_local $2 - (f32.const 2097152) - ) - ) - (br_if $label$17 - (i32.eqz - (block $label$24 - (set_local $3 - (get_local $3) - ) - (br $label$16) - ) - ) - ) - ) - (br_if $label$18 - (i32.eqz - (loop $label$25 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const 678827100) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block $label$26 (result i32) - (loop $label$27 - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const 421033554) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block $label$28 - (block $label$29 - (nop) - (nop) - ) - (set_local $0 - (get_local $0) - ) - ) - ) - (if (result i32) - (unreachable.atomic.rmw?.xor - (i32.and - (loop $label$30 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $6) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block (result i32) - (set_local $1 - (f32.const 724134784) - ) - (br_if $label$30 - (i32.const 32768) - ) - (if (result i32) - (i32.eqz - (if (result i32) - (i32.eqz - (i32.const -2147483648) - ) - (tee_local $4 - (i32.const -16384) - ) - (tee_local $6 - (i32.const -4) - ) - ) - ) - (get_local $4) - (i32.const 7633019) - ) - ) - ) - (i32.const 15) - ) - (block $label$31 - (set_local $0 - (f64.const 1.4014461213526112e-292) - ) - (br $label$1) - ) - ) - (block $label$32 (result i32) - (call $log-i32 - (loop $label$33 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const -54) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (i32.const -16777216) - ) - ) - (get_local $6) - ) - (block $label$34 (result i32) - (set_local $0 - (f64.const 2305843009213693952) - ) - (i32.const 90) - ) - ) - ) - ) - ) + ) + ) + (block (result i32) + (block $label$48 + (set_local $8 + (tee_local $8 + (tee_local $8 + (tee_local $8 + (tee_local $9 + (tee_local $9 + (tee_local $8 + (get_local $9) ) - (get_local $3) ) ) ) ) + ) + ) + (if + (get_local $8) + (block $label$49 + (set_global $global$3 + (get_local $3) + ) (set_local $3 - (i64.const 17592186044416) + (f64.const 274877906944) + ) + ) + (block $label$64 + (set_local $5 + (i64.const -32) + ) + (set_local $1 + (get_local $1) ) ) - (br_if $label$15 - (tee_local $6 - (loop $label$35 (result i32) + ) + ) + (br_if $label$47 + (get_local $9) + ) + (block $label$66 (result i32) + (set_local $6 + (get_local $4) + ) + (if (result i32) + (i32.eqz + (get_local $8) + ) + (block $label$67 (result i32) + (br_if $label$46 + (i32.eqz + (get_local $8) + ) + ) + (tee_local $8 + (loop $label$68 (result i32) (block (if (i32.eqz (get_global $hangLimit) ) (return - (i32.const -4) + (get_local $8) ) ) (set_global $hangLimit @@ -1146,269 +726,146 @@ ) ) (block (result i32) - (block $label$36 - (set_local $6 - (br_if $label$0 - (tee_local $4 - (loop $label$39 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const -2048) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) + (set_local $8 + (tee_local $9 + (tee_local $9 + (i32.const 32767) + ) + ) + ) + (br_if $label$68 + (i32.eqz + (call $func_11 + (i64.const 8245) + (get_local $3) + (block $label$69 (result f32) + (if + (i32.const 1001235) + (set_local $7 + (if (result i64) + (get_local $9) + (get_local $0) + (i64.const 32768) ) ) - (tee_local $6 - (tee_local $6 - (i32.const -32768) - ) + (set_local $7 + (get_local $0) ) ) + (f32.const 23316) ) - (i32.eqz - (br_if $label$0 - (loop $label$37 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $6) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) + (loop $label$70 (result f64) + (block + (if + (i32.eqz + (get_global $hangLimit) ) - (block $label$38 (result i32) - (set_local $4 - (i32.const -128) - ) - (tee_local $6 - (br_if $label$0 - (i32.const -12) - (i32.eqz - (get_local $4) - ) - ) - ) + (return + (i32.const -8388608) ) ) - (get_local $4) - ) - ) - ) - ) - (set_local $1 - (f32.const -2147483648) - ) - ) - (br_if $label$35 - (if (result i32) - (i32.eqz - (block $label$40 (result i32) - (tee_local $3 - (loop $label$41 - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $4) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block $label$42 - (loop $label$43 - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const -76) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block - (set_local $6 - (loop $label$44 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (get_local $4) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (get_local $6) - ) - ) - (br_if $label$43 - (i32.eqz - (i32.const 33554432) - ) - ) - (block $label$45 - (block $label$46 - (set_local $5 - (i64.const 262144) - ) - ) - (set_local $3 - (get_local $5) - ) - ) - ) - ) - (br $label$35) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) ) ) ) - (tee_local $6 - (tee_local $4 - (i32.const -33554432) - ) - ) - ) - ) - (block $label$47 (result i32) - (set_local $2 - (get_local $1) - ) - (tee_local $4 - (tee_local $6 - (tee_local $6 - (i32.const -2147483648) - ) - ) - ) - ) - (block $label$48 (result i32) - (br_if $label$35 - (i32.eqz - (select - (loop $label$50 (result i32) - (block - (if - (i32.eqz - (get_global $hangLimit) - ) - (return - (i32.const -74) - ) - ) - (set_global $hangLimit - (i32.sub - (get_global $hangLimit) - (i32.const 1) - ) - ) - ) - (block (result i32) - (if - (tee_local $6 - (i32.const 12081) - ) - (set_local $6 - (get_local $6) - ) - (set_local $4 - (i32.const 8) - ) - ) - (br_if $label$50 - (i32.eqz - (if (result i32) - (i32.eqz - (br_if $label$48 - (i32.const 85) - (i32.const 289932813) - ) - ) - (get_local $6) - (get_local $4) - ) - ) - ) - (get_local $6) - ) - ) - (i32.const -2147483647) - (block $label$49 - (set_local $0 - (get_local $0) - ) - (br $label$1) + (block (result f64) + (nop) + (br_if $label$70 + (tee_local $9 + (i32.const 134217728) ) ) + (get_local $3) ) ) - (get_local $4) ) ) ) - (get_local $6) + (tee_local $8 + (tee_local $8 + (tee_local $8 + (i32.const 167) + ) + ) + ) ) ) ) ) - (i32.const -65535) + (block $label$72 + (set_local $6 + (get_local $2) + ) + (br $label$46) + ) + ) + ) + ) + ) + (block $label$73 + (set_local $1 + (block $label$74 (result f64) + (call $log-i64 + (i64.const 108) + ) + (tee_local $3 + (f64.const 9223372036854775808) ) ) - (block $label$51 (result i32) - (i32.const 504305950) + ) + (call $log-i64 + (tee_local $0 + (loop $label$75 + (block + (if + (i32.eqz + (get_global $hangLimit) + ) + (return + (get_local $8) + ) + ) + (set_global $hangLimit + (i32.sub + (get_global $hangLimit) + (i32.const 1) + ) + ) + ) + (block $label$76 + (set_local $9 + (tee_local $8 + (i32.const 80) + ) + ) + (br $label$46) + ) + ) ) ) ) + (set_local $9 + (i32.const -1024) + ) ) - (get_local $6) ) ) + (br_if $label$1 + (get_local $9) + (get_local $9) + ) ) - (get_local $4) ) ) - (func $hangLimitInitializer (; 15 ;) + (func $hangLimitInitializer (; 12 ;) (set_global $hangLimit (i32.const 10) ) ) - (func $deNan32 (; 16 ;) (param $0 f32) (result f32) + (func $deNan32 (; 13 ;) (param $0 f32) (result f32) (if (result f32) (f32.eq (get_local $0) @@ -1418,7 +875,7 @@ (f32.const 0) ) ) - (func $deNan64 (; 17 ;) (param $0 f64) (result f64) + (func $deNan64 (; 14 ;) (param $0 f64) (result f64) (if (result f64) (f64.eq (get_local $0) diff --git a/test/spec/conversions.wast b/test/spec/conversions.wast index 17036a75f..21f058897 100644 --- a/test/spec/conversions.wast +++ b/test/spec/conversions.wast @@ -10,6 +10,14 @@ (func (export "i64.trunc_u_f32") (param $x f32) (result i64) (i64.trunc_u/f32 (get_local $x))) (func (export "i64.trunc_s_f64") (param $x f64) (result i64) (i64.trunc_s/f64 (get_local $x))) (func (export "i64.trunc_u_f64") (param $x f64) (result i64) (i64.trunc_u/f64 (get_local $x))) + (func (export "i32.trunc_s_sat_f32") (param $x f32) (result i32) (i32.trunc_s:sat/f32 (get_local $x))) + (func (export "i32.trunc_u_sat_f32") (param $x f32) (result i32) (i32.trunc_u:sat/f32 (get_local $x))) + (func (export "i32.trunc_s_sat_f64") (param $x f64) (result i32) (i32.trunc_s:sat/f64 (get_local $x))) + (func (export "i32.trunc_u_sat_f64") (param $x f64) (result i32) (i32.trunc_u:sat/f64 (get_local $x))) + (func (export "i64.trunc_s_sat_f32") (param $x f32) (result i64) (i64.trunc_s:sat/f32 (get_local $x))) + (func (export "i64.trunc_u_sat_f32") (param $x f32) (result i64) (i64.trunc_u:sat/f32 (get_local $x))) + (func (export "i64.trunc_s_sat_f64") (param $x f64) (result i64) (i64.trunc_s:sat/f64 (get_local $x))) + (func (export "i64.trunc_u_sat_f64") (param $x f64) (result i64) (i64.trunc_u:sat/f64 (get_local $x))) (func (export "f32.convert_s_i32") (param $x i32) (result f32) (f32.convert_s/i32 (get_local $x))) (func (export "f32.convert_s_i64") (param $x i64) (result f32) (f32.convert_s/i64 (get_local $x))) (func (export "f64.convert_s_i32") (param $x i32) (result f64) (f64.convert_s/i32 (get_local $x))) @@ -217,6 +225,170 @@ (assert_trap (invoke "i64.trunc_u_f64" (f64.const -infinity)) "integer overflow") (assert_trap (invoke "i64.trunc_u_f64" (f64.const nan)) "invalid conversion to integer") +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const 0.0)) (i32.const 0)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const -0.0)) (i32.const 0)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const 0x1p-149)) (i32.const 0)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const -0x1p-149)) (i32.const 0)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const 1.0)) (i32.const 1)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const 0x1.19999ap+0)) (i32.const 1)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const 1.5)) (i32.const 1)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const -1.0)) (i32.const -1)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const -0x1.19999ap+0)) (i32.const -1)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const -1.5)) (i32.const -1)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const -1.9)) (i32.const -1)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const -2.0)) (i32.const -2)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const 2147483520.0)) (i32.const 2147483520)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const -2147483648.0)) (i32.const -2147483648)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const 2147483648.0)) (i32.const 2147483647)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const -2147483904.0)) (i32.const -2147483648)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const infinity)) (i32.const 2147483647)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const -infinity)) (i32.const -2147483648)) +(assert_return (invoke "i32.trunc_s_sat_f32" (f32.const nan)) (i32.const 0)) + +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const 0.0)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const -0.0)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const 0x1p-149)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const -0x1p-149)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const 1.0)) (i32.const 1)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const 0x1.19999ap+0)) (i32.const 1)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const 1.5)) (i32.const 1)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const 1.9)) (i32.const 1)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const 2.0)) (i32.const 2)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const 2147483648)) (i32.const -2147483648)) ;; 0x1.00000p+31 -> 8000 0000 +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const 4294967040.0)) (i32.const -256)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const -0x1.ccccccp-1)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const -0x1.fffffep-1)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const 4294967296.0)) (i32.const 4294967295)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const -1.0)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const infinity)) (i32.const 4294967295)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const -infinity)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f32" (f32.const nan)) (i32.const 0)) + +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const 0.0)) (i32.const 0)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const -0.0)) (i32.const 0)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const 0x0.0000000000001p-1022)) (i32.const 0)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const -0x0.0000000000001p-1022)) (i32.const 0)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const 1.0)) (i32.const 1)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const 0x1.199999999999ap+0)) (i32.const 1)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const 1.5)) (i32.const 1)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const -1.0)) (i32.const -1)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const -0x1.199999999999ap+0)) (i32.const -1)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const -1.5)) (i32.const -1)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const -1.9)) (i32.const -1)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const -2.0)) (i32.const -2)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const 2147483647.0)) (i32.const 2147483647)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const -2147483648.0)) (i32.const -2147483648)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const 2147483648.0)) (i32.const 2147483647)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const -2147483649.0)) (i32.const -2147483648)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const infinity)) (i32.const 2147483647)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const -infinity)) (i32.const -2147483648)) +(assert_return (invoke "i32.trunc_s_sat_f64" (f64.const nan)) (i32.const 0)) + +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 0.0)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const -0.0)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 0x0.0000000000001p-1022)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const -0x0.0000000000001p-1022)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 1.0)) (i32.const 1)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 0x1.199999999999ap+0)) (i32.const 1)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 1.5)) (i32.const 1)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 1.9)) (i32.const 1)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 2.0)) (i32.const 2)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 2147483648)) (i32.const -2147483648)) ;; 0x1.00000p+31 -> 8000 0000 +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 4294967295.0)) (i32.const -1)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const -0x1.ccccccccccccdp-1)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const -0x1.fffffffffffffp-1)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 1e8)) (i32.const 100000000)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 4294967296.0)) (i32.const 4294967295)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const -1.0)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 1e16)) (i32.const 4294967295)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 1e30)) (i32.const 4294967295)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const 9223372036854775808)) (i32.const 4294967295)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const infinity)) (i32.const 4294967295)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const -infinity)) (i32.const 0)) +(assert_return (invoke "i32.trunc_u_sat_f64" (f64.const nan)) (i32.const 0)) + +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const 0.0)) (i64.const 0)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const -0.0)) (i64.const 0)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const 0x1p-149)) (i64.const 0)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const -0x1p-149)) (i64.const 0)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const 1.0)) (i64.const 1)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const 0x1.19999ap+0)) (i64.const 1)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const 1.5)) (i64.const 1)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const -1.0)) (i64.const -1)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const -0x1.19999ap+0)) (i64.const -1)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const -1.5)) (i64.const -1)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const -1.9)) (i64.const -1)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const -2.0)) (i64.const -2)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const 4294967296)) (i64.const 4294967296)) ;; 0x1.00000p+32 -> 1 0000 0000 +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const -4294967296)) (i64.const -4294967296)) ;; -0x1.00000p+32 -> ffff ffff 0000 0000 +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const 9223371487098961920.0)) (i64.const 9223371487098961920)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const -9223372036854775808.0)) (i64.const -9223372036854775808)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const 9223372036854775808.0)) (i64.const 9223372036854775807)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const -9223373136366403584.0)) (i64.const -9223372036854775808)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const infinity)) (i64.const 9223372036854775807)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const -infinity)) (i64.const -9223372036854775808)) +(assert_return (invoke "i64.trunc_s_sat_f32" (f32.const nan)) (i64.const 0)) + +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const 0.0)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const -0.0)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const 0x1p-149)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const -0x1p-149)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const 1.0)) (i64.const 1)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const 0x1.19999ap+0)) (i64.const 1)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const 1.5)) (i64.const 1)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const 4294967296)) (i64.const 4294967296)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const 18446742974197923840.0)) (i64.const -1099511627776)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const -0x1.ccccccp-1)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const -0x1.fffffep-1)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const 18446744073709551616.0)) (i64.const 18446744073709551615)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const -1.0)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const infinity)) (i64.const 18446744073709551615)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const -infinity)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f32" (f32.const nan)) (i64.const 0)) + +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const 0.0)) (i64.const 0)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const -0.0)) (i64.const 0)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const 0x0.0000000000001p-1022)) (i64.const 0)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const -0x0.0000000000001p-1022)) (i64.const 0)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const 1.0)) (i64.const 1)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const 0x1.199999999999ap+0)) (i64.const 1)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const 1.5)) (i64.const 1)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const -1.0)) (i64.const -1)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const -0x1.199999999999ap+0)) (i64.const -1)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const -1.5)) (i64.const -1)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const -1.9)) (i64.const -1)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const -2.0)) (i64.const -2)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const 4294967296)) (i64.const 4294967296)) ;; 0x1.00000p+32 -> 1 0000 0000 +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const -4294967296)) (i64.const -4294967296)) ;; -0x1.00000p+32 -> ffff ffff 0000 0000 +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const 9223372036854774784.0)) (i64.const 9223372036854774784)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const -9223372036854775808.0)) (i64.const -9223372036854775808)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const 9223372036854775808.0)) (i64.const 9223372036854775807)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const -9223372036854777856.0)) (i64.const -9223372036854775808)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const infinity)) (i64.const 9223372036854775807)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const -infinity)) (i64.const -9223372036854775808)) +(assert_return (invoke "i64.trunc_s_sat_f64" (f64.const nan)) (i64.const 0)) + +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 0.0)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const -0.0)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 0x0.0000000000001p-1022)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const -0x0.0000000000001p-1022)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 1.0)) (i64.const 1)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 0x1.199999999999ap+0)) (i64.const 1)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 1.5)) (i64.const 1)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 4294967295)) (i64.const 0xffffffff)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 4294967296)) (i64.const 0x100000000)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 18446744073709549568.0)) (i64.const -2048)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const -0x1.ccccccccccccdp-1)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const -0x1.fffffffffffffp-1)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 1e8)) (i64.const 100000000)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 1e16)) (i64.const 10000000000000000)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 9223372036854775808)) (i64.const -9223372036854775808)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const 18446744073709551616.0)) (i64.const 18446744073709551615)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const -1.0)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const infinity)) (i64.const 18446744073709551615)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const -infinity)) (i64.const 0)) +(assert_return (invoke "i64.trunc_u_sat_f64" (f64.const nan)) (i64.const 0)) + (assert_return (invoke "f32.convert_s_i32" (i32.const 1)) (f32.const 1.0)) (assert_return (invoke "f32.convert_s_i32" (i32.const -1)) (f32.const -1.0)) (assert_return (invoke "f32.convert_s_i32" (i32.const 0)) (f32.const 0.0)) |