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

Side by Side Diff: runtime/vm/intermediate_language_mips.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
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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
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 3067 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 summary->set_out(Location::RequiresFpuRegister()); 3078 summary->set_out(Location::RequiresFpuRegister());
3079 return summary; 3079 return summary;
3080 } 3080 }
3081 3081
3082 3082
3083 void MathSqrtInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3083 void MathSqrtInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3084 __ sqrtd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg()); 3084 __ sqrtd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg());
3085 } 3085 }
3086 3086
3087 3087
3088 LocationSummary* MathMinMaxInstr::MakeLocationSummary() const {
3089 if (result_cid() == kDoubleCid) {
3090 const intptr_t kNumInputs = 2;
3091 const intptr_t kNumTemps = 1;
3092 LocationSummary* summary =
3093 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3094 summary->set_in(0, Location::RequiresFpuRegister());
3095 summary->set_in(1, Location::RequiresFpuRegister());
3096 summary->set_temp(0, Location::RequiresRegister());
3097 summary->set_out(Location::RequiresFpuRegister());
3098 return summary;
3099 }
3100 ASSERT(result_cid() == kSmiCid);
3101 UNIMPLEMENTED();
3102 return NULL;
3103 }
3104
3105
3106 void MathMinMaxInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3107 if (result_cid() == kDoubleCid) {
3108 Label done, is_nan, is_left;
3109 DRegister left = locs()->in(0).fpu_reg();
3110 DRegister right = locs()->in(1).fpu_reg();
3111 DRegister result = locs()->out().fpu_reg();
3112 Register temp = locs()->temp(0).reg();
3113 __ cund(left, right);
3114 __ bc1t(&is_nan);
3115 if (op_kind() == MethodRecognizer::kMathMin) {
3116 __ coltd(left, right);
3117 } else {
3118 ASSERT(op_kind() == MethodRecognizer::kMathMax);
3119 __ coltd(right, left);
3120 }
3121 __ bc1t(&is_left);
3122 __ movd(result, right);
zra 2013/07/22 16:21:02 It would be okay to add a TODO here for me to add
srdjan 2013/07/22 16:42:48 Done.
3123 __ b(&done);
3124 __ Bind(&is_left);
3125 __ movd(result, right);
3126 __ b(&done);
3127 __ Bind(&is_nan);
3128 static double kNaN = NAN;
3129 __ LoadImmediate(temp, reinterpret_cast<int32_t>(&kNaN));
3130 __ ldc1(result, Address(temp, 0));
zra 2013/07/22 16:21:02 __ LoadDImmediate(result, NAN);
srdjan 2013/07/22 16:42:48 Done.
srdjan 2013/07/22 17:07:57 Actually, there is no LoadDImmedaite on MIPS yet.
3131 __ Bind(&done);
3132 return;
3133 }
3134 ASSERT(result_cid() == kSmiCid);
3135 UNIMPLEMENTED();
3136 }
3137
3138
3088 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const { 3139 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const {
3089 const intptr_t kNumInputs = 1; 3140 const intptr_t kNumInputs = 1;
3090 const intptr_t kNumTemps = 0; 3141 const intptr_t kNumTemps = 0;
3091 LocationSummary* summary = 3142 LocationSummary* summary =
3092 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 3143 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3093 summary->set_in(0, Location::RequiresRegister()); 3144 summary->set_in(0, Location::RequiresRegister());
3094 // We make use of 3-operand instructions by not requiring result register 3145 // We make use of 3-operand instructions by not requiring result register
3095 // to be identical to first input register as on Intel. 3146 // to be identical to first input register as on Intel.
3096 summary->set_out(Location::RequiresRegister()); 3147 summary->set_out(Location::RequiresRegister());
3097 return summary; 3148 return summary;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 result->set_in(0, Location::FpuRegisterLocation(D6)); 3281 result->set_in(0, Location::FpuRegisterLocation(D6));
3231 if (InputCount() == 2) { 3282 if (InputCount() == 2) {
3232 result->set_in(1, Location::FpuRegisterLocation(D7)); 3283 result->set_in(1, Location::FpuRegisterLocation(D7));
3233 } 3284 }
3234 result->set_out(Location::FpuRegisterLocation(D0)); 3285 result->set_out(Location::FpuRegisterLocation(D0));
3235 return result; 3286 return result;
3236 } 3287 }
3237 3288
3238 3289
3239 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3290 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3240 // For pow-function return NAN if exponent is NAN. 3291 // For pow-function return NaN if exponent is NaN.
3241 Label do_call, skip_call; 3292 Label do_call, skip_call;
3242 if (recognized_kind() == MethodRecognizer::kDoublePow) { 3293 if (recognized_kind() == MethodRecognizer::kDoublePow) {
3243 DRegister exp = locs()->in(1).fpu_reg(); 3294 DRegister exp = locs()->in(1).fpu_reg();
3244 __ cund(exp, exp); 3295 __ cund(exp, exp);
3245 __ bc1f(&do_call); 3296 __ bc1f(&do_call);
3246 // Exponent is NaN, return NaN. 3297 // Exponent is NaN, return NaN.
3247 __ movd(locs()->out().fpu_reg(), exp); 3298 __ movd(locs()->out().fpu_reg(), exp);
3248 __ b(&skip_call); 3299 __ b(&skip_call);
3249 } 3300 }
3250 __ Bind(&do_call); 3301 __ Bind(&do_call);
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
3773 compiler->GenerateCall(token_pos(), 3824 compiler->GenerateCall(token_pos(),
3774 &label, 3825 &label,
3775 PcDescriptors::kOther, 3826 PcDescriptors::kOther,
3776 locs()); 3827 locs());
3777 __ Drop(2); // Discard type arguments and receiver. 3828 __ Drop(2); // Discard type arguments and receiver.
3778 } 3829 }
3779 3830
3780 } // namespace dart 3831 } // namespace dart
3781 3832
3782 #endif // defined TARGET_ARCH_MIPS 3833 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698