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 #ifndef V8_BASE_BITS_H_ | 5 #ifndef V8_BASE_BITS_H_ |
6 #define V8_BASE_BITS_H_ | 6 #define V8_BASE_BITS_H_ |
7 | 7 |
8 #include "include/v8stdint.h" | 8 #include "include/v8stdint.h" |
9 #include "src/base/macros.h" | 9 #include "src/base/macros.h" |
10 #if V8_CC_MSVC | 10 #if V8_CC_MSVC |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 inline bool SignedSubOverflow32(int32_t lhs, int32_t rhs, int32_t* val) { | 180 inline bool SignedSubOverflow32(int32_t lhs, int32_t rhs, int32_t* val) { |
181 #if V8_HAS_BUILTIN_SSUB_OVERFLOW | 181 #if V8_HAS_BUILTIN_SSUB_OVERFLOW |
182 return __builtin_ssub_overflow(lhs, rhs, val); | 182 return __builtin_ssub_overflow(lhs, rhs, val); |
183 #else | 183 #else |
184 uint32_t res = static_cast<uint32_t>(lhs) - static_cast<uint32_t>(rhs); | 184 uint32_t res = static_cast<uint32_t>(lhs) - static_cast<uint32_t>(rhs); |
185 *val = bit_cast<int32_t>(res); | 185 *val = bit_cast<int32_t>(res); |
186 return ((res ^ lhs) & (res ^ ~rhs) & (1U << 31)) != 0; | 186 return ((res ^ lhs) & (res ^ ~rhs) & (1U << 31)) != 0; |
187 #endif | 187 #endif |
188 } | 188 } |
189 | 189 |
| 190 |
| 191 // SignedMulHigh32(lhs, rhs) multiplies two signed 32-bit values |lhs| and |
| 192 // |rhs|, extracts the most significant 32 bits of the result, and returns |
| 193 // those. |
| 194 int32_t SignedMulHigh32(int32_t lhs, int32_t rhs); |
| 195 |
| 196 |
| 197 // SignedMulHighAndAdd32(lhs, rhs, acc) multiplies two signed 32-bit values |
| 198 // |lhs| and |rhs|, extracts the most significant 32 bits of the result, and |
| 199 // adds the accumulate value |acc|. |
| 200 int32_t SignedMulHighAndAdd32(int32_t lhs, int32_t rhs, int32_t acc); |
| 201 |
| 202 |
| 203 // SignedMulHighAndAdd32(lhs, rhs, acc) multiplies two signed 32-bit values |
| 204 // |lhs| and |rhs|, extracts the most significant 32 bits of the result, and |
| 205 // subtracts it from the accumulate value |acc|. |
| 206 int32_t SignedMulHighAndSub32(int32_t lhs, int32_t rhs, int32_t acc); |
| 207 |
190 } // namespace bits | 208 } // namespace bits |
191 } // namespace base | 209 } // namespace base |
192 } // namespace v8 | 210 } // namespace v8 |
193 | 211 |
194 #endif // V8_BASE_BITS_H_ | 212 #endif // V8_BASE_BITS_H_ |
OLD | NEW |