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 7761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7772 | 7772 |
7773 EVALUATE(TMLH) { | 7773 EVALUATE(TMLH) { |
7774 UNIMPLEMENTED(); | 7774 UNIMPLEMENTED(); |
7775 USE(instr); | 7775 USE(instr); |
7776 return 0; | 7776 return 0; |
7777 } | 7777 } |
7778 | 7778 |
7779 EVALUATE(TMLL) { | 7779 EVALUATE(TMLL) { |
7780 DCHECK_OPCODE(TMLL); | 7780 DCHECK_OPCODE(TMLL); |
7781 DECODE_RI_A_INSTRUCTION(instr, r1, i2); | 7781 DECODE_RI_A_INSTRUCTION(instr, r1, i2); |
7782 int mask = i2 & 0x0000FFFF; | 7782 uint32_t mask = i2 & 0x0000FFFF; |
7783 if (mask == 0) { | |
7784 condition_reg_ = 0x0; | |
7785 return length; | |
7786 } | |
7787 uint32_t r1_val = get_low_register<uint32_t>(r1); | 7783 uint32_t r1_val = get_low_register<uint32_t>(r1); |
7788 r1_val = r1_val & 0x0000FFFF; // uses only the last 16bits | 7784 r1_val = r1_val & 0x0000FFFF; // uses only the last 16bits |
7789 | 7785 |
7790 // Test if all selected bits are Zero | 7786 // Test if all selected bits are zeros or mask is zero |
7791 bool allSelectedBitsAreZeros = true; | 7787 if (0 == (mask & r1_val)) { |
7792 for (int i = 0; i < 15; i++) { | |
7793 if (mask & (1 << i)) { | |
7794 if (r1_val & (1 << i)) { | |
7795 allSelectedBitsAreZeros = false; | |
7796 break; | |
7797 } | |
7798 } | |
7799 } | |
7800 if (allSelectedBitsAreZeros) { | |
7801 condition_reg_ = 0x8; | 7788 condition_reg_ = 0x8; |
7802 return length; // Done! | 7789 return length; // Done! |
7803 } | 7790 } |
7804 | 7791 |
| 7792 DCHECK(mask != 0); |
7805 // Test if all selected bits are one | 7793 // Test if all selected bits are one |
7806 bool allSelectedBitsAreOnes = true; | 7794 if (mask == (mask & r1_val)) { |
7807 for (int i = 0; i < 15; i++) { | |
7808 if (mask & (1 << i)) { | |
7809 if (!(r1_val & (1 << i))) { | |
7810 allSelectedBitsAreOnes = false; | |
7811 break; | |
7812 } | |
7813 } | |
7814 } | |
7815 if (allSelectedBitsAreOnes) { | |
7816 condition_reg_ = 0x1; | 7795 condition_reg_ = 0x1; |
7817 return length; // Done! | 7796 return length; // Done! |
7818 } | 7797 } |
7819 | 7798 |
7820 // Now we know selected bits mixed zeros and ones | 7799 // Now we know selected bits mixed zeros and ones |
7821 // Test if the leftmost bit is zero or one | 7800 // Test if the leftmost bit is zero or one |
7822 for (int i = 14; i >= 0; i--) { | 7801 #if defined(__GNUC__) |
| 7802 int leadingZeros = __builtin_clz(mask); |
| 7803 mask = 0x80000000u >> leadingZeros; |
| 7804 if (mask & r1_val) { |
| 7805 // leftmost bit is one |
| 7806 condition_reg_ = 0x4; |
| 7807 } else { |
| 7808 // leftmost bit is zero |
| 7809 condition_reg_ = 0x2; |
| 7810 } |
| 7811 return length; // Done! |
| 7812 #else |
| 7813 for (int i = 15; i >= 0; i--) { |
7823 if (mask & (1 << i)) { | 7814 if (mask & (1 << i)) { |
7824 if (r1_val & (1 << i)) { | 7815 if (r1_val & (1 << i)) { |
7825 // leftmost bit is one | 7816 // leftmost bit is one |
7826 condition_reg_ = 0x2; | 7817 condition_reg_ = 0x2; |
7827 } else { | 7818 } else { |
7828 // leftmost bit is zero | 7819 // leftmost bit is zero |
7829 condition_reg_ = 0x4; | 7820 condition_reg_ = 0x4; |
7830 } | 7821 } |
7831 return length; // Done! | 7822 return length; // Done! |
7832 } | 7823 } |
7833 } | 7824 } |
| 7825 #endif |
| 7826 UNREACHABLE(); |
7834 return length; | 7827 return length; |
7835 } | 7828 } |
7836 | 7829 |
7837 EVALUATE(TMHH) { | 7830 EVALUATE(TMHH) { |
7838 UNIMPLEMENTED(); | 7831 UNIMPLEMENTED(); |
7839 USE(instr); | 7832 USE(instr); |
7840 return 0; | 7833 return 0; |
7841 } | 7834 } |
7842 | 7835 |
7843 EVALUATE(TMHL) { | 7836 EVALUATE(TMHL) { |
(...skipping 4925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12769 return 0; | 12762 return 0; |
12770 } | 12763 } |
12771 | 12764 |
12772 #undef EVALUATE | 12765 #undef EVALUATE |
12773 | 12766 |
12774 } // namespace internal | 12767 } // namespace internal |
12775 } // namespace v8 | 12768 } // namespace v8 |
12776 | 12769 |
12777 #endif // USE_SIMULATOR | 12770 #endif // USE_SIMULATOR |
12778 #endif // V8_TARGET_ARCH_S390 | 12771 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |