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

Side by Side Diff: src/mips64/macro-assembler-mips64.cc

Issue 540343002: MIPS: Generalized division via multiplication. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | 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 #include <limits.h> // For LONG_MIN, LONG_MAX. 5 #include <limits.h> // For LONG_MIN, LONG_MAX.
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #if V8_TARGET_ARCH_MIPS64 9 #if V8_TARGET_ARCH_MIPS64
10 10
11 #include "src/base/division-by-constant.h"
11 #include "src/bootstrapper.h" 12 #include "src/bootstrapper.h"
12 #include "src/codegen.h" 13 #include "src/codegen.h"
13 #include "src/cpu-profiler.h" 14 #include "src/cpu-profiler.h"
14 #include "src/debug.h" 15 #include "src/debug.h"
15 #include "src/isolate-inl.h" 16 #include "src/isolate-inl.h"
16 #include "src/runtime.h" 17 #include "src/runtime.h"
17 18
18 namespace v8 { 19 namespace v8 {
19 namespace internal { 20 namespace internal {
20 21
(...skipping 6062 matching lines...) Expand 10 before | Expand all | Expand 10 after
6083 masm_.emit(instr); 6084 masm_.emit(instr);
6084 } 6085 }
6085 6086
6086 6087
6087 void MacroAssembler::TruncatingDiv(Register result, 6088 void MacroAssembler::TruncatingDiv(Register result,
6088 Register dividend, 6089 Register dividend,
6089 int32_t divisor) { 6090 int32_t divisor) {
6090 DCHECK(!dividend.is(result)); 6091 DCHECK(!dividend.is(result));
6091 DCHECK(!dividend.is(at)); 6092 DCHECK(!dividend.is(at));
6092 DCHECK(!result.is(at)); 6093 DCHECK(!result.is(at));
6093 MultiplierAndShift ms(divisor); 6094 base::MagicNumbersForDivision<uint32_t> mag =
6094 li(at, Operand(ms.multiplier())); 6095 base::SignedDivisionByConstant(static_cast<uint32_t>(divisor));
6096 li(at, Operand(mag.multiplier));
6095 Mulh(result, dividend, Operand(at)); 6097 Mulh(result, dividend, Operand(at));
6096 if (divisor > 0 && ms.multiplier() < 0) { 6098 bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0;
6099 if (divisor > 0 && neg) {
6097 Addu(result, result, Operand(dividend)); 6100 Addu(result, result, Operand(dividend));
6098 } 6101 }
6099 if (divisor < 0 && ms.multiplier() > 0) { 6102 if (divisor < 0 && !neg && mag.multiplier > 0) {
6100 Subu(result, result, Operand(dividend)); 6103 Subu(result, result, Operand(dividend));
6101 } 6104 }
6102 if (ms.shift() > 0) sra(result, result, ms.shift()); 6105 if (mag.shift > 0) sra(result, result, mag.shift);
6103 srl(at, dividend, 31); 6106 srl(at, dividend, 31);
6104 Addu(result, result, Operand(at)); 6107 Addu(result, result, Operand(at));
6105 } 6108 }
6106 6109
6107 6110
6108 } } // namespace v8::internal 6111 } } // namespace v8::internal
6109 6112
6110 #endif // V8_TARGET_ARCH_MIPS64 6113 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698