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

Side by Side Diff: runtime/vm/intermediate_language_arm.cc

Issue 18331006: Adds support for integer division for ARM chips without the sdiv instruction. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 LocationSummary* BinarySmiOpInstr::MakeLocationSummary() const { 2182 LocationSummary* BinarySmiOpInstr::MakeLocationSummary() const {
2183 const intptr_t kNumInputs = 2; 2183 const intptr_t kNumInputs = 2;
2184 const intptr_t kNumTemps = 0; 2184 const intptr_t kNumTemps = 0;
2185 LocationSummary* summary = 2185 LocationSummary* summary =
2186 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 2186 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
2187 if (op_kind() == Token::kTRUNCDIV) { 2187 if (op_kind() == Token::kTRUNCDIV) {
2188 summary->set_in(0, Location::RequiresRegister()); 2188 summary->set_in(0, Location::RequiresRegister());
2189 if (RightIsPowerOfTwoConstant()) { 2189 if (RightIsPowerOfTwoConstant()) {
2190 ConstantInstr* right_constant = right()->definition()->AsConstant(); 2190 ConstantInstr* right_constant = right()->definition()->AsConstant();
2191 summary->set_in(1, Location::Constant(right_constant->value())); 2191 summary->set_in(1, Location::Constant(right_constant->value()));
2192 summary->AddTemp(Location::RequiresRegister());
2192 } else { 2193 } else {
2193 summary->set_in(1, Location::RequiresRegister()); 2194 summary->set_in(1, Location::RequiresRegister());
2195 summary->AddTemp(Location::RequiresRegister());
2196 summary->AddTemp(Location::RequiresFpuRegister());
2194 } 2197 }
2195 summary->AddTemp(Location::RequiresRegister());
2196 summary->set_out(Location::RequiresRegister()); 2198 summary->set_out(Location::RequiresRegister());
2197 return summary; 2199 return summary;
2198 } 2200 }
2199 summary->set_in(0, Location::RequiresRegister()); 2201 summary->set_in(0, Location::RequiresRegister());
2200 summary->set_in(1, Location::RegisterOrSmiConstant(right())); 2202 summary->set_in(1, Location::RegisterOrSmiConstant(right()));
2201 if (((op_kind() == Token::kSHL) && !is_truncating()) || 2203 if (((op_kind() == Token::kSHL) && !is_truncating()) ||
2202 (op_kind() == Token::kSHR)) { 2204 (op_kind() == Token::kSHR)) {
2203 summary->AddTemp(Location::RequiresRegister()); 2205 summary->AddTemp(Location::RequiresRegister());
2204 } 2206 }
2205 // We make use of 3-operand instructions by not requiring result register 2207 // We make use of 3-operand instructions by not requiring result register
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 case Token::kBIT_XOR: { 2406 case Token::kBIT_XOR: {
2405 // No overflow check. 2407 // No overflow check.
2406 __ eor(result, left, ShifterOperand(right)); 2408 __ eor(result, left, ShifterOperand(right));
2407 break; 2409 break;
2408 } 2410 }
2409 case Token::kTRUNCDIV: { 2411 case Token::kTRUNCDIV: {
2410 // Handle divide by zero in runtime. 2412 // Handle divide by zero in runtime.
2411 __ cmp(right, ShifterOperand(0)); 2413 __ cmp(right, ShifterOperand(0));
2412 __ b(deopt, EQ); 2414 __ b(deopt, EQ);
2413 Register temp = locs()->temp(0).reg(); 2415 Register temp = locs()->temp(0).reg();
2416 DRegister dtemp = locs()->temp(1).fpu_reg();
2414 __ Asr(temp, left, kSmiTagSize); // SmiUntag left into temp. 2417 __ Asr(temp, left, kSmiTagSize); // SmiUntag left into temp.
2415 __ Asr(IP, right, kSmiTagSize); // SmiUntag right into IP. 2418 __ Asr(IP, right, kSmiTagSize); // SmiUntag right into IP.
2416 if (!CPUFeatures::integer_division_supported()) { 2419
2417 UNIMPLEMENTED(); 2420 __ IntegerDivide(result, temp, IP, dtemp, DTMP);
2418 } 2421
2419 __ sdiv(result, temp, IP);
2420 // Check the corner case of dividing the 'MIN_SMI' with -1, in which 2422 // Check the corner case of dividing the 'MIN_SMI' with -1, in which
2421 // case we cannot tag the result. 2423 // case we cannot tag the result.
2422 __ CompareImmediate(result, 0x40000000); 2424 __ CompareImmediate(result, 0x40000000);
2423 __ b(deopt, EQ); 2425 __ b(deopt, EQ);
2424 __ SmiTag(result); 2426 __ SmiTag(result);
2425 break; 2427 break;
2426 } 2428 }
2427 case Token::kSHR: { 2429 case Token::kSHR: {
2428 if (CanDeoptimize()) { 2430 if (CanDeoptimize()) {
2429 __ CompareImmediate(right, 0); 2431 __ CompareImmediate(right, 0);
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
3594 compiler->GenerateCall(token_pos(), 3596 compiler->GenerateCall(token_pos(),
3595 &label, 3597 &label,
3596 PcDescriptors::kOther, 3598 PcDescriptors::kOther,
3597 locs()); 3599 locs());
3598 __ Drop(2); // Discard type arguments and receiver. 3600 __ Drop(2); // Discard type arguments and receiver.
3599 } 3601 }
3600 3602
3601 } // namespace dart 3603 } // namespace dart
3602 3604
3603 #endif // defined TARGET_ARCH_ARM 3605 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698