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 "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 4981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4992 } | 4992 } |
4993 break; | 4993 break; |
4994 } | 4994 } |
4995 default: | 4995 default: |
4996 UNREACHABLE(); | 4996 UNREACHABLE(); |
4997 } | 4997 } |
4998 } else { | 4998 } else { |
4999 // Code for a variable shift amount. | 4999 // Code for a variable shift amount. |
5000 Register shift = locs()->in(1).reg(); | 5000 Register shift = locs()->in(1).reg(); |
5001 | 5001 |
| 5002 // Code below assumes shift amount is not 0 (cannot shift by 32 - 0). |
| 5003 Label non_zero_shift, done; |
| 5004 __ bne(shift, ZR, &non_zero_shift); |
| 5005 __ delay_slot()->mov(out_lo, left_lo); |
| 5006 __ b(&done); |
| 5007 __ delay_slot()->mov(out_hi, left_hi); |
| 5008 __ Bind(&non_zero_shift); |
| 5009 |
5002 // Deopt if shift is larger than 63 or less than 0. | 5010 // Deopt if shift is larger than 63 or less than 0. |
5003 if (has_shift_count_check()) { | 5011 if (has_shift_count_check()) { |
5004 __ sltiu(CMPRES1, shift, Immediate(2*(kMintShiftCountLimit + 1))); | 5012 __ sltiu(CMPRES1, shift, Immediate(2*(kMintShiftCountLimit + 1))); |
5005 __ beq(CMPRES1, ZR, deopt); | 5013 __ beq(CMPRES1, ZR, deopt); |
5006 // Untag shift count. | 5014 // Untag shift count. |
5007 __ delay_slot()->SmiUntag(shift); | 5015 __ delay_slot()->SmiUntag(shift); |
5008 } else { | 5016 } else { |
5009 // Untag shift count. | 5017 // Untag shift count. |
5010 __ SmiUntag(shift); | 5018 __ SmiUntag(shift); |
5011 } | 5019 } |
5012 | 5020 |
5013 switch (op_kind()) { | 5021 switch (op_kind()) { |
5014 case Token::kSHR: { | 5022 case Token::kSHR: { |
5015 Label large_shift, done; | 5023 Label large_shift; |
5016 __ sltiu(CMPRES1, shift, Immediate(32)); | 5024 __ sltiu(CMPRES1, shift, Immediate(32)); |
5017 __ beq(CMPRES1, ZR, &large_shift); | 5025 __ beq(CMPRES1, ZR, &large_shift); |
5018 | 5026 |
5019 // shift < 32. | 5027 // 0 < shift < 32. |
5020 __ delay_slot()->ori(TMP, ZR, Immediate(32)); | 5028 __ delay_slot()->ori(TMP, ZR, Immediate(32)); |
5021 __ subu(TMP, TMP, shift); // TMP = 32 - shift; 0 < TMP <= 31. | 5029 __ subu(TMP, TMP, shift); // TMP = 32 - shift; 0 < TMP <= 31. |
5022 __ sllv(out_lo, left_hi, TMP); | 5030 __ sllv(out_lo, left_hi, TMP); |
5023 __ srlv(TMP, left_lo, shift); | 5031 __ srlv(TMP, left_lo, shift); |
5024 __ or_(out_lo, out_lo, TMP); | 5032 __ or_(out_lo, out_lo, TMP); |
5025 __ b(&done); | 5033 __ b(&done); |
5026 __ delay_slot()->srav(out_hi, left_hi, shift); | 5034 __ delay_slot()->srav(out_hi, left_hi, shift); |
5027 | 5035 |
5028 // shift >= 32. | 5036 // shift >= 32. |
5029 __ Bind(&large_shift); | 5037 __ Bind(&large_shift); |
5030 __ sra(out_hi, left_hi, 31); | 5038 __ sra(out_hi, left_hi, 31); |
5031 __ srav(out_lo, left_hi, shift); // Only 5 low bits of shift used. | 5039 __ srav(out_lo, left_hi, shift); // Only 5 low bits of shift used. |
5032 | 5040 |
5033 __ Bind(&done); | |
5034 break; | 5041 break; |
5035 } | 5042 } |
5036 case Token::kSHL: { | 5043 case Token::kSHL: { |
5037 Label large_shift, done; | 5044 Label large_shift; |
5038 __ sltiu(CMPRES1, shift, Immediate(32)); | 5045 __ sltiu(CMPRES1, shift, Immediate(32)); |
5039 __ beq(CMPRES1, ZR, &large_shift); | 5046 __ beq(CMPRES1, ZR, &large_shift); |
5040 | 5047 |
5041 // shift < 32. | 5048 // 0 < shift < 32. |
5042 __ delay_slot()->ori(TMP, ZR, Immediate(32)); | 5049 __ delay_slot()->ori(TMP, ZR, Immediate(32)); |
5043 __ subu(TMP, TMP, shift); // TMP = 32 - shift; 0 < TMP <= 31. | 5050 __ subu(TMP, TMP, shift); // TMP = 32 - shift; 0 < TMP <= 31. |
5044 __ srlv(out_hi, left_lo, TMP); | 5051 __ srlv(out_hi, left_lo, TMP); |
5045 __ sllv(TMP, left_hi, shift); | 5052 __ sllv(TMP, left_hi, shift); |
5046 __ or_(out_hi, out_hi, TMP); | 5053 __ or_(out_hi, out_hi, TMP); |
5047 // Check for overflow. | 5054 // Check for overflow. |
5048 if (can_overflow()) { | 5055 if (can_overflow()) { |
5049 // Compare high word from input with shifted high word from output. | 5056 // Compare high word from input with shifted high word from output. |
5050 __ srav(TMP, out_hi, shift); | 5057 __ srav(TMP, out_hi, shift); |
5051 __ beq(TMP, left_hi, &done); | 5058 __ beq(TMP, left_hi, &done); |
(...skipping 13 matching lines...) Expand all Loading... |
5065 // high word from input to sign of output. | 5072 // high word from input to sign of output. |
5066 // Overflow if they aren't equal. | 5073 // Overflow if they aren't equal. |
5067 __ srav(TMP, out_hi, shift); | 5074 __ srav(TMP, out_hi, shift); |
5068 __ bne(TMP, left_lo, deopt); | 5075 __ bne(TMP, left_lo, deopt); |
5069 __ delay_slot()->sra(TMP, out_hi, 31); | 5076 __ delay_slot()->sra(TMP, out_hi, 31); |
5070 __ bne(TMP, left_hi, deopt); | 5077 __ bne(TMP, left_hi, deopt); |
5071 __ delay_slot()->mov(out_lo, ZR); | 5078 __ delay_slot()->mov(out_lo, ZR); |
5072 } else { | 5079 } else { |
5073 __ mov(out_lo, ZR); | 5080 __ mov(out_lo, ZR); |
5074 } | 5081 } |
5075 __ Bind(&done); | |
5076 break; | 5082 break; |
5077 } | 5083 } |
5078 default: | 5084 default: |
5079 UNREACHABLE(); | 5085 UNREACHABLE(); |
5080 } | 5086 } |
| 5087 __ Bind(&done); |
5081 } | 5088 } |
5082 } | 5089 } |
5083 | 5090 |
5084 | 5091 |
5085 LocationSummary* UnaryMintOpInstr::MakeLocationSummary(Zone* zone, | 5092 LocationSummary* UnaryMintOpInstr::MakeLocationSummary(Zone* zone, |
5086 bool opt) const { | 5093 bool opt) const { |
5087 const intptr_t kNumInputs = 1; | 5094 const intptr_t kNumInputs = 1; |
5088 const intptr_t kNumTemps = 0; | 5095 const intptr_t kNumTemps = 0; |
5089 LocationSummary* summary = new(zone) LocationSummary( | 5096 LocationSummary* summary = new(zone) LocationSummary( |
5090 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 5097 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5609 1, | 5616 1, |
5610 locs()); | 5617 locs()); |
5611 __ lw(result, Address(SP, 1 * kWordSize)); | 5618 __ lw(result, Address(SP, 1 * kWordSize)); |
5612 __ addiu(SP, SP, Immediate(2 * kWordSize)); | 5619 __ addiu(SP, SP, Immediate(2 * kWordSize)); |
5613 } | 5620 } |
5614 | 5621 |
5615 | 5622 |
5616 } // namespace dart | 5623 } // namespace dart |
5617 | 5624 |
5618 #endif // defined TARGET_ARCH_MIPS | 5625 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |