Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 3076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3087 | 3087 |
| 3088 LocationSummary* MathMinMaxInstr::MakeLocationSummary() const { | 3088 LocationSummary* MathMinMaxInstr::MakeLocationSummary() const { |
| 3089 if (result_cid() == kDoubleCid) { | 3089 if (result_cid() == kDoubleCid) { |
| 3090 const intptr_t kNumInputs = 2; | 3090 const intptr_t kNumInputs = 2; |
| 3091 const intptr_t kNumTemps = 1; | 3091 const intptr_t kNumTemps = 1; |
| 3092 LocationSummary* summary = | 3092 LocationSummary* summary = |
| 3093 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 3093 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 3094 summary->set_in(0, Location::RequiresFpuRegister()); | 3094 summary->set_in(0, Location::RequiresFpuRegister()); |
| 3095 summary->set_in(1, Location::RequiresFpuRegister()); | 3095 summary->set_in(1, Location::RequiresFpuRegister()); |
| 3096 summary->set_out(Location::RequiresFpuRegister()); | 3096 summary->set_out(Location::RequiresFpuRegister()); |
| 3097 summary->set_temp(0, Location::RequiresRegister()); | |
| 3097 return summary; | 3098 return summary; |
| 3098 } | 3099 } |
| 3099 ASSERT(result_cid() == kSmiCid); | 3100 ASSERT(result_cid() == kSmiCid); |
| 3100 UNIMPLEMENTED(); | 3101 UNIMPLEMENTED(); |
| 3101 return NULL; | 3102 return NULL; |
| 3102 } | 3103 } |
| 3103 | 3104 |
| 3104 | 3105 |
| 3105 void MathMinMaxInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3106 void MathMinMaxInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3107 ASSERT((op_kind() == MethodRecognizer::kMathMin) || | |
| 3108 (op_kind() == MethodRecognizer::kMathMax)); | |
| 3106 if (result_cid() == kDoubleCid) { | 3109 if (result_cid() == kDoubleCid) { |
| 3107 Label done, is_nan, is_left; | 3110 Label done, returns_nan, returns_left, are_equal; |
| 3108 DRegister left = locs()->in(0).fpu_reg(); | 3111 DRegister left = locs()->in(0).fpu_reg(); |
| 3109 DRegister right = locs()->in(1).fpu_reg(); | 3112 DRegister right = locs()->in(1).fpu_reg(); |
| 3110 DRegister result = locs()->out().fpu_reg(); | 3113 DRegister result = locs()->out().fpu_reg(); |
| 3114 Register temp = locs()->temp(0).reg(); | |
| 3111 __ cund(left, right); | 3115 __ cund(left, right); |
| 3112 __ bc1t(&is_nan); | 3116 __ bc1t(&returns_nan); |
| 3113 if (op_kind() == MethodRecognizer::kMathMin) { | 3117 __ ceqd(left, right); |
| 3118 __ bc1t(&are_equal); | |
| 3119 const intptr_t is_min = (op_kind() == MethodRecognizer::kMathMin); | |
| 3120 if (is_min) { | |
| 3114 __ coltd(left, right); | 3121 __ coltd(left, right); |
| 3115 } else { | 3122 } else { |
| 3116 ASSERT(op_kind() == MethodRecognizer::kMathMax); | |
| 3117 __ coltd(right, left); | 3123 __ coltd(right, left); |
| 3118 } | 3124 } |
| 3119 // TODO(zra): Add conditional moves. | 3125 // TODO(zra): Add conditional moves. |
| 3120 __ bc1t(&is_left); | 3126 __ bc1t(&returns_left); |
| 3121 __ movd(result, right); | 3127 __ movd(result, right); |
| 3122 __ b(&done); | 3128 __ b(&done); |
| 3123 __ Bind(&is_left); | 3129 |
| 3130 __ Bind(&returns_left); | |
| 3124 __ movd(result, right); | 3131 __ movd(result, right); |
| 3125 __ b(&done); | 3132 __ b(&done); |
| 3126 __ Bind(&is_nan); | 3133 |
| 3134 __ Bind(&returns_nan); | |
| 3127 __ LoadImmediate(result, NAN); | 3135 __ LoadImmediate(result, NAN); |
| 3136 __ b(&done); | |
| 3137 | |
| 3138 __ Bind(&are_equal); | |
| 3139 Label left_is_negative; | |
| 3140 // Check for negative zero: -0.0 is equal 0.0 but min or max must return | |
| 3141 // -0.0 or 0.0 respectively. | |
| 3142 // Check for negative left value (get the sign bit): | |
| 3143 // - min -> left is negative ? left : right. | |
| 3144 // - max -> left is negative ? right : left | |
| 3145 // Check the sign bit. | |
| 3146 __ mfc1(temp, OddFRegisterOf(left)); // Moves bits 32...63 of left to temp. | |
| 3147 __ srl(temp, temp, 31); // Get the sign bit down to bit 0. | |
| 3148 __ andi(CMPRES, temp, Immediate(1)); // Check if the bit is set. | |
|
regis
2013/07/22 20:55:11
You do not need the 2 instructions above. Use bltz
srdjan
2013/07/22 21:10:16
Done.
| |
| 3149 // NE -> Sign bit set. | |
| 3150 __ bne(temp, ZR, &left_is_negative); // Sign bit set. | |
| 3151 // Left is positive. | |
| 3152 __ movd(result, (is_min ? right : left)); | |
| 3153 __ b(&done); | |
| 3154 | |
| 3155 __ Bind(&left_is_negative); | |
| 3156 __ movd(result, (is_min ? left : right)); | |
| 3128 __ Bind(&done); | 3157 __ Bind(&done); |
| 3129 return; | 3158 return; |
| 3130 } | 3159 } |
| 3131 ASSERT(result_cid() == kSmiCid); | 3160 ASSERT(result_cid() == kSmiCid); |
| 3132 UNIMPLEMENTED(); | 3161 UNIMPLEMENTED(); |
| 3133 } | 3162 } |
| 3134 | 3163 |
| 3135 | 3164 |
| 3136 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const { | 3165 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const { |
| 3137 const intptr_t kNumInputs = 1; | 3166 const intptr_t kNumInputs = 1; |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3821 compiler->GenerateCall(token_pos(), | 3850 compiler->GenerateCall(token_pos(), |
| 3822 &label, | 3851 &label, |
| 3823 PcDescriptors::kOther, | 3852 PcDescriptors::kOther, |
| 3824 locs()); | 3853 locs()); |
| 3825 __ Drop(2); // Discard type arguments and receiver. | 3854 __ Drop(2); // Discard type arguments and receiver. |
| 3826 } | 3855 } |
| 3827 | 3856 |
| 3828 } // namespace dart | 3857 } // namespace dart |
| 3829 | 3858 |
| 3830 #endif // defined TARGET_ARCH_MIPS | 3859 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |