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

Side by Side Diff: src/mips/simulator-mips.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/hydrogen-instructions.cc ('k') | src/mips64/simulator-mips64.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_MIPS 12 #if V8_TARGET_ARCH_MIPS
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/mips/constants-mips.h" 18 #include "src/mips/constants-mips.h"
18 #include "src/mips/simulator-mips.h" 19 #include "src/mips/simulator-mips.h"
19 #include "src/ostreams.h" 20 #include "src/ostreams.h"
20 21
21 22
22 // Only build the simulator if not compiling for real MIPS hardware. 23 // Only build the simulator if not compiling for real MIPS hardware.
23 #if defined(USE_SIMULATOR) 24 #if defined(USE_SIMULATOR)
24 25
(...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 case SRAV: 1960 case SRAV:
1960 *alu_out = rt >> rs; 1961 *alu_out = rt >> rs;
1961 break; 1962 break;
1962 case MFHI: // MFHI == CLZ on R6. 1963 case MFHI: // MFHI == CLZ on R6.
1963 if (!IsMipsArchVariant(kMips32r6)) { 1964 if (!IsMipsArchVariant(kMips32r6)) {
1964 DCHECK(instr->SaValue() == 0); 1965 DCHECK(instr->SaValue() == 0);
1965 *alu_out = get_register(HI); 1966 *alu_out = get_register(HI);
1966 } else { 1967 } else {
1967 // MIPS spec: If no bits were set in GPR rs, the result written to 1968 // MIPS spec: If no bits were set in GPR rs, the result written to
1968 // GPR rd is 32. 1969 // GPR rd is 32.
1969 // GCC __builtin_clz: If input is 0, the result is undefined.
1970 DCHECK(instr->SaValue() == 1); 1970 DCHECK(instr->SaValue() == 1);
1971 *alu_out = 1971 *alu_out = base::bits::CountLeadingZeros32(rs_u);
1972 rs_u == 0 ? 32 : CompilerIntrinsics::CountLeadingZeros(rs_u);
1973 } 1972 }
1974 break; 1973 break;
1975 case MFLO: 1974 case MFLO:
1976 *alu_out = get_register(LO); 1975 *alu_out = get_register(LO);
1977 break; 1976 break;
1978 case MULT: // MULT == MUL_MUH. 1977 case MULT: // MULT == MUL_MUH.
1979 if (!IsMipsArchVariant(kMips32r6)) { 1978 if (!IsMipsArchVariant(kMips32r6)) {
1980 *i64hilo = static_cast<int64_t>(rs) * static_cast<int64_t>(rt); 1979 *i64hilo = static_cast<int64_t>(rs) * static_cast<int64_t>(rt);
1981 } else { 1980 } else {
1982 switch (instr->SaValue()) { 1981 switch (instr->SaValue()) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 } 2086 }
2088 break; 2087 break;
2089 case SPECIAL2: 2088 case SPECIAL2:
2090 switch (instr->FunctionFieldRaw()) { 2089 switch (instr->FunctionFieldRaw()) {
2091 case MUL: 2090 case MUL:
2092 *alu_out = rs_u * rt_u; // Only the lower 32 bits are kept. 2091 *alu_out = rs_u * rt_u; // Only the lower 32 bits are kept.
2093 break; 2092 break;
2094 case CLZ: 2093 case CLZ:
2095 // MIPS32 spec: If no bits were set in GPR rs, the result written to 2094 // MIPS32 spec: If no bits were set in GPR rs, the result written to
2096 // GPR rd is 32. 2095 // GPR rd is 32.
2097 // GCC __builtin_clz: If input is 0, the result is undefined. 2096 *alu_out = base::bits::CountLeadingZeros32(rs_u);
2098 *alu_out =
2099 rs_u == 0 ? 32 : CompilerIntrinsics::CountLeadingZeros(rs_u);
2100 break; 2097 break;
2101 default: 2098 default:
2102 UNREACHABLE(); 2099 UNREACHABLE();
2103 } 2100 }
2104 break; 2101 break;
2105 case SPECIAL3: 2102 case SPECIAL3:
2106 switch (instr->FunctionFieldRaw()) { 2103 switch (instr->FunctionFieldRaw()) {
2107 case INS: { // Mips32r2 instruction. 2104 case INS: { // Mips32r2 instruction.
2108 // Interpret rd field as 5-bit msb of insert. 2105 // Interpret rd field as 5-bit msb of insert.
2109 uint16_t msb = rd_reg; 2106 uint16_t msb = rd_reg;
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
3264 } 3261 }
3265 3262
3266 3263
3267 #undef UNSUPPORTED 3264 #undef UNSUPPORTED
3268 3265
3269 } } // namespace v8::internal 3266 } } // namespace v8::internal
3270 3267
3271 #endif // USE_SIMULATOR 3268 #endif // USE_SIMULATOR
3272 3269
3273 #endif // V8_TARGET_ARCH_MIPS 3270 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/mips64/simulator-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698