OLD | NEW |
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 4310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4321 | 4321 |
4322 TEST(RunInt32PairSubWithSharedInput) { | 4322 TEST(RunInt32PairSubWithSharedInput) { |
4323 TestInt32PairSubWithSharedInput(0, 0, 0, 0); | 4323 TestInt32PairSubWithSharedInput(0, 0, 0, 0); |
4324 TestInt32PairSubWithSharedInput(1, 0, 0, 0); | 4324 TestInt32PairSubWithSharedInput(1, 0, 0, 0); |
4325 TestInt32PairSubWithSharedInput(0, 1, 0, 0); | 4325 TestInt32PairSubWithSharedInput(0, 1, 0, 0); |
4326 TestInt32PairSubWithSharedInput(0, 0, 1, 0); | 4326 TestInt32PairSubWithSharedInput(0, 0, 1, 0); |
4327 TestInt32PairSubWithSharedInput(0, 0, 0, 1); | 4327 TestInt32PairSubWithSharedInput(0, 0, 0, 1); |
4328 TestInt32PairSubWithSharedInput(1, 1, 0, 0); | 4328 TestInt32PairSubWithSharedInput(1, 1, 0, 0); |
4329 } | 4329 } |
4330 | 4330 |
| 4331 TEST(RunInt32PairMul) { |
| 4332 BufferedRawMachineAssemblerTester<int32_t> m( |
| 4333 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(), |
| 4334 MachineType::Uint32()); |
| 4335 |
| 4336 uint32_t high; |
| 4337 uint32_t low; |
| 4338 |
| 4339 Node* PairMul = m.Int32PairMul(m.Parameter(0), m.Parameter(1), m.Parameter(2), |
| 4340 m.Parameter(3)); |
| 4341 |
| 4342 m.StoreToPointer(&low, MachineRepresentation::kWord32, |
| 4343 m.Projection(0, PairMul)); |
| 4344 m.StoreToPointer(&high, MachineRepresentation::kWord32, |
| 4345 m.Projection(1, PairMul)); |
| 4346 m.Return(m.Int32Constant(74)); |
| 4347 |
| 4348 FOR_UINT64_INPUTS(i) { |
| 4349 FOR_UINT64_INPUTS(j) { |
| 4350 m.Call(static_cast<uint32_t>(*i & 0xffffffff), |
| 4351 static_cast<uint32_t>(*i >> 32), |
| 4352 static_cast<uint32_t>(*j & 0xffffffff), |
| 4353 static_cast<uint32_t>(*j >> 32)); |
| 4354 CHECK_EQ(*i * *j, ToInt64(low, high)); |
| 4355 } |
| 4356 } |
| 4357 } |
| 4358 |
| 4359 void TestInt32PairMulWithSharedInput(int a, int b, int c, int d) { |
| 4360 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(), |
| 4361 MachineType::Uint32()); |
| 4362 |
| 4363 uint32_t high; |
| 4364 uint32_t low; |
| 4365 |
| 4366 Node* PairMul = m.Int32PairMul(m.Parameter(a), m.Parameter(b), m.Parameter(c), |
| 4367 m.Parameter(d)); |
| 4368 |
| 4369 m.StoreToPointer(&low, MachineRepresentation::kWord32, |
| 4370 m.Projection(0, PairMul)); |
| 4371 m.StoreToPointer(&high, MachineRepresentation::kWord32, |
| 4372 m.Projection(1, PairMul)); |
| 4373 m.Return(m.Int32Constant(74)); |
| 4374 |
| 4375 FOR_UINT32_INPUTS(i) { |
| 4376 FOR_UINT32_INPUTS(j) { |
| 4377 m.Call(*i, *j); |
| 4378 uint32_t inputs[] = {*i, *j}; |
| 4379 CHECK_EQ(ToInt64(inputs[a], inputs[b]) * ToInt64(inputs[c], inputs[d]), |
| 4380 ToInt64(low, high)); |
| 4381 } |
| 4382 } |
| 4383 } |
| 4384 |
| 4385 TEST(RunInt32PairMulWithSharedInput) { |
| 4386 TestInt32PairMulWithSharedInput(0, 0, 0, 0); |
| 4387 TestInt32PairMulWithSharedInput(1, 0, 0, 0); |
| 4388 TestInt32PairMulWithSharedInput(0, 1, 0, 0); |
| 4389 TestInt32PairMulWithSharedInput(0, 0, 1, 0); |
| 4390 TestInt32PairMulWithSharedInput(0, 0, 0, 1); |
| 4391 TestInt32PairMulWithSharedInput(1, 1, 0, 0); |
| 4392 TestInt32PairMulWithSharedInput(0, 1, 1, 0); |
| 4393 } |
| 4394 |
4331 TEST(RunWord32PairShl) { | 4395 TEST(RunWord32PairShl) { |
4332 BufferedRawMachineAssemblerTester<int32_t> m( | 4396 BufferedRawMachineAssemblerTester<int32_t> m( |
4333 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); | 4397 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); |
4334 | 4398 |
4335 uint32_t high; | 4399 uint32_t high; |
4336 uint32_t low; | 4400 uint32_t low; |
4337 | 4401 |
4338 Node* PairAdd = | 4402 Node* PairAdd = |
4339 m.Word32PairShl(m.Parameter(0), m.Parameter(1), m.Parameter(2)); | 4403 m.Word32PairShl(m.Parameter(0), m.Parameter(1), m.Parameter(2)); |
4340 | 4404 |
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6316 r.Goto(&merge); | 6380 r.Goto(&merge); |
6317 r.Bind(&merge); | 6381 r.Bind(&merge); |
6318 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); | 6382 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); |
6319 r.Return(phi); | 6383 r.Return(phi); |
6320 CHECK_EQ(1, r.Call(1)); | 6384 CHECK_EQ(1, r.Call(1)); |
6321 } | 6385 } |
6322 | 6386 |
6323 } // namespace compiler | 6387 } // namespace compiler |
6324 } // namespace internal | 6388 } // namespace internal |
6325 } // namespace v8 | 6389 } // namespace v8 |
OLD | NEW |