diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-05-03 22:01:14 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-05-03 22:01:14 -0700 |
commit | c7d7083920ddd9ff7d1a44577287b8ecc048a221 (patch) | |
tree | 1eb9e0cd2e50566b62f65171ccc35b29f8ca5c4d /src/asm2wasm.h | |
parent | 5b2adeb4b2a66dfcda7667ce7a4c27ec49c62b1b (diff) | |
download | binaryen-c7d7083920ddd9ff7d1a44577287b8ecc048a221.tar.gz binaryen-c7d7083920ddd9ff7d1a44577287b8ecc048a221.tar.bz2 binaryen-c7d7083920ddd9ff7d1a44577287b8ecc048a221.zip |
Harmonize the internal opcodes with the binary format (#433)
* harmonize the internal opcodes with the binary format, so they clearly parallel, and also this helps us avoid needing the type to disambiguate
* comment on GetLocal in C API
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 974a06bf3..fa35211a4 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -1101,7 +1101,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { auto ret = process(ast[2]); // we are a +() coercion if (ret->type == i32) { auto conv = allocator.alloc<Unary>(); - conv->op = isUnsignedCoercion(ast[2]) ? ConvertUInt32 : ConvertSInt32; + conv->op = isUnsignedCoercion(ast[2]) ? ConvertUInt32ToFloat64 : ConvertSInt32ToFloat64; conv->value = ret; conv->type = WasmType::f64; return conv; @@ -1149,7 +1149,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { if (imprecise) { auto ret = allocator.alloc<Unary>(); ret->value = process(ast[2][2]); - ret->op = ret->value->type == f64 ? TruncSFloat64 : TruncSFloat32; // imprecise, because this wasm thing might trap, while asm.js never would + ret->op = ret->value->type == f64 ? TruncSFloat64ToInt32 : TruncSFloat32ToInt32; // imprecise, because this wasm thing might trap, while asm.js never would ret->type = WasmType::i32; return ret; } else { @@ -1233,7 +1233,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { if (ret->value->type == f64) { ret->op = DemoteFloat64; } else if (ret->value->type == i32) { - ret->op = ConvertSInt32; + ret->op = ConvertSInt32ToFloat32; } else if (ret->value->type == f32) { return ret->value; } else if (ret->value->type == none) { // call, etc. @@ -1564,7 +1564,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { Ref writtenValue = ast[1][3]; if (writeType == ASM_INT && (readType == ASM_FLOAT || readType == ASM_DOUBLE)) { auto conv = allocator.alloc<Unary>(); - conv->op = ReinterpretInt; + conv->op = ReinterpretInt32; conv->value = process(writtenValue); conv->type = WasmType::f32; if (readType == ASM_DOUBLE) { @@ -1577,11 +1577,11 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { return conv; } else if (writeType == ASM_FLOAT && readType == ASM_INT) { auto conv = allocator.alloc<Unary>(); - conv->op = ReinterpretFloat; + conv->op = ReinterpretFloat32; conv->value = process(writtenValue); if (conv->value->type == f64) { // this has an implicit f64->f32 in the write to memory - conv->value = builder.makeUnary(DemoteFloat64, conv->value, f32); + conv->value = builder.makeUnary(DemoteFloat64, conv->value); } conv->type = WasmType::i32; return conv; |