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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
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 4729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4740 case Token::kSUB: | 4740 case Token::kSUB: |
4741 __ subpl(left, right); | 4741 __ subpl(left, right); |
4742 break; | 4742 break; |
4743 default: UNREACHABLE(); | 4743 default: UNREACHABLE(); |
4744 } | 4744 } |
4745 } | 4745 } |
4746 | 4746 |
4747 | 4747 |
4748 LocationSummary* MathUnaryInstr::MakeLocationSummary(Zone* zone, | 4748 LocationSummary* MathUnaryInstr::MakeLocationSummary(Zone* zone, |
4749 bool opt) const { | 4749 bool opt) const { |
4750 if ((kind() == MathUnaryInstr::kSin) || (kind() == MathUnaryInstr::kCos)) { | |
4751 // Calling convention on x64 uses XMM0 and XMM1 to pass the first two | |
4752 // double arguments and XMM0 to return the result. Unfortunately | |
4753 // currently we can't specify these registers because ParallelMoveResolver | |
4754 // assumes that XMM0 is free at all times. | |
4755 // TODO(vegorov): allow XMM0 to be used. | |
4756 const intptr_t kNumTemps = 1; | |
4757 LocationSummary* summary = new(zone) LocationSummary( | |
4758 zone, InputCount(), kNumTemps, LocationSummary::kCall); | |
4759 summary->set_in(0, Location::FpuRegisterLocation(XMM1)); | |
4760 // R13 is chosen because it is callee saved so we do not need to back it | |
4761 // up before calling into the runtime. | |
4762 summary->set_temp(0, Location::RegisterLocation(R13)); | |
4763 summary->set_out(0, Location::FpuRegisterLocation(XMM1)); | |
4764 return summary; | |
4765 } | |
4766 ASSERT((kind() == MathUnaryInstr::kSqrt) || | 4750 ASSERT((kind() == MathUnaryInstr::kSqrt) || |
4767 (kind() == MathUnaryInstr::kDoubleSquare)); | 4751 (kind() == MathUnaryInstr::kDoubleSquare)); |
4768 const intptr_t kNumInputs = 1; | 4752 const intptr_t kNumInputs = 1; |
4769 const intptr_t kNumTemps = 0; | 4753 const intptr_t kNumTemps = 0; |
4770 LocationSummary* summary = new(zone) LocationSummary( | 4754 LocationSummary* summary = new(zone) LocationSummary( |
4771 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 4755 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
4772 summary->set_in(0, Location::RequiresFpuRegister()); | 4756 summary->set_in(0, Location::RequiresFpuRegister()); |
4773 if (kind() == MathUnaryInstr::kDoubleSquare) { | 4757 if (kind() == MathUnaryInstr::kDoubleSquare) { |
4774 summary->set_out(0, Location::SameAsFirstInput()); | 4758 summary->set_out(0, Location::SameAsFirstInput()); |
4775 } else { | 4759 } else { |
4776 summary->set_out(0, Location::RequiresFpuRegister()); | 4760 summary->set_out(0, Location::RequiresFpuRegister()); |
4777 } | 4761 } |
4778 return summary; | 4762 return summary; |
4779 } | 4763 } |
4780 | 4764 |
4781 | 4765 |
4782 void MathUnaryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4766 void MathUnaryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
4783 if (kind() == MathUnaryInstr::kSqrt) { | 4767 if (kind() == MathUnaryInstr::kSqrt) { |
4784 __ sqrtsd(locs()->out(0).fpu_reg(), locs()->in(0).fpu_reg()); | 4768 __ sqrtsd(locs()->out(0).fpu_reg(), locs()->in(0).fpu_reg()); |
4785 } else if (kind() == MathUnaryInstr::kDoubleSquare) { | 4769 } else if (kind() == MathUnaryInstr::kDoubleSquare) { |
4786 XmmRegister value_reg = locs()->in(0).fpu_reg(); | 4770 XmmRegister value_reg = locs()->in(0).fpu_reg(); |
4787 __ mulsd(value_reg, value_reg); | 4771 __ mulsd(value_reg, value_reg); |
4788 ASSERT(value_reg == locs()->out(0).fpu_reg()); | 4772 ASSERT(value_reg == locs()->out(0).fpu_reg()); |
4789 } else { | 4773 } else { |
4790 ASSERT((kind() == MathUnaryInstr::kSin) || | 4774 UNREACHABLE(); |
4791 (kind() == MathUnaryInstr::kCos)); | |
4792 // Save RSP. | |
4793 __ movq(locs()->temp(0).reg(), RSP); | |
4794 __ ReserveAlignedFrameSpace(0); | |
4795 __ movaps(XMM0, locs()->in(0).fpu_reg()); | |
4796 __ CallRuntime(TargetFunction(), InputCount()); | |
4797 __ movaps(locs()->out(0).fpu_reg(), XMM0); | |
4798 // Restore RSP. | |
4799 __ movq(RSP, locs()->temp(0).reg()); | |
4800 } | 4775 } |
4801 } | 4776 } |
4802 | 4777 |
4803 | 4778 |
4804 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary( | 4779 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary( |
4805 Zone* zone, bool opt) const { | 4780 Zone* zone, bool opt) const { |
4806 const intptr_t kNumTemps = 0; | 4781 const intptr_t kNumTemps = 0; |
4807 LocationSummary* summary = new(zone) LocationSummary( | 4782 LocationSummary* summary = new(zone) LocationSummary( |
4808 zone, InputCount(), kNumTemps, LocationSummary::kCall); | 4783 zone, InputCount(), kNumTemps, LocationSummary::kCall); |
4809 summary->set_in(0, Location::RegisterLocation(CallingConventions::kArg1Reg)); | 4784 summary->set_in(0, Location::RegisterLocation(CallingConventions::kArg1Reg)); |
(...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6618 __ Drop(1); | 6593 __ Drop(1); |
6619 __ popq(result); | 6594 __ popq(result); |
6620 } | 6595 } |
6621 | 6596 |
6622 | 6597 |
6623 } // namespace dart | 6598 } // namespace dart |
6624 | 6599 |
6625 #undef __ | 6600 #undef __ |
6626 | 6601 |
6627 #endif // defined TARGET_ARCH_X64 | 6602 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |