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

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

Issue 677483005: [turbofan] Implement the correct semantics for integer division/modulus. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixes and tests Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | src/base/bits.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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // |rhs|, extracts the most significant 32 bits of the result, and returns 192 // |rhs|, extracts the most significant 32 bits of the result, and returns
193 // those. 193 // those.
194 int32_t SignedMulHigh32(int32_t lhs, int32_t rhs); 194 int32_t SignedMulHigh32(int32_t lhs, int32_t rhs);
195 195
196 196
197 // SignedMulHighAndAdd32(lhs, rhs, acc) multiplies two signed 32-bit values 197 // SignedMulHighAndAdd32(lhs, rhs, acc) multiplies two signed 32-bit values
198 // |lhs| and |rhs|, extracts the most significant 32 bits of the result, and 198 // |lhs| and |rhs|, extracts the most significant 32 bits of the result, and
199 // adds the accumulate value |acc|. 199 // adds the accumulate value |acc|.
200 int32_t SignedMulHighAndAdd32(int32_t lhs, int32_t rhs, int32_t acc); 200 int32_t SignedMulHighAndAdd32(int32_t lhs, int32_t rhs, int32_t acc);
201 201
202
203 // SignedDiv32(lhs, rhs) divides |lhs| by |rhs| and returns the quotient
204 // truncated to int32. If |rhs| is zero, then zero is returned. If |lhs|
205 // is minint and |rhs| is -1, it returns minint.
206 int32_t SignedDiv32(int32_t lhs, int32_t rhs);
207
208
209 // SignedMod32(lhs, rhs) divides |lhs| by |rhs| and returns the remainder
210 // truncated to int32. If either |rhs| is zero or |lhs| is minint and |rhs|
211 // is -1, it returns zero.
212 int32_t SignedMod32(int32_t lhs, int32_t rhs);
213
214
215 // UnsignedDiv32(lhs, rhs) divides |lhs| by |rhs| and returns the quotient
216 // truncated to uint32. If |rhs| is zero, then zero is returned.
217 inline uint32_t UnsignedDiv32(uint32_t lhs, uint32_t rhs) {
218 return rhs ? lhs / rhs : 0u;
219 }
220
221
222 // UnsignedMod32(lhs, rhs) divides |lhs| by |rhs| and returns the remainder
223 // truncated to uint32. If |rhs| is zero, then zero is returned.
224 inline uint32_t UnsignedMod32(uint32_t lhs, uint32_t rhs) {
225 return rhs ? lhs % rhs : 0u;
226 }
227
202 } // namespace bits 228 } // namespace bits
203 } // namespace base 229 } // namespace base
204 } // namespace v8 230 } // namespace v8
205 231
206 #endif // V8_BASE_BITS_H_ 232 #endif // V8_BASE_BITS_H_
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | src/base/bits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698