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(ARMv8vrintX) { | |
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 __ sub(fp, ip, Operand(4)); | |
Rodolph Perfetta (ARM)
2014/10/28 19:41:41
This is not necessary, you should be able to only
sigurds
2014/10/29 11:47:15
Done.
| |
1708 | |
1709 __ mov(r4, Operand(r0)); | |
1710 | |
1711 // Test vrint | |
Rodolph Perfetta (ARM)
2014/10/28 19:41:41
nit: vrinta
sigurds
2014/10/29 11:47:15
Done.
| |
1712 __ vldr(d6, r4, OFFSET_OF(T, input)); | |
1713 __ vrinta(d5, d6); | |
1714 __ vstr(d5, r4, OFFSET_OF(T, ar)); | |
1715 | |
1716 // Test vrintn | |
1717 __ vldr(d6, r4, OFFSET_OF(T, input)); | |
1718 __ vrintn(d5, d6); | |
1719 __ vstr(d5, r4, OFFSET_OF(T, nr)); | |
1720 | |
1721 // Test vrintp | |
1722 __ vldr(d6, r4, OFFSET_OF(T, input)); | |
1723 __ vrintp(d5, d6); | |
1724 __ vstr(d5, r4, OFFSET_OF(T, pr)); | |
1725 | |
1726 // Test vrintm | |
1727 __ vldr(d6, r4, OFFSET_OF(T, input)); | |
1728 __ vrintm(d5, d6); | |
1729 __ vstr(d5, r4, OFFSET_OF(T, mr)); | |
1730 | |
1731 // Test vrintz | |
1732 __ vldr(d6, r4, OFFSET_OF(T, input)); | |
1733 __ vrintz(d5, d6); | |
1734 __ vstr(d5, r4, OFFSET_OF(T, zr)); | |
1735 | |
1736 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); | |
1737 | |
1738 CodeDesc desc; | |
1739 assm.GetCode(&desc); | |
1740 Handle<Code> code = isolate->factory()->NewCode( | |
1741 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
1742 #ifdef DEBUG | |
1743 OFStream os(stdout); | |
1744 code->Print(os); | |
1745 #endif | |
1746 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
1747 | |
1748 Object* dummy = nullptr; | |
1749 USE(dummy); | |
1750 | |
1751 #define CHECK_VRINT(input_val, ares, nres, mres, pres, zres) \ | |
1752 t.input = input_val; \ | |
1753 dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); \ | |
1754 CHECK_EQ(ares, t.ar); \ | |
1755 CHECK_EQ(nres, t.nr); \ | |
1756 CHECK_EQ(mres, t.mr); \ | |
1757 CHECK_EQ(pres, t.pr); \ | |
1758 CHECK_EQ(zres, t.zr); | |
1759 | |
1760 CHECK_VRINT(-0.5, -1.0, -0.0, -1.0, -0.0, -0.0) | |
1761 CHECK_VRINT(-0.6, -1.0, -1.0, -1.0, -0.0, -0.0) | |
1762 CHECK_VRINT(-1.1, -1.0, -1.0, -2.0, -1.0, -1.0) | |
1763 CHECK_VRINT(0.5, 1.0, 0.0, 0.0, 1.0, 0.0) | |
1764 CHECK_VRINT(0.6, 1.0, 1.0, 0.0, 1.0, 0.0) | |
1765 CHECK_VRINT(1.1, 1.0, 1.0, 1.0, 2.0, 1.0) | |
1766 double inf = std::numeric_limits<double>::infinity(); | |
1767 CHECK_VRINT(inf, inf, inf, inf, inf, inf) | |
1768 CHECK_VRINT(-inf, -inf, -inf, -inf, -inf, -inf) | |
1769 CHECK_VRINT(-0.0, -0.0, -0.0, -0.0, -0.0, -0.0) | |
1770 double nan = std::numeric_limits<double>::quiet_NaN(); | |
1771 CHECK_VRINT(nan, nan, nan, nan, nan, nan) | |
1772 | |
1773 #undef CHECK_VRINT | |
1774 } | |
1775 } | |
1679 #undef __ | 1776 #undef __ |
OLD | NEW |