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

Side by Side Diff: src/compiler/mips64/code-generator-mips64.cc

Issue 1477043004: MIPS: [turbofan] Implement Float32Round(TiesEven|RoundUp|RoundDown|Truncate). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 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 "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 #include "src/compiler/code-generator-impl.h" 6 #include "src/compiler/code-generator-impl.h"
7 #include "src/compiler/gap-resolver.h" 7 #include "src/compiler/gap-resolver.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/osr.h" 9 #include "src/compiler/osr.h"
10 #include "src/mips/macro-assembler-mips.h" 10 #include "src/mips/macro-assembler-mips.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 __ dsrl(at, kScratchReg, 31); 185 __ dsrl(at, kScratchReg, 31);
186 __ dsll(at, at, 31); 186 __ dsll(at, at, 31);
187 __ mthc1(at, result_); 187 __ mthc1(at, result_);
188 } 188 }
189 189
190 private: 190 private:
191 DoubleRegister const result_; 191 DoubleRegister const result_;
192 }; 192 };
193 193
194 194
195 class OutOfLineRound32 : public OutOfLineCode {
196 public:
197 OutOfLineRound32(CodeGenerator* gen, DoubleRegister result)
198 : OutOfLineCode(gen), result_(result) {}
199
200 void Generate() final {
201 // Handle rounding to zero case where sign has to be preserved.
202 // High bits of float input already in kScratchReg.
203 __ srl(at, kScratchReg, 31);
204 __ sll(at, at, 31);
205 __ mtc1(at, result_);
206 }
207
208 private:
209 DoubleRegister const result_;
210 };
211
212
195 class OutOfLineTruncate final : public OutOfLineRound { 213 class OutOfLineTruncate final : public OutOfLineRound {
196 public: 214 public:
197 OutOfLineTruncate(CodeGenerator* gen, DoubleRegister result) 215 OutOfLineTruncate(CodeGenerator* gen, DoubleRegister result)
198 : OutOfLineRound(gen, result) {} 216 : OutOfLineRound(gen, result) {}
199 }; 217 };
200 218
201 219
202 class OutOfLineFloor final : public OutOfLineRound { 220 class OutOfLineFloor final : public OutOfLineRound {
203 public: 221 public:
204 OutOfLineFloor(CodeGenerator* gen, DoubleRegister result) 222 OutOfLineFloor(CodeGenerator* gen, DoubleRegister result)
205 : OutOfLineRound(gen, result) {} 223 : OutOfLineRound(gen, result) {}
206 }; 224 };
207 225
208 226
209 class OutOfLineCeil final : public OutOfLineRound { 227 class OutOfLineCeil final : public OutOfLineRound {
210 public: 228 public:
211 OutOfLineCeil(CodeGenerator* gen, DoubleRegister result) 229 OutOfLineCeil(CodeGenerator* gen, DoubleRegister result)
212 : OutOfLineRound(gen, result) {} 230 : OutOfLineRound(gen, result) {}
213 }; 231 };
214 232
215 233
216 class OutOfLineTiesEven final : public OutOfLineRound { 234 class OutOfLineTiesEven final : public OutOfLineRound {
217 public: 235 public:
218 OutOfLineTiesEven(CodeGenerator* gen, DoubleRegister result) 236 OutOfLineTiesEven(CodeGenerator* gen, DoubleRegister result)
219 : OutOfLineRound(gen, result) {} 237 : OutOfLineRound(gen, result) {}
220 }; 238 };
221 239
240 class OutOfLineTruncate32 final : public OutOfLineRound32 {
titzer 2015/11/26 08:43:03 Looks like the out of line code is exactly the sam
dusan.milosavljevic 2015/11/26 12:52:37 Right, too much duplicated code.
dusan.milosavljevic 2015/11/26 12:52:37 Done.
241 public:
242 OutOfLineTruncate32(CodeGenerator* gen, DoubleRegister result)
243 : OutOfLineRound32(gen, result) {}
244 };
245
246
247 class OutOfLineFloor32 final : public OutOfLineRound32 {
248 public:
249 OutOfLineFloor32(CodeGenerator* gen, DoubleRegister result)
250 : OutOfLineRound32(gen, result) {}
251 };
252
253
254 class OutOfLineCeil32 final : public OutOfLineRound32 {
255 public:
256 OutOfLineCeil32(CodeGenerator* gen, DoubleRegister result)
257 : OutOfLineRound32(gen, result) {}
258 };
259
260
261 class OutOfLineTiesEven32 final : public OutOfLineRound32 {
262 public:
263 OutOfLineTiesEven32(CodeGenerator* gen, DoubleRegister result)
264 : OutOfLineRound32(gen, result) {}
265 };
266
222 267
223 class OutOfLineRecordWrite final : public OutOfLineCode { 268 class OutOfLineRecordWrite final : public OutOfLineCode {
224 public: 269 public:
225 OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index, 270 OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index,
226 Register value, Register scratch0, Register scratch1, 271 Register value, Register scratch0, Register scratch1,
227 RecordWriteMode mode) 272 RecordWriteMode mode)
228 : OutOfLineCode(gen), 273 : OutOfLineCode(gen),
229 object_(object), 274 object_(object),
230 index_(index), 275 index_(index),
231 value_(value), 276 value_(value),
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 Operand(HeapNumber::kExponentBias + HeapNumber::kMantissaBits)); \ 490 Operand(HeapNumber::kExponentBias + HeapNumber::kMantissaBits)); \
446 __ mov_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ 491 __ mov_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \
447 __ asm_instr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ 492 __ asm_instr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \
448 __ dmfc1(at, i.OutputDoubleRegister()); \ 493 __ dmfc1(at, i.OutputDoubleRegister()); \
449 __ Branch(USE_DELAY_SLOT, ool->entry(), eq, at, Operand(zero_reg)); \ 494 __ Branch(USE_DELAY_SLOT, ool->entry(), eq, at, Operand(zero_reg)); \
450 __ cvt_d_l(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ 495 __ cvt_d_l(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \
451 __ bind(ool->exit()); \ 496 __ bind(ool->exit()); \
452 __ bind(&done); \ 497 __ bind(&done); \
453 } while (0) 498 } while (0)
454 499
500 #define ASSEMBLE_ROUND_FLOAT_TO_FLOAT(asm_instr, operation) \
501 do { \
502 int32_t kFloat32ExponentBias = 127; \
503 int32_t kFloat32MantissaBits = 23; \
504 int32_t kFloat32ExponentBits = 8; \
505 auto ool = \
506 new (zone()) OutOfLine##operation##32(this, i.OutputDoubleRegister()); \
507 Label done; \
508 __ mfc1(kScratchReg, i.InputDoubleRegister(0)); \
509 __ Ext(at, kScratchReg, kFloat32MantissaBits, kFloat32ExponentBits); \
510 __ Branch(USE_DELAY_SLOT, &done, hs, at, \
511 Operand(kFloat32ExponentBias + kFloat32MantissaBits)); \
512 __ mov_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \
513 __ asm_instr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \
514 __ mfc1(at, i.OutputDoubleRegister()); \
515 __ Branch(USE_DELAY_SLOT, ool->entry(), eq, at, Operand(zero_reg)); \
516 __ cvt_s_w(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \
517 __ bind(ool->exit()); \
518 __ bind(&done); \
519 } while (0)
455 520
456 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { 521 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) {
457 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); 522 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta);
458 if (sp_slot_delta > 0) { 523 if (sp_slot_delta > 0) {
459 __ daddiu(sp, sp, sp_slot_delta * kPointerSize); 524 __ daddiu(sp, sp, sp_slot_delta * kPointerSize);
460 } 525 }
461 if (frame()->needs_frame()) { 526 if (frame()->needs_frame()) {
462 __ Pop(ra, fp); 527 __ Pop(ra, fp);
463 } 528 }
464 frame_access_state()->SetFrameAccessToDefault(); 529 frame_access_state()->SetFrameAccessToDefault();
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 i.InputDoubleRegister(1)); 938 i.InputDoubleRegister(1));
874 break; 939 break;
875 case kMips64MinD: 940 case kMips64MinD:
876 __ min_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), 941 __ min_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0),
877 i.InputDoubleRegister(1)); 942 i.InputDoubleRegister(1));
878 break; 943 break;
879 case kMips64Float64RoundDown: { 944 case kMips64Float64RoundDown: {
880 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(floor_l_d, Floor); 945 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(floor_l_d, Floor);
881 break; 946 break;
882 } 947 }
948 case kMips64Float32RoundDown: {
949 ASSEMBLE_ROUND_FLOAT_TO_FLOAT(floor_w_s, Floor);
950 break;
951 }
883 case kMips64Float64RoundTruncate: { 952 case kMips64Float64RoundTruncate: {
884 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(trunc_l_d, Truncate); 953 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(trunc_l_d, Truncate);
885 break; 954 break;
886 } 955 }
956 case kMips64Float32RoundTruncate: {
957 ASSEMBLE_ROUND_FLOAT_TO_FLOAT(trunc_w_s, Truncate);
958 break;
959 }
887 case kMips64Float64RoundUp: { 960 case kMips64Float64RoundUp: {
888 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(ceil_l_d, Ceil); 961 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(ceil_l_d, Ceil);
889 break; 962 break;
890 } 963 }
964 case kMips64Float32RoundUp: {
965 ASSEMBLE_ROUND_FLOAT_TO_FLOAT(ceil_w_s, Ceil);
966 break;
967 }
891 case kMips64Float64RoundTiesEven: { 968 case kMips64Float64RoundTiesEven: {
892 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(round_l_d, TiesEven); 969 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(round_l_d, TiesEven);
893 break; 970 break;
894 } 971 }
972 case kMips64Float32RoundTiesEven: {
973 ASSEMBLE_ROUND_FLOAT_TO_FLOAT(round_w_s, TiesEven);
974 break;
975 }
895 case kMips64Float64Max: { 976 case kMips64Float64Max: {
896 // (b < a) ? a : b 977 // (b < a) ? a : b
897 if (kArchVariant == kMips64r6) { 978 if (kArchVariant == kMips64r6) {
898 __ cmp_d(OLT, i.OutputDoubleRegister(), i.InputDoubleRegister(1), 979 __ cmp_d(OLT, i.OutputDoubleRegister(), i.InputDoubleRegister(1),
899 i.InputDoubleRegister(0)); 980 i.InputDoubleRegister(0));
900 __ sel_d(i.OutputDoubleRegister(), i.InputDoubleRegister(1), 981 __ sel_d(i.OutputDoubleRegister(), i.InputDoubleRegister(1),
901 i.InputDoubleRegister(0)); 982 i.InputDoubleRegister(0));
902 } else { 983 } else {
903 __ c_d(OLT, i.InputDoubleRegister(0), i.InputDoubleRegister(1)); 984 __ c_d(OLT, i.InputDoubleRegister(0), i.InputDoubleRegister(1));
904 // Left operand is result, passthrough if false. 985 // Left operand is result, passthrough if false.
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 padding_size -= v8::internal::Assembler::kInstrSize; 1809 padding_size -= v8::internal::Assembler::kInstrSize;
1729 } 1810 }
1730 } 1811 }
1731 } 1812 }
1732 1813
1733 #undef __ 1814 #undef __
1734 1815
1735 } // namespace compiler 1816 } // namespace compiler
1736 } // namespace internal 1817 } // namespace internal
1737 } // namespace v8 1818 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/mips/instruction-selector-mips.cc ('k') | src/compiler/mips64/instruction-codes-mips64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698