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

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

Issue 2799923002: MIPS[64]: Implement fill.df, copy_u.df, copy_s.df instructions in simulator (Closed)
Patch Set: Move constants to constants-mips[64].h 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 | « src/mips64/disasm-mips64.cc ('k') | src/mips64/simulator-mips64.cc » ('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 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Coprocessor registers. 186 // Coprocessor registers.
187 // Generated code will always use doubles. So we will only use even registers. 187 // Generated code will always use doubles. So we will only use even registers.
188 enum FPURegister { 188 enum FPURegister {
189 f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, 189 f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11,
190 f12, f13, f14, f15, // f12 and f14 are arguments FPURegisters. 190 f12, f13, f14, f15, // f12 and f14 are arguments FPURegisters.
191 f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, 191 f16, f17, f18, f19, f20, f21, f22, f23, f24, f25,
192 f26, f27, f28, f29, f30, f31, 192 f26, f27, f28, f29, f30, f31,
193 kNumFPURegisters 193 kNumFPURegisters
194 }; 194 };
195 195
196 // MSA registers
197 enum MSARegister {
198 w0,
199 w1,
200 w2,
201 w3,
202 w4,
203 w5,
204 w6,
205 w7,
206 w8,
207 w9,
208 w10,
209 w11,
210 w12,
211 w13,
212 w14,
213 w15,
214 w16,
215 w17,
216 w18,
217 w19,
218 w20,
219 w21,
220 w22,
221 w23,
222 w24,
223 w25,
224 w26,
225 w27,
226 w28,
227 w29,
228 w30,
229 w31,
230 kNumMSARegisters
231 };
232
196 explicit Simulator(Isolate* isolate); 233 explicit Simulator(Isolate* isolate);
197 ~Simulator(); 234 ~Simulator();
198 235
199 // The currently executing Simulator instance. Potentially there can be one 236 // The currently executing Simulator instance. Potentially there can be one
200 // for each native thread. 237 // for each native thread.
201 static Simulator* current(v8::internal::Isolate* isolate); 238 static Simulator* current(v8::internal::Isolate* isolate);
202 239
203 // Accessors for register state. Reading the pc value adheres to the MIPS 240 // Accessors for register state. Reading the pc value adheres to the MIPS
204 // architecture specification and is off by a 8 from the currently executing 241 // architecture specification and is off by a 8 from the currently executing
205 // instruction. 242 // instruction.
(...skipping 13 matching lines...) Expand all
219 void set_fpu_register_word_invalid_result(float original, float rounded); 256 void set_fpu_register_word_invalid_result(float original, float rounded);
220 void set_fpu_register_invalid_result64(double original, double rounded); 257 void set_fpu_register_invalid_result64(double original, double rounded);
221 void set_fpu_register_invalid_result(double original, double rounded); 258 void set_fpu_register_invalid_result(double original, double rounded);
222 void set_fpu_register_word_invalid_result(double original, double rounded); 259 void set_fpu_register_word_invalid_result(double original, double rounded);
223 int64_t get_fpu_register(int fpureg) const; 260 int64_t get_fpu_register(int fpureg) const;
224 int32_t get_fpu_register_word(int fpureg) const; 261 int32_t get_fpu_register_word(int fpureg) const;
225 int32_t get_fpu_register_signed_word(int fpureg) const; 262 int32_t get_fpu_register_signed_word(int fpureg) const;
226 int32_t get_fpu_register_hi_word(int fpureg) const; 263 int32_t get_fpu_register_hi_word(int fpureg) const;
227 float get_fpu_register_float(int fpureg) const; 264 float get_fpu_register_float(int fpureg) const;
228 double get_fpu_register_double(int fpureg) const; 265 double get_fpu_register_double(int fpureg) const;
266 template <typename T>
267 void get_msa_register(int wreg, T* value);
ivica.bogosavljevic 2017/05/15 15:05:36 Can we have T get_msa_register(int wreg) since it
dusan.simicic 2017/05/16 13:12:41 No, because "value" is pointer to int[8|16|32|64]_
268 template <typename T>
269 void set_msa_register(int wreg, const T* value);
229 void set_fcsr_bit(uint32_t cc, bool value); 270 void set_fcsr_bit(uint32_t cc, bool value);
230 bool test_fcsr_bit(uint32_t cc); 271 bool test_fcsr_bit(uint32_t cc);
231 bool set_fcsr_round_error(double original, double rounded); 272 bool set_fcsr_round_error(double original, double rounded);
232 bool set_fcsr_round64_error(double original, double rounded); 273 bool set_fcsr_round64_error(double original, double rounded);
233 bool set_fcsr_round_error(float original, float rounded); 274 bool set_fcsr_round_error(float original, float rounded);
234 bool set_fcsr_round64_error(float original, float rounded); 275 bool set_fcsr_round64_error(float original, float rounded);
235 void round_according_to_fcsr(double toRound, double& rounded, 276 void round_according_to_fcsr(double toRound, double& rounded,
236 int32_t& rounded_int, double fs); 277 int32_t& rounded_int, double fs);
237 void round64_according_to_fcsr(double toRound, double& rounded, 278 void round64_according_to_fcsr(double toRound, double& rounded,
238 int64_t& rounded_int, double fs); 279 int64_t& rounded_int, double fs);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 BYTE, 349 BYTE,
309 HALF, 350 HALF,
310 WORD, 351 WORD,
311 DWORD, 352 DWORD,
312 FLOAT, 353 FLOAT,
313 DOUBLE, 354 DOUBLE,
314 FLOAT_DOUBLE, 355 FLOAT_DOUBLE,
315 WORD_DWORD 356 WORD_DWORD
316 }; 357 };
317 358
359 // MSA Data Format
360 enum MSADataFormat { MSA_VECT = 0, MSA_BYTE, MSA_HALF, MSA_WORD, MSA_DWORD };
361
318 // Read and write memory. 362 // Read and write memory.
319 inline uint32_t ReadBU(int64_t addr); 363 inline uint32_t ReadBU(int64_t addr);
320 inline int32_t ReadB(int64_t addr); 364 inline int32_t ReadB(int64_t addr);
321 inline void WriteB(int64_t addr, uint8_t value); 365 inline void WriteB(int64_t addr, uint8_t value);
322 inline void WriteB(int64_t addr, int8_t value); 366 inline void WriteB(int64_t addr, int8_t value);
323 367
324 inline uint16_t ReadHU(int64_t addr, Instruction* instr); 368 inline uint16_t ReadHU(int64_t addr, Instruction* instr);
325 inline int16_t ReadH(int64_t addr, Instruction* instr); 369 inline int16_t ReadH(int64_t addr, Instruction* instr);
326 // Note: Overloaded on the sign of the value. 370 // Note: Overloaded on the sign of the value.
327 inline void WriteH(int64_t addr, uint16_t value, Instruction* instr); 371 inline void WriteH(int64_t addr, uint16_t value, Instruction* instr);
328 inline void WriteH(int64_t addr, int16_t value, Instruction* instr); 372 inline void WriteH(int64_t addr, int16_t value, Instruction* instr);
329 373
330 inline uint32_t ReadWU(int64_t addr, Instruction* instr); 374 inline uint32_t ReadWU(int64_t addr, Instruction* instr);
331 inline int32_t ReadW(int64_t addr, Instruction* instr, TraceType t = WORD); 375 inline int32_t ReadW(int64_t addr, Instruction* instr, TraceType t = WORD);
332 inline void WriteW(int64_t addr, int32_t value, Instruction* instr); 376 inline void WriteW(int64_t addr, int32_t value, Instruction* instr);
333 inline int64_t Read2W(int64_t addr, Instruction* instr); 377 inline int64_t Read2W(int64_t addr, Instruction* instr);
334 inline void Write2W(int64_t addr, int64_t value, Instruction* instr); 378 inline void Write2W(int64_t addr, int64_t value, Instruction* instr);
335 379
336 inline double ReadD(int64_t addr, Instruction* instr); 380 inline double ReadD(int64_t addr, Instruction* instr);
337 inline void WriteD(int64_t addr, double value, Instruction* instr); 381 inline void WriteD(int64_t addr, double value, Instruction* instr);
338 382
339 // Helper for debugging memory access. 383 // Helper for debugging memory access.
340 inline void DieOrDebug(); 384 inline void DieOrDebug();
341 385
342 void TraceRegWr(int64_t value, TraceType t = DWORD); 386 void TraceRegWr(int64_t value, TraceType t = DWORD);
387 template <typename T>
388 void TraceMSARegWr(T* value, TraceType t);
343 void TraceMemWr(int64_t addr, int64_t value, TraceType t); 389 void TraceMemWr(int64_t addr, int64_t value, TraceType t);
344 void TraceMemRd(int64_t addr, int64_t value, TraceType t = DWORD); 390 void TraceMemRd(int64_t addr, int64_t value, TraceType t = DWORD);
345 391
346 // Operations depending on endianness. 392 // Operations depending on endianness.
347 // Get Double Higher / Lower word. 393 // Get Double Higher / Lower word.
348 inline int32_t GetDoubleHIW(double* addr); 394 inline int32_t GetDoubleHIW(double* addr);
349 inline int32_t GetDoubleLOW(double* addr); 395 inline int32_t GetDoubleLOW(double* addr);
350 // Set Double Higher / Lower word. 396 // Set Double Higher / Lower word.
351 inline int32_t SetDoubleHIW(double* addr); 397 inline int32_t SetDoubleHIW(double* addr);
352 inline int32_t SetDoubleLOW(double* addr); 398 inline int32_t SetDoubleLOW(double* addr);
(...skipping 13 matching lines...) Expand all
366 void DecodeTypeRegisterSPECIAL3(); 412 void DecodeTypeRegisterSPECIAL3();
367 413
368 void DecodeTypeRegisterSRsType(); 414 void DecodeTypeRegisterSRsType();
369 415
370 void DecodeTypeRegisterDRsType(); 416 void DecodeTypeRegisterDRsType();
371 417
372 void DecodeTypeRegisterWRsType(); 418 void DecodeTypeRegisterWRsType();
373 419
374 void DecodeTypeRegisterLRsType(); 420 void DecodeTypeRegisterLRsType();
375 421
422 int DecodeMsaDataFormat();
423 void DecodeTypeMsaI8();
424 void DecodeTypeMsaI5();
425 void DecodeTypeMsaI10();
426 void DecodeTypeMsaELM();
427 void DecodeTypeMsaBIT();
428 void DecodeTypeMsaMI10();
429 void DecodeTypeMsa3R();
430 void DecodeTypeMsa3RF();
431 void DecodeTypeMsaVec();
432 void DecodeTypeMsa2R();
433 void DecodeTypeMsa2RF();
434
376 // Executing is handled based on the instruction type. 435 // Executing is handled based on the instruction type.
377 void DecodeTypeRegister(); 436 void DecodeTypeRegister();
378 437
379 inline int32_t rs_reg() const { return instr_.RsValue(); } 438 inline int32_t rs_reg() const { return instr_.RsValue(); }
380 inline int64_t rs() const { return get_register(rs_reg()); } 439 inline int64_t rs() const { return get_register(rs_reg()); }
381 inline uint64_t rs_u() const { 440 inline uint64_t rs_u() const {
382 return static_cast<uint64_t>(get_register(rs_reg())); 441 return static_cast<uint64_t>(get_register(rs_reg()));
383 } 442 }
384 inline int32_t rt_reg() const { return instr_.RtValue(); } 443 inline int32_t rt_reg() const { return instr_.RtValue(); }
385 inline int64_t rt() const { return get_register(rt_reg()); } 444 inline int64_t rt() const { return get_register(rt_reg()); }
386 inline uint64_t rt_u() const { 445 inline uint64_t rt_u() const {
387 return static_cast<uint64_t>(get_register(rt_reg())); 446 return static_cast<uint64_t>(get_register(rt_reg()));
388 } 447 }
389 inline int32_t rd_reg() const { return instr_.RdValue(); } 448 inline int32_t rd_reg() const { return instr_.RdValue(); }
390 inline int32_t fr_reg() const { return instr_.FrValue(); } 449 inline int32_t fr_reg() const { return instr_.FrValue(); }
391 inline int32_t fs_reg() const { return instr_.FsValue(); } 450 inline int32_t fs_reg() const { return instr_.FsValue(); }
392 inline int32_t ft_reg() const { return instr_.FtValue(); } 451 inline int32_t ft_reg() const { return instr_.FtValue(); }
393 inline int32_t fd_reg() const { return instr_.FdValue(); } 452 inline int32_t fd_reg() const { return instr_.FdValue(); }
394 inline int32_t sa() const { return instr_.SaValue(); } 453 inline int32_t sa() const { return instr_.SaValue(); }
395 inline int32_t lsa_sa() const { return instr_.LsaSaValue(); } 454 inline int32_t lsa_sa() const { return instr_.LsaSaValue(); }
455 inline int32_t ws_reg() const { return instr_.WsValue(); }
456 inline int32_t wt_reg() const { return instr_.WtValue(); }
457 inline int32_t wd_reg() const { return instr_.WdValue(); }
396 458
397 inline void SetResult(const int32_t rd_reg, const int64_t alu_out) { 459 inline void SetResult(const int32_t rd_reg, const int64_t alu_out) {
398 set_register(rd_reg, alu_out); 460 set_register(rd_reg, alu_out);
399 TraceRegWr(alu_out); 461 TraceRegWr(alu_out);
400 } 462 }
401 463
402 inline void SetFPUWordResult(int32_t fd_reg, int32_t alu_out) { 464 inline void SetFPUWordResult(int32_t fd_reg, int32_t alu_out) {
403 set_fpu_register_word(fd_reg, alu_out); 465 set_fpu_register_word(fd_reg, alu_out);
404 TraceRegWr(get_fpu_register(fd_reg), WORD); 466 TraceRegWr(get_fpu_register(fd_reg), WORD);
405 } 467 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 // Handle arguments and return value for runtime FP functions. 567 // Handle arguments and return value for runtime FP functions.
506 void GetFpArgs(double* x, double* y, int32_t* z); 568 void GetFpArgs(double* x, double* y, int32_t* z);
507 void SetFpResult(const double& result); 569 void SetFpResult(const double& result);
508 570
509 void CallInternal(byte* entry); 571 void CallInternal(byte* entry);
510 572
511 // Architecture state. 573 // Architecture state.
512 // Registers. 574 // Registers.
513 int64_t registers_[kNumSimuRegisters]; 575 int64_t registers_[kNumSimuRegisters];
514 // Coprocessor Registers. 576 // Coprocessor Registers.
515 int64_t FPUregisters_[kNumFPURegisters]; 577 // Note: FPUregisters_[] array is increased to 64 * 8B = 32 * 16B in
578 // order to support MSA registers
579 int64_t FPUregisters_[kNumFPURegisters * 2];
516 // FPU control register. 580 // FPU control register.
517 uint32_t FCSR_; 581 uint32_t FCSR_;
518 582
519 // Simulator support. 583 // Simulator support.
520 // Allocate 1MB for stack. 584 // Allocate 1MB for stack.
521 size_t stack_size_; 585 size_t stack_size_;
522 char* stack_; 586 char* stack_;
523 bool pc_modified_; 587 bool pc_modified_;
524 int64_t icount_; 588 int64_t icount_;
525 int break_count_; 589 int break_count_;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 static inline void UnregisterCTryCatch(Isolate* isolate) { 652 static inline void UnregisterCTryCatch(Isolate* isolate) {
589 Simulator::current(isolate)->PopAddress(); 653 Simulator::current(isolate)->PopAddress();
590 } 654 }
591 }; 655 };
592 656
593 } // namespace internal 657 } // namespace internal
594 } // namespace v8 658 } // namespace v8
595 659
596 #endif // !defined(USE_SIMULATOR) 660 #endif // !defined(USE_SIMULATOR)
597 #endif // V8_MIPS_SIMULATOR_MIPS_H_ 661 #endif // V8_MIPS_SIMULATOR_MIPS_H_
OLDNEW
« no previous file with comments | « src/mips64/disasm-mips64.cc ('k') | src/mips64/simulator-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698