| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 | 1277 |
| 1278 // Set the oVerflow flag. | 1278 // Set the oVerflow flag. |
| 1279 void Simulator::SetVFlag(bool val) { | 1279 void Simulator::SetVFlag(bool val) { |
| 1280 v_flag_ = val; | 1280 v_flag_ = val; |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 | 1283 |
| 1284 // Calculate C flag value for additions. | 1284 // Calculate C flag value for additions. |
| 1285 bool Simulator::CarryFrom(int32_t left, int32_t right) { | 1285 bool Simulator::CarryFrom(int32_t left, int32_t right, int32_t carry) { |
| 1286 uint32_t uleft = static_cast<uint32_t>(left); | 1286 uint32_t uleft = static_cast<uint32_t>(left); |
| 1287 uint32_t uright = static_cast<uint32_t>(right); | 1287 uint32_t uright = static_cast<uint32_t>(right); |
| 1288 uint32_t urest = 0xffffffffU - uleft; | 1288 uint32_t urest = 0xffffffffU - uleft; |
| 1289 | 1289 |
| 1290 return (uright > urest); | 1290 return (uright > urest) || |
| 1291 (carry && (((uright + 1) > urest) || (uright > (urest - 1)))); |
| 1291 } | 1292 } |
| 1292 | 1293 |
| 1293 | 1294 |
| 1294 // Calculate C flag value for subtractions. | 1295 // Calculate C flag value for subtractions. |
| 1295 bool Simulator::BorrowFrom(int32_t left, int32_t right) { | 1296 bool Simulator::BorrowFrom(int32_t left, int32_t right) { |
| 1296 uint32_t uleft = static_cast<uint32_t>(left); | 1297 uint32_t uleft = static_cast<uint32_t>(left); |
| 1297 uint32_t uright = static_cast<uint32_t>(right); | 1298 uint32_t uright = static_cast<uint32_t>(right); |
| 1298 | 1299 |
| 1299 return (uright > uleft); | 1300 return (uright > uleft); |
| 1300 } | 1301 } |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2202 set_register(rd, alu_out); | 2203 set_register(rd, alu_out); |
| 2203 if (instr->HasS()) { | 2204 if (instr->HasS()) { |
| 2204 SetNZFlags(alu_out); | 2205 SetNZFlags(alu_out); |
| 2205 SetCFlag(CarryFrom(rn_val, shifter_operand)); | 2206 SetCFlag(CarryFrom(rn_val, shifter_operand)); |
| 2206 SetVFlag(OverflowFrom(alu_out, rn_val, shifter_operand, true)); | 2207 SetVFlag(OverflowFrom(alu_out, rn_val, shifter_operand, true)); |
| 2207 } | 2208 } |
| 2208 break; | 2209 break; |
| 2209 } | 2210 } |
| 2210 | 2211 |
| 2211 case ADC: { | 2212 case ADC: { |
| 2212 Format(instr, "adc'cond's 'rd, 'rn, 'shift_rm"); | 2213 // Format(instr, "adc'cond's 'rd, 'rn, 'shift_rm"); |
| 2213 Format(instr, "adc'cond's 'rd, 'rn, 'imm"); | 2214 // Format(instr, "adc'cond's 'rd, 'rn, 'imm"); |
| 2215 alu_out = rn_val + shifter_operand + GetCarry(); |
| 2216 set_register(rd, alu_out); |
| 2217 if (instr->HasS()) { |
| 2218 SetNZFlags(alu_out); |
| 2219 SetCFlag(CarryFrom(rn_val, shifter_operand, GetCarry())); |
| 2220 SetVFlag(OverflowFrom(alu_out, rn_val, shifter_operand, true)); |
| 2221 } |
| 2214 break; | 2222 break; |
| 2215 } | 2223 } |
| 2216 | 2224 |
| 2217 case SBC: { | 2225 case SBC: { |
| 2218 Format(instr, "sbc'cond's 'rd, 'rn, 'shift_rm"); | 2226 Format(instr, "sbc'cond's 'rd, 'rn, 'shift_rm"); |
| 2219 Format(instr, "sbc'cond's 'rd, 'rn, 'imm"); | 2227 Format(instr, "sbc'cond's 'rd, 'rn, 'imm"); |
| 2220 break; | 2228 break; |
| 2221 } | 2229 } |
| 2222 | 2230 |
| 2223 case RSC: { | 2231 case RSC: { |
| (...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3297 uintptr_t address = *stack_slot; | 3305 uintptr_t address = *stack_slot; |
| 3298 set_register(sp, current_sp + sizeof(uintptr_t)); | 3306 set_register(sp, current_sp + sizeof(uintptr_t)); |
| 3299 return address; | 3307 return address; |
| 3300 } | 3308 } |
| 3301 | 3309 |
| 3302 } } // namespace v8::internal | 3310 } } // namespace v8::internal |
| 3303 | 3311 |
| 3304 #endif // USE_SIMULATOR | 3312 #endif // USE_SIMULATOR |
| 3305 | 3313 |
| 3306 #endif // V8_TARGET_ARCH_ARM | 3314 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |