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

Side by Side Diff: src/utils.h

Issue 2629223005: [ARM] Add Neon shift instructions vshl, vshr. (Closed)
Patch Set: Fix DCHECK in ArithmeticShiftRight. Created 3 years, 11 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/arm/simulator-arm.cc ('k') | test/cctest/test-assembler-arm.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_UTILS_H_ 5 #ifndef V8_UTILS_H_
6 #define V8_UTILS_H_ 6 #define V8_UTILS_H_
7 7
8 #include <limits.h> 8 #include <limits.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 nibble += 8; 130 nibble += 8;
131 x >>= 8; 131 x >>= 8;
132 } 132 }
133 if (x & 0xf0) { 133 if (x & 0xf0) {
134 nibble += 4; 134 nibble += 4;
135 x >>= 4; 135 x >>= 4;
136 } 136 }
137 return nibble + msb4[x]; 137 return nibble + msb4[x];
138 } 138 }
139 139
140 140 template <typename T>
141 // The C++ standard leaves the semantics of '>>' undefined for 141 static T ArithmeticShiftRight(T x, int shift) {
142 // negative signed operands. Most implementations do the right thing, 142 DCHECK_LE(0, shift);
143 // though. 143 if (x < 0) {
144 inline int ArithmeticShiftRight(int x, int s) { 144 // Right shift of signed values is implementation defined. Simulate a
145 return x >> s; 145 // true arithmetic right shift by adding leading sign bits.
146 using UnsignedT = typename std::make_unsigned<T>::type;
147 UnsignedT mask = ~(static_cast<UnsignedT>(~0) >> shift);
148 return (static_cast<UnsignedT>(x) >> shift) | mask;
149 } else {
150 return x >> shift;
151 }
146 } 152 }
147 153
148
149 template <typename T> 154 template <typename T>
150 int Compare(const T& a, const T& b) { 155 int Compare(const T& a, const T& b) {
151 if (a == b) 156 if (a == b)
152 return 0; 157 return 0;
153 else if (a < b) 158 else if (a < b)
154 return -1; 159 return -1;
155 else 160 else
156 return 1; 161 return 1;
157 } 162 }
158 163
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 private: 1704 private:
1700 T value_; 1705 T value_;
1701 ThreadedListZoneEntry<T>* next_; 1706 ThreadedListZoneEntry<T>* next_;
1702 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry); 1707 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry);
1703 }; 1708 };
1704 1709
1705 } // namespace internal 1710 } // namespace internal
1706 } // namespace v8 1711 } // namespace v8
1707 1712
1708 #endif // V8_UTILS_H_ 1713 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | test/cctest/test-assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698