OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 CodeDesc desc; | 1669 CodeDesc desc; |
1670 assm.GetCode(&desc); | 1670 assm.GetCode(&desc); |
1671 Handle<Code> code = isolate->factory()->NewCode( | 1671 Handle<Code> code = isolate->factory()->NewCode( |
1672 desc, Code::ComputeFlags(Code::STUB), code_object); | 1672 desc, Code::ComputeFlags(Code::STUB), code_object); |
1673 F1 f = FUNCTION_CAST<F1>(code->entry()); | 1673 F1 f = FUNCTION_CAST<F1>(code->entry()); |
1674 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 21, 0, 0, 0, 0)); | 1674 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 21, 0, 0, 0, 0)); |
1675 ::printf("f() = %d\n", res); | 1675 ::printf("f() = %d\n", res); |
1676 CHECK_EQ(42, res); | 1676 CHECK_EQ(42, res); |
1677 } | 1677 } |
1678 | 1678 |
| 1679 |
| 1680 TEST(ARMv8_vrintX) { |
| 1681 // Test the vrintX floating point instructions. |
| 1682 CcTest::InitializeVM(); |
| 1683 Isolate* isolate = CcTest::i_isolate(); |
| 1684 HandleScope scope(isolate); |
| 1685 |
| 1686 typedef struct { |
| 1687 double input; |
| 1688 double ar; |
| 1689 double nr; |
| 1690 double mr; |
| 1691 double pr; |
| 1692 double zr; |
| 1693 } T; |
| 1694 T t; |
| 1695 |
| 1696 // Create a function that accepts &t, and loads, manipulates, and stores |
| 1697 // the doubles and floats. |
| 1698 Assembler assm(isolate, NULL, 0); |
| 1699 Label L, C; |
| 1700 |
| 1701 |
| 1702 if (CpuFeatures::IsSupported(ARMv8)) { |
| 1703 CpuFeatureScope scope(&assm, ARMv8); |
| 1704 |
| 1705 __ mov(ip, Operand(sp)); |
| 1706 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
| 1707 |
| 1708 __ mov(r4, Operand(r0)); |
| 1709 |
| 1710 // Test vrinta |
| 1711 __ vldr(d6, r4, OFFSET_OF(T, input)); |
| 1712 __ vrinta(d5, d6); |
| 1713 __ vstr(d5, r4, OFFSET_OF(T, ar)); |
| 1714 |
| 1715 // Test vrintn |
| 1716 __ vldr(d6, r4, OFFSET_OF(T, input)); |
| 1717 __ vrintn(d5, d6); |
| 1718 __ vstr(d5, r4, OFFSET_OF(T, nr)); |
| 1719 |
| 1720 // Test vrintp |
| 1721 __ vldr(d6, r4, OFFSET_OF(T, input)); |
| 1722 __ vrintp(d5, d6); |
| 1723 __ vstr(d5, r4, OFFSET_OF(T, pr)); |
| 1724 |
| 1725 // Test vrintm |
| 1726 __ vldr(d6, r4, OFFSET_OF(T, input)); |
| 1727 __ vrintm(d5, d6); |
| 1728 __ vstr(d5, r4, OFFSET_OF(T, mr)); |
| 1729 |
| 1730 // Test vrintz |
| 1731 __ vldr(d6, r4, OFFSET_OF(T, input)); |
| 1732 __ vrintz(d5, d6); |
| 1733 __ vstr(d5, r4, OFFSET_OF(T, zr)); |
| 1734 |
| 1735 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); |
| 1736 |
| 1737 CodeDesc desc; |
| 1738 assm.GetCode(&desc); |
| 1739 Handle<Code> code = isolate->factory()->NewCode( |
| 1740 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 1741 #ifdef DEBUG |
| 1742 OFStream os(stdout); |
| 1743 code->Print(os); |
| 1744 #endif |
| 1745 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 1746 |
| 1747 Object* dummy = nullptr; |
| 1748 USE(dummy); |
| 1749 |
| 1750 #define CHECK_VRINT(input_val, ares, nres, mres, pres, zres) \ |
| 1751 t.input = input_val; \ |
| 1752 dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); \ |
| 1753 CHECK_EQ(ares, t.ar); \ |
| 1754 CHECK_EQ(nres, t.nr); \ |
| 1755 CHECK_EQ(mres, t.mr); \ |
| 1756 CHECK_EQ(pres, t.pr); \ |
| 1757 CHECK_EQ(zres, t.zr); |
| 1758 |
| 1759 CHECK_VRINT(-0.5, -1.0, -0.0, -1.0, -0.0, -0.0) |
| 1760 CHECK_VRINT(-0.6, -1.0, -1.0, -1.0, -0.0, -0.0) |
| 1761 CHECK_VRINT(-1.1, -1.0, -1.0, -2.0, -1.0, -1.0) |
| 1762 CHECK_VRINT(0.5, 1.0, 0.0, 0.0, 1.0, 0.0) |
| 1763 CHECK_VRINT(0.6, 1.0, 1.0, 0.0, 1.0, 0.0) |
| 1764 CHECK_VRINT(1.1, 1.0, 1.0, 1.0, 2.0, 1.0) |
| 1765 double inf = std::numeric_limits<double>::infinity(); |
| 1766 CHECK_VRINT(inf, inf, inf, inf, inf, inf) |
| 1767 CHECK_VRINT(-inf, -inf, -inf, -inf, -inf, -inf) |
| 1768 CHECK_VRINT(-0.0, -0.0, -0.0, -0.0, -0.0, -0.0) |
| 1769 double nan = std::numeric_limits<double>::quiet_NaN(); |
| 1770 CHECK_VRINT(nan, nan, nan, nan, nan, nan) |
| 1771 |
| 1772 #undef CHECK_VRINT |
| 1773 } |
| 1774 } |
1679 #undef __ | 1775 #undef __ |
OLD | NEW |