OLD | NEW |
---|---|
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 #define xmm1 (static_cast<const XMMRegister&>(double_register_1)) | 224 #define xmm1 (static_cast<const XMMRegister&>(double_register_1)) |
225 #define xmm2 (static_cast<const XMMRegister&>(double_register_2)) | 225 #define xmm2 (static_cast<const XMMRegister&>(double_register_2)) |
226 #define xmm3 (static_cast<const XMMRegister&>(double_register_3)) | 226 #define xmm3 (static_cast<const XMMRegister&>(double_register_3)) |
227 #define xmm4 (static_cast<const XMMRegister&>(double_register_4)) | 227 #define xmm4 (static_cast<const XMMRegister&>(double_register_4)) |
228 #define xmm5 (static_cast<const XMMRegister&>(double_register_5)) | 228 #define xmm5 (static_cast<const XMMRegister&>(double_register_5)) |
229 #define xmm6 (static_cast<const XMMRegister&>(double_register_6)) | 229 #define xmm6 (static_cast<const XMMRegister&>(double_register_6)) |
230 #define xmm7 (static_cast<const XMMRegister&>(double_register_7)) | 230 #define xmm7 (static_cast<const XMMRegister&>(double_register_7)) |
231 #define no_xmm_reg (static_cast<const XMMRegister&>(no_double_reg)) | 231 #define no_xmm_reg (static_cast<const XMMRegister&>(no_double_reg)) |
232 | 232 |
233 | 233 |
234 struct X87Register : IntelDoubleRegister { | |
Sven Panne
2014/05/07 13:46:03
I think we can nuke/merge IntelDoubleRegister/Doub
| |
235 static const int kNumAllocatableRegisters = 5; | |
236 static const int kNumRegisters = 5; | |
237 | |
238 bool is(X87Register reg) const { | |
239 return code_ == reg.code_; | |
240 } | |
241 | |
242 static const char* AllocationIndexToString(int index) { | |
243 ASSERT(index >= 0 && index < kNumAllocatableRegisters); | |
244 const char* const names[] = { | |
245 "stX_0", "stX_1", "stX_2", "stX_3", "stX_4" | |
246 }; | |
247 return names[index]; | |
248 } | |
249 | |
250 static X87Register FromAllocationIndex(int index) { | |
251 STATIC_ASSERT(sizeof(X87Register) == sizeof(IntelDoubleRegister)); | |
252 ASSERT(index >= 0 && index < NumAllocatableRegisters()); | |
253 X87Register result; | |
254 result.code_ = index; | |
255 return result; | |
256 } | |
257 | |
258 static int ToAllocationIndex(X87Register reg) { | |
259 return reg.code_; | |
260 } | |
261 }; | |
262 | |
263 #define stX_0 static_cast<const X87Register&>(double_register_0) | |
264 #define stX_1 static_cast<const X87Register&>(double_register_1) | |
265 #define stX_2 static_cast<const X87Register&>(double_register_2) | |
266 #define stX_3 static_cast<const X87Register&>(double_register_3) | |
267 #define stX_4 static_cast<const X87Register&>(double_register_4) | |
268 | |
269 | |
270 typedef IntelDoubleRegister DoubleRegister; | 234 typedef IntelDoubleRegister DoubleRegister; |
271 | 235 |
272 | 236 |
273 enum Condition { | 237 enum Condition { |
274 // any value < 0 is considered no_condition | 238 // any value < 0 is considered no_condition |
275 no_condition = -1, | 239 no_condition = -1, |
276 | 240 |
277 overflow = 0, | 241 overflow = 0, |
278 no_overflow = 1, | 242 no_overflow = 1, |
279 below = 2, | 243 below = 2, |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
513 class NextField: public BitField<int, 2, 32-2> {}; | 477 class NextField: public BitField<int, 2, 32-2> {}; |
514 | 478 |
515 void init(Label* L, Type type); | 479 void init(Label* L, Type type); |
516 }; | 480 }; |
517 | 481 |
518 | 482 |
519 | 483 |
520 // CpuFeatures keeps track of which features are supported by the target CPU. | 484 // CpuFeatures keeps track of which features are supported by the target CPU. |
521 // Supported features must be enabled by a CpuFeatureScope before use. | 485 // Supported features must be enabled by a CpuFeatureScope before use. |
522 // Example: | 486 // Example: |
523 // if (assembler->IsSupported(SSE2)) { | 487 // if (assembler->IsSupported(CMOV)) { |
524 // CpuFeatureScope fscope(assembler, SSE2); | 488 // CpuFeatureScope fscope(assembler, CMOV); |
525 // // Generate SSE2 floating point code. | 489 // // Generate code containing cmov. |
526 // } else { | 490 // } else { |
527 // // Generate standard x87 floating point code. | 491 // // Generate alternative code. |
528 // } | 492 // } |
529 class CpuFeatures : public AllStatic { | 493 class CpuFeatures : public AllStatic { |
530 public: | 494 public: |
531 // Detect features of the target CPU. Set safe defaults if the serializer | 495 // Detect features of the target CPU. Set safe defaults if the serializer |
532 // is enabled (snapshots must be portable). | 496 // is enabled (snapshots must be portable). |
533 static void Probe(bool serializer_enabled); | 497 static void Probe(bool serializer_enabled); |
534 | 498 |
535 // Check whether a feature is supported by the target CPU. | 499 // Check whether a feature is supported by the target CPU. |
536 static bool IsSupported(CpuFeature f) { | 500 static bool IsSupported(CpuFeature f) { |
537 ASSERT(initialized_); | 501 ASSERT(initialized_); |
538 if (Check(f, cross_compile_)) return true; | 502 if (Check(f, cross_compile_)) return true; |
539 if (f == SSE2 && !FLAG_enable_sse2) return false; | |
540 if (f == SSE3 && !FLAG_enable_sse3) return false; | 503 if (f == SSE3 && !FLAG_enable_sse3) return false; |
541 if (f == SSE4_1 && !FLAG_enable_sse4_1) return false; | 504 if (f == SSE4_1 && !FLAG_enable_sse4_1) return false; |
542 if (f == CMOV && !FLAG_enable_cmov) return false; | 505 if (f == CMOV && !FLAG_enable_cmov) return false; |
543 return Check(f, supported_); | 506 return Check(f, supported_); |
544 } | 507 } |
545 | 508 |
546 static bool IsSafeForSnapshot(Isolate* isolate, CpuFeature f) { | 509 static bool IsSafeForSnapshot(Isolate* isolate, CpuFeature f) { |
547 return Check(f, cross_compile_) || | 510 return Check(f, cross_compile_) || |
548 (IsSupported(f) && | 511 (IsSupported(f) && |
549 !(Serializer::enabled(isolate) && | 512 !(Serializer::enabled(isolate) && |
550 Check(f, found_by_runtime_probing_only_))); | 513 Check(f, found_by_runtime_probing_only_))); |
551 } | 514 } |
552 | 515 |
553 static bool VerifyCrossCompiling() { | 516 static bool VerifyCrossCompiling() { |
554 return cross_compile_ == 0; | 517 return cross_compile_ == 0; |
555 } | 518 } |
556 | 519 |
557 static bool VerifyCrossCompiling(CpuFeature f) { | 520 static bool VerifyCrossCompiling(CpuFeature f) { |
558 uint64_t mask = flag2set(f); | 521 uint64_t mask = flag2set(f); |
559 return cross_compile_ == 0 || | 522 return cross_compile_ == 0 || |
560 (cross_compile_ & mask) == mask; | 523 (cross_compile_ & mask) == mask; |
561 } | 524 } |
562 | 525 |
563 static bool SupportsCrankshaft() { return IsSupported(SSE2); } | 526 static bool SupportsCrankshaft() { return true; } |
564 | 527 |
565 private: | 528 private: |
566 static bool Check(CpuFeature f, uint64_t set) { | 529 static bool Check(CpuFeature f, uint64_t set) { |
567 return (set & flag2set(f)) != 0; | 530 return (set & flag2set(f)) != 0; |
568 } | 531 } |
569 | 532 |
570 static uint64_t flag2set(CpuFeature f) { | 533 static uint64_t flag2set(CpuFeature f) { |
571 return static_cast<uint64_t>(1) << f; | 534 return static_cast<uint64_t>(1) << f; |
572 } | 535 } |
573 | 536 |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1288 private: | 1251 private: |
1289 Assembler* assembler_; | 1252 Assembler* assembler_; |
1290 #ifdef DEBUG | 1253 #ifdef DEBUG |
1291 int space_before_; | 1254 int space_before_; |
1292 #endif | 1255 #endif |
1293 }; | 1256 }; |
1294 | 1257 |
1295 } } // namespace v8::internal | 1258 } } // namespace v8::internal |
1296 | 1259 |
1297 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1260 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
OLD | NEW |