OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 #include "src/base/division-by-constant.h" | 9 #include "src/base/division-by-constant.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2355 | 2355 |
2356 void MacroAssembler::Movt(Register rd, Register rs, uint16_t cc) { | 2356 void MacroAssembler::Movt(Register rd, Register rs, uint16_t cc) { |
2357 movt(rd, rs, cc); | 2357 movt(rd, rs, cc); |
2358 } | 2358 } |
2359 | 2359 |
2360 | 2360 |
2361 void MacroAssembler::Movf(Register rd, Register rs, uint16_t cc) { | 2361 void MacroAssembler::Movf(Register rd, Register rs, uint16_t cc) { |
2362 movf(rd, rs, cc); | 2362 movf(rd, rs, cc); |
2363 } | 2363 } |
2364 | 2364 |
| 2365 #define __ masm-> |
| 2366 |
| 2367 static bool ZeroHelper_d(MacroAssembler* masm, MaxMinKind kind, FPURegister dst, |
| 2368 FPURegister src1, FPURegister src2, Label* equal) { |
| 2369 if (src1.is(src2)) { |
| 2370 __ Move(dst, src1); |
| 2371 return true; |
| 2372 } |
| 2373 |
| 2374 Label other, compare_not_equal; |
| 2375 FPURegister left, right; |
| 2376 if (kind == MaxMinKind::kMin) { |
| 2377 left = src1; |
| 2378 right = src2; |
| 2379 } else { |
| 2380 left = src2; |
| 2381 right = src1; |
| 2382 } |
| 2383 |
| 2384 __ BranchF64(&compare_not_equal, nullptr, ne, src1, src2); |
| 2385 // Left and right hand side are equal, check for -0 vs. +0. |
| 2386 __ dmfc1(t8, src1); |
| 2387 __ Branch(&other, eq, t8, Operand(0x8000000000000000)); |
| 2388 __ Move_d(dst, right); |
| 2389 __ Branch(equal); |
| 2390 __ bind(&other); |
| 2391 __ Move_d(dst, left); |
| 2392 __ Branch(equal); |
| 2393 __ bind(&compare_not_equal); |
| 2394 return false; |
| 2395 } |
| 2396 |
| 2397 static bool ZeroHelper_s(MacroAssembler* masm, MaxMinKind kind, FPURegister dst, |
| 2398 FPURegister src1, FPURegister src2, Label* equal) { |
| 2399 if (src1.is(src2)) { |
| 2400 __ Move(dst, src1); |
| 2401 return true; |
| 2402 } |
| 2403 |
| 2404 Label other, compare_not_equal; |
| 2405 FPURegister left, right; |
| 2406 if (kind == MaxMinKind::kMin) { |
| 2407 left = src1; |
| 2408 right = src2; |
| 2409 } else { |
| 2410 left = src2; |
| 2411 right = src1; |
| 2412 } |
| 2413 |
| 2414 __ BranchF32(&compare_not_equal, nullptr, ne, src1, src2); |
| 2415 // Left and right hand side are equal, check for -0 vs. +0. |
| 2416 __ FmoveLow(t8, src1); |
| 2417 __ dsll32(t8, t8, 0); |
| 2418 __ Branch(&other, eq, t8, Operand(0x8000000000000000)); |
| 2419 __ Move_s(dst, right); |
| 2420 __ Branch(equal); |
| 2421 __ bind(&other); |
| 2422 __ Move_s(dst, left); |
| 2423 __ Branch(equal); |
| 2424 __ bind(&compare_not_equal); |
| 2425 return false; |
| 2426 } |
| 2427 |
| 2428 #undef __ |
| 2429 |
| 2430 void MacroAssembler::MinNaNCheck_d(FPURegister dst, FPURegister src1, |
| 2431 FPURegister src2, Label* nan) { |
| 2432 if (nan) { |
| 2433 BranchF64(nullptr, nan, eq, src1, src2); |
| 2434 } |
| 2435 if (kArchVariant >= kMips64r6) { |
| 2436 min_d(dst, src1, src2); |
| 2437 } else { |
| 2438 Label skip; |
| 2439 if (!ZeroHelper_d(this, MaxMinKind::kMin, dst, src1, src2, &skip)) { |
| 2440 if (dst.is(src1)) { |
| 2441 BranchF64(&skip, nullptr, le, src1, src2); |
| 2442 Move_d(dst, src2); |
| 2443 } else if (dst.is(src2)) { |
| 2444 BranchF64(&skip, nullptr, ge, src1, src2); |
| 2445 Move_d(dst, src1); |
| 2446 } else { |
| 2447 Label right; |
| 2448 BranchF64(&right, nullptr, gt, src1, src2); |
| 2449 Move_d(dst, src1); |
| 2450 Branch(&skip); |
| 2451 bind(&right); |
| 2452 Move_d(dst, src2); |
| 2453 } |
| 2454 } |
| 2455 bind(&skip); |
| 2456 } |
| 2457 } |
| 2458 |
| 2459 void MacroAssembler::MaxNaNCheck_d(FPURegister dst, FPURegister src1, |
| 2460 FPURegister src2, Label* nan) { |
| 2461 if (nan) { |
| 2462 BranchF64(nullptr, nan, eq, src1, src2); |
| 2463 } |
| 2464 if (kArchVariant >= kMips64r6) { |
| 2465 max_d(dst, src1, src2); |
| 2466 } else { |
| 2467 Label skip; |
| 2468 if (!ZeroHelper_d(this, MaxMinKind::kMax, dst, src1, src2, &skip)) { |
| 2469 if (dst.is(src1)) { |
| 2470 BranchF64(&skip, nullptr, ge, src1, src2); |
| 2471 Move_d(dst, src2); |
| 2472 } else if (dst.is(src2)) { |
| 2473 BranchF64(&skip, nullptr, le, src1, src2); |
| 2474 Move_d(dst, src1); |
| 2475 } else { |
| 2476 Label right; |
| 2477 BranchF64(&right, nullptr, lt, src1, src2); |
| 2478 Move_d(dst, src1); |
| 2479 Branch(&skip); |
| 2480 bind(&right); |
| 2481 Move_d(dst, src2); |
| 2482 } |
| 2483 } |
| 2484 bind(&skip); |
| 2485 } |
| 2486 } |
| 2487 |
| 2488 void MacroAssembler::MinNaNCheck_s(FPURegister dst, FPURegister src1, |
| 2489 FPURegister src2, Label* nan) { |
| 2490 if (nan) { |
| 2491 BranchF32(nullptr, nan, eq, src1, src2); |
| 2492 } |
| 2493 if (kArchVariant >= kMips64r6) { |
| 2494 min_s(dst, src1, src2); |
| 2495 } else { |
| 2496 Label skip; |
| 2497 if (!ZeroHelper_s(this, MaxMinKind::kMin, dst, src1, src2, &skip)) { |
| 2498 if (dst.is(src1)) { |
| 2499 BranchF32(&skip, nullptr, le, src1, src2); |
| 2500 Move_s(dst, src2); |
| 2501 } else if (dst.is(src2)) { |
| 2502 BranchF32(&skip, nullptr, ge, src1, src2); |
| 2503 Move_s(dst, src1); |
| 2504 } else { |
| 2505 Label right; |
| 2506 BranchF32(&right, nullptr, gt, src1, src2); |
| 2507 Move_s(dst, src1); |
| 2508 Branch(&skip); |
| 2509 bind(&right); |
| 2510 Move_s(dst, src2); |
| 2511 } |
| 2512 } |
| 2513 bind(&skip); |
| 2514 } |
| 2515 } |
| 2516 |
| 2517 void MacroAssembler::MaxNaNCheck_s(FPURegister dst, FPURegister src1, |
| 2518 FPURegister src2, Label* nan) { |
| 2519 if (nan) { |
| 2520 BranchF32(nullptr, nan, eq, src1, src2); |
| 2521 } |
| 2522 if (kArchVariant >= kMips64r6) { |
| 2523 max_s(dst, src1, src2); |
| 2524 } else { |
| 2525 Label skip; |
| 2526 if (!ZeroHelper_s(this, MaxMinKind::kMax, dst, src1, src2, &skip)) { |
| 2527 if (dst.is(src1)) { |
| 2528 BranchF32(&skip, nullptr, ge, src1, src2); |
| 2529 Move_s(dst, src2); |
| 2530 } else if (dst.is(src2)) { |
| 2531 BranchF32(&skip, nullptr, le, src1, src2); |
| 2532 Move_s(dst, src1); |
| 2533 } else { |
| 2534 Label right; |
| 2535 BranchF32(&right, nullptr, lt, src1, src2); |
| 2536 Move_s(dst, src1); |
| 2537 Branch(&skip); |
| 2538 bind(&right); |
| 2539 Move_s(dst, src2); |
| 2540 } |
| 2541 } |
| 2542 bind(&skip); |
| 2543 } |
| 2544 } |
2365 | 2545 |
2366 void MacroAssembler::Clz(Register rd, Register rs) { | 2546 void MacroAssembler::Clz(Register rd, Register rs) { |
2367 clz(rd, rs); | 2547 clz(rd, rs); |
2368 } | 2548 } |
2369 | 2549 |
2370 | 2550 |
2371 void MacroAssembler::EmitFPUTruncate(FPURoundingMode rounding_mode, | 2551 void MacroAssembler::EmitFPUTruncate(FPURoundingMode rounding_mode, |
2372 Register result, | 2552 Register result, |
2373 DoubleRegister double_input, | 2553 DoubleRegister double_input, |
2374 Register scratch, | 2554 Register scratch, |
(...skipping 4328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6703 if (mag.shift > 0) sra(result, result, mag.shift); | 6883 if (mag.shift > 0) sra(result, result, mag.shift); |
6704 srl(at, dividend, 31); | 6884 srl(at, dividend, 31); |
6705 Addu(result, result, Operand(at)); | 6885 Addu(result, result, Operand(at)); |
6706 } | 6886 } |
6707 | 6887 |
6708 | 6888 |
6709 } // namespace internal | 6889 } // namespace internal |
6710 } // namespace v8 | 6890 } // namespace v8 |
6711 | 6891 |
6712 #endif // V8_TARGET_ARCH_MIPS64 | 6892 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |