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 6595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6606 int32_t r2_val = get_low_register<int32_t>(r2); | 6606 int32_t r2_val = get_low_register<int32_t>(r2); |
6607 SetS390ConditionCode<int32_t>(r2_val, 0); | 6607 SetS390ConditionCode<int32_t>(r2_val, 0); |
6608 set_low_register(r1, r2_val); | 6608 set_low_register(r1, r2_val); |
6609 return length; | 6609 return length; |
6610 } | 6610 } |
6611 | 6611 |
6612 EVALUATE(LCR) { | 6612 EVALUATE(LCR) { |
6613 DCHECK_OPCODE(LCR); | 6613 DCHECK_OPCODE(LCR); |
6614 DECODE_RR_INSTRUCTION(r1, r2); | 6614 DECODE_RR_INSTRUCTION(r1, r2); |
6615 int32_t r2_val = get_low_register<int32_t>(r2); | 6615 int32_t r2_val = get_low_register<int32_t>(r2); |
6616 r2_val = ~r2_val; | 6616 int32_t result = 0; |
6617 r2_val = r2_val + 1; | 6617 bool isOF = false; |
6618 set_low_register(r1, r2_val); | 6618 isOF = __builtin_ssub_overflow(0, r2_val, &result); |
| 6619 set_low_register(r1, result); |
6619 SetS390ConditionCode<int32_t>(r2_val, 0); | 6620 SetS390ConditionCode<int32_t>(r2_val, 0); |
6620 // Checks for overflow where r2_val = -2147483648. | 6621 // Checks for overflow where r2_val = -2147483648. |
6621 // Cannot do int comparison due to GCC 4.8 bug on x86. | 6622 // Cannot do int comparison due to GCC 4.8 bug on x86. |
6622 // Detect INT_MIN alternatively, as it is the only value where both | 6623 // Detect INT_MIN alternatively, as it is the only value where both |
6623 // original and result are negative due to overflow. | 6624 // original and result are negative due to overflow. |
6624 if (r2_val == (static_cast<int32_t>(1) << 31)) { | 6625 if (isOF) { |
6625 SetS390OverflowCode(true); | 6626 SetS390OverflowCode(true); |
6626 } | 6627 } |
6627 return length; | 6628 return length; |
6628 } | 6629 } |
6629 | 6630 |
6630 EVALUATE(NR) { | 6631 EVALUATE(NR) { |
6631 DCHECK_OPCODE(NR); | 6632 DCHECK_OPCODE(NR); |
6632 DECODE_RR_INSTRUCTION(r1, r2); | 6633 DECODE_RR_INSTRUCTION(r1, r2); |
6633 int32_t r1_val = get_low_register<int32_t>(r1); | 6634 int32_t r1_val = get_low_register<int32_t>(r1); |
6634 int32_t r2_val = get_low_register<int32_t>(r2); | 6635 int32_t r2_val = get_low_register<int32_t>(r2); |
(...skipping 3330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9965 int64_t r2_val = get_register(r2); | 9966 int64_t r2_val = get_register(r2); |
9966 SetS390ConditionCode<int64_t>(r2_val, 0); | 9967 SetS390ConditionCode<int64_t>(r2_val, 0); |
9967 set_register(r1, get_register(r2)); | 9968 set_register(r1, get_register(r2)); |
9968 return length; | 9969 return length; |
9969 } | 9970 } |
9970 | 9971 |
9971 EVALUATE(LCGR) { | 9972 EVALUATE(LCGR) { |
9972 DCHECK_OPCODE(LCGR); | 9973 DCHECK_OPCODE(LCGR); |
9973 DECODE_RRE_INSTRUCTION(r1, r2); | 9974 DECODE_RRE_INSTRUCTION(r1, r2); |
9974 int64_t r2_val = get_register(r2); | 9975 int64_t r2_val = get_register(r2); |
9975 r2_val = ~r2_val; | 9976 int64_t result = 0; |
9976 r2_val = r2_val + 1; | 9977 bool isOF = false; |
9977 set_register(r1, r2_val); | 9978 #ifdef V8_TARGET_ARCH_S390X |
9978 SetS390ConditionCode<int64_t>(r2_val, 0); | 9979 isOF = __builtin_ssubl_overflow(0L, r2_val, &result); |
9979 // if the input is INT_MIN, loading its compliment would be overflowing | 9980 #else |
9980 if (r2_val == (static_cast<int64_t>(1) << 63)) { | 9981 isOF = __builtin_ssubll_overflow(0L, r2_val, &result); |
| 9982 #endif |
| 9983 set_register(r1, result); |
| 9984 SetS390ConditionCode<int64_t>(result, 0); |
| 9985 if (isOF) { |
9981 SetS390OverflowCode(true); | 9986 SetS390OverflowCode(true); |
9982 } | 9987 } |
9983 return length; | 9988 return length; |
9984 } | 9989 } |
9985 | 9990 |
9986 EVALUATE(SGR) { | 9991 EVALUATE(SGR) { |
9987 DCHECK_OPCODE(SGR); | 9992 DCHECK_OPCODE(SGR); |
9988 DECODE_RRE_INSTRUCTION(r1, r2); | 9993 DECODE_RRE_INSTRUCTION(r1, r2); |
9989 int64_t r1_val = get_register(r1); | 9994 int64_t r1_val = get_register(r1); |
9990 int64_t r2_val = get_register(r2); | 9995 int64_t r2_val = get_register(r2); |
(...skipping 2867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12858 return 0; | 12863 return 0; |
12859 } | 12864 } |
12860 | 12865 |
12861 #undef EVALUATE | 12866 #undef EVALUATE |
12862 | 12867 |
12863 } // namespace internal | 12868 } // namespace internal |
12864 } // namespace v8 | 12869 } // namespace v8 |
12865 | 12870 |
12866 #endif // USE_SIMULATOR | 12871 #endif // USE_SIMULATOR |
12867 #endif // V8_TARGET_ARCH_S390 | 12872 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |