OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdarg.h> | 5 #include <stdarg.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #if V8_TARGET_ARCH_S390 | 9 #if V8_TARGET_ARCH_S390 |
10 | 10 |
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 registers_[3] = 0x50Bad4U; | 1786 registers_[3] = 0x50Bad4U; |
1787 registers_[12] = 0x50Bad4U; | 1787 registers_[12] = 0x50Bad4U; |
1788 #endif | 1788 #endif |
1789 } | 1789 } |
1790 | 1790 |
1791 uint32_t Simulator::ReadWU(intptr_t addr, Instruction* instr) { | 1791 uint32_t Simulator::ReadWU(intptr_t addr, Instruction* instr) { |
1792 uint32_t* ptr = reinterpret_cast<uint32_t*>(addr); | 1792 uint32_t* ptr = reinterpret_cast<uint32_t*>(addr); |
1793 return *ptr; | 1793 return *ptr; |
1794 } | 1794 } |
1795 | 1795 |
| 1796 int64_t Simulator::ReadW64(intptr_t addr, Instruction* instr) { |
| 1797 int64_t* ptr = reinterpret_cast<int64_t*>(addr); |
| 1798 return *ptr; |
| 1799 } |
| 1800 |
1796 int32_t Simulator::ReadW(intptr_t addr, Instruction* instr) { | 1801 int32_t Simulator::ReadW(intptr_t addr, Instruction* instr) { |
1797 int32_t* ptr = reinterpret_cast<int32_t*>(addr); | 1802 int32_t* ptr = reinterpret_cast<int32_t*>(addr); |
1798 return *ptr; | 1803 return *ptr; |
1799 } | 1804 } |
1800 | 1805 |
1801 void Simulator::WriteW(intptr_t addr, uint32_t value, Instruction* instr) { | 1806 void Simulator::WriteW(intptr_t addr, uint32_t value, Instruction* instr) { |
1802 uint32_t* ptr = reinterpret_cast<uint32_t*>(addr); | 1807 uint32_t* ptr = reinterpret_cast<uint32_t*>(addr); |
1803 *ptr = value; | 1808 *ptr = value; |
1804 return; | 1809 return; |
1805 } | 1810 } |
(...skipping 3745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5551 break; | 5556 break; |
5552 } | 5557 } |
5553 default: | 5558 default: |
5554 UNREACHABLE(); | 5559 UNREACHABLE(); |
5555 return false; | 5560 return false; |
5556 } | 5561 } |
5557 return true; | 5562 return true; |
5558 } | 5563 } |
5559 | 5564 |
5560 int16_t Simulator::ByteReverse(int16_t hword) { | 5565 int16_t Simulator::ByteReverse(int16_t hword) { |
| 5566 #if defined(__GNUC__) |
| 5567 return __builtin_bswap16(hword); |
| 5568 #else |
5561 return (hword << 8) | ((hword >> 8) & 0x00ff); | 5569 return (hword << 8) | ((hword >> 8) & 0x00ff); |
| 5570 #endif |
5562 } | 5571 } |
5563 | 5572 |
5564 int32_t Simulator::ByteReverse(int32_t word) { | 5573 int32_t Simulator::ByteReverse(int32_t word) { |
| 5574 #if defined(__GNUC__) |
| 5575 return __builtin_bswap32(word); |
| 5576 #else |
5565 int32_t result = word << 24; | 5577 int32_t result = word << 24; |
5566 result |= (word << 8) & 0x00ff0000; | 5578 result |= (word << 8) & 0x00ff0000; |
5567 result |= (word >> 8) & 0x0000ff00; | 5579 result |= (word >> 8) & 0x0000ff00; |
5568 result |= (word >> 24) & 0x00000ff; | 5580 result |= (word >> 24) & 0x00000ff; |
5569 return result; | 5581 return result; |
| 5582 #endif |
| 5583 } |
| 5584 |
| 5585 int64_t Simulator::ByteReverse(int64_t dword) { |
| 5586 #if defined(__GNUC__) |
| 5587 return __builtin_bswap64(dword); |
| 5588 #else |
| 5589 #error unsupport __builtin_bswap64 |
| 5590 #endif |
5570 } | 5591 } |
5571 | 5592 |
5572 int Simulator::DecodeInstructionOriginal(Instruction* instr) { | 5593 int Simulator::DecodeInstructionOriginal(Instruction* instr) { |
5573 int instrLength = instr->InstructionLength(); | 5594 int instrLength = instr->InstructionLength(); |
5574 bool processed = true; | 5595 bool processed = true; |
5575 if (instrLength == 2) | 5596 if (instrLength == 2) |
5576 processed = DecodeTwoByte(instr); | 5597 processed = DecodeTwoByte(instr); |
5577 else if (instrLength == 4) | 5598 else if (instrLength == 4) |
5578 processed = DecodeFourByte(instr); | 5599 processed = DecodeFourByte(instr); |
5579 else if (instrLength == 6) | 5600 else if (instrLength == 6) |
(...skipping 4395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9975 return 0; | 9996 return 0; |
9976 } | 9997 } |
9977 | 9998 |
9978 EVALUATE(KMAC) { | 9999 EVALUATE(KMAC) { |
9979 UNIMPLEMENTED(); | 10000 UNIMPLEMENTED(); |
9980 USE(instr); | 10001 USE(instr); |
9981 return 0; | 10002 return 0; |
9982 } | 10003 } |
9983 | 10004 |
9984 EVALUATE(LRVR) { | 10005 EVALUATE(LRVR) { |
9985 UNIMPLEMENTED(); | 10006 DCHECK_OPCODE(LRVR); |
9986 USE(instr); | 10007 DECODE_RRE_INSTRUCTION(r1, r2); |
9987 return 0; | 10008 uint32_t r2_val = get_low_register<uint32_t>(r2); |
| 10009 uint32_t r1_val = 0; |
| 10010 #if defined(__GNUC__) |
| 10011 r1_val = __builtin_bswap32(r2_val); |
| 10012 #else |
| 10013 #error unsupport __builtin_bswap32 |
| 10014 #endif |
| 10015 |
| 10016 set_low_register(r1, r1_val); |
| 10017 return length; |
9988 } | 10018 } |
9989 | 10019 |
9990 EVALUATE(CGR) { | 10020 EVALUATE(CGR) { |
9991 DCHECK_OPCODE(CGR); | 10021 DCHECK_OPCODE(CGR); |
9992 DECODE_RRE_INSTRUCTION(r1, r2); | 10022 DECODE_RRE_INSTRUCTION(r1, r2); |
9993 // Compare (64) | 10023 // Compare (64) |
9994 int64_t r1_val = get_register(r1); | 10024 int64_t r1_val = get_register(r1); |
9995 int64_t r2_val = get_register(r2); | 10025 int64_t r2_val = get_register(r2); |
9996 SetS390ConditionCode<int64_t>(r1_val, r2_val); | 10026 SetS390ConditionCode<int64_t>(r1_val, r2_val); |
9997 return length; | 10027 return length; |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10776 USE(instr); | 10806 USE(instr); |
10777 return 0; | 10807 return 0; |
10778 } | 10808 } |
10779 | 10809 |
10780 EVALUATE(CVBG) { | 10810 EVALUATE(CVBG) { |
10781 UNIMPLEMENTED(); | 10811 UNIMPLEMENTED(); |
10782 USE(instr); | 10812 USE(instr); |
10783 return 0; | 10813 return 0; |
10784 } | 10814 } |
10785 | 10815 |
10786 EVALUATE(LRVG) { | |
10787 UNIMPLEMENTED(); | |
10788 USE(instr); | |
10789 return 0; | |
10790 } | |
10791 | |
10792 EVALUATE(LT) { | 10816 EVALUATE(LT) { |
10793 DCHECK_OPCODE(LT); | 10817 DCHECK_OPCODE(LT); |
10794 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 10818 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
10795 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 10819 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
10796 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 10820 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
10797 intptr_t addr = x2_val + b2_val + d2; | 10821 intptr_t addr = x2_val + b2_val + d2; |
10798 int32_t value = ReadW(addr, instr); | 10822 int32_t value = ReadW(addr, instr); |
10799 set_low_register(r1, value); | 10823 set_low_register(r1, value); |
10800 SetS390ConditionCode<int32_t>(value, 0); | 10824 SetS390ConditionCode<int32_t>(value, 0); |
10801 return length; | 10825 return length; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10878 USE(instr); | 10902 USE(instr); |
10879 return 0; | 10903 return 0; |
10880 } | 10904 } |
10881 | 10905 |
10882 EVALUATE(DSGF) { | 10906 EVALUATE(DSGF) { |
10883 UNIMPLEMENTED(); | 10907 UNIMPLEMENTED(); |
10884 USE(instr); | 10908 USE(instr); |
10885 return 0; | 10909 return 0; |
10886 } | 10910 } |
10887 | 10911 |
| 10912 EVALUATE(LRVG) { |
| 10913 DCHECK_OPCODE(LRVG); |
| 10914 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 10915 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 10916 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 10917 intptr_t mem_addr = b2_val + x2_val + d2; |
| 10918 int64_t mem_val = ReadW64(mem_addr, instr); |
| 10919 #if defined(__GNUC__) |
| 10920 set_register(r1, __builtin_bswap64(mem_val)); |
| 10921 #else |
| 10922 #error unsupport __builtin_bswap64 |
| 10923 #endif |
| 10924 return length; |
| 10925 } |
| 10926 |
10888 EVALUATE(LRV) { | 10927 EVALUATE(LRV) { |
10889 DCHECK_OPCODE(LRV); | 10928 DCHECK_OPCODE(LRV); |
10890 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 10929 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
10891 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 10930 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
10892 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 10931 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
10893 intptr_t mem_addr = b2_val + x2_val + d2; | 10932 intptr_t mem_addr = b2_val + x2_val + d2; |
10894 int32_t mem_val = ReadW(mem_addr, instr); | 10933 int32_t mem_val = ReadW(mem_addr, instr); |
10895 set_low_register(r1, ByteReverse(mem_val)); | 10934 set_low_register(r1, ByteReverse(mem_val)); |
10896 return length; | 10935 return length; |
10897 } | 10936 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10945 USE(instr); | 10984 USE(instr); |
10946 return 0; | 10985 return 0; |
10947 } | 10986 } |
10948 | 10987 |
10949 EVALUATE(CVDG) { | 10988 EVALUATE(CVDG) { |
10950 UNIMPLEMENTED(); | 10989 UNIMPLEMENTED(); |
10951 USE(instr); | 10990 USE(instr); |
10952 return 0; | 10991 return 0; |
10953 } | 10992 } |
10954 | 10993 |
10955 EVALUATE(STRVG) { | |
10956 UNIMPLEMENTED(); | |
10957 USE(instr); | |
10958 return 0; | |
10959 } | |
10960 | |
10961 EVALUATE(CGF) { | 10994 EVALUATE(CGF) { |
10962 UNIMPLEMENTED(); | 10995 UNIMPLEMENTED(); |
10963 USE(instr); | 10996 USE(instr); |
10964 return 0; | 10997 return 0; |
10965 } | 10998 } |
10966 | 10999 |
10967 EVALUATE(CLGF) { | 11000 EVALUATE(CLGF) { |
10968 UNIMPLEMENTED(); | 11001 UNIMPLEMENTED(); |
10969 USE(instr); | 11002 USE(instr); |
10970 return 0; | 11003 return 0; |
(...skipping 21 matching lines...) Expand all Loading... |
10992 DCHECK_OPCODE(STRV); | 11025 DCHECK_OPCODE(STRV); |
10993 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 11026 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
10994 int32_t r1_val = get_low_register<int32_t>(r1); | 11027 int32_t r1_val = get_low_register<int32_t>(r1); |
10995 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 11028 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
10996 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 11029 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
10997 intptr_t mem_addr = b2_val + x2_val + d2; | 11030 intptr_t mem_addr = b2_val + x2_val + d2; |
10998 WriteW(mem_addr, ByteReverse(r1_val), instr); | 11031 WriteW(mem_addr, ByteReverse(r1_val), instr); |
10999 return length; | 11032 return length; |
11000 } | 11033 } |
11001 | 11034 |
| 11035 EVALUATE(STRVG) { |
| 11036 DCHECK_OPCODE(STRVG); |
| 11037 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 11038 int64_t r1_val = get_register(r1); |
| 11039 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 11040 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 11041 intptr_t mem_addr = b2_val + x2_val + d2; |
| 11042 WriteDW(mem_addr, ByteReverse(r1_val)); |
| 11043 return length; |
| 11044 } |
| 11045 |
11002 EVALUATE(STRVH) { | 11046 EVALUATE(STRVH) { |
11003 DCHECK_OPCODE(STRVH); | 11047 DCHECK_OPCODE(STRVH); |
11004 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 11048 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
11005 int32_t r1_val = get_low_register<int32_t>(r1); | 11049 int32_t r1_val = get_low_register<int32_t>(r1); |
11006 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 11050 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
11007 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 11051 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
11008 intptr_t mem_addr = b2_val + x2_val + d2; | 11052 intptr_t mem_addr = b2_val + x2_val + d2; |
11009 int16_t result = static_cast<int16_t>(r1_val >> 16); | 11053 int16_t result = static_cast<int16_t>(r1_val >> 16); |
11010 WriteH(mem_addr, ByteReverse(result), instr); | 11054 WriteH(mem_addr, ByteReverse(result), instr); |
11011 return length; | 11055 return length; |
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12565 return 0; | 12609 return 0; |
12566 } | 12610 } |
12567 | 12611 |
12568 #undef EVALUATE | 12612 #undef EVALUATE |
12569 | 12613 |
12570 } // namespace internal | 12614 } // namespace internal |
12571 } // namespace v8 | 12615 } // namespace v8 |
12572 | 12616 |
12573 #endif // USE_SIMULATOR | 12617 #endif // USE_SIMULATOR |
12574 #endif // V8_TARGET_ARCH_S390 | 12618 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |