Commit 643ae16f authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[Liftoff] Implement float promotion and demotion

Add support for f32.demote/f64 and f64.promote/f32.
Both are straight forward to implement on ia32 and x64.

R=titzer@chromium.org

Bug: v8:6600
Change-Id: I75213ddf5f422d0aa1d5d9a3bbc90ac32f6950f5
Reviewed-on: https://chromium-review.googlesource.com/955849
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51872}
parent f2695702
...@@ -707,12 +707,18 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode, ...@@ -707,12 +707,18 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
Cvtui2ss(dst.fp(), src.gp(), scratch); Cvtui2ss(dst.fp(), src.gp(), scratch);
return true; return true;
} }
case kExprF32ConvertF64:
cvtsd2ss(dst.fp(), src.fp());
return true;
case kExprF64SConvertI32: case kExprF64SConvertI32:
Cvtsi2sd(dst.fp(), src.gp()); Cvtsi2sd(dst.fp(), src.gp());
return true; return true;
case kExprF64UConvertI32: case kExprF64UConvertI32:
LoadUint32(dst.fp(), src.gp()); LoadUint32(dst.fp(), src.gp());
return true; return true;
case kExprF64ConvertF32:
cvtss2sd(dst.fp(), src.fp());
return true;
default: default:
return false; return false;
} }
......
...@@ -638,12 +638,14 @@ class LiftoffCompiler { ...@@ -638,12 +638,14 @@ class LiftoffCompiler {
&ExternalReference::wasm_int64_to_float32) &ExternalReference::wasm_int64_to_float32)
CASE_TYPE_CONVERSION(F32UConvertI64, F32, I64, CASE_TYPE_CONVERSION(F32UConvertI64, F32, I64,
&ExternalReference::wasm_uint64_to_float32) &ExternalReference::wasm_uint64_to_float32)
CASE_TYPE_CONVERSION(F32ConvertF64, F32, F64, nullptr)
CASE_TYPE_CONVERSION(F64SConvertI32, F64, I32, nullptr) CASE_TYPE_CONVERSION(F64SConvertI32, F64, I32, nullptr)
CASE_TYPE_CONVERSION(F64UConvertI32, F64, I32, nullptr) CASE_TYPE_CONVERSION(F64UConvertI32, F64, I32, nullptr)
CASE_TYPE_CONVERSION(F64SConvertI64, F64, I64, CASE_TYPE_CONVERSION(F64SConvertI64, F64, I64,
&ExternalReference::wasm_int64_to_float64) &ExternalReference::wasm_int64_to_float64)
CASE_TYPE_CONVERSION(F64UConvertI64, F64, I64, CASE_TYPE_CONVERSION(F64UConvertI64, F64, I64,
&ExternalReference::wasm_uint64_to_float64) &ExternalReference::wasm_uint64_to_float64)
CASE_TYPE_CONVERSION(F64ConvertF32, F64, F32, nullptr)
default: default:
return unsupported(decoder, WasmOpcodes::OpcodeName(opcode)); return unsupported(decoder, WasmOpcodes::OpcodeName(opcode));
} }
......
...@@ -658,6 +658,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode, ...@@ -658,6 +658,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
case kExprF32UConvertI64: case kExprF32UConvertI64:
Cvtqui2ss(dst.fp(), src.gp(), kScratchRegister); Cvtqui2ss(dst.fp(), src.gp(), kScratchRegister);
return true; return true;
case kExprF32ConvertF64:
Cvtsd2ss(dst.fp(), src.fp());
return true;
case kExprF64SConvertI32: case kExprF64SConvertI32:
Cvtlsi2sd(dst.fp(), src.gp()); Cvtlsi2sd(dst.fp(), src.gp());
return true; return true;
...@@ -671,6 +674,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode, ...@@ -671,6 +674,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
case kExprF64UConvertI64: case kExprF64UConvertI64:
Cvtqui2sd(dst.fp(), src.gp(), kScratchRegister); Cvtqui2sd(dst.fp(), src.gp(), kScratchRegister);
return true; return true;
case kExprF64ConvertF32:
Cvtss2sd(dst.fp(), src.fp());
return true;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment