OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 // 0 indicates negative, save negative version with conditional move. | 1388 // 0 indicates negative, save negative version with conditional move. |
1389 Clz(dest, dest); | 1389 Clz(dest, dest); |
1390 Movz(scratch, scratch2, dest); | 1390 Movz(scratch, scratch2, dest); |
1391 mov(dest, scratch); | 1391 mov(dest, scratch); |
1392 } | 1392 } |
1393 bind(&done); | 1393 bind(&done); |
1394 } | 1394 } |
1395 | 1395 |
1396 | 1396 |
1397 void MacroAssembler::EmitFPUTruncate(FPURoundingMode rounding_mode, | 1397 void MacroAssembler::EmitFPUTruncate(FPURoundingMode rounding_mode, |
1398 FPURegister result, | 1398 Register result, |
1399 DoubleRegister double_input, | 1399 DoubleRegister double_input, |
1400 Register scratch1, | 1400 Register scratch, |
| 1401 DoubleRegister double_scratch, |
1401 Register except_flag, | 1402 Register except_flag, |
1402 CheckForInexactConversion check_inexact) { | 1403 CheckForInexactConversion check_inexact) { |
| 1404 ASSERT(!result.is(scratch)); |
| 1405 ASSERT(!double_input.is(double_scratch)); |
| 1406 ASSERT(!except_flag.is(scratch)); |
| 1407 |
1403 ASSERT(CpuFeatures::IsSupported(FPU)); | 1408 ASSERT(CpuFeatures::IsSupported(FPU)); |
1404 CpuFeatures::Scope scope(FPU); | 1409 CpuFeatures::Scope scope(FPU); |
| 1410 Label done; |
| 1411 |
| 1412 // Clear the except flag (0 = no exception) |
| 1413 mov(except_flag, zero_reg); |
| 1414 |
| 1415 // Test for values that can be exactly represented as a signed 32-bit integer. |
| 1416 cvt_w_d(double_scratch, double_input); |
| 1417 mfc1(result, double_scratch); |
| 1418 cvt_d_w(double_scratch, double_scratch); |
| 1419 BranchF(&done, NULL, eq, double_input, double_scratch); |
1405 | 1420 |
1406 int32_t except_mask = kFCSRFlagMask; // Assume interested in all exceptions. | 1421 int32_t except_mask = kFCSRFlagMask; // Assume interested in all exceptions. |
1407 | 1422 |
1408 if (check_inexact == kDontCheckForInexactConversion) { | 1423 if (check_inexact == kDontCheckForInexactConversion) { |
1409 // Ingore inexact exceptions. | 1424 // Ignore inexact exceptions. |
1410 except_mask &= ~kFCSRInexactFlagMask; | 1425 except_mask &= ~kFCSRInexactFlagMask; |
1411 } | 1426 } |
1412 | 1427 |
1413 // Save FCSR. | 1428 // Save FCSR. |
1414 cfc1(scratch1, FCSR); | 1429 cfc1(scratch, FCSR); |
1415 // Disable FPU exceptions. | 1430 // Disable FPU exceptions. |
1416 ctc1(zero_reg, FCSR); | 1431 ctc1(zero_reg, FCSR); |
1417 | 1432 |
1418 // Do operation based on rounding mode. | 1433 // Do operation based on rounding mode. |
1419 switch (rounding_mode) { | 1434 switch (rounding_mode) { |
1420 case kRoundToNearest: | 1435 case kRoundToNearest: |
1421 Round_w_d(result, double_input); | 1436 Round_w_d(double_scratch, double_input); |
1422 break; | 1437 break; |
1423 case kRoundToZero: | 1438 case kRoundToZero: |
1424 Trunc_w_d(result, double_input); | 1439 Trunc_w_d(double_scratch, double_input); |
1425 break; | 1440 break; |
1426 case kRoundToPlusInf: | 1441 case kRoundToPlusInf: |
1427 Ceil_w_d(result, double_input); | 1442 Ceil_w_d(double_scratch, double_input); |
1428 break; | 1443 break; |
1429 case kRoundToMinusInf: | 1444 case kRoundToMinusInf: |
1430 Floor_w_d(result, double_input); | 1445 Floor_w_d(double_scratch, double_input); |
1431 break; | 1446 break; |
1432 } // End of switch-statement. | 1447 } // End of switch-statement. |
1433 | 1448 |
1434 // Retrieve FCSR. | 1449 // Retrieve FCSR. |
1435 cfc1(except_flag, FCSR); | 1450 cfc1(except_flag, FCSR); |
1436 // Restore FCSR. | 1451 // Restore FCSR. |
1437 ctc1(scratch1, FCSR); | 1452 ctc1(scratch, FCSR); |
| 1453 // Move the converted value into the result register. |
| 1454 mfc1(result, double_scratch); |
1438 | 1455 |
1439 // Check for fpu exceptions. | 1456 // Check for fpu exceptions. |
1440 And(except_flag, except_flag, Operand(except_mask)); | 1457 And(except_flag, except_flag, Operand(except_mask)); |
| 1458 |
| 1459 bind(&done); |
1441 } | 1460 } |
1442 | 1461 |
1443 | 1462 |
1444 void MacroAssembler::EmitOutOfInt32RangeTruncate(Register result, | 1463 void MacroAssembler::EmitOutOfInt32RangeTruncate(Register result, |
1445 Register input_high, | 1464 Register input_high, |
1446 Register input_low, | 1465 Register input_low, |
1447 Register scratch) { | 1466 Register scratch) { |
1448 Label done, normal_exponent, restore_sign; | 1467 Label done, normal_exponent, restore_sign; |
1449 // Extract the biased exponent in result. | 1468 // Extract the biased exponent in result. |
1450 Ext(result, | 1469 Ext(result, |
(...skipping 4014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5465 opcode == BGTZL); | 5484 opcode == BGTZL); |
5466 opcode = (cond == eq) ? BEQ : BNE; | 5485 opcode = (cond == eq) ? BEQ : BNE; |
5467 instr = (instr & ~kOpcodeMask) | opcode; | 5486 instr = (instr & ~kOpcodeMask) | opcode; |
5468 masm_.emit(instr); | 5487 masm_.emit(instr); |
5469 } | 5488 } |
5470 | 5489 |
5471 | 5490 |
5472 } } // namespace v8::internal | 5491 } } // namespace v8::internal |
5473 | 5492 |
5474 #endif // V8_TARGET_ARCH_MIPS | 5493 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |