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

Side by Side Diff: src/mips/macro-assembler-mips.cc

Issue 1434263003: MIPS: Use BOVC/BNVC for overflow checking on r6. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 1
2 // Copyright 2012 the V8 project authors. All rights reserved. 2 // Copyright 2012 the V8 project authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 #include <limits.h> // For LONG_MIN, LONG_MAX. 6 #include <limits.h> // For LONG_MIN, LONG_MAX.
7 7
8 #if V8_TARGET_ARCH_MIPS 8 #if V8_TARGET_ARCH_MIPS
9 9
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 4279 matching lines...) Expand 10 before | Expand all | Expand 10 after
4290 4290
4291 void MacroAssembler::SmiToDoubleFPURegister(Register smi, 4291 void MacroAssembler::SmiToDoubleFPURegister(Register smi,
4292 FPURegister value, 4292 FPURegister value,
4293 Register scratch1) { 4293 Register scratch1) {
4294 sra(scratch1, smi, kSmiTagSize); 4294 sra(scratch1, smi, kSmiTagSize);
4295 mtc1(scratch1, value); 4295 mtc1(scratch1, value);
4296 cvt_d_w(value, value); 4296 cvt_d_w(value, value);
4297 } 4297 }
4298 4298
4299 4299
4300 void MacroAssembler::AdduAndCheckForOverflow(Register dst, Register left, 4300 void MacroAssembler::AdduAndCheckForOverflow(
4301 const Operand& right, 4301 Register dst, Register left, const Operand& right, Label* overflow_label,
4302 Register overflow_dst, 4302 Label* no_overflow_label, Register scratch, BranchDelaySlot bd) {
4303 Register scratch) { 4303 DCHECK(overflow_label || no_overflow_label);
4304 if (right.is_reg()) { 4304 if (right.is_reg()) {
4305 AdduAndCheckForOverflow(dst, left, right.rm(), overflow_dst, scratch); 4305 AdduAndCheckForOverflow(dst, left, right.rm(), overflow_label,
4306 no_overflow_label, scratch, bd);
4306 } else { 4307 } else {
4307 if (dst.is(left)) { 4308 if (IsMipsArchVariant(kMips32r6)) {
4308 mov(scratch, left); // Preserve left. 4309 DCHECK(!left.is(t9));
4309 Addu(dst, left, right.immediate()); // Left is overwritten. 4310 Register right_reg = t9;
4310 xor_(scratch, dst, scratch); // Original left. 4311 li(right_reg, Operand(right));
4311 // Load right since xori takes uint16 as immediate. 4312 AdduAndCheckForOverflow(dst, left, right_reg, overflow_label,
4312 Addu(t9, zero_reg, right); 4313 no_overflow_label);
4313 xor_(overflow_dst, dst, t9);
4314 and_(overflow_dst, overflow_dst, scratch);
4315 } else { 4314 } else {
4316 Addu(dst, left, right.immediate()); 4315 Register overflow_dst = t9;
4317 xor_(overflow_dst, dst, left); 4316 if (dst.is(left)) {
4318 // Load right since xori takes uint16 as immediate. 4317 mov(scratch, left); // Preserve left.
4319 Addu(t9, zero_reg, right); 4318 Addu(dst, left, right.immediate()); // Left is overwritten.
4320 xor_(scratch, dst, t9); 4319 xor_(scratch, dst, scratch); // Original left.
4321 and_(overflow_dst, scratch, overflow_dst); 4320 // Load right since xori takes uint16 as immediate.
4321 Addu(overflow_dst, zero_reg, right);
4322 xor_(overflow_dst, dst, overflow_dst);
4323 and_(overflow_dst, overflow_dst, scratch);
4324 } else {
4325 Addu(dst, left, right.immediate());
4326 xor_(overflow_dst, dst, left);
4327 // Load right since xori takes uint16 as immediate.
4328 Addu(scratch, zero_reg, right);
4329 xor_(scratch, dst, scratch);
4330 and_(overflow_dst, scratch, overflow_dst);
4331 }
4332 Branch(overflow_label, lt, overflow_dst, Operand(zero_reg));
4333 if (no_overflow_label) bc(no_overflow_label);
paul.l... 2015/11/13 02:16:20 This is not r6, you cannot use 'bc' here can you?
4322 } 4334 }
4323 } 4335 }
4324 } 4336 }
4325 4337
4326 4338
4327 void MacroAssembler::AdduAndCheckForOverflow(Register dst, Register left, 4339 void MacroAssembler::AdduAndCheckForOverflow(
4328 Register right, 4340 Register dst, Register left, Register right, Label* overflow_label,
4329 Register overflow_dst, 4341 Label* no_overflow_label, Register scratch, BranchDelaySlot bd) {
4330 Register scratch) { 4342 if (IsMipsArchVariant(kMips32r6)) {
4331 DCHECK(!dst.is(overflow_dst)); 4343 if (!overflow_label) {
4332 DCHECK(!dst.is(scratch)); 4344 DCHECK(no_overflow_label);
4333 DCHECK(!overflow_dst.is(scratch)); 4345 DCHECK(!dst.is(scratch));
4334 DCHECK(!overflow_dst.is(left)); 4346 DCHECK(!dst.is(t9));
4335 DCHECK(!overflow_dst.is(right)); 4347 Register left_reg = left.is(dst) ? scratch : left;
4348 Register right_reg = right.is(dst) ? t9 : right;
4349 DCHECK(!dst.is(left_reg));
4350 DCHECK(!dst.is(right_reg));
4351 Move(left_reg, left);
4352 Move(right_reg, right);
4353 addu(dst, left, right);
4354 bnvc(left_reg, right_reg, no_overflow_label);
4355 } else {
4356 bovc(left, right, overflow_label);
4357 addu(dst, left, right);
4358 if (no_overflow_label) bc(no_overflow_label);
4359 }
4360 } else {
4361 Register overflow_dst = t9;
4362 DCHECK(!dst.is(scratch));
4363 DCHECK(!dst.is(overflow_dst));
4364 DCHECK(!scratch.is(overflow_dst));
4365 DCHECK(!left.is(overflow_dst));
4366 DCHECK(!right.is(overflow_dst));
4336 4367
4337 if (left.is(right) && dst.is(left)) { 4368 if (left.is(right) && dst.is(left)) {
4338 DCHECK(!dst.is(t9)); 4369 mov(overflow_dst, right);
4339 DCHECK(!scratch.is(t9)); 4370 right = overflow_dst;
4340 DCHECK(!left.is(t9)); 4371 }
4341 DCHECK(!right.is(t9));
4342 DCHECK(!overflow_dst.is(t9));
4343 mov(t9, right);
4344 right = t9;
4345 }
4346 4372
4347 if (dst.is(left)) { 4373 if (dst.is(left)) {
4348 mov(scratch, left); // Preserve left. 4374 mov(scratch, left); // Preserve left.
4349 addu(dst, left, right); // Left is overwritten. 4375 addu(dst, left, right); // Left is overwritten.
4350 xor_(scratch, dst, scratch); // Original left. 4376 xor_(scratch, dst, scratch); // Original left.
4351 xor_(overflow_dst, dst, right); 4377 xor_(overflow_dst, dst, right);
4352 and_(overflow_dst, overflow_dst, scratch); 4378 and_(overflow_dst, overflow_dst, scratch);
4353 } else if (dst.is(right)) { 4379 } else if (dst.is(right)) {
4354 mov(scratch, right); // Preserve right. 4380 mov(scratch, right); // Preserve right.
4355 addu(dst, left, right); // Right is overwritten. 4381 addu(dst, left, right); // Right is overwritten.
4356 xor_(scratch, dst, scratch); // Original right. 4382 xor_(scratch, dst, scratch); // Original right.
4357 xor_(overflow_dst, dst, left); 4383 xor_(overflow_dst, dst, left);
4358 and_(overflow_dst, overflow_dst, scratch); 4384 and_(overflow_dst, overflow_dst, scratch);
4359 } else { 4385 } else {
4360 addu(dst, left, right); 4386 addu(dst, left, right);
4361 xor_(overflow_dst, dst, left); 4387 xor_(overflow_dst, dst, left);
4362 xor_(scratch, dst, right); 4388 xor_(scratch, dst, right);
4363 and_(overflow_dst, scratch, overflow_dst); 4389 and_(overflow_dst, scratch, overflow_dst);
4390 }
4391 if (!overflow_label) {
4392 DCHECK(no_overflow_label);
4393 Branch(no_overflow_label, ge, overflow_dst, Operand(zero_reg));
4394 } else {
4395 Branch(overflow_label, lt, overflow_dst, Operand(zero_reg));
4396 if (no_overflow_label) bc(no_overflow_label);
4397 }
4364 } 4398 }
4365 } 4399 }
4366 4400
4367 4401
4368 void MacroAssembler::SubuAndCheckForOverflow(Register dst, Register left, 4402 void MacroAssembler::SubuAndCheckForOverflow(Register dst, Register left,
4369 const Operand& right, 4403 const Operand& right,
4370 Register overflow_dst, 4404 Register overflow_dst,
4371 Register scratch) { 4405 Register scratch) {
4372 if (right.is_reg()) { 4406 if (right.is_reg()) {
4373 SubuAndCheckForOverflow(dst, left, right.rm(), overflow_dst, scratch); 4407 SubuAndCheckForOverflow(dst, left, right.rm(), overflow_dst, scratch);
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
5853 if (mag.shift > 0) sra(result, result, mag.shift); 5887 if (mag.shift > 0) sra(result, result, mag.shift);
5854 srl(at, dividend, 31); 5888 srl(at, dividend, 31);
5855 Addu(result, result, Operand(at)); 5889 Addu(result, result, Operand(at));
5856 } 5890 }
5857 5891
5858 5892
5859 } // namespace internal 5893 } // namespace internal
5860 } // namespace v8 5894 } // namespace v8
5861 5895
5862 #endif // V8_TARGET_ARCH_MIPS 5896 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« src/mips/macro-assembler-mips.h ('K') | « src/mips/macro-assembler-mips.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698