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

Side by Side Diff: test/cctest/compiler/test-run-machops.cc

Issue 1778893005: [wasm] Int64Lowering of Int64Sub on ia32 and arm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-add
Patch Set: Rebase. Created 4 years, 9 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 | « src/compiler/x87/instruction-selector-x87.cc ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 #include <functional> 6 #include <functional>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 4179 matching lines...) Expand 10 before | Expand all | Expand 10 after
4190 4190
4191 4191
4192 TEST(RunTruncateFloat64ToFloat32) { 4192 TEST(RunTruncateFloat64ToFloat32) {
4193 BufferedRawMachineAssemblerTester<float> m(MachineType::Float64()); 4193 BufferedRawMachineAssemblerTester<float> m(MachineType::Float64());
4194 4194
4195 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); 4195 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0)));
4196 4196
4197 FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(DoubleToFloat32(*i), m.Call(*i)); } 4197 FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(DoubleToFloat32(*i), m.Call(*i)); }
4198 } 4198 }
4199 4199
4200 int64_t ToInt64(uint32_t low, uint32_t high) { 4200 uint64_t ToInt64(uint32_t low, uint32_t high) {
4201 return (static_cast<int64_t>(high) << 32) | static_cast<int64_t>(low); 4201 return (static_cast<uint64_t>(high) << 32) | static_cast<uint64_t>(low);
4202 } 4202 }
4203 4203
4204 #if V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_PPC && \ 4204 #if V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_PPC && \
4205 !V8_TARGET_ARCH_X87 4205 !V8_TARGET_ARCH_X87
4206 TEST(RunInt32PairAdd) { 4206 TEST(RunInt32PairAdd) {
4207 BufferedRawMachineAssemblerTester<int32_t> m( 4207 BufferedRawMachineAssemblerTester<int32_t> m(
4208 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), 4208 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(),
4209 MachineType::Int32()); 4209 MachineType::Uint32());
4210 4210
4211 uint32_t high; 4211 uint32_t high;
4212 uint32_t low; 4212 uint32_t low;
4213 4213
4214 Node* PairAdd = m.Int32PairAdd(m.Parameter(0), m.Parameter(1), m.Parameter(2), 4214 Node* PairAdd = m.Int32PairAdd(m.Parameter(0), m.Parameter(1), m.Parameter(2),
4215 m.Parameter(3)); 4215 m.Parameter(3));
4216 4216
4217 m.StoreToPointer(&low, MachineRepresentation::kWord32, 4217 m.StoreToPointer(&low, MachineRepresentation::kWord32,
4218 m.Projection(0, PairAdd)); 4218 m.Projection(0, PairAdd));
4219 m.StoreToPointer(&high, MachineRepresentation::kWord32, 4219 m.StoreToPointer(&high, MachineRepresentation::kWord32,
4220 m.Projection(1, PairAdd)); 4220 m.Projection(1, PairAdd));
4221 m.Return(m.Int32Constant(74)); 4221 m.Return(m.Int32Constant(74));
4222 4222
4223 FOR_INT64_INPUTS(i) { 4223 FOR_UINT64_INPUTS(i) {
4224 FOR_INT64_INPUTS(j) { 4224 FOR_UINT64_INPUTS(j) {
4225 m.Call(static_cast<int32_t>(*i & 0xffffffff), 4225 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4226 static_cast<int32_t>(*i >> 32), 4226 static_cast<uint32_t>(*i >> 32),
4227 static_cast<int32_t>(*j & 0xffffffff), 4227 static_cast<uint32_t>(*j & 0xffffffff),
4228 static_cast<int32_t>(*j >> 32)); 4228 static_cast<uint32_t>(*j >> 32));
4229 CHECK_EQ(*i + *j, ToInt64(low, high)); 4229 CHECK_EQ(*i + *j, ToInt64(low, high));
4230 } 4230 }
4231 } 4231 }
4232 } 4232 }
4233 4233
4234 void TestInt32PairAddWithSharedInput(int a, int b, int c, int d) { 4234 void TestInt32PairAddWithSharedInput(int a, int b, int c, int d) {
4235 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(), 4235 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
4236 MachineType::Uint32()); 4236 MachineType::Uint32());
4237 4237
4238 uint32_t high; 4238 uint32_t high;
(...skipping 20 matching lines...) Expand all
4259 4259
4260 TEST(RunInt32PairAddWithSharedInput) { 4260 TEST(RunInt32PairAddWithSharedInput) {
4261 TestInt32PairAddWithSharedInput(0, 0, 0, 0); 4261 TestInt32PairAddWithSharedInput(0, 0, 0, 0);
4262 TestInt32PairAddWithSharedInput(1, 0, 0, 0); 4262 TestInt32PairAddWithSharedInput(1, 0, 0, 0);
4263 TestInt32PairAddWithSharedInput(0, 1, 0, 0); 4263 TestInt32PairAddWithSharedInput(0, 1, 0, 0);
4264 TestInt32PairAddWithSharedInput(0, 0, 1, 0); 4264 TestInt32PairAddWithSharedInput(0, 0, 1, 0);
4265 TestInt32PairAddWithSharedInput(0, 0, 0, 1); 4265 TestInt32PairAddWithSharedInput(0, 0, 0, 1);
4266 TestInt32PairAddWithSharedInput(1, 1, 0, 0); 4266 TestInt32PairAddWithSharedInput(1, 1, 0, 0);
4267 } 4267 }
4268 4268
4269 TEST(RunInt32PairSub) {
4270 BufferedRawMachineAssemblerTester<int32_t> m(
4271 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(),
4272 MachineType::Uint32());
4273
4274 uint32_t high;
4275 uint32_t low;
4276
4277 Node* PairSub = m.Int32PairSub(m.Parameter(0), m.Parameter(1), m.Parameter(2),
4278 m.Parameter(3));
4279
4280 m.StoreToPointer(&low, MachineRepresentation::kWord32,
4281 m.Projection(0, PairSub));
4282 m.StoreToPointer(&high, MachineRepresentation::kWord32,
4283 m.Projection(1, PairSub));
4284 m.Return(m.Int32Constant(74));
4285
4286 FOR_UINT64_INPUTS(i) {
4287 FOR_UINT64_INPUTS(j) {
4288 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4289 static_cast<uint32_t>(*i >> 32),
4290 static_cast<uint32_t>(*j & 0xffffffff),
4291 static_cast<uint32_t>(*j >> 32));
4292 CHECK_EQ(*i - *j, ToInt64(low, high));
4293 }
4294 }
4295 }
4296
4297 void TestInt32PairSubWithSharedInput(int a, int b, int c, int d) {
4298 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
4299 MachineType::Uint32());
4300
4301 uint32_t high;
4302 uint32_t low;
4303
4304 Node* PairSub = m.Int32PairSub(m.Parameter(a), m.Parameter(b), m.Parameter(c),
4305 m.Parameter(d));
4306
4307 m.StoreToPointer(&low, MachineRepresentation::kWord32,
4308 m.Projection(0, PairSub));
4309 m.StoreToPointer(&high, MachineRepresentation::kWord32,
4310 m.Projection(1, PairSub));
4311 m.Return(m.Int32Constant(74));
4312
4313 FOR_UINT32_INPUTS(i) {
4314 FOR_UINT32_INPUTS(j) {
4315 m.Call(*i, *j);
4316 uint32_t inputs[] = {*i, *j};
4317 CHECK_EQ(ToInt64(inputs[a], inputs[b]) - ToInt64(inputs[c], inputs[d]),
4318 ToInt64(low, high));
4319 }
4320 }
4321 }
4322
4323 TEST(RunInt32PairSubWithSharedInput) {
4324 TestInt32PairSubWithSharedInput(0, 0, 0, 0);
4325 TestInt32PairSubWithSharedInput(1, 0, 0, 0);
4326 TestInt32PairSubWithSharedInput(0, 1, 0, 0);
4327 TestInt32PairSubWithSharedInput(0, 0, 1, 0);
4328 TestInt32PairSubWithSharedInput(0, 0, 0, 1);
4329 TestInt32PairSubWithSharedInput(1, 1, 0, 0);
4330 }
4331
4269 TEST(RunWord32PairShl) { 4332 TEST(RunWord32PairShl) {
4270 BufferedRawMachineAssemblerTester<int32_t> m( 4333 BufferedRawMachineAssemblerTester<int32_t> m(
4271 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); 4334 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
4272 4335
4273 uint32_t high; 4336 uint32_t high;
4274 uint32_t low; 4337 uint32_t low;
4275 4338
4276 Node* PairAdd = 4339 Node* PairAdd =
4277 m.Word32PairShl(m.Parameter(0), m.Parameter(1), m.Parameter(2)); 4340 m.Word32PairShl(m.Parameter(0), m.Parameter(1), m.Parameter(2));
4278 4341
4279 m.StoreToPointer(&low, MachineRepresentation::kWord32, 4342 m.StoreToPointer(&low, MachineRepresentation::kWord32,
4280 m.Projection(0, PairAdd)); 4343 m.Projection(0, PairAdd));
4281 m.StoreToPointer(&high, MachineRepresentation::kWord32, 4344 m.StoreToPointer(&high, MachineRepresentation::kWord32,
4282 m.Projection(1, PairAdd)); 4345 m.Projection(1, PairAdd));
4283 m.Return(m.Int32Constant(74)); 4346 m.Return(m.Int32Constant(74));
4284 4347
4285 FOR_INT64_INPUTS(i) { 4348 FOR_UINT64_INPUTS(i) {
4286 for (uint32_t j = 0; j < 64; j++) { 4349 for (uint32_t j = 0; j < 64; j++) {
4287 m.Call(static_cast<uint32_t>(*i & 0xffffffff), 4350 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4288 static_cast<uint32_t>(*i >> 32), j); 4351 static_cast<uint32_t>(*i >> 32), j);
4289 CHECK_EQ(*i << j, ToInt64(low, high)); 4352 CHECK_EQ(*i << j, ToInt64(low, high));
4290 } 4353 }
4291 } 4354 }
4292 } 4355 }
4293 4356
4294 void TestWord32PairShlWithSharedInput(int a, int b) { 4357 void TestWord32PairShlWithSharedInput(int a, int b) {
4295 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(), 4358 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after
6254 r.Goto(&merge); 6317 r.Goto(&merge);
6255 r.Bind(&merge); 6318 r.Bind(&merge);
6256 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); 6319 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb);
6257 r.Return(phi); 6320 r.Return(phi);
6258 CHECK_EQ(1, r.Call(1)); 6321 CHECK_EQ(1, r.Call(1));
6259 } 6322 }
6260 6323
6261 } // namespace compiler 6324 } // namespace compiler
6262 } // namespace internal 6325 } // namespace internal
6263 } // namespace v8 6326 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x87/instruction-selector-x87.cc ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698