Lines Matching refs:rhs

234 // SignedAddOverflow32(lhs,rhs,val) performs a signed summation of |lhs| and
235 // |rhs| and stores the result into the variable pointed to by |val| and
237 inline bool SignedAddOverflow32(int32_t lhs, int32_t rhs, int32_t* val) {
239 return __builtin_sadd_overflow(lhs, rhs, val);
241 uint32_t res = static_cast<uint32_t>(lhs) + static_cast<uint32_t>(rhs);
243 return ((res ^ lhs) & (res ^ rhs) & (1U << 31)) != 0;
248 // SignedSubOverflow32(lhs,rhs,val) performs a signed subtraction of |lhs| and
249 // |rhs| and stores the result into the variable pointed to by |val| and
251 inline bool SignedSubOverflow32(int32_t lhs, int32_t rhs, int32_t* val) {
253 return __builtin_ssub_overflow(lhs, rhs, val);
255 uint32_t res = static_cast<uint32_t>(lhs) - static_cast<uint32_t>(rhs);
257 return ((res ^ lhs) & (res ^ ~rhs) & (1U << 31)) != 0;
261 // SignedMulOverflow32(lhs,rhs,val) performs a signed multiplication of |lhs|
262 // and |rhs| and stores the result into the variable pointed to by |val| and
264 V8_BASE_EXPORT bool SignedMulOverflow32(int32_t lhs, int32_t rhs, int32_t* val);
266 // SignedAddOverflow64(lhs,rhs,val) performs a signed summation of |lhs| and
267 // |rhs| and stores the result into the variable pointed to by |val| and
269 inline bool SignedAddOverflow64(int64_t lhs, int64_t rhs, int64_t* val) {
270 uint64_t res = static_cast<uint64_t>(lhs) + static_cast<uint64_t>(rhs);
272 return ((res ^ lhs) & (res ^ rhs) & (1ULL << 63)) != 0;
276 // SignedSubOverflow64(lhs,rhs,val) performs a signed subtraction of |lhs| and
277 // |rhs| and stores the result into the variable pointed to by |val| and
279 inline bool SignedSubOverflow64(int64_t lhs, int64_t rhs, int64_t* val) {
280 uint64_t res = static_cast<uint64_t>(lhs) - static_cast<uint64_t>(rhs);
282 return ((res ^ lhs) & (res ^ ~rhs) & (1ULL << 63)) != 0;
285 // SignedMulHigh32(lhs, rhs) multiplies two signed 32-bit values |lhs| and
286 // |rhs|, extracts the most significant 32 bits of the result, and returns
288 V8_BASE_EXPORT int32_t SignedMulHigh32(int32_t lhs, int32_t rhs);
290 // SignedMulHighAndAdd32(lhs, rhs, acc) multiplies two signed 32-bit values
291 // |lhs| and |rhs|, extracts the most significant 32 bits of the result, and
293 V8_BASE_EXPORT int32_t SignedMulHighAndAdd32(int32_t lhs, int32_t rhs,
296 // SignedDiv32(lhs, rhs) divides |lhs| by |rhs| and returns the quotient
297 // truncated to int32. If |rhs| is zero, then zero is returned. If |lhs|
298 // is minint and |rhs| is -1, it returns minint.
299 V8_BASE_EXPORT int32_t SignedDiv32(int32_t lhs, int32_t rhs);
301 // SignedMod32(lhs, rhs) divides |lhs| by |rhs| and returns the remainder
302 // truncated to int32. If either |rhs| is zero or |lhs| is minint and |rhs|
304 V8_BASE_EXPORT int32_t SignedMod32(int32_t lhs, int32_t rhs);
306 // UnsignedAddOverflow32(lhs,rhs,val) performs an unsigned summation of |lhs|
307 // and |rhs| and stores the result into the variable pointed to by |val| and
309 inline bool UnsignedAddOverflow32(uint32_t lhs, uint32_t rhs, uint32_t* val) {
311 return __builtin_uadd_overflow(lhs, rhs, val);
313 *val = lhs + rhs;
314 return *val < (lhs | rhs);
319 // UnsignedDiv32(lhs, rhs) divides |lhs| by |rhs| and returns the quotient
320 // truncated to uint32. If |rhs| is zero, then zero is returned.
321 inline uint32_t UnsignedDiv32(uint32_t lhs, uint32_t rhs) {
322 return rhs ? lhs / rhs : 0u;
326 // UnsignedMod32(lhs, rhs) divides |lhs| by |rhs| and returns the remainder
327 // truncated to uint32. If |rhs| is zero, then zero is returned.
328 inline uint32_t UnsignedMod32(uint32_t lhs, uint32_t rhs) {
329 return rhs ? lhs % rhs : 0u;
334 inline int32_t WraparoundAdd32(int32_t lhs, int32_t rhs) {
336 static_cast<uint32_t>(rhs));
343 // SignedSaturatedAdd64(lhs, rhs) adds |lhs| and |rhs|,
345 V8_BASE_EXPORT int64_t SignedSaturatedAdd64(int64_t lhs, int64_t rhs);
347 // SignedSaturatedSub64(lhs, rhs) subtracts |lhs| by |rhs|,
349 V8_BASE_EXPORT int64_t SignedSaturatedSub64(int64_t lhs, int64_t rhs);