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

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

Issue 1593313010: Revert of [turbofan] Implement rounding of floats on x64 and ia32 without sse4.1. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months 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
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if V8_TARGET_ARCH_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 574
575 void MacroAssembler::DebugBreak() { 575 void MacroAssembler::DebugBreak() {
576 Move(eax, Immediate(0)); 576 Move(eax, Immediate(0));
577 mov(ebx, Immediate(ExternalReference(Runtime::kHandleDebuggerStatement, 577 mov(ebx, Immediate(ExternalReference(Runtime::kHandleDebuggerStatement,
578 isolate()))); 578 isolate())));
579 CEntryStub ces(isolate(), 1); 579 CEntryStub ces(isolate(), 1);
580 call(ces.GetCode(), RelocInfo::DEBUGGER_STATEMENT); 580 call(ces.GetCode(), RelocInfo::DEBUGGER_STATEMENT);
581 } 581 }
582 582
583 583
584 void MacroAssembler::Cvtsi2ss(XMMRegister dst, const Operand& src) {
585 xorps(dst, dst);
586 cvtsi2ss(dst, src);
587 }
588
589
590 void MacroAssembler::Cvtsi2sd(XMMRegister dst, const Operand& src) { 584 void MacroAssembler::Cvtsi2sd(XMMRegister dst, const Operand& src) {
591 xorps(dst, dst); 585 xorps(dst, dst);
592 cvtsi2sd(dst, src); 586 cvtsi2sd(dst, src);
593 } 587 }
594 588
595 589
596 void MacroAssembler::Roundss(XMMRegister dst, XMMRegister src, Register tmp,
597 RoundingMode mode) {
598 if (CpuFeatures::IsSupported(SSE4_1)) {
599 CpuFeatureScope sse_scope(this, SSE4_1);
600 roundss(dst, src, mode);
601 } else {
602 // We have to store the original rounding mode to restore it later.
603 {
604 sub(esp, Immediate(kPointerSize * 2));
605 stmxcsr(Operand(esp, 0));
606 mov(tmp, Operand(esp, 0));
607 and_(tmp, Immediate(0xffff9fff));
608 or_(tmp, Immediate(mode << 13));
609 mov(Operand(esp, kPointerSize), tmp);
610 ldmxcsr(Operand(esp, kPointerSize));
611 }
612
613 // Do rounding by conversion to int.
614 cvtss2si(tmp, src);
615
616 Label out_of_range;
617 Label done;
618 // Check whether the input is within int32 range.
619 cmp(tmp, Immediate(1));
620 j(overflow, &out_of_range);
621 // If the conversion results in INT_MIN, then the input is outside
622 // int range, and due to the limited precision of float32 this means
623 // that the input must have been an integer already. We are therefore
624 // done already.
625 cvtsi2ss(dst, tmp);
626 if (!dst.is(src)) {
627 jmp(&done);
628 }
629
630 bind(&out_of_range);
631 if (!dst.is(src)) {
632 movss(dst, src);
633 }
634
635 bind(&done);
636 // Restore the original rounding mode.
637 ldmxcsr(Operand(esp, 0));
638 add(esp, Immediate(kPointerSize * 2));
639 }
640 }
641
642
643 void MacroAssembler::Roundsd(XMMRegister dst, XMMRegister src, Register tmp,
644 XMMRegister xtmp, RoundingMode mode) {
645 if (CpuFeatures::IsSupported(SSE4_1)) {
646 CpuFeatureScope sse_scope(this, SSE4_1);
647 roundsd(dst, src, mode);
648 } else {
649 // We have to store the original rounding mode to restore it later.
650 {
651 sub(esp, Immediate(kPointerSize * 2));
652 stmxcsr(Operand(esp, 0));
653 mov(tmp, Operand(esp, 0));
654 and_(tmp, Immediate(0xffff9fff));
655 or_(tmp, Immediate(mode << 13));
656 mov(Operand(esp, kPointerSize), tmp);
657 ldmxcsr(Operand(esp, kPointerSize));
658 }
659
660 // Convert the input to int32.
661 cvtsd2si(tmp, src);
662
663 Label out_of_range;
664 Label done;
665 // Check whether the input is within int32 range.
666 cmp(tmp, Immediate(1));
667 j(overflow, &out_of_range);
668 // The input is within int32 range. We achieve rounding by converting
669 // back to float.
670 Cvtsi2sd(dst, tmp);
671 jmp(&done);
672 bind(&out_of_range);
673 if (!dst.is(src)) {
674 movsd(dst, src);
675 }
676 // If the input is outside [-2^52, 2^52], then the result = input.
677 int64_t offset = 1;
678 offset <<= 52;
679 Move(xtmp, static_cast<double>(offset));
680
681 ucomisd(xtmp, src);
682
683 j(below_equal, &done);
684
685 Move(xtmp, static_cast<double>(-offset));
686
687 ucomisd(xtmp, src);
688 j(above_equal, &done);
689
690 // Positive number have to be handled differently than negative numbers.
691 xorpd(xtmp, xtmp);
692 ucomisd(xtmp, src);
693
694 Move(xtmp, static_cast<double>(offset));
695
696 Label below_zero;
697 j(above, &below_zero);
698
699 addsd(dst, xtmp);
700 subsd(dst, xtmp);
701 jmp(&done);
702
703 bind(&below_zero);
704 subsd(dst, xtmp);
705 addsd(dst, xtmp);
706
707 bind(&done);
708 // Restore the original rounding mode.
709 ldmxcsr(Operand(esp, 0));
710 add(esp, Immediate(kPointerSize * 2));
711 }
712 }
713
714
715 bool MacroAssembler::IsUnsafeImmediate(const Immediate& x) { 590 bool MacroAssembler::IsUnsafeImmediate(const Immediate& x) {
716 static const int kMaxImmediateBits = 17; 591 static const int kMaxImmediateBits = 17;
717 if (!RelocInfo::IsNone(x.rmode_)) return false; 592 if (!RelocInfo::IsNone(x.rmode_)) return false;
718 return !is_intn(x.x_, kMaxImmediateBits); 593 return !is_intn(x.x_, kMaxImmediateBits);
719 } 594 }
720 595
721 596
722 void MacroAssembler::SafeMove(Register dst, const Immediate& x) { 597 void MacroAssembler::SafeMove(Register dst, const Immediate& x) {
723 if (IsUnsafeImmediate(x) && jit_cookie() != 0) { 598 if (IsUnsafeImmediate(x) && jit_cookie() != 0) {
724 Move(dst, Immediate(x.x_ ^ jit_cookie())); 599 Move(dst, Immediate(x.x_ ^ jit_cookie()));
(...skipping 2516 matching lines...) Expand 10 before | Expand all | Expand 10 after
3241 mov(eax, dividend); 3116 mov(eax, dividend);
3242 shr(eax, 31); 3117 shr(eax, 31);
3243 add(edx, eax); 3118 add(edx, eax);
3244 } 3119 }
3245 3120
3246 3121
3247 } // namespace internal 3122 } // namespace internal
3248 } // namespace v8 3123 } // namespace v8
3249 3124
3250 #endif // V8_TARGET_ARCH_IA32 3125 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698