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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "src/base/utils/random-number-generator.h" 9 #include "src/base/utils/random-number-generator.h"
10 10
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 } else { 1053 } else {
1054 CHECK_EQ(val / denom, r.Call(val)); 1054 CHECK_EQ(val / denom, r.Call(val));
1055 } 1055 }
1056 } 1056 }
1057 } 1057 }
1058 } 1058 }
1059 #endif 1059 #endif
1060 1060
1061 1061
1062 void TestFloat32Binop(WasmOpcode opcode, int32_t expected, float a, float b) { 1062 void TestFloat32Binop(WasmOpcode opcode, int32_t expected, float a, float b) {
1063 WasmRunner<int32_t> r; 1063 {
1064 // return K op K 1064 WasmRunner<int32_t> r;
1065 BUILD(r, WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b))); 1065 // return K op K
1066 CHECK_EQ(expected, r.Call()); 1066 BUILD(r, WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b)));
1067 // TODO(titzer): test float parameters 1067 CHECK_EQ(expected, r.Call());
1068 }
1069 {
1070 WasmRunner<int32_t> r(MachineType::Float32(), MachineType::Float32());
1071 // return a op b
1072 BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
1073 CHECK_EQ(expected, r.Call(a, b));
1074 }
1068 } 1075 }
1069 1076
1070 1077
1071 void TestFloat32BinopWithConvert(WasmOpcode opcode, int32_t expected, float a, 1078 void TestFloat32BinopWithConvert(WasmOpcode opcode, int32_t expected, float a,
1072 float b) { 1079 float b) {
1073 WasmRunner<int32_t> r; 1080 {
1074 // return int(K op K) 1081 WasmRunner<int32_t> r;
1075 BUILD(r, WASM_I32_SCONVERT_F32(WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b)))); 1082 // return int(K op K)
1076 CHECK_EQ(expected, r.Call()); 1083 BUILD(r,
1077 // TODO(titzer): test float parameters 1084 WASM_I32_SCONVERT_F32(WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b))));
1085 CHECK_EQ(expected, r.Call());
1086 }
1087 {
1088 WasmRunner<int32_t> r(MachineType::Float32(), MachineType::Float32());
1089 // return int(a op b)
1090 BUILD(r, WASM_I32_SCONVERT_F32(
1091 WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
1092 CHECK_EQ(expected, r.Call(a, b));
1093 }
1078 } 1094 }
1079 1095
1080 1096
1081 void TestFloat32UnopWithConvert(WasmOpcode opcode, int32_t expected, float a) { 1097 void TestFloat32UnopWithConvert(WasmOpcode opcode, int32_t expected, float a) {
1082 WasmRunner<int32_t> r; 1098 {
1083 // return int(K op K) 1099 WasmRunner<int32_t> r;
1084 BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_F32(a)))); 1100 // return int(op(K))
1085 CHECK_EQ(expected, r.Call()); 1101 BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_F32(a))));
1086 // TODO(titzer): test float parameters 1102 CHECK_EQ(expected, r.Call());
1103 }
1104 {
1105 WasmRunner<int32_t> r(MachineType::Float32());
1106 // return int(op(a))
1107 BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_GET_LOCAL(0))));
1108 CHECK_EQ(expected, r.Call(a));
1109 }
1087 } 1110 }
1088 1111
1089 1112
1090 void TestFloat64Binop(WasmOpcode opcode, int32_t expected, double a, double b) { 1113 void TestFloat64Binop(WasmOpcode opcode, int32_t expected, double a, double b) {
1091 WasmRunner<int32_t> r; 1114 {
1092 // return K op K 1115 WasmRunner<int32_t> r;
1093 BUILD(r, WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b))); 1116 // return K op K
1094 CHECK_EQ(expected, r.Call()); 1117 BUILD(r, WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b)));
1095 // TODO(titzer): test double parameters 1118 CHECK_EQ(expected, r.Call());
1119 }
1120 {
1121 WasmRunner<int32_t> r(MachineType::Float64(), MachineType::Float64());
1122 // return a op b
1123 BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
1124 CHECK_EQ(expected, r.Call(a, b));
1125 }
1096 } 1126 }
1097 1127
1098 1128
1099 void TestFloat64BinopWithConvert(WasmOpcode opcode, int32_t expected, double a, 1129 void TestFloat64BinopWithConvert(WasmOpcode opcode, int32_t expected, double a,
1100 double b) { 1130 double b) {
1101 WasmRunner<int32_t> r; 1131 {
1102 // return int(K op K) 1132 WasmRunner<int32_t> r;
1103 BUILD(r, WASM_I32_SCONVERT_F64(WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b)))); 1133 // return int(K op K)
1104 CHECK_EQ(expected, r.Call()); 1134 BUILD(r,
1105 // TODO(titzer): test double parameters 1135 WASM_I32_SCONVERT_F64(WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b))));
1136 CHECK_EQ(expected, r.Call());
1137 }
1138 {
1139 WasmRunner<int32_t> r(MachineType::Float64(), MachineType::Float64());
1140 BUILD(r, WASM_I32_SCONVERT_F64(
1141 WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
1142 CHECK_EQ(expected, r.Call(a, b));
1143 }
1106 } 1144 }
1107 1145
1108 1146
1109 void TestFloat64UnopWithConvert(WasmOpcode opcode, int32_t expected, double a) { 1147 void TestFloat64UnopWithConvert(WasmOpcode opcode, int32_t expected, double a) {
1110 WasmRunner<int32_t> r; 1148 {
1111 // return int(K op K) 1149 WasmRunner<int32_t> r;
1112 BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_F64(a)))); 1150 // return int(op(K))
1113 CHECK_EQ(expected, r.Call()); 1151 BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_F64(a))));
1114 // TODO(titzer): test float parameters 1152 CHECK_EQ(expected, r.Call());
1153 }
1154 {
1155 WasmRunner<int32_t> r(MachineType::Float64());
1156 // return int(op(a))
1157 BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_GET_LOCAL(0))));
1158 CHECK_EQ(expected, r.Call(a));
1159 }
1115 } 1160 }
1116 1161
1117 1162
1118 // TODO(titzer): Fix for nosee4 and re-enable. 1163 // TODO(titzer): Fix for nosee4 and re-enable.
1119 #if 0 1164 #if 0
1120 1165
1121 TEST(Run_WasmFloat32Binops) { 1166 TEST(Run_WasmFloat32Binops) {
1122 TestFloat32Binop(kExprF32Eq, 1, 8.125f, 8.125f); 1167 TestFloat32Binop(kExprF32Eq, 1, 8.125f, 8.125f);
1123 TestFloat32Binop(kExprF32Ne, 1, 8.125f, 8.127f); 1168 TestFloat32Binop(kExprF32Ne, 1, 8.125f, 8.127f);
1124 TestFloat32Binop(kExprF32Lt, 1, -9.5f, -9.0f); 1169 TestFloat32Binop(kExprF32Lt, 1, -9.5f, -9.0f);
(...skipping 2442 matching lines...) Expand 10 before | Expand all | Expand 10 after
3567 TEST(Run_Wasm_F32CopySign) { 3612 TEST(Run_Wasm_F32CopySign) {
3568 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); 3613 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32());
3569 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 3614 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
3570 3615
3571 FOR_FLOAT32_INPUTS(i) { 3616 FOR_FLOAT32_INPUTS(i) {
3572 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(copysign(*i, *j), r.Call(*i, *j)); } 3617 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(copysign(*i, *j), r.Call(*i, *j)); }
3573 } 3618 }
3574 } 3619 }
3575 3620
3576 #endif 3621 #endif
OLDNEW
« 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