8#ifndef V8_BASE_NUMERICS_SAFE_MATH_CLANG_GCC_IMPL_H_
9#define V8_BASE_NUMERICS_SAFE_MATH_CLANG_GCC_IMPL_H_
20#if !defined(__native_client__) && (defined(__ARMEL__) || defined(__arch64__))
22#define BASE_HAS_ASSEMBLER_SAFE_MATH (1)
24#define BASE_HAS_ASSEMBLER_SAFE_MATH (0)
32#if !BASE_HAS_ASSEMBLER_SAFE_MATH
33template <
typename T,
typename U>
37 static constexpr bool Do(T, U,
V*) {
39 return CheckOnFailure::template HandleFailure<bool>();
43template <
typename T,
typename U>
47 static constexpr V Do(T, U) {
49 return CheckOnFailure::template HandleFailure<V>();
53template <
typename T,
typename U>
57 static constexpr V Do(T, U) {
59 return CheckOnFailure::template HandleFailure<V>();
63template <
typename T,
typename U>
67 static constexpr V Do(T, U) {
69 return CheckOnFailure::template HandleFailure<V>();
73#undef BASE_HAS_ASSEMBLER_SAFE_MATH
75template <
typename T,
typename U>
76struct CheckedAddFastOp {
80 return !__builtin_add_overflow(
x,
y,
result);
84template <
typename T,
typename U>
85struct CheckedSubFastOp {
89 return !__builtin_sub_overflow(
x,
y,
result);
93template <
typename T,
typename U>
94struct CheckedMulFastOp {
101 (kIsTypeInRangeForNumericType<intptr_t, T> &&
102 kIsTypeInRangeForNumericType<intptr_t, U>) ||
103 (kIsTypeInRangeForNumericType<uintptr_t, T> &&
104 kIsTypeInRangeForNumericType<uintptr_t, U>);
108 template <
typename V>
112 : !__builtin_mul_overflow(
x,
y,
result);
116template <
typename T,
typename U>
117struct ClampedAddFastOp {
119 template <
typename V>
125template <
typename T,
typename U>
126struct ClampedSubFastOp {
128 template <
typename V>
134template <
typename T,
typename U>
135struct ClampedMulFastOp {
137 template <
typename V>
144struct ClampedNegFastOp {
150 return !__builtin_sub_overflow(
T(0), value, &
result)
152 : std::numeric_limits<T>::max();
ZoneVector< RpoNumber > & result
static const bool is_supported
__attribute__((always_inline)) static const expr bool Do(T x
static constexpr bool Do(T, U, V *)
static constexpr bool Do(T, U, V *)
static constexpr bool is_supported
static constexpr bool Do(T x, U y, V *result)
__attribute__((always_inline)) static const expr bool Do(T x
static const bool is_supported
static constexpr bool Do(T, U, V *)
static const bool is_supported
static constexpr bool Do(T, U, V *)
__attribute__((always_inline)) static const expr bool Do(T x
static constexpr V Do(T, U)
static constexpr bool is_supported
static constexpr V Do(T, U)
__attribute__((always_inline)) static V Do(T x
static const bool is_supported
static constexpr V Do(T, U)
static constexpr bool is_supported
static constexpr V Do(T, U)
static const bool is_supported
__attribute__((always_inline)) static V Do(T x
__attribute__((always_inline)) static T Do(T value)
static const bool is_supported
static constexpr bool is_supported
static constexpr V Do(T, U)
static constexpr V Do(T, U)
__attribute__((always_inline)) static V Do(T x
static const bool is_supported