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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <functional> | 9 #include <functional> |
10 #include <limits> | 10 #include <limits> |
(...skipping 5517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5528 m.Call(uint64_t(0x8000008000000000))); | 5528 m.Call(uint64_t(0x8000008000000000))); |
5529 CHECK_EQ(bit_cast<double>(uint64_t(0x43e0000010000000)), | 5529 CHECK_EQ(bit_cast<double>(uint64_t(0x43e0000010000000)), |
5530 m.Call(uint64_t(0x8000008000000001))); | 5530 m.Call(uint64_t(0x8000008000000001))); |
5531 CHECK_EQ(bit_cast<double>(uint64_t(0x43e0000000000000)), | 5531 CHECK_EQ(bit_cast<double>(uint64_t(0x43e0000000000000)), |
5532 m.Call(uint64_t(0x8000000000000400))); | 5532 m.Call(uint64_t(0x8000000000000400))); |
5533 CHECK_EQ(bit_cast<double>(uint64_t(0x43e0000000000001)), | 5533 CHECK_EQ(bit_cast<double>(uint64_t(0x43e0000000000001)), |
5534 m.Call(uint64_t(0x8000000000000401))); | 5534 m.Call(uint64_t(0x8000000000000401))); |
5535 } | 5535 } |
5536 | 5536 |
5537 | 5537 |
| 5538 TEST(RunRoundUint64ToFloat32) { |
| 5539 struct { |
| 5540 uint64_t input; |
| 5541 uint32_t expected; |
| 5542 } values[] = {{0x0, 0x0}, |
| 5543 {0x1, 0x3f800000}, |
| 5544 {0xffffffff, 0x4f800000}, |
| 5545 {0x1b09788b, 0x4dd84bc4}, |
| 5546 {0x4c5fce8, 0x4c98bf9d}, |
| 5547 {0xcc0de5bf, 0x4f4c0de6}, |
| 5548 {0x2, 0x40000000}, |
| 5549 {0x3, 0x40400000}, |
| 5550 {0x4, 0x40800000}, |
| 5551 {0x5, 0x40a00000}, |
| 5552 {0x8, 0x41000000}, |
| 5553 {0x9, 0x41100000}, |
| 5554 {0xffffffffffffffff, 0x5f800000}, |
| 5555 {0xfffffffffffffffe, 0x5f800000}, |
| 5556 {0xfffffffffffffffd, 0x5f800000}, |
| 5557 {0x0, 0x0}, |
| 5558 {0x100000000, 0x4f800000}, |
| 5559 {0xffffffff00000000, 0x5f800000}, |
| 5560 {0x1b09788b00000000, 0x5dd84bc4}, |
| 5561 {0x4c5fce800000000, 0x5c98bf9d}, |
| 5562 {0xcc0de5bf00000000, 0x5f4c0de6}, |
| 5563 {0x200000000, 0x50000000}, |
| 5564 {0x300000000, 0x50400000}, |
| 5565 {0x400000000, 0x50800000}, |
| 5566 {0x500000000, 0x50a00000}, |
| 5567 {0x800000000, 0x51000000}, |
| 5568 {0x900000000, 0x51100000}, |
| 5569 {0x273a798e187937a3, 0x5e1ce9e6}, |
| 5570 {0xece3af835495a16b, 0x5f6ce3b0}, |
| 5571 {0xb668ecc11223344, 0x5d3668ed}, |
| 5572 {0x9e, 0x431e0000}, |
| 5573 {0x43, 0x42860000}, |
| 5574 {0xaf73, 0x472f7300}, |
| 5575 {0x116b, 0x458b5800}, |
| 5576 {0x658ecc, 0x4acb1d98}, |
| 5577 {0x2b3b4c, 0x4a2ced30}, |
| 5578 {0x88776655, 0x4f087766}, |
| 5579 {0x70000000, 0x4ee00000}, |
| 5580 {0x7200000, 0x4ce40000}, |
| 5581 {0x7fffffff, 0x4f000000}, |
| 5582 {0x56123761, 0x4eac246f}, |
| 5583 {0x7fffff00, 0x4efffffe}, |
| 5584 {0x761c4761eeeeeeee, 0x5eec388f}, |
| 5585 {0x80000000eeeeeeee, 0x5f000000}, |
| 5586 {0x88888888dddddddd, 0x5f088889}, |
| 5587 {0xa0000000dddddddd, 0x5f200000}, |
| 5588 {0xddddddddaaaaaaaa, 0x5f5dddde}, |
| 5589 {0xe0000000aaaaaaaa, 0x5f600000}, |
| 5590 {0xeeeeeeeeeeeeeeee, 0x5f6eeeef}, |
| 5591 {0xfffffffdeeeeeeee, 0x5f800000}, |
| 5592 {0xf0000000dddddddd, 0x5f700000}, |
| 5593 {0x7fffffdddddddd, 0x5b000000}, |
| 5594 {0x3fffffaaaaaaaa, 0x5a7fffff}, |
| 5595 {0x1fffffaaaaaaaa, 0x59fffffd}, |
| 5596 {0xfffff, 0x497ffff0}, |
| 5597 {0x7ffff, 0x48ffffe0}, |
| 5598 {0x3ffff, 0x487fffc0}, |
| 5599 {0x1ffff, 0x47ffff80}, |
| 5600 {0xffff, 0x477fff00}, |
| 5601 {0x7fff, 0x46fffe00}, |
| 5602 {0x3fff, 0x467ffc00}, |
| 5603 {0x1fff, 0x45fff800}, |
| 5604 {0xfff, 0x457ff000}, |
| 5605 {0x7ff, 0x44ffe000}, |
| 5606 {0x3ff, 0x447fc000}, |
| 5607 {0x1ff, 0x43ff8000}, |
| 5608 {0x3fffffffffff, 0x56800000}, |
| 5609 {0x1fffffffffff, 0x56000000}, |
| 5610 {0xfffffffffff, 0x55800000}, |
| 5611 {0x7ffffffffff, 0x55000000}, |
| 5612 {0x3ffffffffff, 0x54800000}, |
| 5613 {0x1ffffffffff, 0x54000000}, |
| 5614 {0x8000008000000000, 0x5f000000}, |
| 5615 {0x8000008000000001, 0x5f000001}, |
| 5616 {0x8000000000000400, 0x5f000000}, |
| 5617 {0x8000000000000401, 0x5f000000}}; |
| 5618 |
| 5619 BufferedRawMachineAssemblerTester<float> m(kMachUint64); |
| 5620 m.Return(m.RoundUint64ToFloat32(m.Parameter(0))); |
| 5621 |
| 5622 for (int i = 0; i < arraysize(values); i++) { |
| 5623 CHECK_EQ(bit_cast<float>(values[i].expected), m.Call(values[i].input)); |
| 5624 } |
| 5625 } |
| 5626 |
| 5627 |
5538 #endif | 5628 #endif |
5539 | 5629 |
5540 | 5630 |
5541 TEST(RunBitcastFloat32ToInt32) { | 5631 TEST(RunBitcastFloat32ToInt32) { |
5542 float input = 32.25; | 5632 float input = 32.25; |
5543 RawMachineAssemblerTester<int32_t> m; | 5633 RawMachineAssemblerTester<int32_t> m; |
5544 m.Return(m.BitcastFloat32ToInt32(m.LoadFromPointer(&input, kMachFloat32))); | 5634 m.Return(m.BitcastFloat32ToInt32(m.LoadFromPointer(&input, kMachFloat32))); |
5545 FOR_FLOAT32_INPUTS(i) { | 5635 FOR_FLOAT32_INPUTS(i) { |
5546 input = *i; | 5636 input = *i; |
5547 int32_t expected = bit_cast<int32_t>(input); | 5637 int32_t expected = bit_cast<int32_t>(input); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5613 Node* call = r.AddNode(r.common()->Call(desc), phi); | 5703 Node* call = r.AddNode(r.common()->Call(desc), phi); |
5614 r.Return(call); | 5704 r.Return(call); |
5615 | 5705 |
5616 CHECK_EQ(33, r.Call(1)); | 5706 CHECK_EQ(33, r.Call(1)); |
5617 CHECK_EQ(44, r.Call(0)); | 5707 CHECK_EQ(44, r.Call(0)); |
5618 } | 5708 } |
5619 | 5709 |
5620 } // namespace compiler | 5710 } // namespace compiler |
5621 } // namespace internal | 5711 } // namespace internal |
5622 } // namespace v8 | 5712 } // namespace v8 |
OLD | NEW |