1*9356374aSAndroid Build Coastguard Worker// 2*9356374aSAndroid Build Coastguard Worker// Copyright 2017 The Abseil Authors. 3*9356374aSAndroid Build Coastguard Worker// 4*9356374aSAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); 5*9356374aSAndroid Build Coastguard Worker// you may not use this file except in compliance with the License. 6*9356374aSAndroid Build Coastguard Worker// You may obtain a copy of the License at 7*9356374aSAndroid Build Coastguard Worker// 8*9356374aSAndroid Build Coastguard Worker// https://www.apache.org/licenses/LICENSE-2.0 9*9356374aSAndroid Build Coastguard Worker// 10*9356374aSAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 11*9356374aSAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, 12*9356374aSAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*9356374aSAndroid Build Coastguard Worker// See the License for the specific language governing permissions and 14*9356374aSAndroid Build Coastguard Worker// limitations under the License. 15*9356374aSAndroid Build Coastguard Worker 16*9356374aSAndroid Build Coastguard Worker// This file contains :int128 implementation details that depend on internal 17*9356374aSAndroid Build Coastguard Worker// representation when ABSL_HAVE_INTRINSIC_INT128 is defined. This file is 18*9356374aSAndroid Build Coastguard Worker// included by int128.h and relies on ABSL_INTERNAL_WCHAR_T being defined. 19*9356374aSAndroid Build Coastguard Worker 20*9356374aSAndroid Build Coastguard Workernamespace int128_internal { 21*9356374aSAndroid Build Coastguard Worker 22*9356374aSAndroid Build Coastguard Worker// Casts from unsigned to signed while preserving the underlying binary 23*9356374aSAndroid Build Coastguard Worker// representation. 24*9356374aSAndroid Build Coastguard Workerconstexpr __int128 BitCastToSigned(unsigned __int128 v) { 25*9356374aSAndroid Build Coastguard Worker // Casting an unsigned integer to a signed integer of the same 26*9356374aSAndroid Build Coastguard Worker // width is implementation defined behavior if the source value would not fit 27*9356374aSAndroid Build Coastguard Worker // in the destination type. We step around it with a roundtrip bitwise not 28*9356374aSAndroid Build Coastguard Worker // operation to make sure this function remains constexpr. Clang and GCC 29*9356374aSAndroid Build Coastguard Worker // optimize this to a no-op on x86-64. 30*9356374aSAndroid Build Coastguard Worker return v & (static_cast<unsigned __int128>(1) << 127) 31*9356374aSAndroid Build Coastguard Worker ? ~static_cast<__int128>(~v) 32*9356374aSAndroid Build Coastguard Worker : static_cast<__int128>(v); 33*9356374aSAndroid Build Coastguard Worker} 34*9356374aSAndroid Build Coastguard Worker 35*9356374aSAndroid Build Coastguard Worker} // namespace int128_internal 36*9356374aSAndroid Build Coastguard Worker 37*9356374aSAndroid Build Coastguard Workerinline int128& int128::operator=(__int128 v) { 38*9356374aSAndroid Build Coastguard Worker v_ = v; 39*9356374aSAndroid Build Coastguard Worker return *this; 40*9356374aSAndroid Build Coastguard Worker} 41*9356374aSAndroid Build Coastguard Worker 42*9356374aSAndroid Build Coastguard Workerconstexpr uint64_t Int128Low64(int128 v) { 43*9356374aSAndroid Build Coastguard Worker return static_cast<uint64_t>(v.v_ & ~uint64_t{0}); 44*9356374aSAndroid Build Coastguard Worker} 45*9356374aSAndroid Build Coastguard Worker 46*9356374aSAndroid Build Coastguard Workerconstexpr int64_t Int128High64(int128 v) { 47*9356374aSAndroid Build Coastguard Worker // Initially cast to unsigned to prevent a right shift on a negative value. 48*9356374aSAndroid Build Coastguard Worker return int128_internal::BitCastToSigned( 49*9356374aSAndroid Build Coastguard Worker static_cast<uint64_t>(static_cast<unsigned __int128>(v.v_) >> 64)); 50*9356374aSAndroid Build Coastguard Worker} 51*9356374aSAndroid Build Coastguard Worker 52*9356374aSAndroid Build Coastguard Workerconstexpr int128::int128(int64_t high, uint64_t low) 53*9356374aSAndroid Build Coastguard Worker // Initially cast to unsigned to prevent a left shift that overflows. 54*9356374aSAndroid Build Coastguard Worker : v_(int128_internal::BitCastToSigned(static_cast<unsigned __int128>(high) 55*9356374aSAndroid Build Coastguard Worker << 64) | 56*9356374aSAndroid Build Coastguard Worker low) {} 57*9356374aSAndroid Build Coastguard Worker 58*9356374aSAndroid Build Coastguard Worker 59*9356374aSAndroid Build Coastguard Workerconstexpr int128::int128(int v) : v_{v} {} 60*9356374aSAndroid Build Coastguard Worker 61*9356374aSAndroid Build Coastguard Workerconstexpr int128::int128(long v) : v_{v} {} // NOLINT(runtime/int) 62*9356374aSAndroid Build Coastguard Worker 63*9356374aSAndroid Build Coastguard Workerconstexpr int128::int128(long long v) : v_{v} {} // NOLINT(runtime/int) 64*9356374aSAndroid Build Coastguard Worker 65*9356374aSAndroid Build Coastguard Workerconstexpr int128::int128(__int128 v) : v_{v} {} 66*9356374aSAndroid Build Coastguard Worker 67*9356374aSAndroid Build Coastguard Workerconstexpr int128::int128(unsigned int v) : v_{v} {} 68*9356374aSAndroid Build Coastguard Worker 69*9356374aSAndroid Build Coastguard Workerconstexpr int128::int128(unsigned long v) : v_{v} {} // NOLINT(runtime/int) 70*9356374aSAndroid Build Coastguard Worker 71*9356374aSAndroid Build Coastguard Worker// NOLINTNEXTLINE(runtime/int) 72*9356374aSAndroid Build Coastguard Workerconstexpr int128::int128(unsigned long long v) : v_{v} {} 73*9356374aSAndroid Build Coastguard Worker 74*9356374aSAndroid Build Coastguard Workerconstexpr int128::int128(unsigned __int128 v) : v_{static_cast<__int128>(v)} {} 75*9356374aSAndroid Build Coastguard Worker 76*9356374aSAndroid Build Coastguard Workerinline int128::int128(float v) { 77*9356374aSAndroid Build Coastguard Worker v_ = static_cast<__int128>(v); 78*9356374aSAndroid Build Coastguard Worker} 79*9356374aSAndroid Build Coastguard Worker 80*9356374aSAndroid Build Coastguard Workerinline int128::int128(double v) { 81*9356374aSAndroid Build Coastguard Worker v_ = static_cast<__int128>(v); 82*9356374aSAndroid Build Coastguard Worker} 83*9356374aSAndroid Build Coastguard Worker 84*9356374aSAndroid Build Coastguard Workerinline int128::int128(long double v) { 85*9356374aSAndroid Build Coastguard Worker v_ = static_cast<__int128>(v); 86*9356374aSAndroid Build Coastguard Worker} 87*9356374aSAndroid Build Coastguard Worker 88*9356374aSAndroid Build Coastguard Workerconstexpr int128::int128(uint128 v) : v_{static_cast<__int128>(v)} {} 89*9356374aSAndroid Build Coastguard Worker 90*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator bool() const { return static_cast<bool>(v_); } 91*9356374aSAndroid Build Coastguard Worker 92*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator char() const { return static_cast<char>(v_); } 93*9356374aSAndroid Build Coastguard Worker 94*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator signed char() const { 95*9356374aSAndroid Build Coastguard Worker return static_cast<signed char>(v_); 96*9356374aSAndroid Build Coastguard Worker} 97*9356374aSAndroid Build Coastguard Worker 98*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator unsigned char() const { 99*9356374aSAndroid Build Coastguard Worker return static_cast<unsigned char>(v_); 100*9356374aSAndroid Build Coastguard Worker} 101*9356374aSAndroid Build Coastguard Worker 102*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator char16_t() const { 103*9356374aSAndroid Build Coastguard Worker return static_cast<char16_t>(v_); 104*9356374aSAndroid Build Coastguard Worker} 105*9356374aSAndroid Build Coastguard Worker 106*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator char32_t() const { 107*9356374aSAndroid Build Coastguard Worker return static_cast<char32_t>(v_); 108*9356374aSAndroid Build Coastguard Worker} 109*9356374aSAndroid Build Coastguard Worker 110*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator ABSL_INTERNAL_WCHAR_T() const { 111*9356374aSAndroid Build Coastguard Worker return static_cast<ABSL_INTERNAL_WCHAR_T>(v_); 112*9356374aSAndroid Build Coastguard Worker} 113*9356374aSAndroid Build Coastguard Worker 114*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator short() const { // NOLINT(runtime/int) 115*9356374aSAndroid Build Coastguard Worker return static_cast<short>(v_); // NOLINT(runtime/int) 116*9356374aSAndroid Build Coastguard Worker} 117*9356374aSAndroid Build Coastguard Worker 118*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator unsigned short() const { // NOLINT(runtime/int) 119*9356374aSAndroid Build Coastguard Worker return static_cast<unsigned short>(v_); // NOLINT(runtime/int) 120*9356374aSAndroid Build Coastguard Worker} 121*9356374aSAndroid Build Coastguard Worker 122*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator int() const { 123*9356374aSAndroid Build Coastguard Worker return static_cast<int>(v_); 124*9356374aSAndroid Build Coastguard Worker} 125*9356374aSAndroid Build Coastguard Worker 126*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator unsigned int() const { 127*9356374aSAndroid Build Coastguard Worker return static_cast<unsigned int>(v_); 128*9356374aSAndroid Build Coastguard Worker} 129*9356374aSAndroid Build Coastguard Worker 130*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator long() const { // NOLINT(runtime/int) 131*9356374aSAndroid Build Coastguard Worker return static_cast<long>(v_); // NOLINT(runtime/int) 132*9356374aSAndroid Build Coastguard Worker} 133*9356374aSAndroid Build Coastguard Worker 134*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator unsigned long() const { // NOLINT(runtime/int) 135*9356374aSAndroid Build Coastguard Worker return static_cast<unsigned long>(v_); // NOLINT(runtime/int) 136*9356374aSAndroid Build Coastguard Worker} 137*9356374aSAndroid Build Coastguard Worker 138*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator long long() const { // NOLINT(runtime/int) 139*9356374aSAndroid Build Coastguard Worker return static_cast<long long>(v_); // NOLINT(runtime/int) 140*9356374aSAndroid Build Coastguard Worker} 141*9356374aSAndroid Build Coastguard Worker 142*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator unsigned long long() const { // NOLINT(runtime/int) 143*9356374aSAndroid Build Coastguard Worker return static_cast<unsigned long long>(v_); // NOLINT(runtime/int) 144*9356374aSAndroid Build Coastguard Worker} 145*9356374aSAndroid Build Coastguard Worker 146*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator __int128() const { return v_; } 147*9356374aSAndroid Build Coastguard Worker 148*9356374aSAndroid Build Coastguard Workerconstexpr int128::operator unsigned __int128() const { 149*9356374aSAndroid Build Coastguard Worker return static_cast<unsigned __int128>(v_); 150*9356374aSAndroid Build Coastguard Worker} 151*9356374aSAndroid Build Coastguard Worker 152*9356374aSAndroid Build Coastguard Worker// Clang on PowerPC sometimes produces incorrect __int128 to floating point 153*9356374aSAndroid Build Coastguard Worker// conversions. In that case, we do the conversion with a similar implementation 154*9356374aSAndroid Build Coastguard Worker// to the conversion operators in int128_no_intrinsic.inc. 155*9356374aSAndroid Build Coastguard Worker#if defined(__clang__) && !defined(__ppc64__) 156*9356374aSAndroid Build Coastguard Workerinline int128::operator float() const { return static_cast<float>(v_); } 157*9356374aSAndroid Build Coastguard Worker 158*9356374aSAndroid Build Coastguard Workerinline int128::operator double() const { return static_cast<double>(v_); } 159*9356374aSAndroid Build Coastguard Worker 160*9356374aSAndroid Build Coastguard Workerinline int128::operator long double() const { 161*9356374aSAndroid Build Coastguard Worker return static_cast<long double>(v_); 162*9356374aSAndroid Build Coastguard Worker} 163*9356374aSAndroid Build Coastguard Worker 164*9356374aSAndroid Build Coastguard Worker#else // Clang on PowerPC 165*9356374aSAndroid Build Coastguard Worker 166*9356374aSAndroid Build Coastguard Workerinline int128::operator float() const { 167*9356374aSAndroid Build Coastguard Worker // We must convert the absolute value and then negate as needed, because 168*9356374aSAndroid Build Coastguard Worker // floating point types are typically sign-magnitude. Otherwise, the 169*9356374aSAndroid Build Coastguard Worker // difference between the high and low 64 bits when interpreted as two's 170*9356374aSAndroid Build Coastguard Worker // complement overwhelms the precision of the mantissa. 171*9356374aSAndroid Build Coastguard Worker // 172*9356374aSAndroid Build Coastguard Worker // Also check to make sure we don't negate Int128Min() 173*9356374aSAndroid Build Coastguard Worker return v_ < 0 && *this != Int128Min() 174*9356374aSAndroid Build Coastguard Worker ? -static_cast<float>(-*this) 175*9356374aSAndroid Build Coastguard Worker : static_cast<float>(Int128Low64(*this)) + 176*9356374aSAndroid Build Coastguard Worker std::ldexp(static_cast<float>(Int128High64(*this)), 64); 177*9356374aSAndroid Build Coastguard Worker} 178*9356374aSAndroid Build Coastguard Worker 179*9356374aSAndroid Build Coastguard Workerinline int128::operator double() const { 180*9356374aSAndroid Build Coastguard Worker // See comment in int128::operator float() above. 181*9356374aSAndroid Build Coastguard Worker return v_ < 0 && *this != Int128Min() 182*9356374aSAndroid Build Coastguard Worker ? -static_cast<double>(-*this) 183*9356374aSAndroid Build Coastguard Worker : static_cast<double>(Int128Low64(*this)) + 184*9356374aSAndroid Build Coastguard Worker std::ldexp(static_cast<double>(Int128High64(*this)), 64); 185*9356374aSAndroid Build Coastguard Worker} 186*9356374aSAndroid Build Coastguard Worker 187*9356374aSAndroid Build Coastguard Workerinline int128::operator long double() const { 188*9356374aSAndroid Build Coastguard Worker // See comment in int128::operator float() above. 189*9356374aSAndroid Build Coastguard Worker return v_ < 0 && *this != Int128Min() 190*9356374aSAndroid Build Coastguard Worker ? -static_cast<long double>(-*this) 191*9356374aSAndroid Build Coastguard Worker : static_cast<long double>(Int128Low64(*this)) + 192*9356374aSAndroid Build Coastguard Worker std::ldexp(static_cast<long double>(Int128High64(*this)), 193*9356374aSAndroid Build Coastguard Worker 64); 194*9356374aSAndroid Build Coastguard Worker} 195*9356374aSAndroid Build Coastguard Worker#endif // Clang on PowerPC 196*9356374aSAndroid Build Coastguard Worker 197*9356374aSAndroid Build Coastguard Worker// Comparison operators. 198*9356374aSAndroid Build Coastguard Worker 199*9356374aSAndroid Build Coastguard Workerconstexpr bool operator==(int128 lhs, int128 rhs) { 200*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) == static_cast<__int128>(rhs); 201*9356374aSAndroid Build Coastguard Worker} 202*9356374aSAndroid Build Coastguard Worker 203*9356374aSAndroid Build Coastguard Workerconstexpr bool operator!=(int128 lhs, int128 rhs) { 204*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) != static_cast<__int128>(rhs); 205*9356374aSAndroid Build Coastguard Worker} 206*9356374aSAndroid Build Coastguard Worker 207*9356374aSAndroid Build Coastguard Workerconstexpr bool operator<(int128 lhs, int128 rhs) { 208*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) < static_cast<__int128>(rhs); 209*9356374aSAndroid Build Coastguard Worker} 210*9356374aSAndroid Build Coastguard Worker 211*9356374aSAndroid Build Coastguard Workerconstexpr bool operator>(int128 lhs, int128 rhs) { 212*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) > static_cast<__int128>(rhs); 213*9356374aSAndroid Build Coastguard Worker} 214*9356374aSAndroid Build Coastguard Worker 215*9356374aSAndroid Build Coastguard Workerconstexpr bool operator<=(int128 lhs, int128 rhs) { 216*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) <= static_cast<__int128>(rhs); 217*9356374aSAndroid Build Coastguard Worker} 218*9356374aSAndroid Build Coastguard Worker 219*9356374aSAndroid Build Coastguard Workerconstexpr bool operator>=(int128 lhs, int128 rhs) { 220*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) >= static_cast<__int128>(rhs); 221*9356374aSAndroid Build Coastguard Worker} 222*9356374aSAndroid Build Coastguard Worker 223*9356374aSAndroid Build Coastguard Worker#ifdef __cpp_impl_three_way_comparison 224*9356374aSAndroid Build Coastguard Workerconstexpr absl::strong_ordering operator<=>(int128 lhs, int128 rhs) { 225*9356374aSAndroid Build Coastguard Worker if (auto lhs_128 = static_cast<__int128>(lhs), 226*9356374aSAndroid Build Coastguard Worker rhs_128 = static_cast<__int128>(rhs); 227*9356374aSAndroid Build Coastguard Worker lhs_128 < rhs_128) { 228*9356374aSAndroid Build Coastguard Worker return absl::strong_ordering::less; 229*9356374aSAndroid Build Coastguard Worker } else if (lhs_128 > rhs_128) { 230*9356374aSAndroid Build Coastguard Worker return absl::strong_ordering::greater; 231*9356374aSAndroid Build Coastguard Worker } else { 232*9356374aSAndroid Build Coastguard Worker return absl::strong_ordering::equal; 233*9356374aSAndroid Build Coastguard Worker } 234*9356374aSAndroid Build Coastguard Worker} 235*9356374aSAndroid Build Coastguard Worker#endif 236*9356374aSAndroid Build Coastguard Worker 237*9356374aSAndroid Build Coastguard Worker// Unary operators. 238*9356374aSAndroid Build Coastguard Worker 239*9356374aSAndroid Build Coastguard Workerconstexpr int128 operator-(int128 v) { return -static_cast<__int128>(v); } 240*9356374aSAndroid Build Coastguard Worker 241*9356374aSAndroid Build Coastguard Workerconstexpr bool operator!(int128 v) { return !static_cast<__int128>(v); } 242*9356374aSAndroid Build Coastguard Worker 243*9356374aSAndroid Build Coastguard Workerconstexpr int128 operator~(int128 val) { return ~static_cast<__int128>(val); } 244*9356374aSAndroid Build Coastguard Worker 245*9356374aSAndroid Build Coastguard Worker// Arithmetic operators. 246*9356374aSAndroid Build Coastguard Worker 247*9356374aSAndroid Build Coastguard Workerconstexpr int128 operator+(int128 lhs, int128 rhs) { 248*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) + static_cast<__int128>(rhs); 249*9356374aSAndroid Build Coastguard Worker} 250*9356374aSAndroid Build Coastguard Worker 251*9356374aSAndroid Build Coastguard Workerconstexpr int128 operator-(int128 lhs, int128 rhs) { 252*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) - static_cast<__int128>(rhs); 253*9356374aSAndroid Build Coastguard Worker} 254*9356374aSAndroid Build Coastguard Worker 255*9356374aSAndroid Build Coastguard Workerinline int128 operator*(int128 lhs, int128 rhs) { 256*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) * static_cast<__int128>(rhs); 257*9356374aSAndroid Build Coastguard Worker} 258*9356374aSAndroid Build Coastguard Worker 259*9356374aSAndroid Build Coastguard Workerinline int128 operator/(int128 lhs, int128 rhs) { 260*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) / static_cast<__int128>(rhs); 261*9356374aSAndroid Build Coastguard Worker} 262*9356374aSAndroid Build Coastguard Worker 263*9356374aSAndroid Build Coastguard Workerinline int128 operator%(int128 lhs, int128 rhs) { 264*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) % static_cast<__int128>(rhs); 265*9356374aSAndroid Build Coastguard Worker} 266*9356374aSAndroid Build Coastguard Worker 267*9356374aSAndroid Build Coastguard Workerinline int128 int128::operator++(int) { 268*9356374aSAndroid Build Coastguard Worker int128 tmp(*this); 269*9356374aSAndroid Build Coastguard Worker ++v_; 270*9356374aSAndroid Build Coastguard Worker return tmp; 271*9356374aSAndroid Build Coastguard Worker} 272*9356374aSAndroid Build Coastguard Worker 273*9356374aSAndroid Build Coastguard Workerinline int128 int128::operator--(int) { 274*9356374aSAndroid Build Coastguard Worker int128 tmp(*this); 275*9356374aSAndroid Build Coastguard Worker --v_; 276*9356374aSAndroid Build Coastguard Worker return tmp; 277*9356374aSAndroid Build Coastguard Worker} 278*9356374aSAndroid Build Coastguard Worker 279*9356374aSAndroid Build Coastguard Workerinline int128& int128::operator++() { 280*9356374aSAndroid Build Coastguard Worker ++v_; 281*9356374aSAndroid Build Coastguard Worker return *this; 282*9356374aSAndroid Build Coastguard Worker} 283*9356374aSAndroid Build Coastguard Worker 284*9356374aSAndroid Build Coastguard Workerinline int128& int128::operator--() { 285*9356374aSAndroid Build Coastguard Worker --v_; 286*9356374aSAndroid Build Coastguard Worker return *this; 287*9356374aSAndroid Build Coastguard Worker} 288*9356374aSAndroid Build Coastguard Worker 289*9356374aSAndroid Build Coastguard Workerconstexpr int128 operator|(int128 lhs, int128 rhs) { 290*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) | static_cast<__int128>(rhs); 291*9356374aSAndroid Build Coastguard Worker} 292*9356374aSAndroid Build Coastguard Worker 293*9356374aSAndroid Build Coastguard Workerconstexpr int128 operator&(int128 lhs, int128 rhs) { 294*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) & static_cast<__int128>(rhs); 295*9356374aSAndroid Build Coastguard Worker} 296*9356374aSAndroid Build Coastguard Worker 297*9356374aSAndroid Build Coastguard Workerconstexpr int128 operator^(int128 lhs, int128 rhs) { 298*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) ^ static_cast<__int128>(rhs); 299*9356374aSAndroid Build Coastguard Worker} 300*9356374aSAndroid Build Coastguard Worker 301*9356374aSAndroid Build Coastguard Workerconstexpr int128 operator<<(int128 lhs, int amount) { 302*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) << amount; 303*9356374aSAndroid Build Coastguard Worker} 304*9356374aSAndroid Build Coastguard Worker 305*9356374aSAndroid Build Coastguard Workerconstexpr int128 operator>>(int128 lhs, int amount) { 306*9356374aSAndroid Build Coastguard Worker return static_cast<__int128>(lhs) >> amount; 307*9356374aSAndroid Build Coastguard Worker} 308