| 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_PPC | 9 #if V8_TARGET_ARCH_PPC |
| 10 | 10 |
| (...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 break; | 2018 break; |
| 2019 } | 2019 } |
| 2020 case SUBFCX: { | 2020 case SUBFCX: { |
| 2021 int rt = instr->RTValue(); | 2021 int rt = instr->RTValue(); |
| 2022 int ra = instr->RAValue(); | 2022 int ra = instr->RAValue(); |
| 2023 int rb = instr->RBValue(); | 2023 int rb = instr->RBValue(); |
| 2024 // int oe = instr->Bit(10); | 2024 // int oe = instr->Bit(10); |
| 2025 uintptr_t ra_val = get_register(ra); | 2025 uintptr_t ra_val = get_register(ra); |
| 2026 uintptr_t rb_val = get_register(rb); | 2026 uintptr_t rb_val = get_register(rb); |
| 2027 uintptr_t alu_out = ~ra_val + rb_val + 1; | 2027 uintptr_t alu_out = ~ra_val + rb_val + 1; |
| 2028 // Set carry |
| 2029 if (ra_val <= rb_val) { |
| 2030 special_reg_xer_ = (special_reg_xer_ & ~0xF0000000) | 0x20000000; |
| 2031 } else { |
| 2032 special_reg_xer_ &= ~0xF0000000; |
| 2033 } |
| 2028 set_register(rt, alu_out); | 2034 set_register(rt, alu_out); |
| 2029 // If the sign of rb and alu_out don't match, carry = 0 | |
| 2030 if ((alu_out ^ rb_val) & 0x80000000) { | |
| 2031 special_reg_xer_ &= ~0xF0000000; | |
| 2032 } else { | |
| 2033 special_reg_xer_ = (special_reg_xer_ & ~0xF0000000) | 0x20000000; | |
| 2034 } | |
| 2035 if (instr->Bit(0)) { // RC bit set | 2035 if (instr->Bit(0)) { // RC bit set |
| 2036 SetCR0(alu_out); | 2036 SetCR0(alu_out); |
| 2037 } | 2037 } |
| 2038 // todo - handle OE bit | 2038 // todo - handle OE bit |
| 2039 break; | 2039 break; |
| 2040 } | 2040 } |
| 2041 case SUBFEX: { |
| 2042 int rt = instr->RTValue(); |
| 2043 int ra = instr->RAValue(); |
| 2044 int rb = instr->RBValue(); |
| 2045 // int oe = instr->Bit(10); |
| 2046 uintptr_t ra_val = get_register(ra); |
| 2047 uintptr_t rb_val = get_register(rb); |
| 2048 uintptr_t alu_out = ~ra_val + rb_val; |
| 2049 if (special_reg_xer_ & 0x20000000) { |
| 2050 alu_out += 1; |
| 2051 } |
| 2052 set_register(rt, alu_out); |
| 2053 if (instr->Bit(0)) { // RC bit set |
| 2054 SetCR0(static_cast<intptr_t>(alu_out)); |
| 2055 } |
| 2056 // todo - handle OE bit |
| 2057 break; |
| 2058 } |
| 2041 case ADDCX: { | 2059 case ADDCX: { |
| 2042 int rt = instr->RTValue(); | 2060 int rt = instr->RTValue(); |
| 2043 int ra = instr->RAValue(); | 2061 int ra = instr->RAValue(); |
| 2044 int rb = instr->RBValue(); | 2062 int rb = instr->RBValue(); |
| 2045 // int oe = instr->Bit(10); | 2063 // int oe = instr->Bit(10); |
| 2046 uintptr_t ra_val = get_register(ra); | 2064 uintptr_t ra_val = get_register(ra); |
| 2047 uintptr_t rb_val = get_register(rb); | 2065 uintptr_t rb_val = get_register(rb); |
| 2048 uintptr_t alu_out = ra_val + rb_val; | 2066 uintptr_t alu_out = ra_val + rb_val; |
| 2049 // Set carry | 2067 // Set carry |
| 2050 if (~ra_val < rb_val) { | 2068 if (~ra_val < rb_val) { |
| (...skipping 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4111 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); | 4129 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); |
| 4112 uintptr_t address = *stack_slot; | 4130 uintptr_t address = *stack_slot; |
| 4113 set_register(sp, current_sp + sizeof(uintptr_t)); | 4131 set_register(sp, current_sp + sizeof(uintptr_t)); |
| 4114 return address; | 4132 return address; |
| 4115 } | 4133 } |
| 4116 } // namespace internal | 4134 } // namespace internal |
| 4117 } // namespace v8 | 4135 } // namespace v8 |
| 4118 | 4136 |
| 4119 #endif // USE_SIMULATOR | 4137 #endif // USE_SIMULATOR |
| 4120 #endif // V8_TARGET_ARCH_PPC | 4138 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |