OLD | NEW |
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 // Declares a Simulator for S390 instructions if we are not generating a native | 5 // Declares a Simulator for S390 instructions if we are not generating a native |
6 // S390 binary. This Simulator allows us to run and debug S390 code generation | 6 // S390 binary. This Simulator allows us to run and debug S390 code generation |
7 // on regular desktop machines. | 7 // on regular desktop machines. |
8 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, | 8 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, |
9 // which will start execution in the Simulator or forwards to the real entry | 9 // which will start execution in the Simulator or forwards to the real entry |
10 // on a S390 hardware platform. | 10 // on a S390 hardware platform. |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 bool DecodeFourByte(Instruction* instr); | 310 bool DecodeFourByte(Instruction* instr); |
311 bool DecodeFourByteArithmetic(Instruction* instr); | 311 bool DecodeFourByteArithmetic(Instruction* instr); |
312 bool DecodeFourByteFloatingPoint(Instruction* instr); | 312 bool DecodeFourByteFloatingPoint(Instruction* instr); |
313 void DecodeFourByteFloatingPointIntConversion(Instruction* instr); | 313 void DecodeFourByteFloatingPointIntConversion(Instruction* instr); |
314 void DecodeFourByteFloatingPointRound(Instruction* instr); | 314 void DecodeFourByteFloatingPointRound(Instruction* instr); |
315 | 315 |
316 bool DecodeSixByte(Instruction* instr); | 316 bool DecodeSixByte(Instruction* instr); |
317 bool DecodeSixByteArithmetic(Instruction* instr); | 317 bool DecodeSixByteArithmetic(Instruction* instr); |
318 bool S390InstructionDecode(Instruction* instr); | 318 bool S390InstructionDecode(Instruction* instr); |
319 | 319 |
| 320 // Used by the CL**BR instructions. |
| 321 template <typename T1, typename T2> |
| 322 void SetS390RoundConditionCode(T1 r2_val, T2 max, T2 min) { |
| 323 condition_reg_ = 0; |
| 324 double r2_dval = static_cast<double>(r2_val); |
| 325 double dbl_min = static_cast<double>(min); |
| 326 double dbl_max = static_cast<double>(max); |
| 327 |
| 328 if (r2_dval == 0.0) |
| 329 condition_reg_ = 8; |
| 330 else if (r2_dval < 0.0 && r2_dval >= dbl_min && std::isfinite(r2_dval)) |
| 331 condition_reg_ = 4; |
| 332 else if (r2_dval > 0.0 && r2_dval <= dbl_max && std::isfinite(r2_dval)) |
| 333 condition_reg_ = 2; |
| 334 else |
| 335 condition_reg_ = 1; |
| 336 } |
| 337 |
| 338 template <typename T1> |
| 339 void SetS390RoundConditionCode(T1 r2_val, int64_t max, int64_t min) { |
| 340 condition_reg_ = 0; |
| 341 double r2_dval = static_cast<double>(r2_val); |
| 342 double dbl_min = static_cast<double>(min); |
| 343 double dbl_max = static_cast<double>(max); |
| 344 |
| 345 // Note that the IEEE 754 floating-point representations (both 32 and |
| 346 // 64 bit) cannot exactly represent INT64_MAX. The closest it can get |
| 347 // is INT64_max + 1. IEEE 754 FP can, though, represent INT64_MIN |
| 348 // exactly. |
| 349 |
| 350 // This is not an issue for INT32, as IEEE754 64-bit can represent |
| 351 // INT32_MAX and INT32_MIN with exact precision. |
| 352 |
| 353 if (r2_dval == 0.0) |
| 354 condition_reg_ = 8; |
| 355 else if (r2_dval < 0.0 && r2_dval >= dbl_min && std::isfinite(r2_dval)) |
| 356 condition_reg_ = 4; |
| 357 else if (r2_dval > 0.0 && r2_dval < dbl_max && std::isfinite(r2_dval)) |
| 358 condition_reg_ = 2; |
| 359 else |
| 360 condition_reg_ = 1; |
| 361 } |
| 362 |
| 363 // Used by the CL**BR instructions. |
| 364 template <typename T1, typename T2, typename T3> |
| 365 void SetS390ConvertConditionCode(T1 src, T2 dst, T3 max) { |
| 366 condition_reg_ = 0; |
| 367 if (src == static_cast<T1>(0.0)) { |
| 368 condition_reg_ |= 8; |
| 369 } else if (src < static_cast<T1>(0.0) && static_cast<T2>(src) == 0 && |
| 370 std::isfinite(src)) { |
| 371 condition_reg_ |= 4; |
| 372 } else if (src > static_cast<T1>(0.0) && std::isfinite(src) && |
| 373 src < static_cast<T1>(max)) { |
| 374 condition_reg_ |= 2; |
| 375 } else { |
| 376 condition_reg_ |= 1; |
| 377 } |
| 378 } |
| 379 |
320 template <typename T> | 380 template <typename T> |
321 void SetS390ConditionCode(T lhs, T rhs) { | 381 void SetS390ConditionCode(T lhs, T rhs) { |
322 condition_reg_ = 0; | 382 condition_reg_ = 0; |
323 if (lhs == rhs) { | 383 if (lhs == rhs) { |
324 condition_reg_ |= CC_EQ; | 384 condition_reg_ |= CC_EQ; |
325 } else if (lhs < rhs) { | 385 } else if (lhs < rhs) { |
326 condition_reg_ |= CC_LT; | 386 condition_reg_ |= CC_LT; |
327 } else if (lhs > rhs) { | 387 } else if (lhs > rhs) { |
328 condition_reg_ |= CC_GT; | 388 condition_reg_ |= CC_GT; |
329 } | 389 } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { | 524 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { |
465 Simulator::current(isolate)->PopAddress(); | 525 Simulator::current(isolate)->PopAddress(); |
466 } | 526 } |
467 }; | 527 }; |
468 | 528 |
469 } // namespace internal | 529 } // namespace internal |
470 } // namespace v8 | 530 } // namespace v8 |
471 | 531 |
472 #endif // !defined(USE_SIMULATOR) | 532 #endif // !defined(USE_SIMULATOR) |
473 #endif // V8_S390_SIMULATOR_S390_H_ | 533 #endif // V8_S390_SIMULATOR_S390_H_ |
OLD | NEW |