OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #if V8_TARGET_ARCH_ARM | 9 #if V8_TARGET_ARCH_ARM |
10 | 10 |
(...skipping 4053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4064 } | 4064 } |
4065 | 4065 |
4066 | 4066 |
4067 void MacroAssembler::TruncatingDiv(Register result, | 4067 void MacroAssembler::TruncatingDiv(Register result, |
4068 Register dividend, | 4068 Register dividend, |
4069 int32_t divisor) { | 4069 int32_t divisor) { |
4070 DCHECK(!dividend.is(result)); | 4070 DCHECK(!dividend.is(result)); |
4071 DCHECK(!dividend.is(ip)); | 4071 DCHECK(!dividend.is(ip)); |
4072 DCHECK(!result.is(ip)); | 4072 DCHECK(!result.is(ip)); |
4073 base::MagicNumbersForDivision<uint32_t> mag = | 4073 base::MagicNumbersForDivision<uint32_t> mag = |
4074 base::SignedDivisionByConstant(static_cast<uint32_t>(divisor)); | 4074 base::SignedDivisionByConstant(bit_cast<uint32_t>(divisor)); |
4075 mov(ip, Operand(mag.multiplier)); | 4075 mov(ip, Operand(mag.multiplier)); |
4076 smull(ip, result, dividend, ip); | 4076 bool neg = (mag.multiplier & (1U << 31)) != 0; |
4077 bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0; | |
4078 if (divisor > 0 && neg) { | 4077 if (divisor > 0 && neg) { |
4079 add(result, result, Operand(dividend)); | 4078 smmla(result, dividend, ip, dividend); |
4080 } | 4079 } else { |
4081 if (divisor < 0 && !neg && mag.multiplier > 0) { | 4080 smmul(result, dividend, ip); |
4082 sub(result, result, Operand(dividend)); | 4081 if (divisor < 0 && !neg && mag.multiplier > 0) { |
| 4082 sub(result, result, Operand(dividend)); |
| 4083 } |
4083 } | 4084 } |
4084 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); | 4085 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); |
4085 add(result, result, Operand(dividend, LSR, 31)); | 4086 add(result, result, Operand(dividend, LSR, 31)); |
4086 } | 4087 } |
4087 | 4088 |
4088 | 4089 } // namespace internal |
4089 } } // namespace v8::internal | 4090 } // namespace v8 |
4090 | 4091 |
4091 #endif // V8_TARGET_ARCH_ARM | 4092 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |