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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 case EQUAL: return NOT_EQUAL; | 381 case EQUAL: return NOT_EQUAL; |
382 case NOT_EQUAL: return EQUAL; | 382 case NOT_EQUAL: return EQUAL; |
383 case LESS: return GREATER_EQUAL; | 383 case LESS: return GREATER_EQUAL; |
384 case LESS_EQUAL: return GREATER; | 384 case LESS_EQUAL: return GREATER; |
385 case GREATER: return LESS_EQUAL; | 385 case GREATER: return LESS_EQUAL; |
386 case GREATER_EQUAL: return LESS; | 386 case GREATER_EQUAL: return LESS; |
387 case BELOW: return ABOVE_EQUAL; | 387 case BELOW: return ABOVE_EQUAL; |
388 case BELOW_EQUAL: return ABOVE; | 388 case BELOW_EQUAL: return ABOVE; |
389 case ABOVE: return BELOW_EQUAL; | 389 case ABOVE: return BELOW_EQUAL; |
390 case ABOVE_EQUAL: return BELOW; | 390 case ABOVE_EQUAL: return BELOW; |
| 391 case PARITY_ODD: return PARITY_EVEN; |
| 392 case PARITY_EVEN: return PARITY_ODD; |
391 default: | 393 default: |
392 UNIMPLEMENTED(); | 394 UNIMPLEMENTED(); |
393 return EQUAL; | 395 return EQUAL; |
394 } | 396 } |
395 } | 397 } |
396 | 398 |
397 | 399 |
398 static void EmitBranchOnCondition(FlowGraphCompiler* compiler, | 400 static void EmitBranchOnCondition(FlowGraphCompiler* compiler, |
399 Condition true_condition, | 401 Condition true_condition, |
400 BranchLabels labels) { | 402 BranchLabels labels) { |
(...skipping 3494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3895 case Token::kMUL: __ mulsd(left, right); break; | 3897 case Token::kMUL: __ mulsd(left, right); break; |
3896 case Token::kDIV: __ divsd(left, right); break; | 3898 case Token::kDIV: __ divsd(left, right); break; |
3897 default: UNREACHABLE(); | 3899 default: UNREACHABLE(); |
3898 } | 3900 } |
3899 } | 3901 } |
3900 | 3902 |
3901 | 3903 |
3902 LocationSummary* DoubleTestOpInstr::MakeLocationSummary(Zone* zone, | 3904 LocationSummary* DoubleTestOpInstr::MakeLocationSummary(Zone* zone, |
3903 bool opt) const { | 3905 bool opt) const { |
3904 const intptr_t kNumInputs = 1; | 3906 const intptr_t kNumInputs = 1; |
3905 const intptr_t kNumTemps = 0; | 3907 const intptr_t kNumTemps = |
| 3908 (op_kind() == MethodRecognizer::kDouble_getIsInfinite) ? 1 : 0; |
3906 LocationSummary* summary = new(zone) LocationSummary( | 3909 LocationSummary* summary = new(zone) LocationSummary( |
3907 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 3910 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
3908 summary->set_in(0, Location::RequiresFpuRegister()); | 3911 summary->set_in(0, Location::RequiresFpuRegister()); |
| 3912 if (op_kind() == MethodRecognizer::kDouble_getIsInfinite) { |
| 3913 summary->set_temp(0, Location::RequiresRegister()); |
| 3914 } |
3909 summary->set_out(0, Location::RequiresRegister()); | 3915 summary->set_out(0, Location::RequiresRegister()); |
3910 return summary; | 3916 return summary; |
3911 } | 3917 } |
3912 | 3918 |
3913 | 3919 |
3914 void DoubleTestOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3920 Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
| 3921 BranchLabels labels) { |
3915 ASSERT(compiler->is_optimizing()); | 3922 ASSERT(compiler->is_optimizing()); |
3916 const XmmRegister value = locs()->in(0).fpu_reg(); | 3923 const XmmRegister value = locs()->in(0).fpu_reg(); |
3917 const Register result = locs()->out(0).reg(); | 3924 const bool is_negated = kind() != Token::kEQ; |
3918 if (op_kind() == MethodRecognizer::kDouble_getIsNaN) { | 3925 if (op_kind() == MethodRecognizer::kDouble_getIsNaN) { |
3919 Label is_nan; | 3926 Label is_nan; |
3920 __ LoadObject(result, Bool::True()); | |
3921 __ comisd(value, value); | 3927 __ comisd(value, value); |
3922 __ j(PARITY_EVEN, &is_nan, Assembler::kNearJump); | 3928 return is_negated ? PARITY_ODD : PARITY_EVEN; |
3923 __ LoadObject(result, Bool::False()); | |
3924 __ Bind(&is_nan); | |
3925 } else { | 3929 } else { |
3926 ASSERT(op_kind() == MethodRecognizer::kDouble_getIsInfinite); | 3930 ASSERT(op_kind() == MethodRecognizer::kDouble_getIsInfinite); |
3927 Label not_inf, done; | 3931 const Register temp = locs()->temp(0).reg(); |
| 3932 Label check_upper; |
3928 __ AddImmediate(ESP, Immediate(-kDoubleSize)); | 3933 __ AddImmediate(ESP, Immediate(-kDoubleSize)); |
3929 __ movsd(Address(ESP, 0), value); | 3934 __ movsd(Address(ESP, 0), value); |
3930 __ movl(result, Address(ESP, 0)); | 3935 __ movl(temp, Address(ESP, 0)); |
3931 // If the low word isn't zero, then it isn't infinity. | 3936 // If the low word isn't zero, then it isn't infinity. |
3932 __ cmpl(result, Immediate(0)); | 3937 __ cmpl(temp, Immediate(0)); |
3933 __ j(NOT_EQUAL, ¬_inf, Assembler::kNearJump); | 3938 __ j(EQUAL, &check_upper, Assembler::kNearJump); |
| 3939 __ AddImmediate(ESP, Immediate(kDoubleSize)); |
| 3940 __ jmp(is_negated ? labels.true_label : labels.false_label); |
| 3941 __ Bind(&check_upper); |
3934 // Check the high word. | 3942 // Check the high word. |
3935 __ movl(result, Address(ESP, kWordSize)); | 3943 __ movl(temp, Address(ESP, kWordSize)); |
| 3944 __ AddImmediate(ESP, Immediate(kDoubleSize)); |
3936 // Mask off sign bit. | 3945 // Mask off sign bit. |
3937 __ andl(result, Immediate(0x7FFFFFFF)); | 3946 __ andl(temp, Immediate(0x7FFFFFFF)); |
3938 // Compare with +infinity. | 3947 // Compare with +infinity. |
3939 __ cmpl(result, Immediate(0x7FF00000)); | 3948 __ cmpl(temp, Immediate(0x7FF00000)); |
3940 __ j(NOT_EQUAL, ¬_inf, Assembler::kNearJump); | 3949 return is_negated ? NOT_EQUAL : EQUAL; |
3941 __ LoadObject(result, Bool::True()); | 3950 } |
3942 __ jmp(&done); | 3951 } |
3943 | 3952 |
3944 __ Bind(¬_inf); | 3953 |
3945 __ LoadObject(result, Bool::False()); | 3954 void DoubleTestOpInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
3946 __ Bind(&done); | 3955 BranchInstr* branch) { |
3947 __ AddImmediate(ESP, Immediate(kDoubleSize)); | 3956 ASSERT(compiler->is_optimizing()); |
3948 } | 3957 BranchLabels labels = compiler->CreateBranchLabels(branch); |
| 3958 Condition true_condition = EmitComparisonCode(compiler, labels); |
| 3959 EmitBranchOnCondition(compiler, true_condition, labels); |
| 3960 } |
| 3961 |
| 3962 |
| 3963 void DoubleTestOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3964 Label is_true, is_false; |
| 3965 BranchLabels labels = { &is_true, &is_false, &is_false }; |
| 3966 Condition true_condition = EmitComparisonCode(compiler, labels); |
| 3967 EmitBranchOnCondition(compiler, true_condition, labels); |
| 3968 |
| 3969 Register result = locs()->out(0).reg(); |
| 3970 Label done; |
| 3971 __ Bind(&is_false); |
| 3972 __ LoadObject(result, Bool::False()); |
| 3973 __ jmp(&done); |
| 3974 __ Bind(&is_true); |
| 3975 __ LoadObject(result, Bool::True()); |
| 3976 __ Bind(&done); |
3949 } | 3977 } |
3950 | 3978 |
3951 | 3979 |
3952 LocationSummary* BinaryFloat32x4OpInstr::MakeLocationSummary(Zone* zone, | 3980 LocationSummary* BinaryFloat32x4OpInstr::MakeLocationSummary(Zone* zone, |
3953 bool opt) const { | 3981 bool opt) const { |
3954 const intptr_t kNumInputs = 2; | 3982 const intptr_t kNumInputs = 2; |
3955 const intptr_t kNumTemps = 0; | 3983 const intptr_t kNumTemps = 0; |
3956 LocationSummary* summary = new(zone) LocationSummary( | 3984 LocationSummary* summary = new(zone) LocationSummary( |
3957 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 3985 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
3958 summary->set_in(0, Location::RequiresFpuRegister()); | 3986 summary->set_in(0, Location::RequiresFpuRegister()); |
(...skipping 2973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6932 __ Drop(1); | 6960 __ Drop(1); |
6933 __ popl(result); | 6961 __ popl(result); |
6934 } | 6962 } |
6935 | 6963 |
6936 | 6964 |
6937 } // namespace dart | 6965 } // namespace dart |
6938 | 6966 |
6939 #undef __ | 6967 #undef __ |
6940 | 6968 |
6941 #endif // defined TARGET_ARCH_IA32 | 6969 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |