Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/base/bits.h

Issue 1131573006: ARM64: Enable shorten-64-to-32 warning (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/arm64/utils-arm64.cc ('k') | src/compiler/arm64/code-generator-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_BASE_BITS_H_ 5 #ifndef V8_BASE_BITS_H_
6 #define V8_BASE_BITS_H_ 6 #define V8_BASE_BITS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include "src/base/macros.h" 9 #include "src/base/macros.h"
10 #if V8_CC_MSVC 10 #if V8_CC_MSVC
(...skipping 26 matching lines...) Expand all
37 inline unsigned CountPopulation64(uint64_t value) { 37 inline unsigned CountPopulation64(uint64_t value) {
38 #if V8_HAS_BUILTIN_POPCOUNT 38 #if V8_HAS_BUILTIN_POPCOUNT
39 return __builtin_popcountll(value); 39 return __builtin_popcountll(value);
40 #else 40 #else
41 return CountPopulation32(static_cast<uint32_t>(value)) + 41 return CountPopulation32(static_cast<uint32_t>(value)) +
42 CountPopulation32(static_cast<uint32_t>(value >> 32)); 42 CountPopulation32(static_cast<uint32_t>(value >> 32));
43 #endif 43 #endif
44 } 44 }
45 45
46 46
47 // Overloaded versions of CountPopulation32/64.
48 inline unsigned CountPopulation(uint32_t value) {
49 return CountPopulation32(value);
50 }
51
52
53 inline unsigned CountPopulation(uint64_t value) {
54 return CountPopulation64(value);
55 }
56
57
47 // CountLeadingZeros32(value) returns the number of zero bits following the most 58 // CountLeadingZeros32(value) returns the number of zero bits following the most
48 // significant 1 bit in |value| if |value| is non-zero, otherwise it returns 32. 59 // significant 1 bit in |value| if |value| is non-zero, otherwise it returns 32.
49 inline unsigned CountLeadingZeros32(uint32_t value) { 60 inline unsigned CountLeadingZeros32(uint32_t value) {
50 #if V8_HAS_BUILTIN_CLZ 61 #if V8_HAS_BUILTIN_CLZ
51 return value ? __builtin_clz(value) : 32; 62 return value ? __builtin_clz(value) : 32;
52 #elif V8_CC_MSVC 63 #elif V8_CC_MSVC
53 unsigned long result; // NOLINT(runtime/int) 64 unsigned long result; // NOLINT(runtime/int)
54 if (!_BitScanReverse(&result, value)) return 32; 65 if (!_BitScanReverse(&result, value)) return 32;
55 return static_cast<unsigned>(31 - result); 66 return static_cast<unsigned>(31 - result);
56 #else 67 #else
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // truncated to uint32. If |rhs| is zero, then zero is returned. 247 // truncated to uint32. If |rhs| is zero, then zero is returned.
237 inline uint32_t UnsignedMod32(uint32_t lhs, uint32_t rhs) { 248 inline uint32_t UnsignedMod32(uint32_t lhs, uint32_t rhs) {
238 return rhs ? lhs % rhs : 0u; 249 return rhs ? lhs % rhs : 0u;
239 } 250 }
240 251
241 } // namespace bits 252 } // namespace bits
242 } // namespace base 253 } // namespace base
243 } // namespace v8 254 } // namespace v8
244 255
245 #endif // V8_BASE_BITS_H_ 256 #endif // V8_BASE_BITS_H_
OLDNEW
« no previous file with comments | « src/arm64/utils-arm64.cc ('k') | src/compiler/arm64/code-generator-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698