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

Side by Side Diff: src/arm64/utils-arm64.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/simulator-arm64.cc ('k') | src/arm64/utils-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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_ARM64_UTILS_ARM64_H_ 5 #ifndef V8_ARM64_UTILS_ARM64_H_
6 #define V8_ARM64_UTILS_ARM64_H_ 6 #define V8_ARM64_UTILS_ARM64_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // Bit counting. 55 // Bit counting.
56 int CountLeadingZeros(uint64_t value, int width); 56 int CountLeadingZeros(uint64_t value, int width);
57 int CountLeadingSignBits(int64_t value, int width); 57 int CountLeadingSignBits(int64_t value, int width);
58 int CountTrailingZeros(uint64_t value, int width); 58 int CountTrailingZeros(uint64_t value, int width);
59 int CountSetBits(uint64_t value, int width); 59 int CountSetBits(uint64_t value, int width);
60 uint64_t LargestPowerOf2Divisor(uint64_t value); 60 uint64_t LargestPowerOf2Divisor(uint64_t value);
61 int MaskToBit(uint64_t mask); 61 int MaskToBit(uint64_t mask);
62 62
63 63
64 template <typename T>
65 T ReverseBits(T value) {
66 DCHECK((sizeof(value) == 1) || (sizeof(value) == 2) || (sizeof(value) == 4) ||
67 (sizeof(value) == 8));
68 T result = 0;
69 for (unsigned i = 0; i < (sizeof(value) * 8); i++) {
70 result = (result << 1) | (value & 1);
71 value >>= 1;
72 }
73 return result;
74 }
75
76
77 template <typename T>
78 T ReverseBytes(T value, int block_bytes_log2) {
79 DCHECK((sizeof(value) == 4) || (sizeof(value) == 8));
80 DCHECK((1U << block_bytes_log2) <= sizeof(value));
81 // Split the 64-bit value into an 8-bit array, where b[0] is the least
82 // significant byte, and b[7] is the most significant.
83 uint8_t bytes[8];
84 uint64_t mask = 0xff00000000000000;
85 for (int i = 7; i >= 0; i--) {
86 bytes[i] = (static_cast<uint64_t>(value) & mask) >> (i * 8);
87 mask >>= 8;
88 }
89
90 // Permutation tables for REV instructions.
91 // permute_table[0] is used by REV16_x, REV16_w
92 // permute_table[1] is used by REV32_x, REV_w
93 // permute_table[2] is used by REV_x
94 DCHECK((0 < block_bytes_log2) && (block_bytes_log2 < 4));
95 static const uint8_t permute_table[3][8] = {{6, 7, 4, 5, 2, 3, 0, 1},
96 {4, 5, 6, 7, 0, 1, 2, 3},
97 {0, 1, 2, 3, 4, 5, 6, 7}};
98 T result = 0;
99 for (int i = 0; i < 8; i++) {
100 result <<= 8;
101 result |= bytes[permute_table[block_bytes_log2 - 1][i]];
102 }
103 return result;
104 }
105
106
64 // NaN tests. 107 // NaN tests.
65 inline bool IsSignallingNaN(double num) { 108 inline bool IsSignallingNaN(double num) {
66 uint64_t raw = double_to_rawbits(num); 109 uint64_t raw = double_to_rawbits(num);
67 if (std::isnan(num) && ((raw & kDQuietNanMask) == 0)) { 110 if (std::isnan(num) && ((raw & kDQuietNanMask) == 0)) {
68 return true; 111 return true;
69 } 112 }
70 return false; 113 return false;
71 } 114 }
72 115
73 116
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 148 }
106 149
107 150
108 inline float FusedMultiplyAdd(float op1, float op2, float a) { 151 inline float FusedMultiplyAdd(float op1, float op2, float a) {
109 return fmaf(op1, op2, a); 152 return fmaf(op1, op2, a);
110 } 153 }
111 154
112 } } // namespace v8::internal 155 } } // namespace v8::internal
113 156
114 #endif // V8_ARM64_UTILS_ARM64_H_ 157 #endif // V8_ARM64_UTILS_ARM64_H_
OLDNEW
« no previous file with comments | « src/arm64/simulator-arm64.cc ('k') | src/arm64/utils-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698