| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkChecksum_opts_DEFINED | 8 #ifndef SkChecksum_opts_DEFINED |
| 9 #define SkChecksum_opts_DEFINED | 9 #define SkChecksum_opts_DEFINED |
| 10 | 10 |
| 11 #include "SkChecksum.h" | 11 #include "SkChecksum.h" |
| 12 #include "SkTypes.h" | 12 #include "SkTypes.h" |
| 13 | 13 |
| 14 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE42 | 14 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE42 |
| 15 #include <immintrin.h> | 15 #include <immintrin.h> |
| 16 #elif defined(SK_CPU_ARM64) && defined(__ARM_FEATURE_CRC32) | 16 #elif defined(SK_CPU_ARM64) && defined(SK_ARM_HAS_CRC32) |
| 17 #include <arm_acle.h> | 17 #include <arm_acle.h> |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 namespace SK_OPTS_NS { | 20 namespace SK_OPTS_NS { |
| 21 | 21 |
| 22 template <typename T> | 22 template <typename T> |
| 23 static inline T unaligned_load(const uint8_t* src) { | 23 static inline T unaligned_load(const uint8_t* src) { |
| 24 T val; | 24 T val; |
| 25 memcpy(&val, src, sizeof(val)); | 25 memcpy(&val, src, sizeof(val)); |
| 26 return val; | 26 return val; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 if (bytes & 2) { | 120 if (bytes & 2) { |
| 121 hash = _mm_crc32_u16(hash, unaligned_load<uint16_t>(data)); | 121 hash = _mm_crc32_u16(hash, unaligned_load<uint16_t>(data)); |
| 122 data += 2; | 122 data += 2; |
| 123 } | 123 } |
| 124 if (bytes & 1) { | 124 if (bytes & 1) { |
| 125 hash = _mm_crc32_u8(hash, unaligned_load<uint8_t>(data)); | 125 hash = _mm_crc32_u8(hash, unaligned_load<uint8_t>(data)); |
| 126 } | 126 } |
| 127 return hash; | 127 return hash; |
| 128 } | 128 } |
| 129 | 129 |
| 130 #elif defined(SK_CPU_ARM64) && defined(__ARM_FEATURE_CRC32) | 130 #elif defined(SK_CPU_ARM64) && defined(SK_ARM_HAS_CRC32) |
| 131 static uint32_t hash_fn(const void* vdata, size_t bytes, uint32_t hash) { | 131 static uint32_t hash_fn(const void* vdata, size_t bytes, uint32_t hash) { |
| 132 auto data = (const uint8_t*)vdata; | 132 auto data = (const uint8_t*)vdata; |
| 133 if (bytes >= 24) { | 133 if (bytes >= 24) { |
| 134 uint32_t a = hash, | 134 uint32_t a = hash, |
| 135 b = hash, | 135 b = hash, |
| 136 c = hash; | 136 c = hash; |
| 137 size_t steps = bytes/24; | 137 size_t steps = bytes/24; |
| 138 while (steps --> 0) { | 138 while (steps --> 0) { |
| 139 a = __crc32d(a, unaligned_load<uint64_t>(data+ 0)); | 139 a = __crc32d(a, unaligned_load<uint64_t>(data+ 0)); |
| 140 b = __crc32d(b, unaligned_load<uint64_t>(data+ 8)); | 140 b = __crc32d(b, unaligned_load<uint64_t>(data+ 8)); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 207 } |
| 208 | 208 |
| 209 hash ^= original_bytes; | 209 hash ^= original_bytes; |
| 210 return SkChecksum::Mix(hash); | 210 return SkChecksum::Mix(hash); |
| 211 } | 211 } |
| 212 #endif | 212 #endif |
| 213 | 213 |
| 214 } // namespace SK_OPTS_NS | 214 } // namespace SK_OPTS_NS |
| 215 | 215 |
| 216 #endif//SkChecksum_opts_DEFINED | 216 #endif//SkChecksum_opts_DEFINED |
| OLD | NEW |