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 4246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4257 } | 4257 } |
4258 | 4258 |
4259 TEST(RunInt32PairAddWithSharedInput) { | 4259 TEST(RunInt32PairAddWithSharedInput) { |
4260 TestInt32PairAddWithSharedInput(0, 0, 0, 0); | 4260 TestInt32PairAddWithSharedInput(0, 0, 0, 0); |
4261 TestInt32PairAddWithSharedInput(1, 0, 0, 0); | 4261 TestInt32PairAddWithSharedInput(1, 0, 0, 0); |
4262 TestInt32PairAddWithSharedInput(0, 1, 0, 0); | 4262 TestInt32PairAddWithSharedInput(0, 1, 0, 0); |
4263 TestInt32PairAddWithSharedInput(0, 0, 1, 0); | 4263 TestInt32PairAddWithSharedInput(0, 0, 1, 0); |
4264 TestInt32PairAddWithSharedInput(0, 0, 0, 1); | 4264 TestInt32PairAddWithSharedInput(0, 0, 0, 1); |
4265 TestInt32PairAddWithSharedInput(1, 1, 0, 0); | 4265 TestInt32PairAddWithSharedInput(1, 1, 0, 0); |
4266 } | 4266 } |
| 4267 |
| 4268 TEST(RunWord32PairShl) { |
| 4269 BufferedRawMachineAssemblerTester<int32_t> m( |
| 4270 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); |
| 4271 |
| 4272 uint32_t high; |
| 4273 uint32_t low; |
| 4274 |
| 4275 Node* PairAdd = |
| 4276 m.Word32PairShl(m.Parameter(0), m.Parameter(1), m.Parameter(2)); |
| 4277 |
| 4278 m.StoreToPointer(&low, MachineRepresentation::kWord32, |
| 4279 m.Projection(0, PairAdd)); |
| 4280 m.StoreToPointer(&high, MachineRepresentation::kWord32, |
| 4281 m.Projection(1, PairAdd)); |
| 4282 m.Return(m.Int32Constant(74)); |
| 4283 |
| 4284 FOR_INT64_INPUTS(i) { |
| 4285 for (uint32_t j = 0; j < 64; j++) { |
| 4286 m.Call(static_cast<uint32_t>(*i & 0xffffffff), |
| 4287 static_cast<uint32_t>(*i >> 32), j); |
| 4288 CHECK_EQ(*i << j, ToInt64(low, high)); |
| 4289 } |
| 4290 } |
| 4291 } |
| 4292 |
| 4293 void TestWord32PairShlWithSharedInput(int a, int b) { |
| 4294 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(), |
| 4295 MachineType::Uint32()); |
| 4296 |
| 4297 uint32_t high; |
| 4298 uint32_t low; |
| 4299 |
| 4300 Node* PairAdd = |
| 4301 m.Word32PairShl(m.Parameter(a), m.Parameter(b), m.Parameter(1)); |
| 4302 |
| 4303 m.StoreToPointer(&low, MachineRepresentation::kWord32, |
| 4304 m.Projection(0, PairAdd)); |
| 4305 m.StoreToPointer(&high, MachineRepresentation::kWord32, |
| 4306 m.Projection(1, PairAdd)); |
| 4307 m.Return(m.Int32Constant(74)); |
| 4308 |
| 4309 FOR_UINT32_INPUTS(i) { |
| 4310 for (uint32_t j = 0; j < 64; j++) { |
| 4311 m.Call(*i, j); |
| 4312 uint32_t inputs[] = {*i, j}; |
| 4313 CHECK_EQ(ToInt64(inputs[a], inputs[b]) << j, ToInt64(low, high)); |
| 4314 } |
| 4315 } |
| 4316 } |
| 4317 |
| 4318 TEST(RunWord32PairShlWithSharedInput) { |
| 4319 TestWord32PairShlWithSharedInput(0, 0); |
| 4320 TestWord32PairShlWithSharedInput(0, 1); |
| 4321 TestWord32PairShlWithSharedInput(1, 0); |
| 4322 TestWord32PairShlWithSharedInput(1, 1); |
| 4323 } |
| 4324 |
4267 #endif | 4325 #endif |
4268 | 4326 |
4269 TEST(RunDeadChangeFloat64ToInt32) { | 4327 TEST(RunDeadChangeFloat64ToInt32) { |
4270 RawMachineAssemblerTester<int32_t> m; | 4328 RawMachineAssemblerTester<int32_t> m; |
4271 const int magic = 0x88abcda4; | 4329 const int magic = 0x88abcda4; |
4272 m.ChangeFloat64ToInt32(m.Float64Constant(999.78)); | 4330 m.ChangeFloat64ToInt32(m.Float64Constant(999.78)); |
4273 m.Return(m.Int32Constant(magic)); | 4331 m.Return(m.Int32Constant(magic)); |
4274 CHECK_EQ(magic, m.Call()); | 4332 CHECK_EQ(magic, m.Call()); |
4275 } | 4333 } |
4276 | 4334 |
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6195 r.Goto(&merge); | 6253 r.Goto(&merge); |
6196 r.Bind(&merge); | 6254 r.Bind(&merge); |
6197 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); | 6255 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); |
6198 r.Return(phi); | 6256 r.Return(phi); |
6199 CHECK_EQ(1, r.Call(1)); | 6257 CHECK_EQ(1, r.Call(1)); |
6200 } | 6258 } |
6201 | 6259 |
6202 } // namespace compiler | 6260 } // namespace compiler |
6203 } // namespace internal | 6261 } // namespace internal |
6204 } // namespace v8 | 6262 } // namespace v8 |
OLD | NEW |