Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: test/cctest/wasm/test-run-wasm.cc

Issue 1562883003: [wasm] Add tests that pass float/double parameters directly for binops and unops. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/test-run-wasm.cc
diff --git a/test/cctest/wasm/test-run-wasm.cc b/test/cctest/wasm/test-run-wasm.cc
index fd41cd9d549dcd4fbd650483e948fa1c4d16895a..432ae70b4078337f1ce21fcde69f91f505d37e21 100644
--- a/test/cctest/wasm/test-run-wasm.cc
+++ b/test/cctest/wasm/test-run-wasm.cc
@@ -1060,58 +1060,103 @@ TEST(Run_WASM_Int64DivU_byzero_const) {
void TestFloat32Binop(WasmOpcode opcode, int32_t expected, float a, float b) {
- WasmRunner<int32_t> r;
- // return K op K
- BUILD(r, WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b)));
- CHECK_EQ(expected, r.Call());
- // TODO(titzer): test float parameters
+ {
+ WasmRunner<int32_t> r;
+ // return K op K
+ BUILD(r, WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b)));
+ CHECK_EQ(expected, r.Call());
+ }
+ {
+ WasmRunner<int32_t> r(MachineType::Float32(), MachineType::Float32());
+ // return a op b
+ BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
+ CHECK_EQ(expected, r.Call(a, b));
+ }
}
void TestFloat32BinopWithConvert(WasmOpcode opcode, int32_t expected, float a,
float b) {
- WasmRunner<int32_t> r;
- // return int(K op K)
- BUILD(r, WASM_I32_SCONVERT_F32(WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b))));
- CHECK_EQ(expected, r.Call());
- // TODO(titzer): test float parameters
+ {
+ WasmRunner<int32_t> r;
+ // return int(K op K)
+ BUILD(r,
+ WASM_I32_SCONVERT_F32(WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b))));
+ CHECK_EQ(expected, r.Call());
+ }
+ {
+ WasmRunner<int32_t> r(MachineType::Float32(), MachineType::Float32());
+ // return int(a op b)
+ BUILD(r, WASM_I32_SCONVERT_F32(
+ WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
+ CHECK_EQ(expected, r.Call(a, b));
+ }
}
void TestFloat32UnopWithConvert(WasmOpcode opcode, int32_t expected, float a) {
- WasmRunner<int32_t> r;
- // return int(K op K)
- BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_F32(a))));
- CHECK_EQ(expected, r.Call());
- // TODO(titzer): test float parameters
+ {
+ WasmRunner<int32_t> r;
+ // return int(op(K))
+ BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_F32(a))));
+ CHECK_EQ(expected, r.Call());
+ }
+ {
+ WasmRunner<int32_t> r(MachineType::Float32());
+ // return int(op(a))
+ BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_GET_LOCAL(0))));
+ CHECK_EQ(expected, r.Call(a));
+ }
}
void TestFloat64Binop(WasmOpcode opcode, int32_t expected, double a, double b) {
- WasmRunner<int32_t> r;
- // return K op K
- BUILD(r, WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b)));
- CHECK_EQ(expected, r.Call());
- // TODO(titzer): test double parameters
+ {
+ WasmRunner<int32_t> r;
+ // return K op K
+ BUILD(r, WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b)));
+ CHECK_EQ(expected, r.Call());
+ }
+ {
+ WasmRunner<int32_t> r(MachineType::Float64(), MachineType::Float64());
+ // return a op b
+ BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
+ CHECK_EQ(expected, r.Call(a, b));
+ }
}
void TestFloat64BinopWithConvert(WasmOpcode opcode, int32_t expected, double a,
double b) {
- WasmRunner<int32_t> r;
- // return int(K op K)
- BUILD(r, WASM_I32_SCONVERT_F64(WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b))));
- CHECK_EQ(expected, r.Call());
- // TODO(titzer): test double parameters
+ {
+ WasmRunner<int32_t> r;
+ // return int(K op K)
+ BUILD(r,
+ WASM_I32_SCONVERT_F64(WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b))));
+ CHECK_EQ(expected, r.Call());
+ }
+ {
+ WasmRunner<int32_t> r(MachineType::Float64(), MachineType::Float64());
+ BUILD(r, WASM_I32_SCONVERT_F64(
+ WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
+ CHECK_EQ(expected, r.Call(a, b));
+ }
}
void TestFloat64UnopWithConvert(WasmOpcode opcode, int32_t expected, double a) {
- WasmRunner<int32_t> r;
- // return int(K op K)
- BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_F64(a))));
- CHECK_EQ(expected, r.Call());
- // TODO(titzer): test float parameters
+ {
+ WasmRunner<int32_t> r;
+ // return int(op(K))
+ BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_F64(a))));
+ CHECK_EQ(expected, r.Call());
+ }
+ {
+ WasmRunner<int32_t> r(MachineType::Float64());
+ // return int(op(a))
+ BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_GET_LOCAL(0))));
+ CHECK_EQ(expected, r.Call(a));
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698