diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-18 10:57:41 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-18 10:57:41 -0800 |
commit | c4e71c7e1a18594735cb49b013dd42d9f5826e23 (patch) | |
tree | 72100d18cac3f3e667a8b1cb300fbeecbfd41c1e /src/asm2wasm.h | |
parent | 47add7947265b99c6c68add694e6ae70911f4f4e (diff) | |
download | binaryen-c4e71c7e1a18594735cb49b013dd42d9f5826e23.tar.gz binaryen-c4e71c7e1a18594735cb49b013dd42d9f5826e23.tar.bz2 binaryen-c4e71c7e1a18594735cb49b013dd42d9f5826e23.zip |
clean up + coercion handling code, and make it work on +HEAPF32
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 35b75a50c..505e3ee87 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -780,23 +780,21 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { ret->type = ret->value.type; return ret; } - AsmType childType = detectAsmType(ast[2], &asmData); - if (childType == ASM_INT) { - auto ret = allocator.alloc<Convert>(); - ret->op = isUnsignedCoercion(ast[2]) ? ConvertUInt32 : ConvertSInt32; - ret->value = process(ast[2]); - ret->type = WasmType::f64; - return ret; + auto ret = process(ast[2]); // we are a +() coercion + if (ret->type == i32) { + auto conv = allocator.alloc<Convert>(); + conv->op = isUnsignedCoercion(ast[2]) ? ConvertUInt32 : ConvertSInt32; + conv->value = ret; + conv->type = WasmType::f64; + return conv; } - if (childType == ASM_FLOAT) { - auto ret = allocator.alloc<Convert>(); - ret->op = PromoteFloat32; - ret->value = process(ast[2]); - ret->type = WasmType::f64; - return ret; + if (ret->type == f32) { + auto conv = allocator.alloc<Convert>(); + conv->op = PromoteFloat32; + conv->value = ret; + conv->type = WasmType::f64; + return conv; } - assert(childType == ASM_NONE || childType == ASM_DOUBLE); // e.g. a coercion on a call or for a return - auto ret = process(ast[2]); // just look through the +() coercion fixCallType(ret, f64); return ret; } else if (ast[1] == MINUS) { |