Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | |
| 233 const uint32_t kMsaI8Mask = ((3U << 24) | ((1 << 6) - 1)); | |
|
Ilija.Pavlovic1
2017/04/20 13:13:46
The same comments as for MIPS32 code.
dusan.simicic
2017/04/20 15:57:42
I'll move constants in the same way as for mips32.
| |
| 234 const uint32_t kMsaI5Mask = ((7U << 23) | ((1 << 6) - 1)); | |
| 235 const uint32_t kMsaMI10Mask = (15U << 2); | |
| 236 const uint32_t kMsaBITMask = ((7U << 23) | ((1 << 6) - 1)); | |
| 237 const uint32_t kMsaELMMask = (15U << 22); | |
| 238 const uint32_t kMsa3RMask = ((7U << 23) | ((1 << 6) - 1)); | |
| 239 const uint32_t kMsa3RFMask = ((15U << 22) | ((1 << 6) - 1)); | |
| 240 const uint32_t kMsaVECMask = (23U << 21); | |
| 241 const uint32_t kMsa2RMask = (7U << 18); | |
| 242 const uint32_t kMsa2RFMask = (15U << 17); | |
| 243 | |
| 196 explicit Simulator(Isolate* isolate); | 244 explicit Simulator(Isolate* isolate); |
| 197 ~Simulator(); | 245 ~Simulator(); |
| 198 | 246 |
| 199 // The currently executing Simulator instance. Potentially there can be one | 247 // The currently executing Simulator instance. Potentially there can be one |
| 200 // for each native thread. | 248 // for each native thread. |
| 201 static Simulator* current(v8::internal::Isolate* isolate); | 249 static Simulator* current(v8::internal::Isolate* isolate); |
| 202 | 250 |
| 203 // Accessors for register state. Reading the pc value adheres to the MIPS | 251 // 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 | 252 // architecture specification and is off by a 8 from the currently executing |
| 205 // instruction. | 253 // instruction. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 219 void set_fpu_register_word_invalid_result(float original, float rounded); | 267 void set_fpu_register_word_invalid_result(float original, float rounded); |
| 220 void set_fpu_register_invalid_result64(double original, double rounded); | 268 void set_fpu_register_invalid_result64(double original, double rounded); |
| 221 void set_fpu_register_invalid_result(double original, double rounded); | 269 void set_fpu_register_invalid_result(double original, double rounded); |
| 222 void set_fpu_register_word_invalid_result(double original, double rounded); | 270 void set_fpu_register_word_invalid_result(double original, double rounded); |
| 223 int64_t get_fpu_register(int fpureg) const; | 271 int64_t get_fpu_register(int fpureg) const; |
| 224 int32_t get_fpu_register_word(int fpureg) const; | 272 int32_t get_fpu_register_word(int fpureg) const; |
| 225 int32_t get_fpu_register_signed_word(int fpureg) const; | 273 int32_t get_fpu_register_signed_word(int fpureg) const; |
| 226 int32_t get_fpu_register_hi_word(int fpureg) const; | 274 int32_t get_fpu_register_hi_word(int fpureg) const; |
| 227 float get_fpu_register_float(int fpureg) const; | 275 float get_fpu_register_float(int fpureg) const; |
| 228 double get_fpu_register_double(int fpureg) const; | 276 double get_fpu_register_double(int fpureg) const; |
| 277 template <typename T> | |
| 278 void get_msa_register(int wreg, T* value); | |
| 279 template <typename T> | |
| 280 void set_msa_register(int wreg, const T* value); | |
| 229 void set_fcsr_bit(uint32_t cc, bool value); | 281 void set_fcsr_bit(uint32_t cc, bool value); |
| 230 bool test_fcsr_bit(uint32_t cc); | 282 bool test_fcsr_bit(uint32_t cc); |
| 231 bool set_fcsr_round_error(double original, double rounded); | 283 bool set_fcsr_round_error(double original, double rounded); |
| 232 bool set_fcsr_round64_error(double original, double rounded); | 284 bool set_fcsr_round64_error(double original, double rounded); |
| 233 bool set_fcsr_round_error(float original, float rounded); | 285 bool set_fcsr_round_error(float original, float rounded); |
| 234 bool set_fcsr_round64_error(float original, float rounded); | 286 bool set_fcsr_round64_error(float original, float rounded); |
| 235 void round_according_to_fcsr(double toRound, double& rounded, | 287 void round_according_to_fcsr(double toRound, double& rounded, |
| 236 int32_t& rounded_int, double fs); | 288 int32_t& rounded_int, double fs); |
| 237 void round64_according_to_fcsr(double toRound, double& rounded, | 289 void round64_according_to_fcsr(double toRound, double& rounded, |
| 238 int64_t& rounded_int, double fs); | 290 int64_t& rounded_int, double fs); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 BYTE, | 360 BYTE, |
| 309 HALF, | 361 HALF, |
| 310 WORD, | 362 WORD, |
| 311 DWORD, | 363 DWORD, |
| 312 FLOAT, | 364 FLOAT, |
| 313 DOUBLE, | 365 DOUBLE, |
| 314 FLOAT_DOUBLE, | 366 FLOAT_DOUBLE, |
| 315 WORD_DWORD | 367 WORD_DWORD |
| 316 }; | 368 }; |
| 317 | 369 |
| 370 // MSA Data Format | |
| 371 enum MSADataFormat { MSA_VECT = 0, MSA_BYTE, MSA_HALF, MSA_WORD, MSA_DWORD }; | |
| 372 | |
| 318 // Read and write memory. | 373 // Read and write memory. |
| 319 inline uint32_t ReadBU(int64_t addr); | 374 inline uint32_t ReadBU(int64_t addr); |
| 320 inline int32_t ReadB(int64_t addr); | 375 inline int32_t ReadB(int64_t addr); |
| 321 inline void WriteB(int64_t addr, uint8_t value); | 376 inline void WriteB(int64_t addr, uint8_t value); |
| 322 inline void WriteB(int64_t addr, int8_t value); | 377 inline void WriteB(int64_t addr, int8_t value); |
| 323 | 378 |
| 324 inline uint16_t ReadHU(int64_t addr, Instruction* instr); | 379 inline uint16_t ReadHU(int64_t addr, Instruction* instr); |
| 325 inline int16_t ReadH(int64_t addr, Instruction* instr); | 380 inline int16_t ReadH(int64_t addr, Instruction* instr); |
| 326 // Note: Overloaded on the sign of the value. | 381 // Note: Overloaded on the sign of the value. |
| 327 inline void WriteH(int64_t addr, uint16_t value, Instruction* instr); | 382 inline void WriteH(int64_t addr, uint16_t value, Instruction* instr); |
| 328 inline void WriteH(int64_t addr, int16_t value, Instruction* instr); | 383 inline void WriteH(int64_t addr, int16_t value, Instruction* instr); |
| 329 | 384 |
| 330 inline uint32_t ReadWU(int64_t addr, Instruction* instr); | 385 inline uint32_t ReadWU(int64_t addr, Instruction* instr); |
| 331 inline int32_t ReadW(int64_t addr, Instruction* instr, TraceType t = WORD); | 386 inline int32_t ReadW(int64_t addr, Instruction* instr, TraceType t = WORD); |
| 332 inline void WriteW(int64_t addr, int32_t value, Instruction* instr); | 387 inline void WriteW(int64_t addr, int32_t value, Instruction* instr); |
| 333 inline int64_t Read2W(int64_t addr, Instruction* instr); | 388 inline int64_t Read2W(int64_t addr, Instruction* instr); |
| 334 inline void Write2W(int64_t addr, int64_t value, Instruction* instr); | 389 inline void Write2W(int64_t addr, int64_t value, Instruction* instr); |
| 335 | 390 |
| 336 inline double ReadD(int64_t addr, Instruction* instr); | 391 inline double ReadD(int64_t addr, Instruction* instr); |
| 337 inline void WriteD(int64_t addr, double value, Instruction* instr); | 392 inline void WriteD(int64_t addr, double value, Instruction* instr); |
| 338 | 393 |
| 339 // Helper for debugging memory access. | 394 // Helper for debugging memory access. |
| 340 inline void DieOrDebug(); | 395 inline void DieOrDebug(); |
| 341 | 396 |
| 342 void TraceRegWr(int64_t value, TraceType t = DWORD); | 397 void TraceRegWr(int64_t value, TraceType t = DWORD); |
| 398 template <typename T> | |
| 399 void TraceMSARegWr(T* value, TraceType t); | |
| 343 void TraceMemWr(int64_t addr, int64_t value, TraceType t); | 400 void TraceMemWr(int64_t addr, int64_t value, TraceType t); |
| 344 void TraceMemRd(int64_t addr, int64_t value, TraceType t = DWORD); | 401 void TraceMemRd(int64_t addr, int64_t value, TraceType t = DWORD); |
| 345 | 402 |
| 346 // Operations depending on endianness. | 403 // Operations depending on endianness. |
| 347 // Get Double Higher / Lower word. | 404 // Get Double Higher / Lower word. |
| 348 inline int32_t GetDoubleHIW(double* addr); | 405 inline int32_t GetDoubleHIW(double* addr); |
| 349 inline int32_t GetDoubleLOW(double* addr); | 406 inline int32_t GetDoubleLOW(double* addr); |
| 350 // Set Double Higher / Lower word. | 407 // Set Double Higher / Lower word. |
| 351 inline int32_t SetDoubleHIW(double* addr); | 408 inline int32_t SetDoubleHIW(double* addr); |
| 352 inline int32_t SetDoubleLOW(double* addr); | 409 inline int32_t SetDoubleLOW(double* addr); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 366 void DecodeTypeRegisterSPECIAL3(); | 423 void DecodeTypeRegisterSPECIAL3(); |
| 367 | 424 |
| 368 void DecodeTypeRegisterSRsType(); | 425 void DecodeTypeRegisterSRsType(); |
| 369 | 426 |
| 370 void DecodeTypeRegisterDRsType(); | 427 void DecodeTypeRegisterDRsType(); |
| 371 | 428 |
| 372 void DecodeTypeRegisterWRsType(); | 429 void DecodeTypeRegisterWRsType(); |
| 373 | 430 |
| 374 void DecodeTypeRegisterLRsType(); | 431 void DecodeTypeRegisterLRsType(); |
| 375 | 432 |
| 433 int DecodeMsaDataFormat(); | |
| 434 void DecodeTypeMsaI8(); | |
| 435 void DecodeTypeMsaI5(); | |
| 436 void DecodeTypeMsaI10(); | |
| 437 void DecodeTypeMsaELM(); | |
| 438 void DecodeTypeMsaBIT(); | |
| 439 void DecodeTypeMsaMI10(); | |
| 440 void DecodeTypeMsa3R(); | |
| 441 void DecodeTypeMsa3RF(); | |
| 442 void DecodeTypeMsaVec(); | |
| 443 void DecodeTypeMsa2R(); | |
| 444 void DecodeTypeMsa2RF(); | |
| 445 | |
| 376 // Executing is handled based on the instruction type. | 446 // Executing is handled based on the instruction type. |
| 377 void DecodeTypeRegister(); | 447 void DecodeTypeRegister(); |
| 378 | 448 |
| 379 inline int32_t rs_reg() const { return instr_.RsValue(); } | 449 inline int32_t rs_reg() const { return instr_.RsValue(); } |
| 380 inline int64_t rs() const { return get_register(rs_reg()); } | 450 inline int64_t rs() const { return get_register(rs_reg()); } |
| 381 inline uint64_t rs_u() const { | 451 inline uint64_t rs_u() const { |
| 382 return static_cast<uint64_t>(get_register(rs_reg())); | 452 return static_cast<uint64_t>(get_register(rs_reg())); |
| 383 } | 453 } |
| 384 inline int32_t rt_reg() const { return instr_.RtValue(); } | 454 inline int32_t rt_reg() const { return instr_.RtValue(); } |
| 385 inline int64_t rt() const { return get_register(rt_reg()); } | 455 inline int64_t rt() const { return get_register(rt_reg()); } |
| 386 inline uint64_t rt_u() const { | 456 inline uint64_t rt_u() const { |
| 387 return static_cast<uint64_t>(get_register(rt_reg())); | 457 return static_cast<uint64_t>(get_register(rt_reg())); |
| 388 } | 458 } |
| 389 inline int32_t rd_reg() const { return instr_.RdValue(); } | 459 inline int32_t rd_reg() const { return instr_.RdValue(); } |
| 390 inline int32_t fr_reg() const { return instr_.FrValue(); } | 460 inline int32_t fr_reg() const { return instr_.FrValue(); } |
| 391 inline int32_t fs_reg() const { return instr_.FsValue(); } | 461 inline int32_t fs_reg() const { return instr_.FsValue(); } |
| 392 inline int32_t ft_reg() const { return instr_.FtValue(); } | 462 inline int32_t ft_reg() const { return instr_.FtValue(); } |
| 393 inline int32_t fd_reg() const { return instr_.FdValue(); } | 463 inline int32_t fd_reg() const { return instr_.FdValue(); } |
| 394 inline int32_t sa() const { return instr_.SaValue(); } | 464 inline int32_t sa() const { return instr_.SaValue(); } |
| 395 inline int32_t lsa_sa() const { return instr_.LsaSaValue(); } | 465 inline int32_t lsa_sa() const { return instr_.LsaSaValue(); } |
| 466 inline int32_t ws_reg() const { return instr_.WsValue(); } | |
| 467 inline int32_t wt_reg() const { return instr_.WtValue(); } | |
| 468 inline int32_t wd_reg() const { return instr_.WdValue(); } | |
| 396 | 469 |
| 397 inline void SetResult(const int32_t rd_reg, const int64_t alu_out) { | 470 inline void SetResult(const int32_t rd_reg, const int64_t alu_out) { |
| 398 set_register(rd_reg, alu_out); | 471 set_register(rd_reg, alu_out); |
| 399 TraceRegWr(alu_out); | 472 TraceRegWr(alu_out); |
| 400 } | 473 } |
| 401 | 474 |
| 402 inline void SetFPUWordResult(int32_t fd_reg, int32_t alu_out) { | 475 inline void SetFPUWordResult(int32_t fd_reg, int32_t alu_out) { |
| 403 set_fpu_register_word(fd_reg, alu_out); | 476 set_fpu_register_word(fd_reg, alu_out); |
| 404 TraceRegWr(get_fpu_register(fd_reg), WORD); | 477 TraceRegWr(get_fpu_register(fd_reg), WORD); |
| 405 } | 478 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 // Handle arguments and return value for runtime FP functions. | 578 // Handle arguments and return value for runtime FP functions. |
| 506 void GetFpArgs(double* x, double* y, int32_t* z); | 579 void GetFpArgs(double* x, double* y, int32_t* z); |
| 507 void SetFpResult(const double& result); | 580 void SetFpResult(const double& result); |
| 508 | 581 |
| 509 void CallInternal(byte* entry); | 582 void CallInternal(byte* entry); |
| 510 | 583 |
| 511 // Architecture state. | 584 // Architecture state. |
| 512 // Registers. | 585 // Registers. |
| 513 int64_t registers_[kNumSimuRegisters]; | 586 int64_t registers_[kNumSimuRegisters]; |
| 514 // Coprocessor Registers. | 587 // Coprocessor Registers. |
| 515 int64_t FPUregisters_[kNumFPURegisters]; | 588 // Note: FPUregisters_[] array is increased to 64 * 8B = 32 * 16B in |
| 589 // order to support MSA registers | |
| 590 int64_t FPUregisters_[kNumFPURegisters * 2]; | |
| 516 // FPU control register. | 591 // FPU control register. |
| 517 uint32_t FCSR_; | 592 uint32_t FCSR_; |
| 518 | 593 |
| 519 // Simulator support. | 594 // Simulator support. |
| 520 // Allocate 1MB for stack. | 595 // Allocate 1MB for stack. |
| 521 size_t stack_size_; | 596 size_t stack_size_; |
| 522 char* stack_; | 597 char* stack_; |
| 523 bool pc_modified_; | 598 bool pc_modified_; |
| 524 int64_t icount_; | 599 int64_t icount_; |
| 525 int break_count_; | 600 int break_count_; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 static inline void UnregisterCTryCatch(Isolate* isolate) { | 663 static inline void UnregisterCTryCatch(Isolate* isolate) { |
| 589 Simulator::current(isolate)->PopAddress(); | 664 Simulator::current(isolate)->PopAddress(); |
| 590 } | 665 } |
| 591 }; | 666 }; |
| 592 | 667 |
| 593 } // namespace internal | 668 } // namespace internal |
| 594 } // namespace v8 | 669 } // namespace v8 |
| 595 | 670 |
| 596 #endif // !defined(USE_SIMULATOR) | 671 #endif // !defined(USE_SIMULATOR) |
| 597 #endif // V8_MIPS_SIMULATOR_MIPS_H_ | 672 #endif // V8_MIPS_SIMULATOR_MIPS_H_ |
| OLD | NEW |