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/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 4521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4532 break; | 4532 break; |
4533 case Token::kSUB: | 4533 case Token::kSUB: |
4534 __ subpl(left, right); | 4534 __ subpl(left, right); |
4535 break; | 4535 break; |
4536 default: UNREACHABLE(); | 4536 default: UNREACHABLE(); |
4537 } | 4537 } |
4538 } | 4538 } |
4539 | 4539 |
4540 | 4540 |
4541 LocationSummary* MathUnaryInstr::MakeLocationSummary(bool opt) const { | 4541 LocationSummary* MathUnaryInstr::MakeLocationSummary(bool opt) const { |
4542 if ((kind() == MethodRecognizer::kMathSin) || | 4542 if ((kind() == MathUnaryInstr::kSin) || (kind() == MathUnaryInstr::kCos)) { |
4543 (kind() == MethodRecognizer::kMathCos)) { | |
4544 const intptr_t kNumInputs = 1; | 4543 const intptr_t kNumInputs = 1; |
4545 const intptr_t kNumTemps = 1; | 4544 const intptr_t kNumTemps = 1; |
4546 LocationSummary* summary = | 4545 LocationSummary* summary = |
4547 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 4546 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
4548 summary->set_in(0, Location::FpuRegisterLocation(XMM1)); | 4547 summary->set_in(0, Location::FpuRegisterLocation(XMM1)); |
4549 // EDI is chosen because it is callee saved so we do not need to back it | 4548 // EDI is chosen because it is callee saved so we do not need to back it |
4550 // up before calling into the runtime. | 4549 // up before calling into the runtime. |
4551 summary->set_temp(0, Location::RegisterLocation(EDI)); | 4550 summary->set_temp(0, Location::RegisterLocation(EDI)); |
4552 summary->set_out(0, Location::FpuRegisterLocation(XMM1)); | 4551 summary->set_out(0, Location::FpuRegisterLocation(XMM1)); |
4553 return summary; | 4552 return summary; |
4554 } | 4553 } |
4555 ASSERT(kind() == MethodRecognizer::kMathSqrt); | 4554 ASSERT((kind() == MathUnaryInstr::kSqrt) || |
| 4555 (kind() == MathUnaryInstr::kDoubleSquare)); |
4556 const intptr_t kNumInputs = 1; | 4556 const intptr_t kNumInputs = 1; |
4557 const intptr_t kNumTemps = 0; | 4557 const intptr_t kNumTemps = 0; |
4558 LocationSummary* summary = | 4558 LocationSummary* summary = |
4559 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 4559 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
4560 summary->set_in(0, Location::RequiresFpuRegister()); | 4560 summary->set_in(0, Location::RequiresFpuRegister()); |
4561 summary->set_out(0, Location::RequiresFpuRegister()); | 4561 if (kind() == MathUnaryInstr::kDoubleSquare) { |
| 4562 summary->set_out(0, Location::SameAsFirstInput()); |
| 4563 } else { |
| 4564 summary->set_out(0, Location::RequiresFpuRegister()); |
| 4565 } |
4562 return summary; | 4566 return summary; |
4563 } | 4567 } |
4564 | 4568 |
4565 | 4569 |
4566 void MathUnaryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4570 void MathUnaryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
4567 if (kind() == MethodRecognizer::kMathSqrt) { | 4571 if (kind() == MathUnaryInstr::kSqrt) { |
4568 __ sqrtsd(locs()->out(0).fpu_reg(), locs()->in(0).fpu_reg()); | 4572 __ sqrtsd(locs()->out(0).fpu_reg(), locs()->in(0).fpu_reg()); |
| 4573 } else if (kind() == MathUnaryInstr::kDoubleSquare) { |
| 4574 XmmRegister value_reg = locs()->in(0).fpu_reg(); |
| 4575 __ mulsd(value_reg, value_reg); |
| 4576 ASSERT(value_reg == locs()->out(0).fpu_reg()); |
4569 } else { | 4577 } else { |
4570 ASSERT((kind() == MethodRecognizer::kMathSin) || | 4578 ASSERT((kind() == MathUnaryInstr::kSin) || |
4571 (kind() == MethodRecognizer::kMathCos)); | 4579 (kind() == MathUnaryInstr::kCos)); |
4572 // Save ESP. | 4580 // Save ESP. |
4573 __ movl(locs()->temp(0).reg(), ESP); | 4581 __ movl(locs()->temp(0).reg(), ESP); |
4574 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount()); | 4582 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount()); |
4575 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); | 4583 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); |
4576 __ CallRuntime(TargetFunction(), InputCount()); | 4584 __ CallRuntime(TargetFunction(), InputCount()); |
4577 __ fstpl(Address(ESP, 0)); | 4585 __ fstpl(Address(ESP, 0)); |
4578 __ movsd(locs()->out(0).fpu_reg(), Address(ESP, 0)); | 4586 __ movsd(locs()->out(0).fpu_reg(), Address(ESP, 0)); |
4579 // Restore ESP. | 4587 // Restore ESP. |
4580 __ movl(ESP, locs()->temp(0).reg()); | 4588 __ movl(ESP, locs()->temp(0).reg()); |
4581 } | 4589 } |
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6022 PcDescriptors::kOther, | 6030 PcDescriptors::kOther, |
6023 locs()); | 6031 locs()); |
6024 __ Drop(ArgumentCount()); // Discard arguments. | 6032 __ Drop(ArgumentCount()); // Discard arguments. |
6025 } | 6033 } |
6026 | 6034 |
6027 } // namespace dart | 6035 } // namespace dart |
6028 | 6036 |
6029 #undef __ | 6037 #undef __ |
6030 | 6038 |
6031 #endif // defined TARGET_ARCH_IA32 | 6039 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |