| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 <assert.h> // For assert | 5 #include <assert.h> // For assert |
| 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_S390 | 8 #if V8_TARGET_ARCH_S390 |
| 9 | 9 |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2400 // Test for exactness | 2400 // Test for exactness |
| 2401 lgdr(scratch, double_scratch); | 2401 lgdr(scratch, double_scratch); |
| 2402 cdfbr(double_scratch, scratch); | 2402 cdfbr(double_scratch, scratch); |
| 2403 cdbr(double_scratch, double_input); | 2403 cdbr(double_scratch, double_input); |
| 2404 beq(exact); | 2404 beq(exact); |
| 2405 b(done); | 2405 b(done); |
| 2406 | 2406 |
| 2407 bind(&exception); | 2407 bind(&exception); |
| 2408 } | 2408 } |
| 2409 | 2409 |
| 2410 void MacroAssembler::FloatCeiling32(DoubleRegister double_output, | |
| 2411 DoubleRegister double_input, | |
| 2412 Register scratch, | |
| 2413 DoubleRegister double_scratch) { | |
| 2414 Label not_zero, no_nan_inf, done, do_ceil; | |
| 2415 Register scratch2 = r0; | |
| 2416 | |
| 2417 // Move high word into scratch | |
| 2418 MovFloatToInt(scratch, double_input); | |
| 2419 | |
| 2420 // Test for NaN/Inf which results in NaN/Inf respectively | |
| 2421 static const uint32_t float32ExponentMask = 0x7f800000u; | |
| 2422 ExtractBitMask(scratch2, scratch, float32ExponentMask); | |
| 2423 CmpLogical32(scratch2, Operand(0xff)); | |
| 2424 bne(&no_nan_inf, Label::kNear); | |
| 2425 Move(double_output, double_input); | |
| 2426 b(&done); | |
| 2427 bind(&no_nan_inf); | |
| 2428 | |
| 2429 // Test for double_input in (-1, -0) which results in -0 | |
| 2430 LoadFloat32Literal(double_scratch, -1.0, scratch2); | |
| 2431 cebr(double_input, double_scratch); | |
| 2432 ble(&do_ceil, Label::kNear); | |
| 2433 Cmp32(scratch, Operand::Zero()); | |
| 2434 bgt(&do_ceil, Label::kNear); | |
| 2435 bne(¬_zero, Label::kNear); | |
| 2436 | |
| 2437 // double_input = +/- 0 which results in +/- 0 respectively | |
| 2438 Move(double_output, double_input); | |
| 2439 b(&done); | |
| 2440 bind(¬_zero); | |
| 2441 | |
| 2442 // double_output = -0 | |
| 2443 llihf(scratch2, Operand(0x80000000)); | |
| 2444 ldgr(double_output, scratch2); | |
| 2445 b(&done); | |
| 2446 bind(&do_ceil); | |
| 2447 | |
| 2448 // Regular case | |
| 2449 // cgdbr(Condition(6), scratch, double_input); | |
| 2450 // cdfbr(double_output, scratch); | |
| 2451 fiebra(double_output, double_input, FIDBRA_ROUND_TOWARD_POS_INF); | |
| 2452 bind(&done); | |
| 2453 } | |
| 2454 | |
| 2455 void MacroAssembler::FloatFloor32(DoubleRegister double_output, | |
| 2456 DoubleRegister double_input, | |
| 2457 Register scratch) { | |
| 2458 Label not_zero, no_nan_inf, done, do_floor; | |
| 2459 Register scratch2 = r0; | |
| 2460 | |
| 2461 // Move high word into scratch | |
| 2462 MovFloatToInt(scratch, double_input); | |
| 2463 | |
| 2464 // Test for NaN/Inf which results in NaN/Inf respectively | |
| 2465 static const uint32_t float32ExponentMask = 0x7f800000u; | |
| 2466 ExtractBitMask(scratch2, scratch, float32ExponentMask); | |
| 2467 CmpLogical32(scratch2, Operand(0xff)); | |
| 2468 bne(&no_nan_inf, Label::kNear); | |
| 2469 Move(double_output, double_input); | |
| 2470 b(&done); | |
| 2471 bind(&no_nan_inf); | |
| 2472 | |
| 2473 // Test for double_input=+/- 0 which results in +/- 0 respectively | |
| 2474 ltebr(double_input, double_input); | |
| 2475 bne(&do_floor, Label::kNear); | |
| 2476 Move(double_output, double_input); | |
| 2477 b(&done); | |
| 2478 bind(&do_floor); | |
| 2479 | |
| 2480 // Regular case | |
| 2481 // cgdbr(Condition(7), scratch, double_input); | |
| 2482 // cdfbr(double_output, scratch); | |
| 2483 fiebra(double_output, double_input, FIDBRA_ROUND_TOWARD_NEG_INF); | |
| 2484 bind(&done); | |
| 2485 } | |
| 2486 | |
| 2487 void MacroAssembler::FloatCeiling64(DoubleRegister double_output, | |
| 2488 DoubleRegister double_input, | |
| 2489 Register scratch, | |
| 2490 DoubleRegister double_scratch) { | |
| 2491 Label not_zero, no_nan_inf, done, do_ceil; | |
| 2492 Register scratch2 = r0; | |
| 2493 | |
| 2494 // Move high word into scratch | |
| 2495 StoreDouble(double_input, MemOperand(sp, -kDoubleSize)); | |
| 2496 LoadlW(scratch, MemOperand(sp, -kDoubleSize + Register::kExponentOffset)); | |
| 2497 | |
| 2498 // Test for NaN/Inf which results in NaN/Inf respectively | |
| 2499 ExtractBitMask(scratch2, scratch, HeapNumber::kExponentMask); | |
| 2500 CmpLogicalP(scratch2, Operand(0x7ff)); | |
| 2501 bne(&no_nan_inf, Label::kNear); | |
| 2502 Move(double_output, double_input); | |
| 2503 b(&done); | |
| 2504 bind(&no_nan_inf); | |
| 2505 | |
| 2506 // Test for double_input in (-1, -0) which results in -0 | |
| 2507 LoadDoubleLiteral(double_scratch, -1.0, scratch2); | |
| 2508 cdbr(double_input, double_scratch); | |
| 2509 ble(&do_ceil, Label::kNear); | |
| 2510 Cmp32(scratch, Operand::Zero()); | |
| 2511 bgt(&do_ceil, Label::kNear); | |
| 2512 bne(¬_zero, Label::kNear); | |
| 2513 | |
| 2514 // double_input = +/- 0 which results in +/- 0 respectively | |
| 2515 Move(double_output, double_input); | |
| 2516 b(&done); | |
| 2517 bind(¬_zero); | |
| 2518 | |
| 2519 // double_output = -0 | |
| 2520 llihf(scratch2, Operand(0x80000000)); | |
| 2521 ldgr(double_output, scratch2); | |
| 2522 b(&done); | |
| 2523 bind(&do_ceil); | |
| 2524 | |
| 2525 // Regular case | |
| 2526 // cgdbr(Condition(6), scratch, double_input); | |
| 2527 // cdfbr(double_output, scratch); | |
| 2528 fidbra(double_output, double_input, FIDBRA_ROUND_TOWARD_POS_INF); | |
| 2529 bind(&done); | |
| 2530 } | |
| 2531 | |
| 2532 void MacroAssembler::FloatFloor64(DoubleRegister double_output, | |
| 2533 DoubleRegister double_input, | |
| 2534 Register scratch) { | |
| 2535 Label not_zero, no_nan_inf, done, do_floor; | |
| 2536 Register scratch2 = r0; | |
| 2537 | |
| 2538 // Move high word into scratch | |
| 2539 StoreDouble(double_input, MemOperand(sp, -kDoubleSize)); | |
| 2540 LoadlW(scratch, MemOperand(sp, -kDoubleSize + Register::kExponentOffset)); | |
| 2541 | |
| 2542 // Test for NaN/Inf which results in NaN/Inf respectively | |
| 2543 ExtractBitMask(scratch2, scratch, HeapNumber::kExponentMask); | |
| 2544 CmpLogicalP(scratch2, Operand(0x7ff)); | |
| 2545 bne(&no_nan_inf, Label::kNear); | |
| 2546 Move(double_output, double_input); | |
| 2547 b(&done); | |
| 2548 bind(&no_nan_inf); | |
| 2549 | |
| 2550 // Test for double_input=+/- 0 which results in +/- 0 respectively | |
| 2551 ltdbr(double_input, double_input); | |
| 2552 bne(&do_floor, Label::kNear); | |
| 2553 Move(double_output, double_input); | |
| 2554 b(&done); | |
| 2555 bind(&do_floor); | |
| 2556 | |
| 2557 // Regular case | |
| 2558 // cgdbr(Condition(7), scratch, double_input); | |
| 2559 // cdfbr(double_output, scratch); | |
| 2560 fidbra(double_output, double_input, FIDBRA_ROUND_TOWARD_NEG_INF); | |
| 2561 bind(&done); | |
| 2562 } | |
| 2563 | |
| 2564 void MacroAssembler::TryInlineTruncateDoubleToI(Register result, | 2410 void MacroAssembler::TryInlineTruncateDoubleToI(Register result, |
| 2565 DoubleRegister double_input, | 2411 DoubleRegister double_input, |
| 2566 Label* done) { | 2412 Label* done) { |
| 2567 DoubleRegister double_scratch = kScratchDoubleReg; | 2413 DoubleRegister double_scratch = kScratchDoubleReg; |
| 2568 #if !V8_TARGET_ARCH_S390X | 2414 #if !V8_TARGET_ARCH_S390X |
| 2569 Register scratch = ip; | 2415 Register scratch = ip; |
| 2570 #endif | 2416 #endif |
| 2571 | 2417 |
| 2572 ConvertDoubleToInt64(double_input, | 2418 ConvertDoubleToInt64(double_input, |
| 2573 #if !V8_TARGET_ARCH_S390X | 2419 #if !V8_TARGET_ARCH_S390X |
| (...skipping 2979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5553 } | 5399 } |
| 5554 if (mag.shift > 0) ShiftRightArith(result, result, Operand(mag.shift)); | 5400 if (mag.shift > 0) ShiftRightArith(result, result, Operand(mag.shift)); |
| 5555 ExtractBit(r0, dividend, 31); | 5401 ExtractBit(r0, dividend, 31); |
| 5556 AddP(result, r0); | 5402 AddP(result, r0); |
| 5557 } | 5403 } |
| 5558 | 5404 |
| 5559 } // namespace internal | 5405 } // namespace internal |
| 5560 } // namespace v8 | 5406 } // namespace v8 |
| 5561 | 5407 |
| 5562 #endif // V8_TARGET_ARCH_S390 | 5408 #endif // V8_TARGET_ARCH_S390 |
| OLD | NEW |