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

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 23219002: Add double unary operation (negate). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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_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/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 3758 matching lines...) Expand 10 before | Expand all | Expand 10 after
3769 3769
3770 3770
3771 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const { 3771 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const {
3772 const intptr_t kNumInputs = 1; 3772 const intptr_t kNumInputs = 1;
3773 return LocationSummary::Make(kNumInputs, 3773 return LocationSummary::Make(kNumInputs,
3774 Location::SameAsFirstInput(), 3774 Location::SameAsFirstInput(),
3775 LocationSummary::kNoCall); 3775 LocationSummary::kNoCall);
3776 } 3776 }
3777 3777
3778 3778
3779 void UnarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3780 Register value = locs()->in(0).reg();
3781 ASSERT(value == locs()->out().reg());
3782 switch (op_kind()) {
3783 case Token::kNEGATE: {
3784 Label* deopt = compiler->AddDeoptStub(deopt_id(),
3785 kDeoptUnaryOp);
3786 __ negq(value);
3787 __ j(OVERFLOW, deopt);
3788 if (FLAG_throw_on_javascript_int_overflow) {
3789 EmitJavascriptOverflowCheck(compiler, range(), deopt, value);
3790 }
3791 break;
3792 }
3793 case Token::kBIT_NOT:
3794 __ notq(value);
3795 __ andq(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag.
3796 break;
3797 default:
3798 UNREACHABLE();
3799 }
3800 }
3801
3802
3803 LocationSummary* UnaryDoubleOpInstr::MakeLocationSummary() const {
3804 const intptr_t kNumInputs = 1;
3805 const intptr_t kNumTemps = 0;
3806 LocationSummary* summary =
3807 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3808 summary->set_in(0, Location::RequiresFpuRegister());
3809 summary->set_out(Location::SameAsFirstInput());
3810 return summary;
3811 }
3812
3813
3814 void UnaryDoubleOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3815 XmmRegister value = locs()->in(0).fpu_reg();
3816 ASSERT(locs()->out().fpu_reg() == value);
3817 __ DoubleNegate(value);
3818 }
3819
3820
3779 LocationSummary* MathMinMaxInstr::MakeLocationSummary() const { 3821 LocationSummary* MathMinMaxInstr::MakeLocationSummary() const {
3780 if (result_cid() == kDoubleCid) { 3822 if (result_cid() == kDoubleCid) {
3781 const intptr_t kNumInputs = 2; 3823 const intptr_t kNumInputs = 2;
3782 const intptr_t kNumTemps = 1; 3824 const intptr_t kNumTemps = 1;
3783 LocationSummary* summary = 3825 LocationSummary* summary =
3784 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 3826 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3785 summary->set_in(0, Location::RequiresFpuRegister()); 3827 summary->set_in(0, Location::RequiresFpuRegister());
3786 summary->set_in(1, Location::RequiresFpuRegister()); 3828 summary->set_in(1, Location::RequiresFpuRegister());
3787 // Reuse the left register so that code can be made shorter. 3829 // Reuse the left register so that code can be made shorter.
3788 summary->set_out(Location::SameAsFirstInput()); 3830 summary->set_out(Location::SameAsFirstInput());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
3858 __ cmpq(left, right); 3900 __ cmpq(left, right);
3859 ASSERT(result == left); 3901 ASSERT(result == left);
3860 if (is_min) { 3902 if (is_min) {
3861 __ cmovgeq(result, right); 3903 __ cmovgeq(result, right);
3862 } else { 3904 } else {
3863 __ cmovlessq(result, right); 3905 __ cmovlessq(result, right);
3864 } 3906 }
3865 } 3907 }
3866 3908
3867 3909
3868 void UnarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3869 Register value = locs()->in(0).reg();
3870 ASSERT(value == locs()->out().reg());
3871 switch (op_kind()) {
3872 case Token::kNEGATE: {
3873 Label* deopt = compiler->AddDeoptStub(deopt_id(),
3874 kDeoptUnaryOp);
3875 __ negq(value);
3876 __ j(OVERFLOW, deopt);
3877 if (FLAG_throw_on_javascript_int_overflow) {
3878 EmitJavascriptOverflowCheck(compiler, range(), deopt, value);
3879 }
3880 break;
3881 }
3882 case Token::kBIT_NOT:
3883 __ notq(value);
3884 __ andq(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag.
3885 break;
3886 default:
3887 UNREACHABLE();
3888 }
3889 }
3890
3891
3892 LocationSummary* SmiToDoubleInstr::MakeLocationSummary() const { 3910 LocationSummary* SmiToDoubleInstr::MakeLocationSummary() const {
3893 const intptr_t kNumInputs = 1; 3911 const intptr_t kNumInputs = 1;
3894 const intptr_t kNumTemps = 0; 3912 const intptr_t kNumTemps = 0;
3895 LocationSummary* result = 3913 LocationSummary* result =
3896 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 3914 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3897 result->set_in(0, Location::WritableRegister()); 3915 result->set_in(0, Location::WritableRegister());
3898 result->set_out(Location::RequiresFpuRegister()); 3916 result->set_out(Location::RequiresFpuRegister());
3899 return result; 3917 return result;
3900 } 3918 }
3901 3919
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
4590 PcDescriptors::kOther, 4608 PcDescriptors::kOther,
4591 locs()); 4609 locs());
4592 __ Drop(2); // Discard type arguments and receiver. 4610 __ Drop(2); // Discard type arguments and receiver.
4593 } 4611 }
4594 4612
4595 } // namespace dart 4613 } // namespace dart
4596 4614
4597 #undef __ 4615 #undef __
4598 4616
4599 #endif // defined TARGET_ARCH_X64 4617 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/intermediate_language_mips.cc ('K') | « runtime/vm/intermediate_language_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698