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

Side by Side Diff: src/mips/simulator-mips.h

Issue 2799923002: MIPS[64]: Implement fill.df, copy_u.df, copy_s.df instructions in simulator (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | src/mips/simulator-mips.cc » ('j') | src/mips/simulator-mips.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 5
6 // Declares a Simulator for MIPS instructions if we are not generating a native 6 // Declares a Simulator for MIPS instructions if we are not generating a native
7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation 7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation
8 // on regular desktop machines. 8 // on regular desktop machines.
9 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, 9 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro,
10 // which will start execution in the Simulator or forwards to the real entry 10 // which will start execution in the Simulator or forwards to the real entry
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // Coprocessor registers. 177 // Coprocessor registers.
178 // Generated code will always use doubles. So we will only use even registers. 178 // Generated code will always use doubles. So we will only use even registers.
179 enum FPURegister { 179 enum FPURegister {
180 f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, 180 f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11,
181 f12, f13, f14, f15, // f12 and f14 are arguments FPURegisters. 181 f12, f13, f14, f15, // f12 and f14 are arguments FPURegisters.
182 f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, 182 f16, f17, f18, f19, f20, f21, f22, f23, f24, f25,
183 f26, f27, f28, f29, f30, f31, 183 f26, f27, f28, f29, f30, f31,
184 kNumFPURegisters 184 kNumFPURegisters
185 }; 185 };
186 186
187 // MSA registers
188 enum MSARegister {
189 w0,
190 w1,
191 w2,
192 w3,
193 w4,
194 w5,
195 w6,
196 w7,
197 w8,
198 w9,
199 w10,
200 w11,
201 w12,
202 w13,
203 w14,
204 w15,
205 w16,
206 w17,
207 w18,
208 w19,
209 w20,
210 w21,
211 w22,
212 w23,
213 w24,
214 w25,
215 w26,
216 w27,
217 w28,
218 w29,
219 w30,
220 w31,
221 kNumMSARegisters
222 };
223
224 const uint32_t kMsaI8Mask = ((3U << 24) | ((1 << 6) - 1));
Ilija.Pavlovic1 2017/04/20 13:13:46 Should be these const definitions placed in consta
dusan.simicic 2017/04/20 15:57:42 I see now that same mask constants are defined als
225 const uint32_t kMsaI5Mask = ((7U << 23) | ((1 << 6) - 1));
226 const uint32_t kMsaMI10Mask = (15U << 2);
227 const uint32_t kMsaBITMask = ((7U << 23) | ((1 << 6) - 1));
228 const uint32_t kMsaELMMask = (15U << 22);
229 const uint32_t kMsa3RMask = ((7U << 23) | ((1 << 6) - 1));
230 const uint32_t kMsa3RFMask = ((15U << 22) | ((1 << 6) - 1));
231 const uint32_t kMsaVECMask = (23U << 21);
232 const uint32_t kMsa2RMask = (7U << 18);
233 const uint32_t kMsa2RFMask = (15U << 17);
234
187 explicit Simulator(Isolate* isolate); 235 explicit Simulator(Isolate* isolate);
188 ~Simulator(); 236 ~Simulator();
189 237
190 // The currently executing Simulator instance. Potentially there can be one 238 // The currently executing Simulator instance. Potentially there can be one
191 // for each native thread. 239 // for each native thread.
192 static Simulator* current(v8::internal::Isolate* isolate); 240 static Simulator* current(v8::internal::Isolate* isolate);
193 241
194 // Accessors for register state. Reading the pc value adheres to the MIPS 242 // Accessors for register state. Reading the pc value adheres to the MIPS
195 // architecture specification and is off by a 8 from the currently executing 243 // architecture specification and is off by a 8 from the currently executing
196 // instruction. 244 // instruction.
(...skipping 12 matching lines...) Expand all
209 void set_fpu_register_word_invalid_result(float original, float rounded); 257 void set_fpu_register_word_invalid_result(float original, float rounded);
210 void set_fpu_register_invalid_result64(double original, double rounded); 258 void set_fpu_register_invalid_result64(double original, double rounded);
211 void set_fpu_register_invalid_result(double original, double rounded); 259 void set_fpu_register_invalid_result(double original, double rounded);
212 void set_fpu_register_word_invalid_result(double original, double rounded); 260 void set_fpu_register_word_invalid_result(double original, double rounded);
213 int64_t get_fpu_register(int fpureg) const; 261 int64_t get_fpu_register(int fpureg) const;
214 int32_t get_fpu_register_word(int fpureg) const; 262 int32_t get_fpu_register_word(int fpureg) const;
215 int32_t get_fpu_register_signed_word(int fpureg) const; 263 int32_t get_fpu_register_signed_word(int fpureg) const;
216 int32_t get_fpu_register_hi_word(int fpureg) const; 264 int32_t get_fpu_register_hi_word(int fpureg) const;
217 float get_fpu_register_float(int fpureg) const; 265 float get_fpu_register_float(int fpureg) const;
218 double get_fpu_register_double(int fpureg) const; 266 double get_fpu_register_double(int fpureg) const;
267 template <typename T>
268 void get_msa_register(int wreg, T* value);
269 template <typename T>
270 void set_msa_register(int wreg, const T* value);
219 void set_fcsr_bit(uint32_t cc, bool value); 271 void set_fcsr_bit(uint32_t cc, bool value);
220 bool test_fcsr_bit(uint32_t cc); 272 bool test_fcsr_bit(uint32_t cc);
221 void set_fcsr_rounding_mode(FPURoundingMode mode); 273 void set_fcsr_rounding_mode(FPURoundingMode mode);
222 unsigned int get_fcsr_rounding_mode(); 274 unsigned int get_fcsr_rounding_mode();
223 bool set_fcsr_round_error(double original, double rounded); 275 bool set_fcsr_round_error(double original, double rounded);
224 bool set_fcsr_round_error(float original, float rounded); 276 bool set_fcsr_round_error(float original, float rounded);
225 bool set_fcsr_round64_error(double original, double rounded); 277 bool set_fcsr_round64_error(double original, double rounded);
226 bool set_fcsr_round64_error(float original, float rounded); 278 bool set_fcsr_round64_error(float original, float rounded);
227 void round_according_to_fcsr(double toRound, double& rounded, 279 void round_according_to_fcsr(double toRound, double& rounded,
228 int32_t& rounded_int, double fs); 280 int32_t& rounded_int, double fs);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // Unpredictable value. 341 // Unpredictable value.
290 Unpredictable = 0xbadbeaf 342 Unpredictable = 0xbadbeaf
291 }; 343 };
292 344
293 // Unsupported instructions use Format to print an error and stop execution. 345 // Unsupported instructions use Format to print an error and stop execution.
294 void Format(Instruction* instr, const char* format); 346 void Format(Instruction* instr, const char* format);
295 347
296 // Helpers for data value tracing. 348 // Helpers for data value tracing.
297 enum TraceType { BYTE, HALF, WORD, DWORD, FLOAT, DOUBLE, FLOAT_DOUBLE }; 349 enum TraceType { BYTE, HALF, WORD, DWORD, FLOAT, DOUBLE, FLOAT_DOUBLE };
298 350
351 // MSA Data Format
352 enum MSADataFormat { MSA_VECT = 0, MSA_BYTE, MSA_HALF, MSA_WORD, MSA_DWORD };
353
299 // Read and write memory. 354 // Read and write memory.
300 inline uint32_t ReadBU(int32_t addr); 355 inline uint32_t ReadBU(int32_t addr);
301 inline int32_t ReadB(int32_t addr); 356 inline int32_t ReadB(int32_t addr);
302 inline void WriteB(int32_t addr, uint8_t value); 357 inline void WriteB(int32_t addr, uint8_t value);
303 inline void WriteB(int32_t addr, int8_t value); 358 inline void WriteB(int32_t addr, int8_t value);
304 359
305 inline uint16_t ReadHU(int32_t addr, Instruction* instr); 360 inline uint16_t ReadHU(int32_t addr, Instruction* instr);
306 inline int16_t ReadH(int32_t addr, Instruction* instr); 361 inline int16_t ReadH(int32_t addr, Instruction* instr);
307 // Note: Overloaded on the sign of the value. 362 // Note: Overloaded on the sign of the value.
308 inline void WriteH(int32_t addr, uint16_t value, Instruction* instr); 363 inline void WriteH(int32_t addr, uint16_t value, Instruction* instr);
309 inline void WriteH(int32_t addr, int16_t value, Instruction* instr); 364 inline void WriteH(int32_t addr, int16_t value, Instruction* instr);
310 365
311 inline int ReadW(int32_t addr, Instruction* instr, TraceType t = WORD); 366 inline int ReadW(int32_t addr, Instruction* instr, TraceType t = WORD);
312 inline void WriteW(int32_t addr, int value, Instruction* instr); 367 inline void WriteW(int32_t addr, int value, Instruction* instr);
313 368
314 inline double ReadD(int32_t addr, Instruction* instr); 369 inline double ReadD(int32_t addr, Instruction* instr);
315 inline void WriteD(int32_t addr, double value, Instruction* instr); 370 inline void WriteD(int32_t addr, double value, Instruction* instr);
316 371
317 void TraceRegWr(int32_t value, TraceType t = WORD); 372 void TraceRegWr(int32_t value, TraceType t = WORD);
318 void TraceRegWr(int64_t value, TraceType t = DWORD); 373 void TraceRegWr(int64_t value, TraceType t = DWORD);
374 template <typename T>
375 void TraceMSARegWr(T* value, TraceType t);
319 void TraceMemWr(int32_t addr, int32_t value, TraceType t = WORD); 376 void TraceMemWr(int32_t addr, int32_t value, TraceType t = WORD);
320 void TraceMemRd(int32_t addr, int32_t value, TraceType t = WORD); 377 void TraceMemRd(int32_t addr, int32_t value, TraceType t = WORD);
321 void TraceMemWr(int32_t addr, int64_t value, TraceType t = DWORD); 378 void TraceMemWr(int32_t addr, int64_t value, TraceType t = DWORD);
322 void TraceMemRd(int32_t addr, int64_t value, TraceType t = DWORD); 379 void TraceMemRd(int32_t addr, int64_t value, TraceType t = DWORD);
323 EmbeddedVector<char, 128> trace_buf_; 380 EmbeddedVector<char, 128> trace_buf_;
324 381
325 // Operations depending on endianness. 382 // Operations depending on endianness.
326 // Get Double Higher / Lower word. 383 // Get Double Higher / Lower word.
327 inline int32_t GetDoubleHIW(double* addr); 384 inline int32_t GetDoubleHIW(double* addr);
328 inline int32_t GetDoubleLOW(double* addr); 385 inline int32_t GetDoubleLOW(double* addr);
(...skipping 19 matching lines...) Expand all
348 405
349 // Called from DecodeTypeRegisterCOP1. 406 // Called from DecodeTypeRegisterCOP1.
350 void DecodeTypeRegisterSRsType(); 407 void DecodeTypeRegisterSRsType();
351 408
352 void DecodeTypeRegisterDRsType(); 409 void DecodeTypeRegisterDRsType();
353 410
354 void DecodeTypeRegisterWRsType(); 411 void DecodeTypeRegisterWRsType();
355 412
356 void DecodeTypeRegisterLRsType(); 413 void DecodeTypeRegisterLRsType();
357 414
415 int DecodeMsaDataFormat();
416 void DecodeTypeMsaI8();
417 void DecodeTypeMsaI5();
418 void DecodeTypeMsaI10();
419 void DecodeTypeMsaELM();
420 void DecodeTypeMsaBIT();
421 void DecodeTypeMsaMI10();
422 void DecodeTypeMsa3R();
423 void DecodeTypeMsa3RF();
424 void DecodeTypeMsaVec();
425 void DecodeTypeMsa2R();
426 void DecodeTypeMsa2RF();
427
358 inline int32_t rs_reg() const { return instr_.RsValue(); } 428 inline int32_t rs_reg() const { return instr_.RsValue(); }
359 inline int32_t rs() const { return get_register(rs_reg()); } 429 inline int32_t rs() const { return get_register(rs_reg()); }
360 inline uint32_t rs_u() const { 430 inline uint32_t rs_u() const {
361 return static_cast<uint32_t>(get_register(rs_reg())); 431 return static_cast<uint32_t>(get_register(rs_reg()));
362 } 432 }
363 inline int32_t rt_reg() const { return instr_.RtValue(); } 433 inline int32_t rt_reg() const { return instr_.RtValue(); }
364 inline int32_t rt() const { return get_register(rt_reg()); } 434 inline int32_t rt() const { return get_register(rt_reg()); }
365 inline uint32_t rt_u() const { 435 inline uint32_t rt_u() const {
366 return static_cast<uint32_t>(get_register(rt_reg())); 436 return static_cast<uint32_t>(get_register(rt_reg()));
367 } 437 }
368 inline int32_t rd_reg() const { return instr_.RdValue(); } 438 inline int32_t rd_reg() const { return instr_.RdValue(); }
369 inline int32_t fr_reg() const { return instr_.FrValue(); } 439 inline int32_t fr_reg() const { return instr_.FrValue(); }
370 inline int32_t fs_reg() const { return instr_.FsValue(); } 440 inline int32_t fs_reg() const { return instr_.FsValue(); }
371 inline int32_t ft_reg() const { return instr_.FtValue(); } 441 inline int32_t ft_reg() const { return instr_.FtValue(); }
372 inline int32_t fd_reg() const { return instr_.FdValue(); } 442 inline int32_t fd_reg() const { return instr_.FdValue(); }
373 inline int32_t sa() const { return instr_.SaValue(); } 443 inline int32_t sa() const { return instr_.SaValue(); }
374 inline int32_t lsa_sa() const { return instr_.LsaSaValue(); } 444 inline int32_t lsa_sa() const { return instr_.LsaSaValue(); }
445 inline int32_t ws_reg() const { return instr_.WsValue(); }
446 inline int32_t wt_reg() const { return instr_.WtValue(); }
447 inline int32_t wd_reg() const { return instr_.WdValue(); }
375 448
376 inline void SetResult(int32_t rd_reg, int32_t alu_out) { 449 inline void SetResult(int32_t rd_reg, int32_t alu_out) {
377 set_register(rd_reg, alu_out); 450 set_register(rd_reg, alu_out);
378 TraceRegWr(alu_out); 451 TraceRegWr(alu_out);
379 } 452 }
380 453
381 inline void SetFPUWordResult(int32_t fd_reg, int32_t alu_out) { 454 inline void SetFPUWordResult(int32_t fd_reg, int32_t alu_out) {
382 set_fpu_register_word(fd_reg, alu_out); 455 set_fpu_register_word(fd_reg, alu_out);
383 TraceRegWr(get_fpu_register_word(fd_reg)); 456 TraceRegWr(get_fpu_register_word(fd_reg));
384 } 457 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 void SetFpResult(const double& result); 549 void SetFpResult(const double& result);
477 550
478 void CallInternal(byte* entry); 551 void CallInternal(byte* entry);
479 552
480 // Architecture state. 553 // Architecture state.
481 // Registers. 554 // Registers.
482 int32_t registers_[kNumSimuRegisters]; 555 int32_t registers_[kNumSimuRegisters];
483 // Coprocessor Registers. 556 // Coprocessor Registers.
484 // Note: FP32 mode uses only the lower 32-bit part of each element, 557 // Note: FP32 mode uses only the lower 32-bit part of each element,
485 // the upper 32-bit is unpredictable. 558 // the upper 32-bit is unpredictable.
486 int64_t FPUregisters_[kNumFPURegisters]; 559 // Note: FPUregisters_[] array is increased to 64 * 8B = 32 * 16B in
560 // order to support MSA registers
561 int64_t FPUregisters_[kNumFPURegisters * 2];
487 // FPU control register. 562 // FPU control register.
488 uint32_t FCSR_; 563 uint32_t FCSR_;
489 564
490 // Simulator support. 565 // Simulator support.
491 // Allocate 1MB for stack. 566 // Allocate 1MB for stack.
492 static const size_t stack_size_ = 1 * 1024*1024; 567 static const size_t stack_size_ = 1 * 1024*1024;
493 char* stack_; 568 char* stack_;
494 bool pc_modified_; 569 bool pc_modified_;
495 uint64_t icount_; 570 uint64_t icount_;
496 int break_count_; 571 int break_count_;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 static inline void UnregisterCTryCatch(Isolate* isolate) { 629 static inline void UnregisterCTryCatch(Isolate* isolate) {
555 Simulator::current(isolate)->PopAddress(); 630 Simulator::current(isolate)->PopAddress();
556 } 631 }
557 }; 632 };
558 633
559 } // namespace internal 634 } // namespace internal
560 } // namespace v8 635 } // namespace v8
561 636
562 #endif // !defined(USE_SIMULATOR) 637 #endif // !defined(USE_SIMULATOR)
563 #endif // V8_MIPS_SIMULATOR_MIPS_H_ 638 #endif // V8_MIPS_SIMULATOR_MIPS_H_
OLDNEW
« no previous file with comments | « no previous file | src/mips/simulator-mips.cc » ('j') | src/mips/simulator-mips.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698