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

Side by Side Diff: src/mips64/simulator-mips64.cc

Issue 494633002: Fix implementation of bit count functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/mips/simulator-mips.cc ('k') | test/base-unittests/bits-unittest.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 #include <limits.h> 5 #include <limits.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
11 11
12 #if V8_TARGET_ARCH_MIPS64 12 #if V8_TARGET_ARCH_MIPS64
13 13
14 #include "src/assembler.h" 14 #include "src/assembler.h"
15 #include "src/base/bits.h"
15 #include "src/disasm.h" 16 #include "src/disasm.h"
16 #include "src/globals.h" // Need the BitCast. 17 #include "src/globals.h" // Need the BitCast.
17 #include "src/mips64/constants-mips64.h" 18 #include "src/mips64/constants-mips64.h"
18 #include "src/mips64/simulator-mips64.h" 19 #include "src/mips64/simulator-mips64.h"
19 #include "src/ostreams.h" 20 #include "src/ostreams.h"
20 21
21 // Only build the simulator if not compiling for real MIPS hardware. 22 // Only build the simulator if not compiling for real MIPS hardware.
22 #if defined(USE_SIMULATOR) 23 #if defined(USE_SIMULATOR)
23 24
24 namespace v8 { 25 namespace v8 {
(...skipping 2042 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 case DSRAV: 2068 case DSRAV:
2068 *alu_out = rt >> rs; 2069 *alu_out = rt >> rs;
2069 break; 2070 break;
2070 case MFHI: // MFHI == CLZ on R6. 2071 case MFHI: // MFHI == CLZ on R6.
2071 if (kArchVariant != kMips64r6) { 2072 if (kArchVariant != kMips64r6) {
2072 DCHECK(instr->SaValue() == 0); 2073 DCHECK(instr->SaValue() == 0);
2073 *alu_out = get_register(HI); 2074 *alu_out = get_register(HI);
2074 } else { 2075 } else {
2075 // MIPS spec: If no bits were set in GPR rs, the result written to 2076 // MIPS spec: If no bits were set in GPR rs, the result written to
2076 // GPR rd is 32. 2077 // GPR rd is 32.
2077 // GCC __builtin_clz: If input is 0, the result is undefined.
2078 DCHECK(instr->SaValue() == 1); 2078 DCHECK(instr->SaValue() == 1);
2079 *alu_out = 2079 *alu_out = base::bits::CountLeadingZeros32(rs_u);
2080 rs_u == 0 ? 32 : CompilerIntrinsics::CountLeadingZeros(rs_u);
2081 } 2080 }
2082 break; 2081 break;
2083 case MFLO: 2082 case MFLO:
2084 *alu_out = get_register(LO); 2083 *alu_out = get_register(LO);
2085 break; 2084 break;
2086 case MULT: // MULT == D_MUL_MUH. 2085 case MULT: // MULT == D_MUL_MUH.
2087 // TODO(plind) - Unify MULT/DMULT with single set of 64-bit HI/Lo 2086 // TODO(plind) - Unify MULT/DMULT with single set of 64-bit HI/Lo
2088 // regs. 2087 // regs.
2089 // TODO(plind) - make the 32-bit MULT ops conform to spec regarding 2088 // TODO(plind) - make the 32-bit MULT ops conform to spec regarding
2090 // checking of 32-bit input values, and un-define operations of HW. 2089 // checking of 32-bit input values, and un-define operations of HW.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 break; 2212 break;
2214 case SPECIAL2: 2213 case SPECIAL2:
2215 switch (instr->FunctionFieldRaw()) { 2214 switch (instr->FunctionFieldRaw()) {
2216 case MUL: 2215 case MUL:
2217 // Only the lower 32 bits are kept. 2216 // Only the lower 32 bits are kept.
2218 *alu_out = (int32_t)rs_u * (int32_t)rt_u; 2217 *alu_out = (int32_t)rs_u * (int32_t)rt_u;
2219 break; 2218 break;
2220 case CLZ: 2219 case CLZ:
2221 // MIPS32 spec: If no bits were set in GPR rs, the result written to 2220 // MIPS32 spec: If no bits were set in GPR rs, the result written to
2222 // GPR rd is 32. 2221 // GPR rd is 32.
2223 // GCC __builtin_clz: If input is 0, the result is undefined. 2222 *alu_out = base::bits::CountLeadingZeros32(rs_u);
2224 *alu_out =
2225 rs_u == 0 ? 32 : CompilerIntrinsics::CountLeadingZeros(rs_u);
2226 break; 2223 break;
2227 default: 2224 default:
2228 UNREACHABLE(); 2225 UNREACHABLE();
2229 } 2226 }
2230 break; 2227 break;
2231 case SPECIAL3: 2228 case SPECIAL3:
2232 switch (instr->FunctionFieldRaw()) { 2229 switch (instr->FunctionFieldRaw()) {
2233 case INS: { // Mips32r2 instruction. 2230 case INS: { // Mips32r2 instruction.
2234 // Interpret rd field as 5-bit msb of insert. 2231 // Interpret rd field as 5-bit msb of insert.
2235 uint16_t msb = rd_reg; 2232 uint16_t msb = rd_reg;
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
3442 } 3439 }
3443 3440
3444 3441
3445 #undef UNSUPPORTED 3442 #undef UNSUPPORTED
3446 3443
3447 } } // namespace v8::internal 3444 } } // namespace v8::internal
3448 3445
3449 #endif // USE_SIMULATOR 3446 #endif // USE_SIMULATOR
3450 3447
3451 #endif // V8_TARGET_ARCH_MIPS64 3448 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/simulator-mips.cc ('k') | test/base-unittests/bits-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698