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

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

Issue 19792007: Recognize Math's min and max function for doubles and inline the operation. (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
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_ia32.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 (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 3329 matching lines...) Expand 10 before | Expand all | Expand 10 after
3340 } 3340 }
3341 3341
3342 3342
3343 void MathSqrtInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3343 void MathSqrtInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3344 DRegister val = EvenDRegisterOf(locs()->in(0).fpu_reg()); 3344 DRegister val = EvenDRegisterOf(locs()->in(0).fpu_reg());
3345 DRegister result = EvenDRegisterOf(locs()->out().fpu_reg()); 3345 DRegister result = EvenDRegisterOf(locs()->out().fpu_reg());
3346 __ vsqrtd(result, val); 3346 __ vsqrtd(result, val);
3347 } 3347 }
3348 3348
3349 3349
3350 LocationSummary* MathMinMaxInstr::MakeLocationSummary() const {
3351 if (result_cid() == kDoubleCid) {
3352 const intptr_t kNumInputs = 2;
3353 const intptr_t kNumTemps = 1;
3354 LocationSummary* summary =
3355 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3356 summary->set_in(0, Location::RequiresFpuRegister());
3357 summary->set_in(1, Location::RequiresFpuRegister());
3358 summary->set_temp(0, Location::RequiresRegister());
3359 summary->set_out(Location::RequiresFpuRegister());
3360 return summary;
3361 }
3362 ASSERT(result_cid() == kSmiCid);
3363 UNIMPLEMENTED();
3364 return NULL;
3365 }
3366
3367
3368 void MathMinMaxInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3369 if (result_cid() == kDoubleCid) {
3370 Label done, is_nan;
3371 DRegister left = EvenDRegisterOf(locs()->in(0).fpu_reg());
3372 DRegister right = EvenDRegisterOf(locs()->in(1).fpu_reg());
3373 DRegister result = EvenDRegisterOf(locs()->out().fpu_reg());
3374 Register temp = locs()->temp(0).reg();
3375 __ vcmpd(left, right);
3376 __ vmstat();
3377 __ b(&is_nan, VS);
3378 Condition double_condition, neg_double_condition;
3379 if (op_kind() == MethodRecognizer::kMathMin) {
3380 double_condition = TokenKindToDoubleCondition(Token::kLT);
3381 neg_double_condition = TokenKindToDoubleCondition(Token::kGTE);
3382 } else {
3383 ASSERT(op_kind() == MethodRecognizer::kMathMax);
3384 double_condition = TokenKindToDoubleCondition(Token::kGT);
3385 neg_double_condition = TokenKindToDoubleCondition(Token::kLTE);
3386 }
3387 __ vmovd(result, left, double_condition);
3388 __ vmovd(result, right, neg_double_condition);
3389 __ b(&done);
3390
3391 __ Bind(&is_nan);
3392 __ LoadDImmediate(result, NAN, temp);
3393 __ Bind(&done);
3394 return;
3395 }
3396 ASSERT(result_cid() == kSmiCid);
3397 UNIMPLEMENTED();
3398 }
3399
3400
3350 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const { 3401 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const {
3351 const intptr_t kNumInputs = 1; 3402 const intptr_t kNumInputs = 1;
3352 const intptr_t kNumTemps = 0; 3403 const intptr_t kNumTemps = 0;
3353 LocationSummary* summary = 3404 LocationSummary* summary =
3354 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 3405 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3355 summary->set_in(0, Location::RequiresRegister()); 3406 summary->set_in(0, Location::RequiresRegister());
3356 // We make use of 3-operand instructions by not requiring result register 3407 // We make use of 3-operand instructions by not requiring result register
3357 // to be identical to first input register as on Intel. 3408 // to be identical to first input register as on Intel.
3358 summary->set_out(Location::RequiresRegister()); 3409 summary->set_out(Location::RequiresRegister());
3359 return summary; 3410 return summary;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
3525 result->set_in(0, Location::FpuRegisterLocation(Q0)); 3576 result->set_in(0, Location::FpuRegisterLocation(Q0));
3526 if (InputCount() == 2) { 3577 if (InputCount() == 2) {
3527 result->set_in(1, Location::FpuRegisterLocation(Q1)); 3578 result->set_in(1, Location::FpuRegisterLocation(Q1));
3528 } 3579 }
3529 result->set_out(Location::FpuRegisterLocation(Q0)); 3580 result->set_out(Location::FpuRegisterLocation(Q0));
3530 return result; 3581 return result;
3531 } 3582 }
3532 3583
3533 3584
3534 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3585 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3535 // For pow-function return NAN if exponent is NAN. 3586 // For pow-function return NaN if exponent is NaN.
3536 Label do_call, skip_call; 3587 Label do_call, skip_call;
3537 if (recognized_kind() == MethodRecognizer::kDoublePow) { 3588 if (recognized_kind() == MethodRecognizer::kDoublePow) {
3538 DRegister exp = EvenDRegisterOf(locs()->in(1).fpu_reg()); 3589 DRegister exp = EvenDRegisterOf(locs()->in(1).fpu_reg());
3539 DRegister result = EvenDRegisterOf(locs()->out().fpu_reg()); 3590 DRegister result = EvenDRegisterOf(locs()->out().fpu_reg());
3540 __ vcmpd(exp, exp); 3591 __ vcmpd(exp, exp);
3541 __ vmstat(); 3592 __ vmstat();
3542 __ b(&do_call, VC); // NaN -> false; 3593 __ b(&do_call, VC); // NaN -> false;
3543 // Exponent is NaN, return NaN. 3594 // Exponent is NaN, return NaN.
3544 __ vmovd(result, exp); 3595 __ vmovd(result, exp);
3545 __ b(&skip_call); 3596 __ b(&skip_call);
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
4038 compiler->GenerateCall(token_pos(), 4089 compiler->GenerateCall(token_pos(),
4039 &label, 4090 &label,
4040 PcDescriptors::kOther, 4091 PcDescriptors::kOther,
4041 locs()); 4092 locs());
4042 __ Drop(2); // Discard type arguments and receiver. 4093 __ Drop(2); // Discard type arguments and receiver.
4043 } 4094 }
4044 4095
4045 } // namespace dart 4096 } // namespace dart
4046 4097
4047 #endif // defined TARGET_ARCH_ARM 4098 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698