From e402a1db65aa233a3f40efb89531bd41e45eceea Mon Sep 17 00:00:00 2001 From: mhbliao <47895780+mhbliao@users.noreply.github.com> Date: Thu, 11 Jul 2019 05:16:15 -0400 Subject: [PATCH] Add missing compound assignment operators. (#1216) [ROCm/clr commit: e701e337f971f2c25500ef552296ec155b4d9dce] --- .../include/hip/hcc_detail/hip_vector_types.h | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/projects/clr/hipamd/include/hip/hcc_detail/hip_vector_types.h b/projects/clr/hipamd/include/hip/hcc_detail/hip_vector_types.h index 953e4eb5f8..3407b8a752 100644 --- a/projects/clr/hipamd/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/clr/hipamd/include/hip/hcc_detail/hip_vector_types.h @@ -294,6 +294,7 @@ THE SOFTWARE. ++*this; return tmp; } + inline __host__ __device__ HIP_vector_type& operator--() noexcept { @@ -306,12 +307,23 @@ THE SOFTWARE. --*this; return tmp; } + inline __host__ __device__ HIP_vector_type& operator+=(const HIP_vector_type& x) noexcept { data += x.data; return *this; } + template< + typename U, + typename std::enable_if< + std::is_convertible{}>::type* = nullptr> + inline __host__ __device__ + HIP_vector_type& operator+=(U x) noexcept + { + return *this += HIP_vector_type{x}; + } + inline __host__ __device__ HIP_vector_type& operator-=(const HIP_vector_type& x) noexcept { @@ -327,18 +339,38 @@ THE SOFTWARE. { return *this -= HIP_vector_type{x}; } + inline __host__ __device__ HIP_vector_type& operator*=(const HIP_vector_type& x) noexcept { data *= x.data; return *this; } + template< + typename U, + typename std::enable_if< + std::is_convertible{}>::type* = nullptr> + inline __host__ __device__ + HIP_vector_type& operator*=(U x) noexcept + { + return *this *= HIP_vector_type{x}; + } + inline __host__ __device__ HIP_vector_type& operator/=(const HIP_vector_type& x) noexcept { data /= x.data; return *this; } + template< + typename U, + typename std::enable_if< + std::is_convertible{}>::type* = nullptr> + inline __host__ __device__ + HIP_vector_type& operator/=(U x) noexcept + { + return *this /= HIP_vector_type{x}; + } template< typename U = T, @@ -361,6 +393,7 @@ THE SOFTWARE. r.data = ~r.data; return r; } + template< typename U = T, typename std::enable_if{}>::type* = nullptr> @@ -370,6 +403,7 @@ THE SOFTWARE. data %= x.data; return *this; } + template< typename U = T, typename std::enable_if{}>::type* = nullptr> @@ -379,6 +413,7 @@ THE SOFTWARE. data ^= x.data; return *this; } + template< typename U = T, typename std::enable_if{}>::type* = nullptr> @@ -388,6 +423,7 @@ THE SOFTWARE. data |= x.data; return *this; } + template< typename U = T, typename std::enable_if{}>::type* = nullptr> @@ -397,6 +433,7 @@ THE SOFTWARE. data &= x.data; return *this; } + template< typename U = T, typename std::enable_if{}>::type* = nullptr> @@ -406,6 +443,7 @@ THE SOFTWARE. data >>= x.data; return *this; } + template< typename U = T, typename std::enable_if{}>::type* = nullptr>