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

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

Issue 2066483008: MIPS: Followup '[turbofan] Introduce new operators Float32SubPreserveNan and Float64SubPreserveNan'. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
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 #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"
11 #include "src/codegen.h" 11 #include "src/codegen.h"
12 #include "src/debug/debug.h" 12 #include "src/debug/debug.h"
13 #include "src/mips64/macro-assembler-mips64.h" 13 #include "src/mips64/macro-assembler-mips64.h"
14 #include "src/register-configuration.h" 14 #include "src/register-configuration.h"
15 #include "src/runtime/runtime.h" 15 #include "src/runtime/runtime.h"
16 16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 19
20 // Floating point constants.
21 const uint32_t kDoubleExponentShift = HeapNumber::kMantissaBits;
22 const uint32_t kDoubleNaNShift = kDoubleExponentShift - 1;
23 const uint64_t kDoubleNaNMask =
24 (HeapNumber::kExponentMask | (1L << (HeapNumber::kExponentShift - 1)))
25 << 32;
26
27 const uint32_t kSingleExponentMask = kBinary32ExponentMask;
28 const uint32_t kSingleExponentShift = kBinary32ExponentShift;
29 const uint32_t kSingleNaNShift = kSingleExponentShift - 1;
30 const uint32_t kSingleNaNMask = kSingleExponentMask | (1 << kSingleNaNShift);
31
20 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size, 32 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size,
21 CodeObjectRequired create_code_object) 33 CodeObjectRequired create_code_object)
22 : Assembler(arg_isolate, buffer, size), 34 : Assembler(arg_isolate, buffer, size),
23 generating_stub_(false), 35 generating_stub_(false),
24 has_frame_(false), 36 has_frame_(false),
25 has_double_zero_reg_set_(false) { 37 has_double_zero_reg_set_(false) {
26 if (create_code_object == CodeObjectRequired::kYes) { 38 if (create_code_object == CodeObjectRequired::kYes) {
27 code_object_ = 39 code_object_ =
28 Handle<Object>::New(isolate()->heap()->undefined_value(), isolate()); 40 Handle<Object>::New(isolate()->heap()->undefined_value(), isolate());
29 } 41 }
(...skipping 4817 matching lines...) Expand 10 before | Expand all | Expand 10 after
4847 bind(&done); 4859 bind(&done);
4848 Daddu(scratch1, elements_reg, 4860 Daddu(scratch1, elements_reg,
4849 Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag - 4861 Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag -
4850 elements_offset)); 4862 elements_offset));
4851 dsra(scratch2, key_reg, 32 - kDoubleSizeLog2); 4863 dsra(scratch2, key_reg, 32 - kDoubleSizeLog2);
4852 Daddu(scratch1, scratch1, scratch2); 4864 Daddu(scratch1, scratch1, scratch2);
4853 // scratch1 is now effective address of the double element. 4865 // scratch1 is now effective address of the double element.
4854 sdc1(double_result, MemOperand(scratch1, 0)); 4866 sdc1(double_result, MemOperand(scratch1, 0));
4855 } 4867 }
4856 4868
4869 void MacroAssembler::SubNanPreservePayloadAndSign_s(FPURegister fd,
4870 FPURegister fs,
4871 FPURegister ft) {
4872 FloatRegister dest = fd.is(fs) || fd.is(ft) ? kLithiumScratchDouble : fd;
4873 Label check_nan, save_payload, done;
4874 Register scratch1 = t8;
4875 Register scratch2 = t9;
4876
4877 sub_s(dest, fs, ft);
4878 // Check if the result of subtraction is NaN.
4879 BranchF32(nullptr, &check_nan, eq, fs, ft);
4880 Branch(USE_DELAY_SLOT, &done);
4881 dest.is(fd) ? nop() : mov_s(fd, dest);
4882
4883 bind(&check_nan);
4884 // Check if first operand is a NaN.
4885 mfc1(scratch1, fs);
4886 BranchF32(nullptr, &save_payload, eq, fs, fs);
4887 // Second operand must be a NaN.
4888 mfc1(scratch1, ft);
4889
4890 bind(&save_payload);
4891 // Reserve payload.
4892 And(scratch1, scratch1, Operand((1 << kSingleNaNShift) - 1));
4893 mfc1(scratch2, dest);
4894 And(scratch2, scratch2, Operand(kSingleNaNMask));
4895 Or(scratch2, scratch2, scratch1);
4896 #if !USE_SIMULATOR
4897 if (kArchVariant == kMips64r6) {
4898 // make NaN quiet.
4899 Or(scratch2, scratch2, Operand(1 << kSingleNaNShift));
4900 }
4901 #endif
4902 mtc1(scratch2, fd);
4903
4904 bind(&done);
4905 }
4906
4907 void MacroAssembler::SubNanPreservePayloadAndSign_d(FPURegister fd,
4908 FPURegister fs,
4909 FPURegister ft) {
4910 FloatRegister dest = fd.is(fs) || fd.is(ft) ? kLithiumScratchDouble : fd;
4911 Label check_nan, save_payload, done;
4912 Register scratch1 = t8;
4913 Register scratch2 = t9;
4914
4915 sub_d(dest, fs, ft);
4916 // Check if the result of subtraction is NaN.
4917 BranchF64(nullptr, &check_nan, eq, fs, ft);
4918 Branch(USE_DELAY_SLOT, &done);
4919 dest.is(fd) ? nop() : mov_d(fd, dest);
4920
4921 bind(&check_nan);
4922 // Check if first operand is a NaN.
4923 dmfc1(scratch1, fs);
4924 BranchF64(nullptr, &save_payload, eq, fs, fs);
4925 // Second operand must be a NaN.
4926 dmfc1(scratch1, ft);
4927
4928 bind(&save_payload);
4929 // Reserve payload.
4930 li(at, Operand(1L << kDoubleNaNShift));
4931 Dsubu(at, at, Operand(1));
4932 And(scratch1, scratch1, at);
4933 dmfc1(scratch2, dest);
4934 And(scratch2, scratch2, Operand(kDoubleNaNMask));
4935 Or(scratch2, scratch2, scratch1);
4936 #if !USE_SIMULATOR
4937 if (kArchVariant == kMips64r6) {
4938 // make NaN quiet.
4939 Or(scratch2, scratch2, Operand(1L << kDoubleNaNShift));
4940 }
4941 #endif
4942 dmtc1(scratch2, fd);
4943
4944 bind(&done);
4945 }
4857 4946
4858 void MacroAssembler::CompareMapAndBranch(Register obj, 4947 void MacroAssembler::CompareMapAndBranch(Register obj,
4859 Register scratch, 4948 Register scratch,
4860 Handle<Map> map, 4949 Handle<Map> map,
4861 Label* early_success, 4950 Label* early_success,
4862 Condition cond, 4951 Condition cond,
4863 Label* branch_to) { 4952 Label* branch_to) {
4864 ld(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); 4953 ld(scratch, FieldMemOperand(obj, HeapObject::kMapOffset));
4865 CompareMapAndBranch(scratch, map, early_success, cond, branch_to); 4954 CompareMapAndBranch(scratch, map, early_success, cond, branch_to);
4866 } 4955 }
(...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after
7143 if (mag.shift > 0) sra(result, result, mag.shift); 7232 if (mag.shift > 0) sra(result, result, mag.shift);
7144 srl(at, dividend, 31); 7233 srl(at, dividend, 31);
7145 Addu(result, result, Operand(at)); 7234 Addu(result, result, Operand(at));
7146 } 7235 }
7147 7236
7148 7237
7149 } // namespace internal 7238 } // namespace internal
7150 } // namespace v8 7239 } // namespace v8
7151 7240
7152 #endif // V8_TARGET_ARCH_MIPS64 7241 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698